Initial working (again) version of gdb://
This commit is contained in:
parent
a2ebdcb650
commit
44ee3ce8d2
|
@ -178,8 +178,12 @@ static char *gdbwrap_extract_from_packet(const char *strtoparse,
|
||||||
if (strsize > maxsize)
|
if (strsize > maxsize)
|
||||||
strsize = maxsize;
|
strsize = maxsize;
|
||||||
|
|
||||||
strncpy (strret, charbegin + strtorem, strsize);
|
//strncpy (strret, charbegin + strtorem, strsize);
|
||||||
|
{
|
||||||
|
char *p = charbegin+strtorem;
|
||||||
|
memmove (strret, p, R_MIN (strlen (p), strsize)+1);
|
||||||
strret[strsize] = GDBWRAP_NULL_CHAR;
|
strret[strsize] = GDBWRAP_NULL_CHAR;
|
||||||
|
}
|
||||||
|
|
||||||
return strret;
|
return strret;
|
||||||
}
|
}
|
||||||
|
@ -392,7 +396,7 @@ static char *gdbwrap_get_packet(gdbwrap_t *desc) {
|
||||||
|
|
||||||
static char *gdbwrap_send_data(gdbwrap_t *desc, const char *query) {
|
static char *gdbwrap_send_data(gdbwrap_t *desc, const char *query) {
|
||||||
int rval = 0;
|
int rval = 0;
|
||||||
char *mes;
|
char *mes = NULL;
|
||||||
if (desc == NULL || query == NULL)
|
if (desc == NULL || query == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -488,14 +492,16 @@ IRAPI gdbwrap_t *gdbwrap_current_get(void) {
|
||||||
*/
|
*/
|
||||||
IRAPI gdbwrap_t *gdbwrap_init(int fd, ut32 num_regs, ut32 reg_size) {
|
IRAPI gdbwrap_t *gdbwrap_init(int fd, ut32 num_regs, ut32 reg_size) {
|
||||||
gdbwrap_t *desc;
|
gdbwrap_t *desc;
|
||||||
if (fd == -1)
|
if (fd == -1) {
|
||||||
|
eprintf ("fd is minus wan\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
desc = malloc (sizeof (gdbwrap_t));
|
desc = malloc (sizeof (gdbwrap_t));
|
||||||
if (!desc) return NULL;
|
if (!desc) return NULL;
|
||||||
desc->reg_size = reg_size;
|
desc->reg_size = reg_size;
|
||||||
desc->num_registers = num_regs;
|
desc->num_registers = num_regs;
|
||||||
desc->regs = malloc(4*desc->reg_size*desc->num_registers);
|
desc->regs = malloc(4*desc->reg_size*desc->num_registers);
|
||||||
if (desc->regs) {
|
if (!desc->regs) {
|
||||||
free (desc);
|
free (desc);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -503,6 +509,7 @@ IRAPI gdbwrap_t *gdbwrap_init(int fd, ut32 num_regs, ut32 reg_size) {
|
||||||
desc->max_packet_size = 2500;
|
desc->max_packet_size = 2500;
|
||||||
desc->packet = malloc((desc->max_packet_size + 1) * sizeof (char));
|
desc->packet = malloc((desc->max_packet_size + 1) * sizeof (char));
|
||||||
if (desc->packet == NULL) {
|
if (desc->packet == NULL) {
|
||||||
|
eprintf ("cant apack\n");
|
||||||
free (desc->regs);
|
free (desc->regs);
|
||||||
free (desc);
|
free (desc);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -40,13 +40,16 @@ static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
|
||||||
p = strchr (port, '/');
|
p = strchr (port, '/');
|
||||||
if (p) *p=0;
|
if (p) *p=0;
|
||||||
_fd = r_socket_new (R_FALSE);
|
_fd = r_socket_new (R_FALSE);
|
||||||
if (_fd) {
|
if (_fd && r_socket_connect_tcp (_fd, host, port)) {
|
||||||
if (r_socket_connect_tcp (_fd, host, port)) {
|
riog = R_NEW (RIOGdb);
|
||||||
riog = R_NEW (RIOGdb);
|
riog->fd = _fd;
|
||||||
riog->fd = _fd;
|
riog->desc = gdbwrap_init (_fd->fd, NUM_REGS, 4);
|
||||||
riog->desc = gdbwrap_init (_fd->fd, NUM_REGS, 4);
|
if (!riog->desc) {
|
||||||
return r_io_desc_new (&r_io_plugin_gdb, _fd->fd, file, rw, mode, riog);
|
r_socket_free (_fd);
|
||||||
|
free (riog);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
return r_io_desc_new (&r_io_plugin_gdb, _fd->fd, file, rw, mode, riog);
|
||||||
}
|
}
|
||||||
eprintf ("gdb.io.open: Cannot connect to host.\n");
|
eprintf ("gdb.io.open: Cannot connect to host.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue