* Fix r2 -d gdb://

- compile debug_gdb plugin statically
  - fix filename construction path
  - /path after :port in gdb uri is now ignored
This commit is contained in:
pancake 2011-05-06 17:14:31 +02:00
parent e83156f06a
commit bd017111d7
6 changed files with 20 additions and 14 deletions

View File

@ -152,6 +152,7 @@ int main(int argc, char **argv) {
is_gdb = (!memcmp (argv[optind], "gdb://", 6));
if (!is_gdb)
strcpy (file, "dbg://");
else *file = 0;
if (optind < argc) {
char *ptr = r_file_path (argv[optind]);
if (ptr) {
@ -171,7 +172,6 @@ int main(int argc, char **argv) {
if (fh != NULL) {
const char *arch = r_config_get (&r, "asm.arch");
// TODO: move into if (debug) ..
eprintf ("ARCH = %s\n", arch);
if (is_gdb) r_debug_use (r.dbg, "gdb");
else r_debug_use (r.dbg, "native");
}

View File

@ -3,6 +3,7 @@
#include <r_asm.h>
#include <r_debug.h>
#include "libgdbwrap/include/gdbwrapper.h"
#include "libgdbwrap/gdbwrapper.c"
/* XXX: hacky copypasta from io/p/io_gdb */
typedef struct {
@ -27,8 +28,9 @@ static int r_debug_gdb_step(RDebug *dbg) {
static int r_debug_gdb_reg_read(RDebug *dbg, int type, ut8 *buf, int size) {
ut8 *p = gdbwrap_readgenreg (desc);
// TODO: allow gdbwrap to read regs on own buffer
memcpy (buf, p, size);
return size;
return R_TRUE;
}
static int r_debug_gdb_reg_write(int pid, int tid, int type, const ut8 *buf, int size) {
@ -92,7 +94,7 @@ static const char *r_debug_gdb_reg_profile(RDebug *dbg) {
return NULL;
}
struct r_debug_plugin_t r_dbg_plugin_gdb = {
struct r_debug_plugin_t r_debug_plugin_gdb = {
.name = "gdb",
/* TODO: Add support for more architectures here */
.arch = R_SYS_ARCH_X86 | R_SYS_ARCH_ARM | R_SYS_ARCH_SH,

View File

@ -1,7 +1,7 @@
include ../../config.mk
BINDEPS=r_reg r_bp r_util r_io r_anal
#include ../../config.mk
#BINDEPS=r_reg r_bp r_util r_io r_anal
CFLAGS+=-Ilibgdbwrap/include
CFLAGS+=-Ip/libgdbwrap/include
ifeq (${OSTYPE},windows)
LDFLAGS+=-lwsock32
endif
@ -9,10 +9,12 @@ ifeq (${OSTYPE},solaris)
LDFLAGS+=-lsocket
endif
OBJ_GDB=debug_gdb.o libgdbwrap/gdbwrapper.o
libgdbwrap/gdbwrapper.o:
${CC} -c ${CFLAGS} ${LDFLAGS} -o libgdbwrap/gdbwrapper.o libgdbwrap/gdbwrapper.c
OBJ_GDB=debug_gdb.o
#libgdbwrap/gdbwrapper.o
#libgdbwrap/gdbwrapper.o:
# ${CC} -c ${CFLAGS} ${LDFLAGS} -o p/libgdbwrap/gdbwrapper.o p/libgdbwrap/gdbwrapper.c
STATIC_OBJ+=${OBJ_GDB}
TARGET_GDB=debug_gdb.${EXT_SO}

View File

@ -241,8 +241,7 @@ static char *gdbwrap_make_message(gdbwrap_t *desc, const char *query)
not check the overlapping tho.*/
if (strlen(query) < max_query_size && query != desc->packet)
{
u_char ret;
ret = snprintf(desc->packet, desc->max_packet_size, "%s%s%s%.2x",
int ret = snprintf(desc->packet, desc->max_packet_size, "%s%s%s%.2x",
GDBWRAP_BEGIN_PACKET, query, GDBWRAP_END_PACKET, checksum);
ASSERT(ret > 0);
}

View File

@ -21,7 +21,7 @@ static int __plugin_open(RIO *io, const char *file) {
}
static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
char host[128], *port;
char host[128], *port, *p;
RSocket *_fd;
RIOGdb *riog;
if (!__plugin_open (io, file))
@ -33,9 +33,12 @@ static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
return NULL;
}
*port = '\0';
port++;
p = strchr (port, '/');
if (p) *p=0;
_fd = r_socket_new (R_FALSE);
if (_fd) {
if (r_socket_connect_tcp (_fd, host, port+1)) {
if (r_socket_connect_tcp (_fd, host, port)) {
riog = R_NEW (RIOGdb);
riog->fd = _fd;
riog->desc = gdbwrap_init (_fd->fd, NUM_REGS, 4);

View File

@ -43,6 +43,7 @@ bp.ppc
cmd.dummy
crypto.aes
debug.native
debug.gdb
fs.fat
fs.ntfs
fs.ext2
@ -77,5 +78,4 @@ asm.bf
asm.csr
asm.psosvm
asm.sparc
debug.gdb
io.shm"