* Fix set_reg_profile callback in r_anal_arm

* Fix dupness issue between RDebug and RAnal sharing RReg
  - Move reg_profile string into inner RReg
* Remove vm.arch setup in rasm2 -ri
This commit is contained in:
pancake 2011-03-24 00:54:09 +01:00
parent 4ab7173cc3
commit daff6aff5d
9 changed files with 23 additions and 21 deletions

View File

@ -419,10 +419,9 @@ static int rabin_show_info() {
"e asm.arch=%s\n"
"e anal.plugin=%s\n"
"e asm.bits=%i\n"
"e vm.arch=%s\n"
"e asm.dwarf=%s\n",
info->rclass, info->big_endian?"true":"false", info->os,
info->arch, info->arch, info->bits, info->arch,
info->arch, info->arch, info->bits,
R_BIN_DBG_STRIPPED (info->dbg_info)?"false":"true");
} else {
eprintf ("[File info]\n");

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2007-2010 */
/* radare - LGPL - Copyright 2007-2011 */
/* pancake<nopcode.org> */
#include <string.h>
@ -275,7 +275,7 @@ struct r_anal_plugin_t r_anal_plugin_arm = {
.init = NULL,
.fini = NULL,
.op = &arm_op,
.set_reg_profile = NULL,
.set_reg_profile = set_reg_profile,
.fingerprint_bb = NULL,
.fingerprint_fcn = NULL,
.diff_bb = NULL,

View File

@ -837,9 +837,11 @@ static void cmd_reg(RCore *core, const char *str) {
break;
case 'p':
if (!str[1]) {
if (core->dbg->reg_profile)
r_cons_printf ("%s\n", core->dbg->reg_profile);
else eprintf ("No register profile defined. Try 'dr.'\n");
if (core->dbg->reg->reg_profile) {
//core->anal->reg = core->dbg->reg;
r_cons_printf ("%s\n", core->dbg->reg->reg_profile);
//r_cons_printf ("%s\n", core->anal->reg->reg_profile);
} else eprintf ("No register profile defined. Try 'dr.'\n");
} else r_reg_set_profile (core->dbg->reg, str+2);
core->anal->reg = core->dbg->reg;
break;

View File

@ -77,8 +77,7 @@ static int config_analplugin_callback(void *user, void *data) {
if (node->value[0] == '?') {
r_anal_list (core->anal);
return R_FALSE;
}
else if (!r_anal_use (core->anal, node->value)) {
} else if (!r_anal_use (core->anal, node->value)) {
eprintf ("Cannot use '%s' anal plugin.\n", node->value);
return R_FALSE;
}
@ -309,7 +308,7 @@ R_API int r_core_config_init(RCore *core) {
r_config_set_i (cfg, "anal.depth", 100);
r_config_set_i (cfg, "anal.ptrdepth", 3);
r_config_set_cb (cfg, "anal.split", "true", &config_analsplit_callback);
r_config_set_cb (cfg, "anal.plugin", "x86", &config_analplugin_callback);
r_config_set_cb (cfg, "anal.plugin", R_SYS_ARCH, &config_analplugin_callback);
/* asm */
r_config_set_cb (cfg, "asm.arch", R_SYS_ARCH, &config_asmarch_callback);
// XXX: not portable

View File

@ -312,8 +312,8 @@ R_API int r_core_init(RCore *core) {
r_core_cmd_init (core);
core->flags = r_flag_new ();
core->dbg = r_debug_new (R_TRUE);
r_debug_use (core->dbg, "native");
core->dbg->anal = core->anal; // XXX: dupped instance.. can cause lost pointerz
r_debug_use (core->dbg, "native");
r_reg_arena_push (core->dbg->reg); // create a 2 level register state stack
// core->dbg->anal->reg = core->anal->reg; // XXX: dupped instance.. can cause lost pointerz
core->sign->printf = r_cons_printf;

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2009-2010 pancake<nopcode.org> */
/* radare - LGPL - Copyright 2009-2011 pancake<nopcode.org> */
#include <r_debug.h>
#include "../config.h"
@ -14,7 +14,6 @@ R_API int r_debug_plugin_init(RDebug *dbg) {
RDebugPlugin *static_plugin;
int i;
dbg->reg_profile = NULL;
INIT_LIST_HEAD (&dbg->plugins);
for (i=0; debug_static_plugins[i]; i++) {
static_plugin = R_NEW (RDebugPlugin);
@ -33,13 +32,13 @@ R_API int r_debug_use(RDebug *dbg, const char *str) {
dbg->bp->breakpoint = dbg->h->breakpoint;
dbg->bp->user = dbg;
if (h->reg_profile) {
free (dbg->reg_profile);
dbg->reg_profile = dbg->h->reg_profile ();
free (dbg->reg->reg_profile);
dbg->reg->reg_profile = dbg->h->reg_profile ();
if (dbg->anal)
dbg->anal->reg = dbg->reg;
if (h->init)
h->init (dbg);
r_reg_set_profile_string (dbg->reg, dbg->reg_profile);
r_reg_set_profile_string (dbg->reg, dbg->reg->reg_profile);
}
return R_TRUE;
}

View File

@ -91,7 +91,6 @@ typedef struct r_debug_t {
int reason; /* stop reason */
RDebugTrace *trace;
int stop_all_threads;
char *reg_profile;
struct r_reg_t *reg;
RBreakpoint *bp;
void *user;

View File

@ -51,6 +51,7 @@ typedef struct r_reg_set_t {
typedef struct r_reg_t {
char *profile;
char *reg_profile;
char *name[R_REG_NAME_LAST];
RRegSet regset[R_REG_TYPE_LAST];
int iters;

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2009-2010 pancake<nopcode.org> */
/* radare - LGPL - Copyright 2009-2011 pancake<nopcode.org> */
#include <r_reg.h>
#include <r_util.h>
@ -35,7 +35,6 @@ R_API int r_reg_get_name_idx(const char *type) {
return -1;
}
R_API int r_reg_set_name(RReg *reg, int role, const char *name) {
if (role>=0 && role<R_REG_NAME_LAST) {
reg->name[role] = r_str_dup (reg->name[role], name);
@ -151,6 +150,8 @@ R_API int r_reg_set_profile_string(RReg *reg, const char *str) {
if (!str||!reg)
return R_FALSE;
free (reg->reg_profile);
reg->reg_profile = strdup (str);
buf[0] = '\0';
/* format file is: 'type name size offset packedsize' */
r_reg_free_internal (reg);
@ -183,15 +184,17 @@ R_API int r_reg_set_profile_string(RReg *reg, const char *str) {
r_reg_set_word (item, word, buf);
if (item->name != NULL) {
r_list_append (reg->regset[item->type].regs, item);
item = r_reg_item_new();
item = r_reg_item_new ();
}
}
chidx = word = 0;
setname = -1;
break;
default:
if (chidx>128) // WTF!!
if (chidx>128) {// WTF!!
eprintf ("PARSE FAILED\n");
return R_FALSE;
}
buf[chidx++] = *str;
buf[chidx] = 0;
break;