Skip to content

Commit 8f11365

Browse files
author
ga
committed
Make avr_where() available for use in debugging. It provides a decoded
string representing the PC's value. Also fix mangled line indentification strings found in use. They occurred when multiple lines had one address.
1 parent 4437fe8 commit 8f11365

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

simavr/sim/sim_avr.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,12 @@ uint64_t
503503
avr_get_time_stamp(
504504
avr_t * avr );
505505

506+
/* This function returns a text string describing where in flash the AVR's
507+
* PC is pointing. It requires the CONFIG_SIMAVR_TRACE option.
508+
*/
509+
510+
const char *avr_where(avr_t *avr);
511+
506512
#ifdef __cplusplus
507513
};
508514
#endif

simavr/sim/sim_core.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ int dont_trace(const char * name)
7171

7272
static int donttrace;
7373

74-
static const char *where(avr_t *avr)
74+
const char *avr_where(avr_t *avr)
7575
{
7676
avr_flashaddr_t pc;
7777
const char *s;
@@ -100,8 +100,8 @@ static const char *where(avr_t *avr)
100100
return "";
101101
}
102102

103-
#define STATE(_f, argsf ...) if (avr->trace) { \
104-
const char *symn = where(avr); \
103+
#define STATE(_f, argsf ...) if (avr->trace) { \
104+
const char *symn = avr_where(avr); \
105105
if (symn) \
106106
printf("%04x: %-25s " _f, avr->pc, symn, ## argsf); \
107107
}
@@ -161,6 +161,8 @@ void crash(avr_t* avr)
161161
avr_sadly_crashed(avr, 0);
162162

163163
}
164+
165+
const char *avr_where(avr_t *avr) { return ""; }
164166
#endif
165167

166168
static inline uint16_t

simavr/sim/sim_dwarf.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ int avr_read_dwarf(avr_t *avr, const char *filename)
306306
CHECK("dwarf_siblingof_b");
307307

308308
#if CONFIG_SIMAVR_TRACE
309+
Dwarf_Addr prev_addr = -1;
309310
const char *last_symbol = NULL;
310311
int i, prev_line;
311312

@@ -322,9 +323,10 @@ int avr_read_dwarf(avr_t *avr, const char *filename)
322323
CHECK("dwarf_lineno");
323324
rv = dwarf_lineaddr(ctx.lines[i], &addr, &err);
324325
CHECK("dwarf_lineaddr");
325-
if (prev_line == lineno)
326+
if (prev_line == lineno || prev_addr == addr)
326327
continue; // Ignore duplicates
327328
prev_line = lineno;
329+
prev_addr = addr;
328330
if (addr == 0) // Inlined?
329331
continue;
330332
ep = avr->trace_data->codeline + (addr >> 1);

0 commit comments

Comments
 (0)