88 if (!
ctx->desc || !
ctx->desc->data) {
94 eprintf(
"rz_debug_gdb_reg_read: small buffer %d vs %d\n",
95 (
int)
size, (
int)
ctx->desc->data_len);
107 ctx->reg_buf = new_buf;
120 memcpy((
void *)(
volatile void *)
ctx->reg_buf,
ctx->desc->data, copy_size);
124 for(
i=0;
i<copy_size;
i++) {
125 if (!(
i%16))
printf (
"\n0x%08x ",
i);
130 return ctx->desc->data_len;
136 if (!
ctx->desc ||
ctx->desc->pid <= 0) {
140 if (
ctx->desc->get_baddr) {
141 ctx->desc->get_baddr =
false;
169 #define GDB_FILE_OPEN_MODE (_S_IREAD | _S_IWRITE)
171 #define GDB_FILE_OPEN_MODE (S_IRUSR | S_IWUSR | S_IXUSR)
189 int unk = 0, perm,
i;
192 char name[1024], region1[100], region2[100], perms[5];
194 region1[0] = region2[0] =
'0';
195 region1[1] = region2[1] =
'x';
196 if (!(ptr = strtok((
char *)
buf,
"\n"))) {
208 bool map_is_shared =
false;
209 line_len = strlen(ptr);
216 ret = sscanf(ptr,
"%s %s %" PFMT64x " %*s %*s %[^\n]", ®ion1[2],
220 }
else if (ret != 4) {
221 eprintf(
"%s: Unable to parse \"%s\"\nContent:\n%s\n",
228 if (!(pos_1 = strchr(®ion1[2],
'-'))) {
229 ptr = strtok(
NULL,
"\n");
232 strncpy(®ion2[2], pos_1 + 1,
sizeof(region2) - 2 - 1);
237 for (
i = 0;
i < 5 && perms[
i];
i++) {
242 case 'p': map_is_shared =
false;
break;
243 case 's': map_is_shared =
true;
break;
248 if (map_start == map_end || map_end == 0) {
249 eprintf(
"%s: ignoring invalid map size: %s - %s\n",
250 __func__, region1, region2);
251 ptr = strtok(
NULL,
"\n");
258 map->shared = map_is_shared;
261 ptr = strtok(
NULL,
"\n");
269 char *lastname =
NULL;
288 if (!lastname || strcmp(lastname,
file)) {
337 ctx->reg_buf = new_buf;
362 if (
ctx->desc->stop_reason.is_valid &&
ctx->desc->stop_reason.thread.present) {
366 ctx->desc->tid =
ctx->desc->stop_reason.thread.tid;
368 return ctx->desc->tid;
377 if (!
ctx->desc->stop_reason.is_valid) {
383 if (
ctx->desc->stop_reason.thread.present) {
385 dbg->
pid =
ctx->desc->stop_reason.thread.pid;
386 dbg->
tid =
ctx->desc->stop_reason.thread.tid;
394 return ctx->desc->stop_reason.reason;
403 if (
d &&
d->plugin &&
d->plugin->name &&
d->data) {
404 if (!strcmp(
"gdb",
d->plugin->name)) {
409 ctx->desc = &
g->desc;
414 eprintf(
"ERROR: Underlying IO descriptor is not a GDB one..\n");
424 if (pid <= 0 || !ctx->
desc->stub_features.multiprocess) {
444 if (!
ctx->desc->target.valid) {
447 if (
ctx->desc->target.regprofile) {
448 return strdup(
ctx->desc->target.regprofile);
521 if (!
ctx->desc || !*
ctx->origrziogdb) {
536 bool list_alloc =
false;
546 rz_list_foreach (th_list, it, th) {
559 eprintf(
"signal: %d\n",
ctx->desc->stop_reason.signum);
560 rdi->signum =
ctx->desc->stop_reason.signum;
578 .arch =
"x86,arm,sh,mips,avr,lm32,v850,ba2",
605 #ifndef RZ_PLUGIN_INCORE
RZ_API ut8 * rz_reg_get_bytes(RzReg *reg, int type, int *size)
static ut64 baddr(RzBinFile *bf)
RzBinInfo * info(RzBinFile *bf)
int bits(struct state *s, int need)
static RzList * rz_debug_native_frames(RzDebug *dbg, ut64 at)
int gdbr_remove_hwa(libgdbr_t *g, ut64 address, int sizebp)
int gdbr_remove_bp(libgdbr_t *g, ut64 address, int sizebp)
int gdbr_open_file(libgdbr_t *g, const char *filename, int flags, int mode)
int gdbr_remove_hwbp(libgdbr_t *g, ut64 address, int sizebp)
int gdbr_read_registers(libgdbr_t *g)
int gdbr_remove_hwr(libgdbr_t *g, ut64 address, int sizebp)
int gdbr_detach(libgdbr_t *g)
detaches from a process
RzList * gdbr_threads_list(libgdbr_t *g, int pid)
get list of threads for given pid
int gdbr_set_bp(libgdbr_t *g, ut64 address, const char *conditions, int sizebp)
Function sets normal breakpoint (0xcc, int3)
char * gdbr_exec_file_read(libgdbr_t *g, int pid)
int gdbr_remove_hww(libgdbr_t *g, ut64 address, int sizebp)
RzList * gdbr_pids_list(libgdbr_t *g, int pid)
get a list of the child processes of the given pid
int gdbr_detach_pid(libgdbr_t *g, int pid)
int gdbr_set_hwa(libgdbr_t *g, ut64 address, const char *conditions, int sizebp)
int gdbr_set_hwbp(libgdbr_t *g, ut64 address, const char *conditions, int sizebp)
int gdbr_step(libgdbr_t *g, int thread_id)
int gdbr_continue(libgdbr_t *g, int pid, int tid, int sig)
int gdbr_set_hwr(libgdbr_t *g, ut64 address, const char *conditions, int sizebp)
int gdbr_write_reg(libgdbr_t *g, const char *name, char *value, int len)
int gdbr_read_file(libgdbr_t *g, ut8 *buf, ut64 max_len)
ut64 gdbr_get_baddr(libgdbr_t *g)
int gdbr_select(libgdbr_t *g, int pid, int tid)
int gdbr_kill(libgdbr_t *g)
kills the process the remote gdbserver is debugging (TODO: handle pid)
int gdbr_set_hww(libgdbr_t *g, ut64 address, const char *conditions, int sizebp)
int gdbr_stop_reason(libgdbr_t *g)
gets reason why remote target stopped
int gdbr_close_file(libgdbr_t *g)
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
static static fork const void static count static fd const char const char static newpath const char static path const char path
static int rz_debug_gdb_set_reg_profile(RzDebug *dbg, const char *str)
static int rz_debug_gdb_reg_read(RzDebug *dbg, int type, ut8 *buf, int size)
static bool rz_debug_gdb_init(RzDebug *dbg, void **user)
static void check_connection(RzDebug *dbg)
struct rz_debug_gdb_ctx_t RzDebugGdbCtx
static int rz_debug_gdb_select(RzDebug *dbg, int pid, int tid)
RzDebugPlugin rz_debug_plugin_gdb
#define GDB_FILE_OPEN_MODE
static int rz_debug_gdb_continue(RzDebug *dbg, int pid, int tid, int sig)
static RzList * rz_debug_gdb_map_get(RzDebug *dbg)
static const char * rz_debug_gdb_reg_profile(RzDebug *dbg)
static RzList * rz_debug_gdb_frames(RzDebug *dbg, ut64 at)
RZ_API RzLibStruct rizin_plugin
static int rz_debug_gdb_step(RzDebug *dbg)
static RzList * rz_debug_gdb_modules_get(RzDebug *dbg)
static RzList * rz_debug_gdb_threads(RzDebug *dbg, int pid)
static bool rz_debug_gdb_kill(RzDebug *dbg, int pid, int tid, int sig)
static RzList * rz_debug_gdb_pids(RzDebug *dbg, int pid)
static int rz_debug_gdb_attach(RzDebug *dbg, int pid)
static int rz_debug_gdb_breakpoint(RzBreakpoint *bp, RzBreakpointItem *b, bool set)
static int rz_debug_gdb_detach(RzDebug *dbg, int pid)
static int rz_debug_gdb_reg_write(RzDebug *dbg, int type, const ut8 *buf, int size)
static RzDebugReasonType rz_debug_gdb_wait(RzDebug *dbg, int pid)
static void rz_debug_gdb_fini(RzDebug *dbg, void *user)
static RzDebugInfo * rz_debug_gdb_info(RzDebug *dbg, const char *arg)
RZ_API void rz_debug_map_free(RzDebugMap *map)
RZ_API RzDebugMap * rz_debug_map_new(char *name, ut64 addr, ut64 addr_end, int perm, int user)
size_t map(int syms, int left, int len)
RZ_API void Ht_() free(HtName_(Ht) *ht)
RZ_API const KEY_TYPE bool * found
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
int gdbr_set_reg_profile(libgdbr_t *g, const char *str)
Function set the gdbr internal registers profile.
bool gdbr_set_architecture(libgdbr_t *g, int arch, int bits)
Function initializes the architecture of the gdbsession.
char * gdbr_get_reg_profile(int arch, int bits)
Function get gdb registers profile based on arch and bits.
static void list(RzEgg *egg)
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
RZ_API void rz_list_delete(RZ_NONNULL RzList *list, RZ_NONNULL RzListIter *iter)
Removes an entry in the list by using the RzListIter pointer.
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
void * realloc(void *ptr, size_t size)
void * malloc(size_t size)
void * calloc(size_t number, 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 kill
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 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 select
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")
RZ_API RzDebugPid * rz_debug_pid_free(RzDebugPid *pid)
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_next_diff(RzReg *reg, int type, const ut8 *buf, int buflen, RzRegItem *prev_ri, int regsize)
@ RZ_DEBUG_REASON_UNKNOWN
void(* RzListFree)(void *ptr)
RZ_API ut64 rz_num_get(RzNum *num, const char *str)
RZ_API int rz_sys_arch_id(const char *arch)
struct rz_io_desc_t * desc
int size
in bits> 8,16,32,64 ... 128/256
int offset
Offset into register profile in bits.
RzRegSet regset[RZ_REG_TYPE_LAST]
ut64(WINAPI *w32_GetEnabledXStateFeatures)()