Enhace 'tb' (bitfield types) output

This commit is contained in:
pancake 2014-09-22 17:23:17 +02:00
parent f7eee65067
commit bb6e9c0074
2 changed files with 10 additions and 6 deletions

View File

@ -47,7 +47,7 @@ static void var_help(RCore *core, char ch) {
static int var_cmd(RCore *core, const char *str) {
RAnalFunction *fcn = r_anal_fcn_find (core->anal, core->offset, -1);
char *p, *p2, *p3, *ostr;
char *p, *ostr;
int scope, delta, type = *str;
ostr = p = strdup (str);
@ -97,7 +97,7 @@ static int var_cmd(RCore *core, const char *str) {
int rw = 0; // 0 = read, 1 = write
char kind = type;
RAnalVar *var = r_anal_var_get (core->anal, fcn->addr,
&kind, atoi (str+2), R_ANAL_VAR_SCOPE_LOCAL);
kind, atoi (str+2), R_ANAL_VAR_SCOPE_LOCAL);
if (var != NULL) {
int scope = (str[1]=='g')?0: 1;
r_anal_var_access (core->anal, fcn->addr, kind,

View File

@ -66,7 +66,7 @@ static int cmd_type(void *data, const char *input) {
break;
case 'b':
{
int i;
int i;
char *p, *s = strdup (input+2);
const char *isenum;
p = strchr (s, ' ');
@ -74,17 +74,21 @@ static int cmd_type(void *data, const char *input) {
*p++ = 0;
isenum = sdb_const_get (core->anal->sdb_types, s, 0);
if (isenum && !strcmp (isenum, "enum")) {
int empty = 1;
ut32 num = (ut32)r_num_math (core->num, p);
r_cons_printf ("0x%08"PFMT64x" : ", num);
for (i=0; i< 32; i++) {
if (num & (1<<i)) {
const char *q = sdb_fmt (0, "%s.0x%x", s, (1<<i));
const char *res = sdb_const_get (core->anal->sdb_types, q, 0);
if (res) r_cons_printf ("%s | ", res);
else r_cons_printf ("0x%x | ", (1<<i));
if (!empty)
r_cons_printf (" | ");
if (res) r_cons_printf ("%s", res);
else r_cons_printf ("0x%x", (1<<i));
empty = 0;
}
}
r_cons_printf ("0\n");
} else {
eprintf ("This is not an enum\n");
}