9 #define IRAPI static inline
18 #define RZ_GDB_MAGIC rz_str_djb2_hash("gdb")
24 return (!strncmp(
file,
"gdb://", 6));
42 packets = sz / size_max;
45 for (
x = 0;
x < packets;
x++,
offset += size_max) {
57 char host[128], *port, *
pid;
64 strncpy(host,
file + 6,
sizeof(host) - 1);
65 host[
sizeof(host) - 1] =
'\0';
71 port = strchr(host,
'@');
75 pid = strchr(port,
':');
77 pid = strchr(host,
':');
80 port = strchr(host,
':');
82 eprintf(
"Invalid debugger URI. Port missing?\nPlease use either\n"
83 " - gdb://host:port[/pid] for a network gdbserver.\n"
84 " - gdb:///dev/DEVICENAME[@speed][:pid] for a serial gdbserver.\n");
89 pid = strchr(port,
'/');
115 eprintf(
"gdbr: Failed to attach to PID %i\n", i_pid);
118 }
else if ((i_pid =
desc->
pid) < 0) {
127 eprintf(
"gdb.io.open: Cannot connect to host.\n");
210 if (
cmd[0] ==
'?' || !strcmp(
cmd,
"help")) {
212 " R!pid - show targeted pid\n"
213 " R!pkt s - send packet 's'\n"
214 " R!rd - show reverse debugging availability\n"
215 " R!dsb - step backwards\n"
216 " R!dcb - continue backwards\n"
217 " R!monitor cmd - hex-encode monitor command and pass"
218 " to target interpreter\n"
219 " R!detach [pid] - detach from remote/detach specific pid\n"
220 " R!inv.reg - invalidate reg cache\n"
221 " R!pktsz - get max packet size used\n"
222 " R!pktsz bytes - set max. packet size as 'bytes' bytes\n"
223 " R!exec_file [pid] - get file which was executed for"
224 " current/specified pid\n");
235 if (!(pktsz = (
ut32)strtoul(ptr,
NULL, 10))) {
267 eprintf(
"[waiting for ack]\n");
284 eprintf(
"Stepping backwards is not supported in this gdbserver implementation\n");
294 eprintf(
"[waiting for ack]\n");
298 eprintf(
"Thread (%d) stopped for an invalid reason: %d\n",
308 eprintf(
"Continue backwards is not supported in this gdbserver implementation\n");
318 eprintf(
"[waiting for ack]\n");
322 eprintf(
"Thread (%d) stopped for an invalid reason: %d\n",
338 const char *qrcmd =
cmd + 8;
353 const char *ptr =
cmd + strlen(
"exec_file");
378 if ((num_retries = atoi(
cmd + 8)) >= 1) {
389 if ((page_size = atoi(
cmd + 10)) >= 64) {
398 if (!strcmp(
cmd,
"baddr")) {
414 .desc =
"Attach to gdbserver instance",
428 #ifndef RZ_PLUGIN_INCORE
int gdbr_disconnect(libgdbr_t *g)
disconnects the lib
int gdbr_read_memory(libgdbr_t *g, ut64 address, ut8 *buf, int len)
int gdbr_connect(libgdbr_t *g, const char *server, int port)
Function connects to a gdbserver instance.
int gdbr_attach(libgdbr_t *g, int pid)
attaches to a process
int gdbr_detach(libgdbr_t *g)
detaches from a process
bool gdbr_lock_enter(libgdbr_t *g)
Acquires the gdbr lock and sets up breaking.
char * gdbr_exec_file_read(libgdbr_t *g, int pid)
void gdbr_lock_leave(libgdbr_t *g)
Releases the gdbr lock.
int gdbr_detach_pid(libgdbr_t *g, int pid)
void gdbr_invalidate_reg_cache(void)
invalidates the reg cache
int gdbr_write_memory(libgdbr_t *g, ut64 address, const uint8_t *data, ut64 len)
int gdbr_send_qRcmd(libgdbr_t *g, const char *cmd, PrintfCallback cb_printf)
sends a qRcmd packet which basically passes a command to the remote target's interpreter.
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 static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
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 void Ht_() free(HtName_(Ht) *ht)
static int __read(RzIO *io, RzIODesc *fd, ut8 *buf, int count)
static int __gettid(RzIODesc *fd)
RzIOPlugin rz_io_plugin_gdb
static int debug_gdb_read_at(ut8 *buf, int sz, ut64 addr)
static bool __plugin_open(RzIO *io, const char *file, bool many)
RZ_API RzLibStruct rizin_plugin
static RzIODesc * __open(RzIO *io, const char *file, int rw, int mode)
int read_packet(libgdbr_t *instance, bool vcont)
static int __write(RzIO *io, RzIODesc *fd, const ut8 *buf, int count)
int send_msg(libgdbr_t *g, const char *command)
static ut64 __lseek(RzIO *io, RzIODesc *fd, ut64 offset, int whence)
static int __close(RzIODesc *fd)
static char * __system(RzIO *io, RzIODesc *fd, const char *cmd)
static int __getpid(RzIODesc *fd)
static int debug_gdb_write_at(const ut8 *buf, int sz, ut64 addr)
return memset(p, 0, total)
int gdbr_cleanup(libgdbr_t *g)
frees all buffers and cleans the libgdbr instance stuff
int gdbr_init(libgdbr_t *g, bool is_server)
Function initializes the libgdbr lib.
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
int handle_stop_reason(libgdbr_t *g)
RZ_API RzIODesc * rz_io_desc_new(RzIO *io, RzIOPlugin *plugin, const char *uri, int flags, int mode, void *data)
RZ_API PJ * pj_kb(PJ *j, const char *k, bool v)
RZ_API PJ * pj_end(PJ *j)
RZ_API const char * pj_string(PJ *pj)
RZ_API void pj_free(PJ *j)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API const char * rz_str_trim_head_ro(const char *str)
RZ_API bool rz_str_startswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle)
Checks if a string starts with a specifc sequence of characters (case sensitive)
struct libgdbr_stop_reason::@441 thread
libgdbr_stop_reason_t stop_reason
libgdbr_stub_features_t stub_features
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const z80_opcode fd[]