Skip to content

Commit 6abb525

Browse files
author
ga
committed
Add parsing of DWARF debugging information in ELF firmware, and use it
in tracing and gdb's "info io_registers" command.
1 parent 7003af0 commit 6abb525

File tree

9 files changed

+720
-146
lines changed

9 files changed

+720
-146
lines changed

Makefile.common

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ OBJ := obj-${shell $(CC) -dumpmachine}
114114
LIBDIR := ${shell pwd}/${SIMAVR}/${OBJ}
115115
LDFLAGS += -L${LIBDIR} -lsimavr -lm
116116

117-
LDFLAGS += -lelf
117+
LDFLAGS += -lelf -ldwarf
118118

119119
ifeq (${WIN}, Msys)
120120
LDFLAGS += -lws2_32

simavr/sim/sim_avr.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ avr_init(
105105
memset(avr->data, 0, avr->ramend + 1);
106106
#ifdef CONFIG_SIMAVR_TRACE
107107
avr->trace_data = calloc(1, sizeof(struct avr_trace_data_t));
108+
avr->trace_data->data_names_size = avr->ioend + 1;
108109
#endif
110+
avr->data_names = calloc(avr->ioend + 1, sizeof (char *));
109111

110112
AVR_LOG(avr, LOG_TRACE, "%s init\n", avr->mmcu);
111113

simavr/sim/sim_avr.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,17 @@ enum {
106106

107107
cpu_Sleeping, // we're now sleeping until an interrupt
108108

109-
cpu_Step, // run ONE instruction, then...
109+
cpu_Step, // run ONE instruction, then...
110110
cpu_StepDone, // tell gdb it's all OK, and give it registers
111111
cpu_Done, // avr software stopped gracefully
112112
cpu_Crashed, // avr software crashed (watchdog fired)
113113
};
114114

115115
// this is only ever used if CONFIG_SIMAVR_TRACE is defined
116116
struct avr_trace_data_t {
117-
struct avr_symbol_t ** codeline;
117+
const char ** codeline; // Text for each Flash address
118+
uint32_t codeline_size; // Size of codeline table.
119+
uint32_t data_names_size;// Size of data_names table.
118120

119121
/* DEBUG ONLY
120122
* this keeps track of "jumps" ie, call,jmp,ret,reti and so on
@@ -152,14 +154,12 @@ typedef void (*avr_run_t)(
152154
#define AVR_FUSE_HIGH 1
153155
#define AVR_FUSE_EXT 2
154156

155-
#define REG_NAME_COUNT (256 + 32) // Size of reg_names table.
156-
157157
/*
158158
* Main AVR instance. Some of these fields are set by the AVR "Core" definition files
159159
* the rest is runtime data (as little as possible)
160160
*/
161161
typedef struct avr_t {
162-
const char * mmcu; // name of the AVR
162+
const char * mmcu; // name of the AVR
163163
// these are filled by sim_core_declare from constants in /usr/lib/avr/include/avr/io*.h
164164
uint16_t ioend;
165165
uint16_t ramend;
@@ -348,6 +348,10 @@ typedef struct avr_t {
348348
uint32_t size;
349349
uint32_t len;
350350
} io_console_buffer;
351+
352+
// Table of register names used by gdb and tracing.
353+
354+
const char ** data_names;
351355
} avr_t;
352356

353357

0 commit comments

Comments
 (0)