gdb: Store watchpoints in avr_gdb_t
[simavr] / simavr / sim / sim_core.h
index 1e9113d..9f83654 100644 (file)
 #ifndef SIM_CORE_H_
 #define SIM_CORE_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
  * Instruction decoder, run ONE instruction
  */
-uint16_t avr_run_one(avr_t * avr);
+avr_flashaddr_t avr_run_one(avr_t * avr);
 
 /*
  * These are for internal access to the stack (for interrupts)
@@ -43,7 +47,7 @@ const char * avr_regname(uint8_t reg);
 
 /* 
  * DEBUG bits follow 
- * These will diseapear when gdb arrives
+ * These will disappear when gdb arrives
  */
 void avr_dump_state(avr_t * avr);
 
@@ -58,10 +62,12 @@ void avr_dump_state(avr_t * avr);
 
 #if AVR_STACK_WATCH
 #define DUMP_STACK() \
-               for (int i = avr->stack_frame_index; i; i--) {\
+               for (int i = avr->trace_data->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->trace_data->stack_frame[pci].pc, \
+                                       avr->trace_data->codeline ? avr->trace_data->codeline[avr->trace_data->stack_frame[pci].pc>>1]->symbol : "unknown", \
+                                                       avr->trace_data->stack_frame[pci].sp);\
                }
 #else
 #define DUMP_STACK()
@@ -69,11 +75,11 @@ void avr_dump_state(avr_t * avr);
 
 #define CRASH()  {\
                DUMP_REG();\
-               printf("*** CYCLE %lld PC %04x\n", avr->cycle, avr->pc);\
+               printf("*** CYCLE %" PRI_avr_cycle_count "PC %04x\n", avr->cycle, avr->pc);\
                for (int i = OLD_PC_SIZE-1; i > 0; i--) {\
-                       int pci = (avr->old_pci + i) & 0xf;\
+                       int pci = (avr->trace_data->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->trace_data->old[pci].pc, avr->trace_data->codeline ? avr->trace_data->codeline[avr->trace_data->old[pci].pc>>1]->symbol : "unknown", OLD_PC_SIZE-i, avr->trace_data->old[pci].sp);\
                }\
                printf("Stack Ptr %04x/%04x = %d \n", _avr_sp_get(avr), avr->ramend, avr->ramend - _avr_sp_get(avr));\
                DUMP_STACK();\
@@ -89,4 +95,8 @@ void avr_dump_state(avr_t * avr);
 
 #endif 
 
+#ifdef __cplusplus
+};
+#endif
+
 #endif /* SIM_CORE_H_ */