This commit is contained in:
Florian Märkl 2018-11-08 15:06:30 +01:00 committed by radare
parent 59362823d4
commit 1f14da28d5
2 changed files with 21 additions and 13 deletions

View File

@ -700,12 +700,8 @@ static int meta_print_item(void *user, const char *k, const char *v) {
if (!meta_deserialize (&it, k, v)) {
return 1;
}
int uirad = ui->rad;
if (ui->rad == 'f') {
if (!r_anal_fcn_in (ui->fcn, it.from)) {
goto beach;
}
ui->rad = 0;
if (ui->fcn && !r_anal_fcn_in (ui->fcn, it.from)) {
goto beach;
}
if (!it.str) {
it.str = strdup (""); // don't break in free
@ -716,19 +712,26 @@ static int meta_print_item(void *user, const char *k, const char *v) {
r_meta_print (ui->anal, &it, ui->rad, true);
beach:
free (it.str);
ui->rad = uirad;
return 1;
}
R_API int r_meta_list_cb(RAnal *a, int type, int rad, SdbForeachCallback cb, void *user, ut64 addr) {
RAnalFunction *fcn = (addr != UT64_MAX) ? r_anal_get_fcn_at (a, addr, 0) : NULL;
RAnalMetaUserItem ui = { a, type, rad, cb, user, 0, fcn};
SdbList *ls = sdb_foreach_list (DB, true);
SdbListIter *lsi;
SdbKv *kv;
if (rad == 'j') {
a->cb_printf ("[");
}
RAnalMetaUserItem ui = { a, type, rad, cb, user, 0, NULL };
if (addr != UT64_MAX) {
ui.fcn = r_anal_get_fcn_in (a, addr, 0);
if (!ui.fcn) {
goto beach;
}
}
SdbList *ls = sdb_foreach_list (DB, true);
SdbListIter *lsi;
SdbKv *kv;
isFirst = true; // TODO: kill global
ls_foreach (ls, lsi, kv) {
if (type == R_META_TYPE_ANY || (strlen (sdbkv_key (kv)) > 5 && sdbkv_key (kv)[5] == type)) {
@ -740,6 +743,8 @@ R_API int r_meta_list_cb(RAnal *a, int type, int rad, SdbForeachCallback cb, voi
}
}
ls_free (ls);
beach:
if (rad == 'j') {
a->cb_printf ("]\n");
}

View File

@ -388,8 +388,11 @@ static int cmd_meta_comment(RCore *core, const char *input) {
case 'j': // "CCfj"
r_meta_list_at (core->anal, R_META_TYPE_COMMENT, 'j', core->offset);
break;
case '*': // "CCf*"
r_meta_list_at (core->anal, R_META_TYPE_COMMENT, 1, core->offset);
break;
default:
r_meta_list_at (core->anal, R_META_TYPE_COMMENT, 'f', core->offset);
r_meta_list_at (core->anal, R_META_TYPE_COMMENT, 0, core->offset);
break;
}
break;