From: Michel Pollet Date: Mon, 14 Dec 2009 20:55:48 +0000 (+0000) Subject: Disable the debugging traces X-Git-Tag: v1.0a1~65 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=1828d61a7a1b5751ddc70f93bd16bd9b0d4b2c6e;p=sx%2Fsimavr.git Disable the debugging traces Added a (Disabled by default) compile flag for the heavy-duty debugger that helped debug the core. No longer needed in full builds since 1) it works 2) gdb works for user code.. Signed-off-by: Michel Pollet --- diff --git a/.simavr.jcc b/.simavr.jcc index b8d106c..261bb2d 100644 --- a/.simavr.jcc +++ b/.simavr.jcc @@ -56,6 +56,14 @@ T F "./simavr/sim/avr_uart.h" T +2 "sim_vcd_file.c" +F +"./simavr/sim/sim_vcd_file.c" +T +2 "sim_vcd_file.h" +F +"./simavr/sim/sim_vcd_file.h" +T 2 "sim_twi.c" F "./simavr/sim/sim_twi.c" diff --git a/simavr/sim/sim_avr.c b/simavr/sim/sim_avr.c index b3ac37b..28c18a0 100644 --- a/simavr/sim/sim_avr.c +++ b/simavr/sim/sim_avr.c @@ -226,7 +226,9 @@ int avr_run(avr_t * avr) if (avr->state == cpu_Running) { new_pc = avr_run_one(avr); +#if CONFIG_SIMAVR_TRACE avr_dump_state(avr); +#endif } // if we just re-enabled the interrupts... diff --git a/simavr/sim/sim_avr.h b/simavr/sim/sim_avr.h index 21e7260..01a12b4 100644 --- a/simavr/sim/sim_avr.h +++ b/simavr/sim/sim_avr.h @@ -141,6 +141,8 @@ typedef struct avr_t { // DEBUG ONLY int trace; + +#if CONFIG_SIMAVR_TRACE struct avr_symbol_t ** codeline; /* DEBUG ONLY @@ -170,6 +172,7 @@ typedef struct avr_t { // keeps track of which registers gets touched by instructions // reset before each new instructions. Allows meaningful traces uint32_t touched[256 / 32]; // debug +#endif // gdb hooking structure. Only present when gdb server is active struct avr_gdb_t * gdb; diff --git a/simavr/sim/sim_core.c b/simavr/sim/sim_core.c index 55a0fab..9d0f773 100644 --- a/simavr/sim/sim_core.c +++ b/simavr/sim/sim_core.c @@ -34,6 +34,7 @@ const char * _sreg_bit_name = "cznvshti"; * This is used only for debugging purposes to be able to * print the effects of each instructions on registers */ +#if CONFIG_SIMAVR_TRACE #define REG_TOUCH(a, r) (a)->touched[(r) >> 5] |= (1 << ((r) & 0x1f)) #define REG_ISTOUCHED(a, r) ((a)->touched[(r) >> 5] & (1 << ((r) & 0x1f))) @@ -76,6 +77,11 @@ int donttrace = 0; printf("%c", avr->sreg[_sbi] ? toupper(_sreg_bit_name[_sbi]) : '.');\ printf("\n");\ } +#else +#define REG_TOUCH(a, r) +#define STATE(_f, args...) +#define SREG() +#endif /* * Set a register (r < 256) @@ -202,10 +208,16 @@ const char * avr_regname(uint8_t reg) */ static void _avr_invalid_opcode(avr_t * avr) { +#if CONFIG_SIMAVR_TRACE printf("\e[31m*** %04x: %-25s Invalid Opcode SP=%04x O=%04x \e[0m\n", avr->pc, avr->codeline[avr->pc>>1]->symbol, _avr_sp_get(avr), avr->flash[avr->pc] | (avr->flash[avr->pc+1]<<8)); +#else + printf("\e[31m*** %04x: Invalid Opcode SP=%04x O=%04x \e[0m\n", + avr->pc, _avr_sp_get(avr), avr->flash[avr->pc] | (avr->flash[avr->pc+1]<<8)); +#endif } +#if CONFIG_SIMAVR_TRACE /* * Dump changed registers when tracing */ @@ -235,6 +247,7 @@ void avr_dump_state(avr_t * avr) } printf("\n"); } +#endif #define get_r_d_10(o) \ const uint8_t r = ((o >> 5) & 0x10) | (o & 0xf); \ @@ -247,6 +260,7 @@ void avr_dump_state(avr_t * avr) /* * Add a "jump" address to the jump trace buffer */ +#if CONFIG_SIMAVR_TRACE #define TRACE_JUMP()\ avr->old[avr->old_pci].pc = avr->pc;\ avr->old[avr->old_pci].sp = _avr_sp_get(avr);\ @@ -263,6 +277,13 @@ void avr_dump_state(avr_t * avr) #else #define STACK_FRAME_PUSH() #define STACK_FRAME_POP() +#endif +#else /* CONFIG_SIMAVR_TRACE */ + +#define TRACE_JUMP() +#define STACK_FRAME_PUSH() +#define STACK_FRAME_POP() + #endif /****************************************************************************\ @@ -368,7 +389,9 @@ uint16_t avr_run_one(avr_t * avr) uint32_t new_pc = avr->pc + 2; // future "default" pc int cycle = 1; +#if CONFIG_SIMAVR_TRACE avr->touched[0] = avr->touched[1] = avr->touched[2] = 0; +#endif switch (opcode & 0xf000) { case 0x0000: { diff --git a/simavr/sim/sim_core.h b/simavr/sim/sim_core.h index 17a65ed..1e9113d 100644 --- a/simavr/sim/sim_core.h +++ b/simavr/sim/sim_core.h @@ -34,6 +34,8 @@ uint16_t _avr_sp_get(avr_t * avr); void _avr_sp_set(avr_t * avr, uint16_t sp); void _avr_push16(avr_t * avr, uint16_t v); +#if CONFIG_SIMAVR_TRACE + /* * Get a "pretty" register name */ @@ -77,5 +79,14 @@ void avr_dump_state(avr_t * avr); DUMP_STACK();\ avr_sadly_crashed(avr, 0);\ } +#else /* CONFIG_SIMAVR_TRACE */ + +#define CRASH() { \ + avr_sadly_crashed(avr, 0);\ + } +#define DUMP_STACK() +#define DUMP_REG(); + +#endif #endif /* SIM_CORE_H_ */ diff --git a/simavr/sim/sim_elf.c b/simavr/sim/sim_elf.c index 8cdb12a..164db2d 100644 --- a/simavr/sim/sim_elf.c +++ b/simavr/sim/sim_elf.c @@ -38,7 +38,9 @@ void avr_load_firmware(avr_t * avr, elf_firmware_t * firmware) { avr->frequency = firmware->mmcu.f_cpu; +#if CONFIG_SIMAVR_TRACE avr->codeline = firmware->codeline; +#endif avr_loadcode(avr, firmware->flash, firmware->flashsize, 0); avr->codeend = firmware->flashsize - firmware->datasize; if (firmware->eeprom && firmware->eesize) {