Skip to content

Commit c67dc73

Browse files
authored
Merge pull request #384 from msquirogac/fix-370
Support for GDB monitor commands
2 parents 7c254e2 + 13b5c33 commit c67dc73

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

simavr/sim/sim_gdb.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,26 @@ gdb_handle_command(
348348
// By sending back nothing, the debugger knows it has read
349349
// all available registers.
350350
}
351+
} else if (strncmp(cmd, "Rcmd", 4) == 0) { // monitor command
352+
char * args = strchr(cmd, ',');
353+
if (args != NULL) {
354+
args++;
355+
while (args != 0x00) {
356+
printf("%s",args);
357+
if (strncmp(args, "7265736574", 10) == 0) { // reset matched
358+
avr->state = cpu_StepDone;
359+
avr_reset(avr);
360+
args += 10;
361+
} else if (strncmp(args, "68616c74", 8) == 0) { // halt matched
362+
avr->state = cpu_Stopped;
363+
args += 8;
364+
} else if (strncmp(args, "20", 2) == 0) { // space matched
365+
args += 2;
366+
} else // no match - end
367+
break;
368+
}
369+
}
370+
gdb_send_reply(g, "OK");
351371
}
352372
gdb_send_reply(g, "");
353373
break;
@@ -496,6 +516,11 @@ gdb_handle_command(
496516
break;
497517
}
498518
} break;
519+
case 'K': // kill
520+
case 'D': { // detach
521+
avr->state = cpu_Done;
522+
gdb_send_reply(g, "OK");
523+
} break;
499524
default:
500525
gdb_send_reply(g, "");
501526
break;

0 commit comments

Comments
 (0)