Fix om for rbin-friendly files, add 'dss'

Implement dss command to skip steps
omr works with just a single argument too
Fix open maps for RBin files
Merge r_th into r_util
This commit is contained in:
pancake 2012-10-25 15:21:47 +02:00
parent ded886e371
commit 5de2e221b2
17 changed files with 56 additions and 128 deletions

View File

@ -347,6 +347,13 @@ Future
- the r_flag_get by string should have another construction with btree
for the string of the name
Threads
=======
* implement non-threaded thread api (dummy one, when no support)
* test w32 port
* Implement a pure clone(2) backend
* Added a threading pool super-api
# Debug information in binaries
* dwarf, pdb, def, lib
- from file, from section, ...

2
configure vendored
View File

@ -475,7 +475,7 @@ for A in ${ENVWORDS} ; do
SEDFLAGS="${SEDFLAGS}s,@${A}@,${VAR},g;"
done
SEDFLAGS="${SEDFLAGS}'"
for A in ./config-user.mk libr/include/r_userconf.h pkgcfg/r_io.pc pkgcfg/r_db.pc pkgcfg/r_magic.pc pkgcfg/r_asm.pc pkgcfg/r_bin.pc pkgcfg/r_anal.pc pkgcfg/r_hash.pc pkgcfg/r_cons.pc pkgcfg/r_diff.pc pkgcfg/r_core.pc pkgcfg/r_lang.pc pkgcfg/r_socket.pc pkgcfg/r_debug.pc pkgcfg/r_reg.pc pkgcfg/r_cmd.pc pkgcfg/r_config.pc pkgcfg/r_flags.pc pkgcfg/r_syscall.pc pkgcfg/r_sign.pc pkgcfg/r_util.pc pkgcfg/r_search.pc pkgcfg/r_bp.pc pkgcfg/r_lib.pc pkgcfg/r_parse.pc pkgcfg/r_print.pc pkgcfg/r_th.pc pkgcfg/r_fs.pc ; do # SUBDIRS
for A in ./config-user.mk libr/include/r_userconf.h pkgcfg/r_io.pc pkgcfg/r_db.pc pkgcfg/r_magic.pc pkgcfg/r_asm.pc pkgcfg/r_bin.pc pkgcfg/r_anal.pc pkgcfg/r_hash.pc pkgcfg/r_cons.pc pkgcfg/r_diff.pc pkgcfg/r_core.pc pkgcfg/r_lang.pc pkgcfg/r_socket.pc pkgcfg/r_debug.pc pkgcfg/r_reg.pc pkgcfg/r_cmd.pc pkgcfg/r_config.pc pkgcfg/r_flags.pc pkgcfg/r_syscall.pc pkgcfg/r_sign.pc pkgcfg/r_util.pc pkgcfg/r_search.pc pkgcfg/r_bp.pc pkgcfg/r_lib.pc pkgcfg/r_parse.pc pkgcfg/r_print.pc pkgcfg/r_fs.pc ; do # SUBDIRS
if [ -f "${VPATH}/${A}.acr" ]; then
SD_TARGET=${A}
else

View File

@ -132,6 +132,5 @@ SUBDIRS ./config-user.mk
pkgcfg/r_lib.pc
pkgcfg/r_parse.pc
pkgcfg/r_print.pc
pkgcfg/r_th.pc
pkgcfg/r_fs.pc
;

View File

@ -7,7 +7,7 @@ LFX=${DESTDIR}/${LIBDIR}
IFX=${DESTDIR}/${INCLUDEDIR}
PWD=$(shell pwd)
LIBS0=util hash th socket
LIBS0=util hash socket
LIBS1=reg cons db magic lib diff bp search config
LIBS2=syscall cmd lang io crypto flags bin
LIBS3=fs anal

View File

