Commit f93ae3d0b1d2c92859ffb1838c4b6edbaaa1b828
authorMichel Pollet <buserror@gmail.com>
Wed, 23 Dec 2009 22:23:21 +0000 (22:23 +0000)
committerMichel Pollet <buserror@gmail.com>
Wed, 23 Dec 2009 22:23:21 +0000 (22:23 +0000)
Debug macros were crashing if the symbols had not been loaded,
and they are never loaded when usin a .hex file

Signed-off-by: Michel Pollet <buserror@gmail.com>
2 files changed:
simavr/sim/sim_core.c
simavr/sim/sim_core.h

index 94de8f6fdcf03de518aa6509a1c8eaf6c9a5161d..51d8c331283ea57eb9644efa02836a0fe0020846 100644 (file)
@@ -58,7 +58,7 @@ int donttrace = 0;
 
 #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) { \
index 1e9113d10aac061ac413c7651518a872113671d9..fb818a0e0cefe0d0baff49d3878eb088564887bb 100644 (file)
@@ -61,7 +61,9 @@ void avr_dump_state(avr_t * avr);
                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()
@@ -73,7 +75,7 @@ void avr_dump_state(avr_t * avr);
                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();\