Skip to content

Commit

Permalink
Add 'id' command to show debug info
Browse files Browse the repository at this point in the history
Use r_core_read_at() instead of r_io_read_at() in core
Another spurious r_io patch!
  • Loading branch information
radare committed Aug 15, 2012
1 parent 52beedb commit ad4e8b0
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion libr/bin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ NAME=r_bin
DEPS=r_lib r_util

foo:
for a in $(LIBSO) ${LIBAR} plugins ; do ${MAKE} $$a ; done
@for a in $(LIBSO) ${LIBAR} plugins ; do ${MAKE} $$a ; done

CFLAGS+=-DCORELIB -Iformat -Imangling

Expand Down
1 change: 1 addition & 0 deletions libr/core/cmd_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static int cmd_info(void *data, const char *input) {
" ia ; show all info (imports, exports, sections..)\n"
" ii ; imports\n"
" iI ; binary info\n"
" id ; debug information (source lines)\n"
" ie ; entrypoint\n"
" is ; symbols\n"
" iS ; sections\n"
Expand Down
10 changes: 4 additions & 6 deletions libr/core/cmd_search.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,18 @@ static int __cb_hit(RSearchKeyword *kw, void *user, ut64 addr) {
switch (kw->type) {
case R_SEARCH_KEYWORD_TYPE_STRING:
len = sizeof (str);
r_io_read_at (core->io, addr, (ut8*)str+1, len-2);
r_core_read_at (core, addr, (ut8*)str+1, len-2);
*str = '"';
r_str_filter_zeroline (str, len);
strcpy (str+strlen (str), "\"");
break;
default:
len = kw->keyword_length + 8; // 8 byte context
if (len>=sizeof (str)) len = sizeof (str)-1;
r_io_read_at (core->io, addr, buf, sizeof (buf));
r_core_read_at (core, addr, buf, sizeof (buf));
for (i=0, p=str; i<len; i++) {
sprintf (p, "%02x", buf[i]);
p += 2;
if (i == kw->keyword_length-1)
*p++ = ' ';
}
*p = 0;
break;
Expand Down Expand Up @@ -520,8 +518,8 @@ static int cmd_search(void *data, const char *input) {
eprintf ("\n\n");
break;
}
ret = r_io_read_at (core->io, at, buf, core->blocksize);
//ret = r_core_read_at (core, at, buf, core->blocksize);
//ret = r_core_read_at (core, at, buf, core->blocksize);
ret = r_io_read_at (core->io, at, buf, core->blocksize);
/*
if (ignorecase) {
int i;
Expand Down
1 change: 0 additions & 1 deletion libr/include/r_bin_dwarf.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ typedef struct {
unsigned int column;
} RBinDwarfRow;
#define r_bin_dwarf_line_new(o,a,f,l) o->address=a, o->file = strdup (f), o->line = l, o->column =0,o
//ut64 addr, const char *file, int line)

R_API int r_bin_dwarf_parse_info_raw(const ut8 *obuf);

Expand Down
2 changes: 1 addition & 1 deletion libr/io/io.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2008-2012 pancake<nopcode.org> */
/* radare - LGPL - Copyright 2008-2012 pancake */

#include "r_io.h"
#include "r_util.h"
Expand Down
10 changes: 3 additions & 7 deletions libr/io/p/gdb.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ OBJ_GDB=io_gdb.o
STATIC_OBJ+=${OBJ_GDB}
TARGET_GDB=io_gdb.${EXT_SO}
ALL_TARGETS+=${TARGET_GDB}
# /p
CFLAGS+=-I../debug/p/libgdbwrap/
CFLAGS+=-I../debug/p/libgdbwrap/include
# /
CFLAGS+=-I../../debug/p/libgdbwrap/
CFLAGS+=-I../../debug/p/libgdbwrap/include
#GDBWRAPFILES=../../debug/p/libgdbwrap/gdbwrapper.c

CFLAGS+=-I$(LTOP)/debug/p/libgdbwrap/
CFLAGS+=-I$(LTOP)/debug/p/libgdbwrap/include

# copypasted from socket/Makefile
# on solaris only
Expand Down
10 changes: 7 additions & 3 deletions libr/io/section.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ R_API ut64 r_io_section_vaddr_to_offset(RIO *io, ut64 vaddr) {

r_list_foreach (io->sections, iter, s) {
if (vaddr >= s->vaddr && vaddr < s->vaddr + s->vsize) {
if (s->vaddr == 0) // hack
return vaddr;
// eprintf ("SG: %llx phys=%llx %s\n", vaddr, vaddr-s->vaddr+s->offset, s->name);
return (vaddr - s->vaddr + s->offset);
}
Expand All @@ -200,12 +202,14 @@ R_API ut64 r_io_section_vaddr_to_offset(RIO *io, ut64 vaddr) {
}

R_API ut64 r_io_section_offset_to_vaddr(RIO *io, ut64 offset) {
RListIter *iter;
RIOSection *s;

RListIter *iter;
r_list_foreach (io->sections, iter, s) {
if (offset >= s->offset && offset < s->offset + s->size)
if (offset >= s->offset && offset < s->offset + s->size) {
if (s->vaddr == 0) // hack
return offset;
return (s->vaddr + offset - s->offset);
}
}
return UT64_MAX;
}
Expand Down

0 comments on commit ad4e8b0

Please sign in to comment.