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;
|
RBinAddr *entry;
|
||||||
RListIter *iter;
|
RListIter *iter;
|
||||||
bool firstexp = true;
|
bool firstexp = true;
|
||||||
bool printHere = false;
|
bool printHere = (args && *args == '.');
|
||||||
|
|
||||||
int i = 0, lastfs = 's';
|
int i = 0, lastfs = 's';
|
||||||
RTable *table = r_core_table (r);
|
RTable *table = r_core_table (r);
|
||||||
bool bin_demangle = r_config_get_i (r->config, "bin.demangle");
|
bool bin_demangle = r_config_get_i (r->config, "bin.demangle");
|
||||||
if (!info) {
|
if (!info) {
|
||||||
if (IS_MODE_JSON (mode)) {
|
if (IS_MODE_JSON (mode)) {
|
||||||
r_cons_printf ("[]");
|
r_cons_printf (printHere? "{}": "[]");
|
||||||
}
|
}
|
||||||
r_table_free (table);
|
r_table_free (table);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args && *args == '.') {
|
PJ *pj = pj_new ();
|
||||||
printHere = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_arm = info && info->arch && !strncmp (info->arch, "arm", 3);
|
bool is_arm = info && info->arch && !strncmp (info->arch, "arm", 3);
|
||||||
const char *lang = bin_demangle ? r_config_get (r->config, "bin.lang") : NULL;
|
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");
|
r_spaces_push (&r->anal->meta_spaces, "bin");
|
||||||
|
|
||||||
if (IS_MODE_JSON (mode) && !printHere) {
|
if (IS_MODE_JSON (mode) && !printHere) {
|
||||||
r_cons_printf ("[");
|
pj_a (pj);
|
||||||
} else if (IS_MODE_SET (mode)) {
|
} else if (IS_MODE_SET (mode)) {
|
||||||
r_flag_space_set (r->flags, R_FLAGS_FS_SYMBOLS);
|
r_flag_space_set (r->flags, R_FLAGS_FS_SYMBOLS);
|
||||||
} else if (!at && exponly) {
|
} 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);
|
r_flag_space_pop (r->flags);
|
||||||
} else if (IS_MODE_JSON (mode)) {
|
} else if (IS_MODE_JSON (mode)) {
|
||||||
char *str = r_str_escape_utf8_for_json (r_symbol_name, -1);
|
char *str = r_str_escape_utf8_for_json (r_symbol_name, -1);
|
||||||
// str = r_str_replace (str, "\"", "\\\"", 1);
|
pj_o (pj);
|
||||||
r_cons_printf ("%s{\"name\":\"%s\","
|
pj_ks (pj, "name", str);
|
||||||
"\"demname\":\"%s\","
|
if (sn.demname) {
|
||||||
"\"flagname\":\"%s\","
|
pj_ks (pj, "demname", sn.demname);
|
||||||
"\"ordinal\":%d,"
|
}
|
||||||
"\"bind\":\"%s\","
|
pj_ks (pj, "flagname", sn.nameflag);
|
||||||
"\"size\":%d,"
|
pj_ks (pj, "realname", symbol->name);
|
||||||
"\"type\":\"%s\","
|
pj_ki (pj, "ordinal", symbol->ordinal);
|
||||||
"\"vaddr\":%"PFMT64d","
|
pj_ks (pj, "bind", symbol->bind);
|
||||||
"\"paddr\":%"PFMT64d","
|
pj_kn (pj, "size", (ut64)symbol->size);
|
||||||
"\"is_imported\":%s}",
|
pj_ks (pj, "type", symbol->type);
|
||||||
((exponly && firstexp) || printHere) ? "" : (iter->p ? "," : ""),
|
pj_kn (pj, "vaddr", addr);
|
||||||
str,
|
pj_kn (pj, "paddr", symbol->paddr);
|
||||||
sn.demname? sn.demname: "",
|
pj_kb (pj, "is_imported", symbol->is_imported);
|
||||||
sn.nameflag,
|
pj_end (pj);
|
||||||
symbol->ordinal,
|
|
||||||
symbol->bind,
|
|
||||||
(int)symbol->size,
|
|
||||||
symbol->type,
|
|
||||||
(ut64)addr, (ut64)symbol->paddr,
|
|
||||||
symbol->is_imported ? "true" : "false");
|
|
||||||
free (str);
|
free (str);
|
||||||
} else if (IS_MODE_SIMPLE (mode)) {
|
} else if (IS_MODE_SIMPLE (mode)) {
|
||||||
const char *name = sn.demname? sn.demname: r_symbol_name;
|
const char *name = sn.demname? sn.demname: r_symbol_name;
|
||||||
|
@ -2339,10 +2331,6 @@ next:
|
||||||
r_cons_printf ("\n%s", s);
|
r_cons_printf ("\n%s", s);
|
||||||
free (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
|
//handle thumb and arm for entry point since they are not present in symbols
|
||||||
if (is_arm) {
|
if (is_arm) {
|
||||||
|
@ -2352,9 +2340,14 @@ next:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (IS_MODE_JSON (mode) && !printHere) {
|
if (IS_MODE_JSON (mode)) {
|
||||||
r_cons_printf ("]");
|
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_spaces_pop (&r->anal->meta_spaces);
|
||||||
r_table_free (table);
|
r_table_free (table);
|
||||||
|
|
|
@ -776,7 +776,7 @@ EXPECT='
|
||||||
nth paddr vaddr bind type size lib name
|
nth paddr vaddr bind type size lib name
|
||||||
----------------------------------------------------
|
----------------------------------------------------
|
||||||
22 0x000009b7 0x080489b7 GLOBAL FUNC 189 decrypt
|
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
|
CMDS=<<EOF
|
||||||
s 0x080489b9
|
s 0x080489b9
|
||||||
iE.
|
iE.
|
||||||
|
|
Loading…
Reference in New Issue