Fix #3852 & changes in midflags

This commit is contained in:
Álvaro Felipe Melchor 2015-12-17 20:18:50 +01:00 committed by pancake
parent b857bf3b06
commit c939ba7da9
3 changed files with 28 additions and 19 deletions

View File

@ -1119,10 +1119,6 @@ static void snFini(SymName *sn) {
R_FREE (sn->methflag);
}
static bool isHidden(RBinSymbol *s) {
if (!s->bind || !s->type) return false;
return (!strcmp (s->bind, "LOCAL") && !strcmp (s->type, "NOTYPE"));
}
static bool isAnExport(RBinSymbol *s) {
/* workaround for some bin plugs */
@ -1168,8 +1164,6 @@ static int bin_symbols_internal(RCore *r, int mode, ut64 laddr, int va, ut64 at,
snInit (r, &sn, symbol, lang);
if (IS_MODE_SET (mode)) {
if (isHidden (symbol))
continue;
if (is_arm) {
int force_bits = 0;
if (va && symbol->bits == 16)
@ -1268,8 +1262,6 @@ static int bin_symbols_internal(RCore *r, int mode, ut64 laddr, int va, ut64 at,
RBinPlugin *plugin;
char *name;
if (isHidden (symbol))
continue;
if (bin_demangle) {
char *mn = r_bin_demangle (r->bin->cur, lang, symbol->name);
if (mn) {

View File

@ -426,6 +426,18 @@ static int cb_strpurge(void *user, void *data) {
return true;
}
static int cb_midflags (void *user, void *data) {
RConfigNode *node = (RConfigNode *)data;
if (node->value[0] == '?') {
eprintf ("Valid values for asm.midflags:\n");
eprintf ("0\t do not show middle flags\n");
eprintf ("1\t print the middfle flag without realign instruction\n");
eprintf ("2\t realign the instruction at the middfle flag\n");
return false;
}
return true;
}
static int cb_strfilter(void *user, void *data) {
RCore *core = (RCore*) user;
RConfigNode *node = (RConfigNode*) data;
@ -1414,7 +1426,7 @@ R_API int r_core_config_init(RCore *core) {
SETCB("asm.invhex", "false", &cb_asm_invhex, "Show invalid instructions as hexadecimal numbers");
SETPREF("asm.bytes", "true", "Display the bytes of each instruction");
SETPREF("asm.flagsinbytes", "false", "Display flags inside the bytes space");
SETPREF("asm.midflags", "true", "Realign disassembly if there is a flag in the middle of an instruction");
SETICB("asm.midflags", 1, &cb_midflags, "Realign disassembly if there is a flag in the middle of an instruction");
SETPREF("asm.cmtflgrefs", "true", "Show comment flags associated to branch reference");
SETPREF("asm.cmtright", "true", "Show comments at right of disassembly if they fit in screen");
SETI("asm.cmtcol", 70, "Align comments at column 60");

View File

@ -7,6 +7,9 @@
#define HAVE_LOCALS 1
#define DEFAULT_NARGS 4
#define R_MIDFLAGS_SHOW 1
#define R_MIDFLAGS_REALIGN 2
#define COLOR(ds, field) (ds->show_color ? ds->field : "")
#define COLOR_CONST(ds, color) (ds->show_color ? Color_ ## color : "")
#define COLOR_RESET(ds) COLOR_CONST(ds, RESET)
@ -606,7 +609,7 @@ static void beginline (RCore *core, RDisasmState *ds, RAnalFunction *f) {
if (ds->show_lines && !ds->linesright) {
r_cons_printf ("%s%s%s%s",
section, COLOR (ds, color_flow),
ds->refline2, COLOR_RESET (ds));
f ? ds->refline2 : " ", COLOR_RESET (ds));
}
}
@ -2334,7 +2337,7 @@ R_API int r_core_print_disasm(RPrint *p, RCore *core, ut64 addr, ut8 *buf, int l
int continueoninvbreak = (len == l) && invbreak;
RAnalFunction *of = NULL;
RAnalFunction *f = NULL;
int ret, idx = 0, i;
int ret, i, skip_bytes = 0, idx = 0;
int dorepeat = 1;
ut8 *nbuf = NULL;
RDisasmState *ds;
@ -2491,13 +2494,20 @@ toro:
if (ds->hint->size) ds->analop.size = ds->hint->size;
if (ds->hint->ptr) ds->analop.ptr = ds->hint->ptr;
}
if (ds->midflags) {
skip_bytes = handleMidFlags (core, ds, true);
if (skip_bytes && ds->midflags == R_MIDFLAGS_SHOW)
ds->at += skip_bytes;
}
handle_show_flags_option (core, ds);
if (skip_bytes && ds->midflags == R_MIDFLAGS_SHOW)
ds->at -= skip_bytes;
handle_instruction_mov_lea (core, ds, idx);
handle_control_flow_comments (core, ds);
handle_adistrick_comments (core, ds);
/* XXX: This is really cpu consuming.. need to be fixed */
handle_show_functions (core, ds);
handle_show_xrefs (core, ds);
handle_show_flags_option (core, ds);
handle_print_pre (core, ds, false);
handle_print_lines_left (core, ds);
@ -2505,7 +2515,6 @@ toro:
if (handle_print_labels (core, ds, f)) {
handle_show_functions (core, ds);
handle_show_xrefs (core, ds);
handle_show_flags_option (core, ds);
handle_print_pre (core, ds, false);
handle_print_lines_left (core, ds);
}
@ -2564,12 +2573,8 @@ toro:
free (ds->opstr);
ds->opstr = NULL;
inc = ds->oplen;
if (ds->midflags) {
int skip_bytes = handleMidFlags (core, ds, true);
if (skip_bytes > 0) {
inc = skip_bytes;
}
}
if (ds->midflags == R_MIDFLAGS_REALIGN && skip_bytes)
inc = skip_bytes;
if (inc < 1) inc = 1;
}
if (nbuf == buf) {