From 8f34c0b2a5aad3c56411748fc2b838a7b58a4d50 Mon Sep 17 00:00:00 2001 From: pancake Date: Fri, 10 Mar 2017 18:09:23 +0100 Subject: [PATCH] Fix #6456 - Show cursor in data words --- libr/core/disasm.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/libr/core/disasm.c b/libr/core/disasm.c index d374b42899..c3df10dc89 100644 --- a/libr/core/disasm.c +++ b/libr/core/disasm.c @@ -1864,7 +1864,8 @@ static void ds_adistrick_comments(RDisasmState *ds) { } -static bool ds_print_data_type(RCore *core, const ut8 *buf, int ib, int size) { +static bool ds_print_data_type(RDisasmState *ds, const ut8 *buf, int ib, int size) { + RCore *core = ds->core; const char *type = NULL; char msg[64]; const int isSigned = (ib == 1 || ib == 8 || ib == 10)? 1: 0; @@ -1876,6 +1877,23 @@ static bool ds_print_data_type(RCore *core, const ut8 *buf, int ib, int size) { default: return false; } ut64 n = r_read_ble (buf, core->print->big_endian, size * 8); + { + int q = core->print->cur_enabled && + ds->cursor >= ds->index && + ds->cursor < (ds->index + size); + if (q) { + if (ds->cursor > ds->index) { + int diff = ds->cursor - ds->index; + r_cons_printf (" %d ", diff); + } else if (ds->cursor == ds->index) { + r_cons_printf (" * "); + } else { + r_cons_printf (" "); + } + } else { + r_cons_printf (" "); + } + } switch (ib) { case 1: @@ -1998,7 +2016,7 @@ static int ds_print_meta_infos(RDisasmState *ds, ut8* buf, int len, int idx) { } ds->oplen = mi->size - delta; core->print->flags &= ~R_PRINT_FLAGS_HEADER; - if (!ds_print_data_type (core, buf + idx, ds->hint? ds->hint->immbase: 0, mi->size)) { + if (!ds_print_data_type (ds, buf + idx, ds->hint? ds->hint->immbase: 0, mi->size)) { r_cons_printf ("hex length=%" PFMT64d " delta=%d\n", mi->size , delta); r_print_hexdump (core->print, ds->at, buf+idx, hexlen-delta, 16, 1); }