Use PJ api in the output of isj and show realname ##json (#15826)
This commit is contained in:
parent
7ef9dc813e
commit
0d701a3b79
|
@ -2087,22 +2087,20 @@ static int bin_symbols(RCore *r, int mode, ut64 laddr, int va, ut64 at, const ch
|
|||
RBinAddr *entry;
|
||||
RListIter *iter;
|
||||
bool firstexp = true;
|
||||
bool printHere = false;
|
||||
bool printHere = (args && *args == '.');
|
||||
|
||||
int i = 0, lastfs = 's';
|
||||
RTable *table = r_core_table (r);
|
||||
bool bin_demangle = r_config_get_i (r->config, "bin.demangle");
|
||||
if (!info) {
|
||||
if (IS_MODE_JSON (mode)) {
|
||||
r_cons_printf ("[]");
|
||||
r_cons_printf (printHere? "{}": "[]");
|
||||
}
|
||||
r_table_free (table);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (args && *args == '.') {
|
||||
printHere = true;
|
||||
}
|
||||
|
||||
PJ *pj = pj_new ();
|
||||
bool is_arm = info && info->arch && !strncmp (info->arch, "arm", 3);
|
||||
const char *lang = bin_demangle ? r_config_get (r->config, "bin.lang") : NULL;
|
||||
|
||||
|
@ -2110,7 +2108,7 @@ static int bin_symbols(RCore *r, int mode, ut64 laddr, int va, ut64 at, const ch
|
|||
r_spaces_push (&r->anal->meta_spaces, "bin");
|
||||
|
||||
if (IS_MODE_JSON (mode) && !printHere) {
|
||||
r_cons_printf ("[");
|
||||
pj_a (pj);
|
||||
} else if (IS_MODE_SET (mode)) {
|
||||
r_flag_space_set (r->flags, R_FLAGS_FS_SYMBOLS);
|
||||
} else if (!at && exponly) {
|
||||
|
@ -2217,27 +2215,21 @@ static int bin_symbols(RCore *r, int mode, ut64 laddr, int va, ut64 at, const ch
|
|||
r_flag_space_pop (r->flags);
|
||||
} else if (IS_MODE_JSON (mode)) {
|
||||
char *str = r_str_escape_utf8_for_json (r_symbol_name, -1);
|
||||
// str = r_str_replace (str, "\"", "\\\"", 1);
|
||||
r_cons_printf ("%s{\"name\":\"%s\","
|
||||
"\"demname\":\"%s\","
|
||||
"\"flagname\":\"%s\","
|
||||
"\"ordinal\":%d,"
|
||||
"\"bind\":\"%s\","
|
||||
"\"size\":%d,"
|
||||
"\"type\":\"%s\","
|
||||
"\"vaddr\":%"PFMT64d","
|
||||
"\"paddr\":%"PFMT64d","
|
||||
"\"is_imported\":%s}",
|
||||
((exponly && firstexp) || printHere) ? "" : (iter->p ? "," : ""),
|
||||
str,
|
||||
sn.demname? sn.demname: "",
|
||||
sn.nameflag,
|
||||
symbol->ordinal,
|
||||
symbol->bind,
|
||||
(int)symbol->size,
|
||||
symbol->type,
|
||||
(ut64)addr, (ut64)symbol->paddr,
|
||||
symbol->is_imported ? "true" : "false");
|
||||
pj_o (pj);
|
||||
pj_ks (pj, "name", str);
|
||||
if (sn.demname) {
|
||||
pj_ks (pj, "demname", sn.demname);
|
||||
}
|
||||
pj_ks (pj, "flagname", sn.nameflag);
|
||||
pj_ks (pj, "realname", symbol->name);
|
||||
pj_ki (pj, "ordinal", symbol->ordinal);
|
||||
pj_ks (pj, "bind", symbol->bind);
|
||||
pj_kn (pj, "size", (ut64)symbol->size);
|
||||
pj_ks (pj, "type", symbol->type);
|
||||
pj_kn (pj, "vaddr", addr);
|
||||
pj_kn (pj, "paddr", symbol->paddr);
|
||||
pj_kb (pj, "is_imported", symbol->is_imported);
|
||||
pj_end (pj);
|
||||
free (str);
|
||||
} else if (IS_MODE_SIMPLE (mode)) {
|
||||
const char *name = sn.demname? sn.demname: r_symbol_name;
|
||||
|
@ -2339,10 +2331,6 @@ next:
|
|||
r_cons_printf ("\n%s", s);
|
||||
free (s);
|
||||
}
|
||||
if (count == 0 && IS_MODE_JSON (mode)) {
|
||||
r_cons_printf ("{}");
|
||||
}
|
||||
|
||||
|
||||
//handle thumb and arm for entry point since they are not present in symbols
|
||||
if (is_arm) {
|
||||
|
@ -2352,9 +2340,14 @@ next:
|
|||
}
|
||||
}
|
||||
}
|
||||
if (IS_MODE_JSON (mode) && !printHere) {
|
||||
r_cons_printf ("]");
|
||||
if (IS_MODE_JSON (mode)) {
|
||||
if (!printHere) {
|
||||
pj_end (pj);
|
||||
}
|
||||
const char *js = pj_string (pj);
|
||||
r_cons_printf ("%s", (js && *js)? js: "{}");
|
||||
}
|
||||
pj_free (pj);
|
||||
|
||||
r_spaces_pop (&r->anal->meta_spaces);
|
||||
r_table_free (table);
|
||||
|
|
|
@ -776,7 +776,7 @@ EXPECT='
|
|||
nth paddr vaddr bind type size lib name
|
||||
----------------------------------------------------
|
||||
22 0x000009b7 0x080489b7 GLOBAL FUNC 189 decrypt
|
||||
{"name":"prog_timeout","demname":"","flagname":"sym.prog_timeout","ordinal":35,"bind":"GLOBAL","size":17,"type":"FUNC","vaddr":134515110,"paddr":2470,"is_imported":false}'
|
||||
{"name":"prog_timeout","flagname":"sym.prog_timeout","realname":"prog_timeout","ordinal":35,"bind":"GLOBAL","size":17,"type":"FUNC","vaddr":134515110,"paddr":2470,"is_imported":false}'
|
||||
CMDS=<<EOF
|
||||
s 0x080489b9
|
||||
iE.
|
||||
|
|
Loading…
Reference in New Issue