Commit 4eb0e42896fde15b3f6e6f34a2d3dce3c025217a
authorga <ga@oldell.fish>
Wed, 16 Mar 2022 19:20:43 +0000 (19:20 +0000)
committerga <ga@oldell.fish>
Wed, 16 Mar 2022 19:25:40 +0000 (19:25 +0000)
1. Do not report a TRAP signal on every stop, as it confuses gdb.
   Initial symptom was failure to step into an ISR.
2. AVR was running after reset command.
3. Excessive processor activity (buzzing) while AVR stopped.

2 files changed:
simavr/sim/sim_avr.c
simavr/sim/sim_gdb.c

index 6e43bf91fd079ed8ebb3f4d4312edad3ea0dd0bf..872904031a5b178c2e0ec1226d46c641951a302b 100644 (file)
@@ -286,7 +286,7 @@ void
 avr_callback_run_gdb(
                avr_t * avr)
 {
-       avr_gdb_processor(avr, avr->state == cpu_Stopped);
+       avr_gdb_processor(avr, avr->state == cpu_Stopped ? 50000 : 0);
 
        if (avr->state == cpu_Stopped)
                return ;
@@ -331,7 +331,6 @@ avr_callback_run_gdb(
        // if we were stepping, use this state to inform remote gdb
        if (step)
                avr->state = cpu_StepDone;
-
 }
 
 /*
index 702a2cd1e69fdcac7f97e64bc948f02a2dce27b0..d68aea24634c3da4113f92321ce973a1935c68e1 100644 (file)
@@ -210,9 +210,10 @@ gdb_send_quick_status(
        READ_SREG_INTO(g->avr, sreg);
 
        sprintf(cmd, "T%02x20:%02x;21:%02x%02x;22:%02x%02x%02x00;",
-               signal ? signal : 5, sreg,
+               signal, sreg,
                g->avr->data[R_SPL], g->avr->data[R_SPH],
-               g->avr->pc & 0xff, (g->avr->pc>>8)&0xff, (g->avr->pc>>16)&0xff);
+               g->avr->pc & 0xff, (g->avr->pc >> 8) & 0xff,
+               (g->avr->pc >> 16) & 0xff);
        gdb_send_reply(g, cmd);
 }
 
@@ -314,8 +315,8 @@ handle_monitor(avr_t * avr, avr_gdb_t * g, char * cmd)
                        ++ip;
 
                if (strncmp(ip, "reset", 5) == 0) {
-                       avr->state = cpu_StepDone;
                        avr_reset(avr);
+                       avr->state = cpu_Stopped;
                        ip += 5;
                } else if (strncmp(ip, "halt", 4) == 0) {
                        avr->state = cpu_Stopped;
@@ -668,8 +669,8 @@ gdb_handle_command(
                        avr->state = cpu_Step;
                }       break;
                case 'r': {     // deprecated, suggested for AVRStudio compatibility
-                       avr->state = cpu_StepDone;
                        avr_reset(avr);
+                       avr->state = cpu_Stopped;
                }       break;
                case 'Z':       // set clear break/watchpoint
                case 'z': {
@@ -792,7 +793,8 @@ gdb_network_handler(
                // control C -- lets send the guy a nice status packet
                if (*src == 3) {
                        src++;
-                       g->avr->state = cpu_StepDone;
+                       gdb_send_quick_status(g, 2); // SIGINT
+                       g->avr->state = cpu_Stopped;
                        printf("GDB hit control-c\n");
                }
                if (*src  == '$') {
@@ -862,7 +864,7 @@ avr_gdb_processor(
        if (avr->state == cpu_Running &&
                        gdb_watch_find(&g->breakpoints, avr->pc) != -1) {
                DBG(printf("avr_gdb_processor hit breakpoint at %08x\n", avr->pc);)
-               gdb_send_quick_status(g, 0);
+               gdb_send_quick_status(g, 5);
                avr->state = cpu_Stopped;
        } else if (avr->state == cpu_StepDone) {
                gdb_send_quick_status(g, 0);