mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-12 07:26:42 +00:00
pj-ify dmmj
This commit is contained in:
parent
f9de72b564
commit
1d0faf8bc4
@ -1359,31 +1359,32 @@ show_help:
|
||||
r_core_cmd_help (core, help_msg_dmm);
|
||||
return;
|
||||
}
|
||||
PJ *pj = pj_new ();
|
||||
if (mode == 'j') {
|
||||
r_cons_print ("[");
|
||||
pj_a (pj);
|
||||
}
|
||||
// TODO: honor mode
|
||||
list = r_debug_modules_list (core->dbg);
|
||||
r_list_foreach (list, iter, map) {
|
||||
switch (mode) {
|
||||
case 0:
|
||||
r_cons_printf ("0x%08"PFMT64x" %s\n", map->addr, map->file);
|
||||
r_cons_printf ("0x%08"PFMT64x" 0x%08"PFMT64x" %s\n", map->addr, map->addr_end, map->file);
|
||||
break;
|
||||
case '.':
|
||||
if (addr >= map->addr && addr < map->addr_end) {
|
||||
r_cons_printf ("0x%08"PFMT64x" %s\n", map->addr, map->file);
|
||||
r_cons_printf ("0x%08"PFMT64x" 0x%08"PFMT64x" %s\n", map->addr, map->addr_end, map->file);
|
||||
goto beach;
|
||||
}
|
||||
break;
|
||||
case 'j':
|
||||
{
|
||||
/* Escape backslashes (e.g. for Windows). */
|
||||
char *escaped_path = r_str_escape (map->file);
|
||||
char *escaped_name = r_str_escape (map->name);
|
||||
r_cons_printf ("{\"address\":%"PFMT64d",\"name\":\"%s\",\"file\":\"%s\"}%s",
|
||||
map->addr, escaped_name, escaped_path, iter->n?",":"");
|
||||
free (escaped_path);
|
||||
free (escaped_name);
|
||||
pj_o (pj);
|
||||
pj_kn (pj, "addr", map->addr);
|
||||
pj_kn (pj, "addr_end", map->addr_end);
|
||||
pj_ks (pj, "file", map->file);
|
||||
pj_ks (pj, "name", map->name);
|
||||
pj_end (pj);
|
||||
}
|
||||
break;
|
||||
case ':':
|
||||
@ -1410,7 +1411,9 @@ show_help:
|
||||
}
|
||||
beach:
|
||||
if (mode == 'j') {
|
||||
r_cons_print ("]\n");
|
||||
pj_end (pj);
|
||||
r_cons_printf ("%s\n", pj_string (pj));
|
||||
pj_free (pj);
|
||||
}
|
||||
r_list_free (list);
|
||||
}
|
||||
@ -2014,34 +2017,37 @@ static void cmd_reg_profile (RCore *core, char from, const char *str) { // "arp"
|
||||
RListIter *iter;
|
||||
RRegItem *r;
|
||||
int i;
|
||||
int first = 1;
|
||||
r_cons_printf ("{\"alias_info\":[");
|
||||
PJ *pj = pj_new ();
|
||||
pj_o (pj);
|
||||
pj_k (pj, "alias_info");
|
||||
pj_a (pj);
|
||||
for (i = 0; i < R_REG_NAME_LAST; i++) {
|
||||
if (core->dbg->reg->name[i]) {
|
||||
if (!first) r_cons_printf (",");
|
||||
r_cons_printf ("{\"role\":%d,", i);
|
||||
r_cons_printf ("\"role_str\":\"%s\",",
|
||||
r_reg_get_role (i));
|
||||
r_cons_printf ("\"reg\":\"%s\"}",
|
||||
core->dbg->reg->name[i]);
|
||||
first = 0;
|
||||
pj_o (pj);
|
||||
pj_kn (pj, "role", i);
|
||||
pj_ks (pj, "role_str", r_reg_get_role (i));
|
||||
pj_ks (pj, "reg", core->dbg->reg->name[i]);
|
||||
pj_end (pj);
|
||||
}
|
||||
}
|
||||
r_cons_printf ("],\"reg_info\":[");
|
||||
first = 1;
|
||||
pj_end (pj);
|
||||
pj_k (pj, "reg_info");
|
||||
pj_a (pj);
|
||||
for (i = 0; i < R_REG_TYPE_LAST; i++) {
|
||||
r_list_foreach (core->dbg->reg->regset[i].regs, iter, r) {
|
||||
if (!first) r_cons_printf (",");
|
||||
r_cons_printf ("{\"type\":%d,", r->type);
|
||||
r_cons_printf ("\"type_str\":\"%s\",",
|
||||
r_reg_get_type (r->type));
|
||||
r_cons_printf ("\"name\":\"%s\",", r->name);
|
||||
r_cons_printf ("\"size\":%d,", r->size);
|
||||
r_cons_printf ("\"offset\":%d}", r->offset);
|
||||
first = 0;
|
||||
pj_o (pj);
|
||||
pj_kn (pj, "type", r->type);
|
||||
pj_ks (pj, "type_str", r_reg_get_type (r->type));
|
||||
pj_ks (pj, "name", r->name);
|
||||
pj_kn (pj, "size", r->size);
|
||||
pj_kn (pj, "offset", r->offset);
|
||||
pj_end (pj);
|
||||
}
|
||||
}
|
||||
r_cons_printf ("]}");
|
||||
pj_end (pj); // "]"
|
||||
pj_end (pj); // "}"
|
||||
r_cons_printf ("%s", pj_string (pj));
|
||||
pj_free (pj);
|
||||
}
|
||||
break;
|
||||
case '?': // "drp?"
|
||||
|
Loading…
Reference in New Issue
Block a user