@ -430,7 +430,6 @@ static void cmd_debug_reg(RCore *core, const char *str) {
*arg = 0;
r = r_reg_get (core->dbg->reg, str+1, R_REG_TYPE_GPR);
if (r) {
//eprintf ("SET(%s)(%s)\n", str, arg+1);
r_cons_printf ("0x%08"PFMT64x" ->", str,
r_reg_get_value (core->dbg->reg, r));
r_reg_set_value (core->dbg->reg, r,
@ -448,10 +447,8 @@ static void cmd_debug_reg(RCore *core, const char *str) {
*arg='\0';
size = atoi (arg);
} else size = core->dbg->bits;
//eprintf ("ARG(%s)\n", str+1);
type = r_reg_type_by_name (str+1);
}
//printf("type = %d\nsize = %d\n", type, size);
if (type != R_REG_TYPE_LAST) {
r_debug_reg_sync (core->dbg, type, R_FALSE);
r_debug_reg_list (core->dbg, type, size, str[0]=='*');
@ -727,6 +724,7 @@ static int cmd_debug(void *data, const char *input) {
r_cons_printf ("Usage: ds[ol] [count]\n"
" ds step one instruction\n"
" ds 4 step 4 instructions\n"
" dss 3 skip 3 step instructions\n"
" dso 3 step over 3 instructions\n"
" dsp step into program (skip libs)\n"
" dsu addr step until address\n"
@ -761,6 +759,25 @@ static int cmd_debug(void *data, const char *input) {
}
}
break;
case 's':
{
ut64 addr = r_debug_reg_get (core->dbg, "pc");
r_reg_arena_swap (core->dbg->reg, R_TRUE);
for (i=0; i<times; i++) {
ut8 buf[64];
RAnalOp aop;
r_debug_reg_sync (core->dbg, R_REG_TYPE_GPR, R_FALSE);
r_io_read_at (core->io, addr, buf, sizeof (buf));
r_anal_op (core->anal, &aop, addr, buf, sizeof (buf));
if (aop.jump != UT64_MAX && aop.fail != UT64_MAX) {
eprintf ("Dont know how to skip this instruction\n");
break;
}
addr += aop.length;
}
r_debug_reg_set (core->dbg, "pc", addr);
}
break;
case 'o':
r_reg_arena_swap (core->dbg->reg, R_TRUE);
r_debug_step_over (core->dbg, times);

View File

@ -3,7 +3,9 @@
static int cmd_open(void *data, const char *input) {
RCore *core = (RCore*)data;
int perms = R_IO_READ;
RIOMap *map = NULL;
RCoreFile *file;
RListIter *iter;
int num = -1;
ut64 addr;
char *ptr;
@ -42,7 +44,6 @@ static int cmd_open(void *data, const char *input) {
switch (input[1]) {
case 'r':
{
RIOMap *map;
ut64 cur, new;
const char *p = strchr (input+3, ' ');
if (p) {
@ -56,7 +57,17 @@ static int cmd_open(void *data, const char *input) {
map->from = new;
map->to = new+diff;
} else eprintf ("Cannot find any map here\n");
} else eprintf ("Usage: omr [oldbase] [newbase]\n");
} else {
cur = core->offset;
new = r_num_math (core->num, input+3);
map = r_io_map_resolve (core->io, core->file->fd->fd);
if (map) {
ut64 diff = map->to - map->from;
map->from = new;
map->to = new+diff;
} else eprintf ("Cannot find any map here\n");
}
}
break;
case ' ':
@ -97,14 +108,10 @@ static int cmd_open(void *data, const char *input) {
}
break;
case '\0':
{
RIOMap *im = NULL;
RListIter *iter;
r_list_foreach (core->io->maps, iter, im) { // _prev?
r_list_foreach (core->io->maps, iter, map) { // _prev?
r_cons_printf (
"%d +0x%08"PFMT64x" 0x%08"PFMT64x" - 0x%08"PFMT64x"\n",
im->fd, im->delta, im->from, im->to);
}
"%d +0x%"PFMT64x" 0x%08"PFMT64x" - 0x%08"PFMT64x"\n",
(int)map->fd, (ut64)map->delta, (ut64)map->from, (ut64)map->to);
}
break;
default:

View File

@ -454,7 +454,7 @@ static int cmd_print(void *data, const char *input) {
break;
case 'W':
for (i=0; i<len; i+=4) {
ut32 *p = core->block+i;
ut32 *p = (ut32*)core->block+i;
r_cons_printf ("0x%08"PFMT64x" 0x%08x\n", core->offset+i, *p);
}
break;
@ -463,7 +463,7 @@ static int cmd_print(void *data, const char *input) {
break;
case 'Q':
for (i=0; i<len; i+=8) {
ut64 *p = core->block+i;
ut64 *p = (ut64*)core->block+i;
r_cons_printf ("0x%08"PFMT64x" 0x%016"PFMT64x"\n",
core->offset+i, *p);
}

View File

@ -162,13 +162,16 @@ R_API int r_core_bin_load(RCore *r, const char *file) {
}
}
r_bin_select (r->bin, r->assembler->cur->arch, r->assembler->bits, NULL);//"x86_32");
{
RIOMap *im;
RListIter *iter;
/* Fix for fat bins */
r_list_foreach (r->io->maps, iter, im) {
im->delta = r->bin->cur.offset;
im->to = im->from + r->bin->cur.size;
if (r->bin->cur.size > 0) {
im->delta = r->bin->cur.offset;
im->to = im->from + r->bin->cur.size;
}
}
}
} else if (!r_bin_load (r->bin, file, R_TRUE))

View File

@ -1,10 +0,0 @@
include ../config.mk
NAME=r_th
DEPS=
LDFLAGS=${TH_LIBS}
OBJS=th.o lock.o
include ../rules.mk

View File

@ -1,21 +0,0 @@
R_TH :: TODO
============
* implement non-threaded thread api (dummy one, when no support)
* test w32 port
* Implement a pure clone(2) backend
* Added a threading pool super-api
/* pools */
R_API void r_th_pool_init(struct r_th_pool_t *thp, int threads, int size)
{
/* TODO: use a thread pool to handle a list of 'size' tasks */
}
R_API struct r_th_pool_t *r_th_pool_new(int threads, int size)
{
struct r_th_pool_t *thp = R_NEW(struct r_th_pool_t);
r_th_pool_init(thp, threads, size);
return thp;
}

View File

@ -1,5 +0,0 @@
OBJ=test.o
BIN=test
BINDEPS=r_th r_util
include ../../rules.mk

View File

@ -1,59 +0,0 @@
/* radare - LGPL - Copyright 2010 pancake<nopcode.org> */
// XXX: Must be implemented
// Launch thread if requested
// Support multiple group of tasks (more than one core f.ex)
//
#include <r_types.h>
#define RTask int
#define MAXTASKS (sizeof (int))
static int tasks;
void int r_task_new(int t, int ) {
if (tasks & flags)
return -1;
tasks |= flags;
return flags;
}
R_API int r_task_wait(int t) {
}
R_API int r_task_step(int t) {
// check and lock if cant continue or stop if cancelled
}
R_API int r_task_stop(int t) {
}
R_API int r_task_pause() {
}
R_API int r_task_finish() {
}
R_API int r_task_check() {
}
#ifdef TEST
#define T_FLAGS 1
#define T_SEARCH 2
void task1() {
RTask t = r_task_new (foo1);
for (;;) {
if (!r_task_step (t) && !r_task_wait (t)) {
r_task_kill (t);
return;
}
}
}
int main() {
return 0;
}
#endif

View File

@ -7,7 +7,7 @@ OBJS=mem.o pool.o num.o str.o hex.o file.o alloca.o range.o log.o
OBJS+=prof.o cache.o sys.o buf.o w32-sys.o base64.o base85.o name.o
OBJS+=list.o flist.o ht.o ht64.o mixed.o btree.o chmod.o graph.o
OBJS+=regex/regcomp.o regex/regerror.o regex/regexec.o uleb128.o
OBJS+=sandbox.o calc.o
OBJS+=sandbox.o calc.o thread.o lock.o
# DO NOT BUILD r_big api (not yet used and its buggy)
ifeq (1,0)
@ -23,6 +23,7 @@ endif
endif
LDFLAGS+=${BN_LIBS}
LDFLAGS=${TH_LIBS}
include ../rules.mk

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2009 pancake<@nopcode.org> */
/* radare - LGPL - Copyright 2009-2012 - pancake */
#include <r_th.h>

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2009-2010 pancake<@nopcode.org> */
/* radare - LGPL - Copyright 2009-2012 - pancake */
#include <r_th.h>

View File

@ -1,11 +0,0 @@
prefix=@PREFIX@
exec_prefix=${prefix}
libdir=@LIBDIR@
includedir=${prefix}/include
Name: r_th
Description: radare foundation libraries
Version: @VERSION@
Requires:
Libs: -L${libdir} -lr_th
Cflags: -I${includedir}/libr