From 6c931a091f0adac7e353efd998e4b25d7675ffc6 Mon Sep 17 00:00:00 2001 From: pancake Date: Mon, 11 Jan 2016 03:08:24 +0100 Subject: [PATCH] Automatic asm.bits depending on CPSR's Thumb bit --- libr/debug/reg.c | 12 ++++++++++++ libr/reg/value.c | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/libr/debug/reg.c b/libr/debug/reg.c index 8a603d5f6f..b5d01ef7df 100644 --- a/libr/debug/reg.c +++ b/libr/debug/reg.c @@ -89,11 +89,23 @@ R_API int r_debug_reg_list(RDebug *dbg, int type, int size, int rad, const char from = type; to = from +1; } + bool is_arm = dbg->arch && strstr (dbg->arch, "arm"); for (i = from; i < to; i++) { head = r_reg_get_list (dbg->reg, i); if (!head) continue; r_list_foreach (head, iter, item) { ut64 value; + + if (is_arm && (rad == 1 || rad == '*') && item->size == 1) { + if (!strcmp (item->name, "tf")) { + bool is_thumb = r_reg_get_value (dbg->reg, item); + int new_bits = is_thumb? 16: 32; + if (dbg->bits != new_bits) + dbg->cb_printf ("e asm.bits=%d\n", new_bits); + } + continue; + } + if (type != -1) { if (type != item->type) continue; if (size != 0 && size != item->size) continue; diff --git a/libr/reg/value.c b/libr/reg/value.c index e318081e16..6b112917c2 100644 --- a/libr/reg/value.c +++ b/libr/reg/value.c @@ -25,6 +25,12 @@ R_API ut64 r_reg_get_value(RReg *reg, RRegItem *item) { 1 : 0; break; + case 4: + if (regset->arena->size - off - 1 >= 0) { + memcpy (&v8, regset->arena->bytes + off, 1); + ret = v8 & 0xF; + } + break; case 8: if (regset->arena->size - off - 1 >= 0) { memcpy (&v8, regset->arena->bytes + off, 1);