Hide switch/case refs from pds ##print

This commit is contained in:
Óscar Carrasco 2019-04-07 08:58:50 +01:00 committed by radare
parent f08143dc9b
commit 3e2bd4e2de

View File

@ -2235,6 +2235,7 @@ static void disasm_strings(RCore *core, const char *input, RAnalFunction *fcn) {
const char *linecolor = NULL;
char *ox, *qo, *string = NULL;
char *line, *s, *str, *string2 = NULL;
char *switchcmp = NULL;
int i, count, use_color = r_config_get_i (core->config, "scr.color");
bool show_comments = r_config_get_i (core->config, "asm.comments");
bool show_offset = r_config_get_i (core->config, "asm.offset");
@ -2341,7 +2342,9 @@ r_cons_pop();
if (asm_flags) {
str = strstr (line, ";-- ");
if (str) {
r_cons_printf ("%s\n", str);
if (!r_str_startswith (str + 4, "case")) {
r_cons_printf ("%s\n", str);
}
}
}
#define USE_PREFIXES 1
@ -2431,10 +2434,23 @@ r_cons_pop();
if (show_comments) {
char *comment = r_core_anal_get_comments (core, addr);
if (comment) {
if (show_offset) {
r_cons_printf ("%s0x%08"PFMT64x" ", use_color? pal->offset: "", addr);
if (switchcmp) {
if (strcmp (comment, switchcmp)) {
if (show_offset) {
r_cons_printf ("%s0x%08"PFMT64x" ", use_color? pal->offset: "", addr);
}
r_cons_printf ("%s%s\n", use_color? pal->comment: "", comment);
}
}
else {
if (show_offset) {
r_cons_printf ("%s0x%08"PFMT64x" ", use_color? pal->offset: "", addr);
}
r_cons_printf ("%s%s\n", use_color? pal->comment: "", comment);
}
if (r_str_startswith (comment, "switch table")) {
switchcmp = strdup (comment);
}
r_cons_printf ("%s%s\n", use_color? pal->comment: "", comment);
R_FREE (comment);
}
}
@ -2526,6 +2542,7 @@ r_cons_pop();
free (string);
free (s);
free (str);
free (switchcmp);
restore_conf:
r_config_set_i (core->config, "asm.offset", show_offset);
r_config_set_i (core->config, "asm.tabs", asm_tabs);