From fe3ff0bb26afb2f8c7d96ffa049bfebabca6291d Mon Sep 17 00:00:00 2001 From: msquirogac Date: Sat, 20 Jun 2020 18:39:37 -0400 Subject: [PATCH 1/3] new gdb commands kill, detach and monitor monitor parser engine supports reset and halt --- simavr/sim/sim_gdb.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/simavr/sim/sim_gdb.c b/simavr/sim/sim_gdb.c index be0320a30..906d1aee5 100644 --- a/simavr/sim/sim_gdb.c +++ b/simavr/sim/sim_gdb.c @@ -348,6 +348,32 @@ gdb_handle_command( // By sending back nothing, the debugger knows it has read // all available registers. } + } else if (strncmp(cmd, "Rcmd", 4) == 0) { // monitor command + char * args = strchr(cmd, ','); + if (args != NULL) + { + args++; + while(args != 0x00) { + printf("%s",args); + if (strncmp(args, "7265736574", 10) == 0) { // reset matched + avr->state = cpu_StepDone; + avr_reset(avr); + args += 10; + printf("Reset\n"); // Remove + } else if (strncmp(args, "68616c74", 8) == 0) { // halt matched + avr->state = cpu_Stopped; + args += 8; + printf("Halting\n"); // Remove + } else if (strncmp(args, "20", 2) == 0) { // space matched + args += 2; + printf("Space\n"); // Remove + } + else{ // no match - end + break; + } + } + } + gdb_send_reply(g, "OK"); } gdb_send_reply(g, ""); break; @@ -496,6 +522,12 @@ gdb_handle_command( break; } } break; + case 'K': // kill + case 'D': { // detach + avr->state = cpu_Done; + gdb_send_reply(g, "OK"); + printf("Halted\n"); // Remove + } break; default: gdb_send_reply(g, ""); break; From 110aadf0e7db6760d303d97ee055d9d87d103bff Mon Sep 17 00:00:00 2001 From: msquirogac Date: Sat, 20 Jun 2020 18:45:50 -0400 Subject: [PATCH 2/3] gdb monitor command clean-up --- simavr/sim/sim_gdb.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/simavr/sim/sim_gdb.c b/simavr/sim/sim_gdb.c index 906d1aee5..b5f4bf173 100644 --- a/simavr/sim/sim_gdb.c +++ b/simavr/sim/sim_gdb.c @@ -359,14 +359,11 @@ gdb_handle_command( avr->state = cpu_StepDone; avr_reset(avr); args += 10; - printf("Reset\n"); // Remove } else if (strncmp(args, "68616c74", 8) == 0) { // halt matched avr->state = cpu_Stopped; args += 8; - printf("Halting\n"); // Remove } else if (strncmp(args, "20", 2) == 0) { // space matched args += 2; - printf("Space\n"); // Remove } else{ // no match - end break; @@ -526,7 +523,6 @@ gdb_handle_command( case 'D': { // detach avr->state = cpu_Done; gdb_send_reply(g, "OK"); - printf("Halted\n"); // Remove } break; default: gdb_send_reply(g, ""); From 13b5c3336c1b9163f012467b233ac47973bd95a0 Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Tue, 30 Jun 2020 17:34:33 +0100 Subject: [PATCH 3/3] Tweaked spacing from PR --- simavr/sim/sim_gdb.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/simavr/sim/sim_gdb.c b/simavr/sim/sim_gdb.c index b5f4bf173..5ea74a126 100644 --- a/simavr/sim/sim_gdb.c +++ b/simavr/sim/sim_gdb.c @@ -350,10 +350,9 @@ gdb_handle_command( } } else if (strncmp(cmd, "Rcmd", 4) == 0) { // monitor command char * args = strchr(cmd, ','); - if (args != NULL) - { + if (args != NULL) { args++; - while(args != 0x00) { + while (args != 0x00) { printf("%s",args); if (strncmp(args, "7265736574", 10) == 0) { // reset matched avr->state = cpu_StepDone; @@ -364,10 +363,8 @@ gdb_handle_command( args += 8; } else if (strncmp(args, "20", 2) == 0) { // space matched args += 2; - } - else{ // no match - end + } else // no match - end break; - } } } gdb_send_reply(g, "OK");