Fix asm.lines.bb with asm.sections set ##disasm

This commit is contained in:
pancake 2021-02-10 02:03:53 +01:00 committed by pancake
parent 8fd0290881
commit 67c44a7c11
2 changed files with 50 additions and 45 deletions

View File

@ -4494,40 +4494,46 @@ static void ds_print_esil_anal_init(RDisasmState *ds) {
}
static void ds_print_bbline(RDisasmState *ds) {
if (ds->show_bbline && ds->at) {
RAnalBlock *bb = NULL;
RAnalFunction *f_before = NULL;
if (ds->fcn) {
bb = r_anal_fcn_bbget_at (ds->core->anal, ds->fcn, ds->at);
if (!ds->show_bbline || !ds->at) {
return;
}
RAnalBlock *bb = NULL;
RAnalFunction *f_before = NULL;
if (ds->fcn) {
bb = r_anal_fcn_bbget_at (ds->core->anal, ds->fcn, ds->at);
} else {
f_before = fcnIn (ds, ds->at - 1, R_ANAL_FCN_TYPE_NULL);
}
if ((ds->fcn && bb && ds->fcn->addr != ds->at) || (!ds->fcn && f_before)) {
ds_begin_line (ds);
// adapted from ds_setup_pre ()
ds->cmtcount = 0;
if (!ds->show_functions || !ds->show_lines_fcn) {
ds->pre = DS_PRE_NONE;
} else {
f_before = fcnIn (ds, ds->at - 1, R_ANAL_FCN_TYPE_NULL);
}
if ((ds->fcn && bb && ds->fcn->addr != ds->at) || (!ds->fcn && f_before)) {
ds_begin_line (ds);
// adapted from ds_setup_pre ()
ds->cmtcount = 0;
if (!ds->show_functions || !ds->show_lines_fcn) {
ds->pre = DS_PRE_NONE;
} else {
ds->pre = DS_PRE_EMPTY;
if (!f_before) {
f_before = fcnIn (ds, ds->at - 1, R_ANAL_FCN_TYPE_NULL);
}
if (f_before == ds->fcn) {
ds->pre = DS_PRE_FCN_MIDDLE;
}
ds->pre = DS_PRE_EMPTY;
if (!f_before) {
f_before = fcnIn (ds, ds->at - 1, R_ANAL_FCN_TYPE_NULL);
}
ds_print_pre (ds, true);
if (!ds->linesright && ds->show_lines_bb && ds->line) {
char *refline, *reflinecol = NULL;
ds_update_ref_lines (ds);
refline = ds->refline2;
reflinecol = ds->prev_line_col;
ds_print_ref_lines (refline, reflinecol, ds);
if (f_before == ds->fcn) {
ds->pre = DS_PRE_FCN_MIDDLE;
}
r_cons_printf ("|");
ds_newline (ds);
}
ds_print_pre (ds, true);
if (ds->show_section && ds->line_col) {
const char *sn = r_core_get_section_name (ds->core, ds->at);
size_t snl = strlen (sn) + 4;
r_cons_printf ("%s", r_str_pad (' ', R_MAX (10, snl - 1)));
}
if (!ds->linesright && ds->show_lines_bb && ds->line) {
char *refline, *reflinecol = NULL;
ds_update_ref_lines (ds);
refline = ds->refline2;
reflinecol = ds->prev_line_col;
ds_print_ref_lines (refline, reflinecol, ds);
}
r_cons_printf ("|");
ds_newline (ds);
}
}

View File

@ -1613,7 +1613,6 @@ EOF
RUN
NAME=asm.lines.bb with asm.sections
BROKEN=1
FILE=bins/elf/analysis/ls2
CMDS=<<EOF
e scr.utf8=false
@ -1627,20 +1626,20 @@ s 0x0040294b
pd 10
EOF
EXPECT=<<EOF
| 0x0040294b c6059ea72100. mov byte [0x0061d0f0], 0
| 0x00402952 83f802 cmp eax, 2
| ,=< 0x00402955 0f8483080000 je 0x4031de
| | |
| | 0x0040295b 83f803 cmp eax, 3
| ,==< 0x0040295e 742f je 0x40298f
| || |
| || 0x00402960 83e801 sub eax, 1
| ,===< 0x00402963 7405 je 0x40296a
| ||| |
| ||| 0x00402965 e8b6f8ffff call sym.imp.abort
| ||| |
| `---> 0x0040296a bf01000000 mov edi, 1
| || 0x0040296f e80cf9ffff call sym.imp.isatty
| .text 0x0040294b c6059ea72100. mov byte [0x0061d0f0], 0
| .text 0x00402952 83f802 cmp eax, 2
| .text ,=< 0x00402955 0f8483080000 je 0x4031de
| | |
| .text | 0x0040295b 83f803 cmp eax, 3
| .text ,==< 0x0040295e 742f je 0x40298f
| || |
| .text || 0x00402960 83e801 sub eax, 1
| .text ,===< 0x00402963 7405 je 0x40296a
| ||| |
| .text ||| 0x00402965 e8b6f8ffff call sym.imp.abort
| ||| |
| .text `---> 0x0040296a bf01000000 mov edi, 1
| .text || 0x0040296f e80cf9ffff call sym.imp.isatty
EOF
RUN
NAME=pd @a overwrites anal hints