Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2013-04-24 15:16:06 -0400
committerEugene Tarassov2013-04-24 15:16:06 -0400
commit83ee189fb36799e98d5157406d28cff262311561 (patch)
treecdbbfab8c04a623b151e68a571a33211a4de05eb
parentada7bca7372503004d2876b7bcf463de20327954 (diff)
downloadorg.eclipse.tcf.agent-83ee189fb36799e98d5157406d28cff262311561.tar.gz
org.eclipse.tcf.agent-83ee189fb36799e98d5157406d28cff262311561.tar.xz
org.eclipse.tcf.agent-83ee189fb36799e98d5157406d28cff262311561.zip
TCF Agent: ARM disassembler: added symbol names in branch instructions comments
-rw-r--r--agent/machine/arm/tcf/disassembler-arm.c33
-rw-r--r--agent/tcf/services/disassembly.c1
-rw-r--r--agent/tcf/services/disassembly.h1
3 files changed, 31 insertions, 4 deletions
diff --git a/agent/machine/arm/tcf/disassembler-arm.c b/agent/machine/arm/tcf/disassembler-arm.c
index 123ea43a..c4be4001 100644
--- a/agent/machine/arm/tcf/disassembler-arm.c
+++ b/agent/machine/arm/tcf/disassembler-arm.c
@@ -18,10 +18,12 @@
#include <assert.h>
#include <stdio.h>
#include <tcf/framework/context.h>
+#include <tcf/services/symbols.h>
#include <machine/arm/tcf/disassembler-arm.h>
static char buf[128];
static size_t buf_pos = 0;
+static Context * ctx = NULL;
static const char * shift_names[] = { "lsl", "lsr", "asr", "ror" };
@@ -116,6 +118,30 @@ static void add_flt_uint64(uint64_t n) {
add_str(buf);
}
+static void add_addr(uint32_t addr) {
+ while (buf_pos < 16) add_char(' ');
+ add_str("; addr=0x");
+ add_hex_uint32(addr);
+#if ENABLE_Symbols
+ if (ctx != NULL) {
+ Symbol * sym = NULL;
+ char * name = NULL;
+ ContextAddress sym_addr = 0;
+ if (find_symbol_by_addr(ctx, STACK_NO_FRAME, addr, &sym) < 0) return;
+ if (get_symbol_name(sym, &name) < 0 || name == NULL) return;
+ if (get_symbol_address(sym, &sym_addr) < 0) return;
+ if (sym_addr <= addr) {
+ add_str(": ");
+ add_str(name);
+ if (sym_addr < addr) {
+ add_str(" + 0x");
+ add_hex_uint32(addr - sym_addr);
+ }
+ }
+ }
+#endif
+}
+
#define add_reg_name(reg) add_str(reg_names[(reg) & 0xf])
static void add_modifed_immediate_constant(uint32_t n) {
@@ -1270,8 +1296,7 @@ static void disassemble_unconditional_instr(uint32_t addr, uint32_t instr) {
add_char('+');
add_dec_uint32(offset);
}
- add_str(" ; addr=0x");
- add_hex_uint32(addr + offset + 8);
+ add_addr(addr + offset + 8);
return;
}
}
@@ -1885,8 +1910,7 @@ static void disassemble_branch_and_block_data_transfer(uint32_t addr, uint32_t i
add_char('+');
add_dec_uint32(offset);
}
- add_str(" ; addr=0x");
- add_hex_uint32(addr + offset + 8);
+ add_addr(addr + offset + 8);
return;
}
@@ -1945,6 +1969,7 @@ DisassemblyResult * disassemble_arm(uint8_t * code,
memset(&dr, 0, sizeof(dr));
dr.size = 4;
buf_pos = 0;
+ ctx = params->ctx;
for (i = 0; i < 4; i++) instr |= (uint32_t)*code++ << (i * 8);
cond = (instr >> 28) & 0xf;
cond_name = cond_names[cond];
diff --git a/agent/tcf/services/disassembly.c b/agent/tcf/services/disassembly.c
index 67c52921..85f84a07 100644
--- a/agent/tcf/services/disassembly.c
+++ b/agent/tcf/services/disassembly.c
@@ -170,6 +170,7 @@ static void disassemble_block(Context * ctx, OutputStream * out, uint8_t * mem_b
int disassembler_ok = 0;
DisassemblerParams param;
+ param.ctx = ctx;
param.big_endian = ctx->big_endian;
param.pseudo_instr = args->pseudo_instr;
param.simplified = args->simplified;
diff --git a/agent/tcf/services/disassembly.h b/agent/tcf/services/disassembly.h
index a61931e4..e2015875 100644
--- a/agent/tcf/services/disassembly.h
+++ b/agent/tcf/services/disassembly.h
@@ -30,6 +30,7 @@ typedef struct {
* Parameters to a disassembler.
*/
typedef struct DisassemblerParams {
+ Context * ctx; /* Debug context to be used to lookup symbols */
int big_endian; /* 0 - little endian, 1 - big endian */
int simplified; /* If true, simplified mnemonics are specified */
int pseudo_instr; /* If true, pseudo-instructions are requested */

Back to the top