#define STATE(_f, args...) { \
if (avr->trace) {\
- if (avr->codeline[avr->pc>>1]) {\
+ if (avr->codeline && avr->codeline[avr->pc>>1]) {\
const char * symn = avr->codeline[avr->pc>>1]->symbol; \
int dont = 0 && dont_trace(symn);\
if (dont!=donttrace) { \
for (int i = avr->stack_frame_index; i; i--) {\
int pci = i-1;\
printf("\e[31m*** %04x: %-25s sp %04x\e[0m\n",\
- avr->stack_frame[pci].pc, avr->codeline[avr->stack_frame[pci].pc>>1]->symbol, avr->stack_frame[pci].sp);\
+ avr->stack_frame[pci].pc, \
+ avr->codeline ? avr->codeline[avr->stack_frame[pci].pc>>1]->symbol : "unknown", \
+ avr->stack_frame[pci].sp);\
}
#else
#define DUMP_STACK()
for (int i = OLD_PC_SIZE-1; i > 0; i--) {\
int pci = (avr->old_pci + i) & 0xf;\
printf("\e[31m*** %04x: %-25s RESET -%d; sp %04x\e[0m\n",\
- avr->old[pci].pc, avr->codeline[avr->old[pci].pc>>1]->symbol, OLD_PC_SIZE-i, avr->old[pci].sp);\
+ avr->old[pci].pc, avr->codeline ? avr->codeline[avr->old[pci].pc>>1]->symbol : "unknown", OLD_PC_SIZE-i, avr->old[pci].sp);\
}\
printf("Stack Ptr %04x/%04x = %d \n", _avr_sp_get(avr), avr->ramend, avr->ramend - _avr_sp_get(avr));\
DUMP_STACK();\