16 #define DBG_BUF_SIZE 512
70 eprintf(
"BreakpointItem is NULL!\n");
115 if (drx_reg_idx != -1) {
132 eprintf(
"failed to determine position of pc after breakpoint");
163 eprintf(
"failed to set PC!\n");
167 eprintf(
"cannot set registers!\n");
187 b->trace ?
"trace" :
"break",
pc);
274 const char *module_name =
module;
278 bool detect_module,
valid =
false;
282 detect_module =
false;
287 module_name =
map->file;
298 detect_module =
true;
302 if (
addr >=
map->addr && addr < map->addr_end) {
305 module_name =
map->file;
308 perm = ((
map->perm & 1) << 2) | (
map->perm & 2) | ((
map->perm & 4) >> 2);
310 eprintf(
"WARNING: setting bp within mapped memory without exec perm\n");
316 eprintf(
"WARNING: module's base addr + delta is not a valid address\n");
324 if (
addr >=
map->addr && addr < map->addr_end) {
325 module_name =
map->file;
351 eprintf(
"rz_debug_str_callback has been called. this should not happen\n");
512 ut8 stackbackup[4096];
515 ut64 rsp, rpc, ra0 = 0LL;
525 eprintf(
"Cannot get register arena bytes\n");
567 eprintf(
"rz_debug_execute: Cannot get program counter\n");
616 if (
dbg->
pid == prev_pid) {
619 if (
dbg->
tid == prev_tid) {
704 eprintf(
"\n==> Process finished\n\n");
745 eprintf(
"Couldn't find PC!\n");
778 if (
name && strcmp(
"SIGTRAP",
name)) {
832 next[0] = sp_top.r32[0];
833 }
else if (has_lr_reg) {
862 next[0] =
op.addr +
op.size;
877 next[0] =
op.addr +
op.size;
884 next[0] =
op.addr +
op.size;
890 for (
i = 0;
i <
br;
i++) {
892 next[
i] = next[
i] - (next[
i] % align);
902 for (
i = 0;
i <
br;
i++) {
964 int ret, steps_taken = 0;
987 for (; steps_taken < steps; steps_taken++) {
993 eprintf(
"trace_ins_before: failed\n");
1003 eprintf(
"Stepping failed!\n");
1009 eprintf(
"trace_ins_after: failed\n");
1035 ut64 buf_pc,
pc, ins_size;
1037 int steps_taken = 0;
1048 for (; steps_taken < steps; steps_taken++) {
1072 for (; steps_taken < steps; steps_taken++) {
1075 if (
pc - buf_pc >
sizeof(
buf)) {
1084 if (
op.fail == -1) {
1085 ins_size =
pc +
op.size;
1099 eprintf(
"step over failed over rep\n");
1112 eprintf(
"Error: out of cnum range\n");
1153 bool has_bp =
false;
1292 eprintf(
"Continue into the signal %d handler\n", sig);
1304 eprintf(
"Skip signal %d handler %s\n",
1356 eprintf(
"Undefined pointer at dbg->analysis\n");
1375 if (
pc - buf_pc >
sizeof(
buf)) {
1393 eprintf(
"rz_debug_step: failed\n");
1444 bool has_bp =
false;
1449 eprintf(
"Error: cannot find PC change vector");
1477 const char *sysname;
1484 sysname =
si->name ?
si->name :
"unknown";
1487 sysname =
"unknown";
1508 int i,
reg, ret =
false;
1519 eprintf(
"--> cannot read registers\n");
1524 eprintf(
"Cannot find 'sn' register for current arch-os.\n");
1553 eprintf(
"--> cannot sync regs, process is probably dead\n");
1568 for (
i = 0;
i < n_sc;
i++) {
1588 eprintf(
"TODO: show syscall information\n");
1608 eprintf(
"Backend does not implement kill()\n");
1692 if (
pid < 0 || tid < 0) {
1720 if (!strcmp(abspath,
map->name)) {
1730 if (
map->perm == 5) {
1740 ut64 diff = new_base - old_base;
RZ_API int rz_analysis_archinfo(RzAnalysis *analysis, int query)
RZ_API bool rz_reg_read_regs(RzReg *reg, ut8 *buf, const int len)
RZ_API ut8 * rz_reg_get_bytes(RzReg *reg, int type, int *size)
RZ_API void rz_reg_arena_swap(RzReg *reg, int copy)
int bits(struct state *s, int need)
RZ_API RZ_BORROW RzBreakpointItem * rz_bp_get_ending_at(RZ_NONNULL RzBreakpoint *bp, ut64 addr)
Get the breakpoint b that fulfills b->addr + b-> size == addr After hitting a (usually software) brea...
RZ_API RzBreakpointItem * rz_bp_get_in(RzBreakpoint *bp, ut64 addr, int perm)
RZ_API RzBreakpoint * rz_bp_new(RZ_BORROW RZ_NONNULL RzBreakpointContext *ctx)
RZ_API RZ_BORROW RzBreakpointItem * rz_bp_get_at(RZ_NONNULL RzBreakpoint *bp, ut64 addr)
Get the breakpoint at exactly addr.
RZ_API RzBreakpoint * rz_bp_free(RzBreakpoint *bp)
RZ_API bool rz_bp_del(RzBreakpoint *bp, ut64 addr)
RZ_API RzBreakpointItem * rz_bp_add_hw(RzBreakpoint *bp, ut64 addr, int size, int perm)
RZ_API RZ_BORROW RzBreakpointItem * rz_bp_add_sw(RZ_NONNULL RzBreakpoint *bp, ut64 addr, int size, int perm)
Add a software breakpoint size preferred size of the breakpoint, or 0 to determine automatically.
RZ_API int rz_bp_size_at(RZ_NONNULL RzBreakpoint *bp, ut64 addr)
Predict the software breakpoint size to use when placing a breakpoint at addr.
RZ_API int rz_bp_restore(RzBreakpoint *bp, bool set)
RZ_API bool rz_bp_restore_except(RzBreakpoint *bp, bool set, ut64 addr)
RZ_API RZ_BORROW RzBreakpointItem * rz_bp_watch_add(RZ_NONNULL RzBreakpoint *bp, ut64 addr, int size, int hw, int perm)
RZ_API RzCons * rz_cons_singleton(void)
RZ_API void rz_cons_break_pop(void)
RZ_API int rz_cons_printf(const char *format,...)
RZ_API bool rz_cons_is_breaked(void)
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags cmd
RZ_API RzList * rz_debug_map_list_new(void)
RZ_API bool rz_debug_map_sync(RzDebug *dbg)
RZ_API RzList * rz_debug_modules_list(RzDebug *dbg)
RZ_API ut64 rz_debug_num_callback(RzNum *userptr, const char *str, int *ok)
RZ_API ut64 rz_debug_reg_get(RzDebug *dbg, const char *name)
RZ_API int rz_debug_reg_sync(RzDebug *dbg, int type, int write)
RZ_API int rz_debug_reg_set(struct rz_debug_t *dbg, const char *name, ut64 num)
RZ_API void rz_debug_session_free(RzDebugSession *session)
RZ_API bool rz_debug_add_checkpoint(RzDebug *dbg)
RZ_API void rz_debug_session_restore_reg_mem(RzDebug *dbg, ut32 cnum)
RZ_API void rz_debug_signal_init(RzDebug *dbg)
RZ_API int rz_debug_signal_what(RzDebug *dbg, int num)
RZ_API void rz_egg_free(RzEgg *egg)
RZ_API RzEgg * rz_egg_new(void)
RZ_API bool rz_egg_setup(RzEgg *egg, const char *arch, int bits, int endian, const char *os)
size_t map(int syms, int left, int len)
RZ_API char * sdb_fmt(const char *fmt,...)
RZ_API void rz_hash_free(RzHash *rh)
RZ_API RzHash * rz_hash_new(void)
RZ_API void Ht_() free(HtName_(Ht) *ht)
RZ_API bool rz_debug_can_kill(RzDebug *dbg)
check whether rz_debug_kill() will not definitely fail (for example because kill is unimplemented by ...
RZ_API int rz_debug_kill(RzDebug *dbg, int pid, int tid, int sig)
static int rz_debug_recoil(RzDebug *dbg, RzDebugRecoilMode rc_mode)
RZ_API int rz_debug_syscall(RzDebug *dbg, int num)
static int rz_debug_continue_until_internal(RzDebug *dbg, ut64 addr, bool block)
RZ_API bool rz_debug_goto_cnum(RzDebug *dbg, ut32 cnum)
void free_tracenodes_kv(HtUPKv *kv)
RZ_API int rz_debug_drx_set(RzDebug *dbg, int idx, ut64 addr, int len, int rwx, int g)
RZ_API int rz_debug_start(RzDebug *dbg, const char *cmd)
RZ_API int rz_debug_continue_syscall(RzDebug *dbg, int sc)
RZ_API RZ_OWN RzDebug * rz_debug_new(RZ_BORROW RZ_NONNULL RzBreakpointContext *bp_ctx)
static bool isStepOverable(ut64 opType)
static int show_syscall(RzDebug *dbg, const char *sysreg)
RZ_API void rz_debug_bp_rebase(RzDebug *dbg, ut64 old_base, ut64 new_base)
RZ_API int rz_debug_step_back(RzDebug *dbg, int steps)
RZ_API int rz_debug_step_over(RzDebug *dbg, int steps)
RZ_API int rz_debug_step(RzDebug *dbg, int steps)
RZ_API int rz_debug_map_protect(RzDebug *dbg, ut64 addr, int size, int perms)
RZ_API RZ_BORROW RzBreakpointItem * rz_debug_bp_add(RZ_NONNULL RzDebug *dbg, ut64 addr, int hw, bool watch, int rw, RZ_NULLABLE const char *module, st64 m_delta)
RZ_API int rz_debug_continue_until_optype(RzDebug *dbg, int type, int over)
RZ_API bool rz_debug_continue_back(RzDebug *dbg)
RZ_API int rz_debug_continue_until(RzDebug *dbg, ut64 addr)
RZ_API RzDebug * rz_debug_free(RzDebug *dbg)
RZ_API int rz_debug_drx_unset(RzDebug *dbg, int idx)
RZ_API int rz_debug_continue_until_nonblock(RzDebug *dbg, ut64 addr)
RZ_API int rz_debug_detach(RzDebug *dbg, int pid)
RZ_API const char * rz_debug_reason_to_string(int type)
RZ_API void rz_debug_bp_update(RzDebug *dbg)
static const char * rz_debug_str_callback(RzNum *userptr, ut64 off, int *ok)
RZ_API int rz_debug_continue(RzDebug *dbg)
RZ_API int rz_debug_stop(RzDebug *dbg)
RZ_API RzDebugReasonType rz_debug_wait(RzDebug *dbg, RzBreakpointItem **bp)
RZ_API int rz_debug_continue_syscalls(RzDebug *dbg, int *sc, int n_sc)
RZ_API int rz_debug_child_clone(RzDebug *dbg)
RZ_API int rz_debug_step_hard(RzDebug *dbg, RzBreakpointItem **pb)
RZ_API int rz_debug_step_cnum(RzDebug *dbg, int steps)
RZ_API int rz_debug_child_fork(RzDebug *dbg)
RZ_API int rz_debug_attach(RzDebug *dbg, int pid)
RZ_API int rz_debug_step_soft(RzDebug *dbg)
RZ_API RzDebugInfo * rz_debug_info(RzDebug *dbg, const char *arg)
RZ_API void rz_debug_tracenodes_reset(RzDebug *dbg)
RZ_API int rz_debug_continue_until_nontraced(RzDebug *dbg)
RZ_API void rz_debug_drx_list(RzDebug *dbg)
RZ_API int rz_debug_continue_pass_exception(RzDebug *dbg)
RZ_API ut64 rz_debug_get_baddr(RzDebug *dbg, const char *file)
RZ_API int rz_debug_startv(struct rz_debug_t *dbg, int argc, char **argv)
RZ_API ut64 rz_debug_execute(RzDebug *dbg, const ut8 *buf, int len, int restore)
RZ_API bool rz_debug_is_dead(RzDebug *dbg)
RZ_API int rz_debug_continue_kill(RzDebug *dbg, int sig)
static int rz_debug_bps_enable(RzDebug *dbg)
RZ_API bool rz_debug_set_arch(RzDebug *dbg, const char *arch, int bits)
RZ_API bool rz_debug_select(RzDebug *dbg, int pid, int tid)
RZ_API RzList * rz_debug_frames(RzDebug *dbg, ut64 at)
RZ_API RzDebugReasonType rz_debug_stop_reason(RzDebug *dbg)
static int rz_debug_drx_at(RzDebug *dbg, ut64 addr)
RZ_API void rz_debug_info_free(RzDebugInfo *rdi)
static int rz_debug_bp_hit(RzDebug *dbg, RzRegItem *pc_ri, ut64 pc, RzBreakpointItem **pb)
static void list(RzEgg *egg)
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
void * malloc(size_t size)
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz fd_set fd_set fd_set struct timeval static timeout const char char static bufsiz const char static swapflags void static offset const char static length static mode static who const char struct statfs static buf unsigned unsigned num
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc pid
static static fork const void static count static fd const char const char static newpath char char argv
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
bool linux_attach_new_process(RzDebug *dbg, int pid)
RZ_API void rz_analysis_op_free(void *op)
RZ_API int rz_analysis_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *data, int len, RzAnalysisOpMask mask)
RZ_API void rz_debug_plugin_init(RzDebug *dbg)
RZ_API RzRegItem * rz_reg_get(RzReg *reg, const char *name, int type)
RZ_API const char * rz_reg_get_name(RzReg *reg, int role)
RZ_API RzRegItem * rz_reg_get_by_role(RzReg *reg, RzRegisterId role)
RZ_API void rz_reg_free(RzReg *reg)
RZ_API RzReg * rz_reg_new(void)
static void repeat(struct parse *, sopno, int, int)
RZ_API bool rz_reg_set_value(RzReg *reg, RzRegItem *item, ut64 value)
RZ_API ut64 rz_reg_get_value(RzReg *reg, RzRegItem *item)
#define RZ_ANALYSIS_ARCHINFO_ALIGN
@ RZ_ANALYSIS_OP_PREFIX_REP
@ RZ_ANALYSIS_OP_PREFIX_LOCK
@ RZ_ANALYSIS_OP_PREFIX_REPNE
@ RZ_ANALYSIS_OP_MASK_BASIC
#define RZ_ANALYSIS_OP_TYPE_MASK
@ RZ_ANALYSIS_OP_TYPE_JMP
@ RZ_ANALYSIS_OP_TYPE_UJMP
@ RZ_ANALYSIS_OP_TYPE_MJMP
@ RZ_ANALYSIS_OP_TYPE_SWI
@ RZ_ANALYSIS_OP_TYPE_CCALL
@ RZ_ANALYSIS_OP_TYPE_CALL
@ RZ_ANALYSIS_OP_TYPE_IRJMP
@ RZ_ANALYSIS_OP_TYPE_RJMP
@ RZ_ANALYSIS_OP_TYPE_CJMP
@ RZ_ANALYSIS_OP_TYPE_ILL
@ RZ_ANALYSIS_OP_TYPE_UCALL
@ RZ_ANALYSIS_OP_TYPE_RET
@ RZ_ANALYSIS_OP_TYPE_RCALL
@ RZ_ANALYSIS_OP_TYPE_IRCALL
#define rz_return_val_if_fail(expr, val)
@ RZ_DEBUG_REASON_NEW_TID
@ RZ_DEBUG_REASON_WRITERR
@ RZ_DEBUG_REASON_READERR
@ RZ_DEBUG_REASON_ILLEGAL
@ RZ_DEBUG_REASON_TRACEPOINT
@ RZ_DEBUG_REASON_UNKNOWN
@ RZ_DEBUG_REASON_BREAKPOINT
@ RZ_DEBUG_REASON_USERSUSP
@ RZ_DEBUG_REASON_NEW_LIB
@ RZ_DEBUG_REASON_EXIT_LIB
@ RZ_DEBUG_REASON_SEGFAULT
@ RZ_DEBUG_REASON_NEW_PID
@ RZ_DEBUG_REASON_EXIT_PID
@ RZ_DEBUG_REASON_EXIT_TID
@ RZ_DEBUG_REASON_DIVBYZERO
RZ_API void rz_event_send(RzEvent *ev, int type, void *data)
@ RZ_EVENT_DEBUG_PROCESS_FINISHED
RZ_API char * rz_file_abspath(const char *file)
RZ_API char * rz_io_system(RzIO *io, const char *cmd)
RZ_API int rz_io_desc_get_tid(RzIODesc *desc)
RZ_API int rz_io_desc_get_pid(RzIODesc *desc)
RZ_API bool rz_io_desc_get_base(RzIODesc *desc, ut64 *base)
RZ_API void * rz_lib_dl_sym(void *handler, const char *name)
RZ_API RzNum * rz_num_new(RzNumCallback cb, RzNumCallback2 cb2, void *ptr)
RZ_API ut64 rz_num_math(RzNum *num, const char *str)
RZ_API void rz_num_free(RzNum *num)
RZ_API const char * rz_signal_to_string(int code)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API char * rz_sys_pid_to_path(int pid)
RZ_API void rz_tree_free(RTree *t)
RZ_API RTree * rz_tree_new(void)
#define rz_vector_foreach_prev(vec, it)
RZ_API bool sdb_free(Sdb *s)
#define br(opcode, mask, lose, flags)
Outer context of mappings/etc. in which the RzBreakpoint instance will operate in....
RzCoreDebugSyscallHit syshit
int(* detach)(RzDebug *dbg, int pid)
bool(* kill)(RzDebug *dbg, int pid, int tid, int sig)
int(* attach)(RzDebug *dbg, int pid)
RzDebugInfo *(* info)(RzDebug *dbg, const char *arg)
int(* step_over)(RzDebug *dbg)
RzList *(* frames)(RzDebug *dbg, ut64 at)
int(* drx)(RzDebug *dbg, int n, ut64 addr, int size, int rwx, int g, int api_type)
int(* select)(RzDebug *dbg, int pid, int tid)
int(* contsc)(RzDebug *dbg, int pid, int sc)
RzDebugReasonType(* wait)(RzDebug *dbg, int pid)
int(* map_protect)(RzDebug *dbg, ut64 addr, int size, int perms)
int(* cont)(RzDebug *dbg, int pid, int tid, int sig)
int(* step)(RzDebug *dbg)
int(* stop)(RzDebug *dbg)
RzDebugRecoilMode recoil_mode
bool continue_all_threads
struct rz_debug_plugin_t * cur
bool nt_x86_xstate_supported
Track whether X86_FEATURE_XSAVE feature is supported on current kernel.
int hitinfo
XXX: MUST SET ///.
struct rz_io_plugin_t * plugin
struct rz_io_desc_t * desc
int arena
In which arena is this reg living. Usually equals type.
int offset
Offset into register profile in bits.
char * name[RZ_REG_NAME_LAST]
RZ_API void rz_syscall_item_free(RzSyscallItem *si)
RZ_API RzSyscallItem * rz_syscall_get(RzSyscall *s, int num, int swi)
RZ_API void rz_debug_trace_free(RzDebugTrace *trace)
RZ_API RzDebugTrace * rz_debug_trace_new(void)
RZ_API bool rz_debug_trace_ins_after(RzDebug *dbg)
RZ_API int rz_debug_trace_pc(RzDebug *dbg, ut64 pc)
RZ_API bool rz_debug_trace_ins_before(RzDebug *dbg)
if(dbg->bits==RZ_SYS_BITS_64)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static char * regname(int reg)