Skip to content

Commit fe3ff0b

Browse files
committed
new gdb commands kill, detach and monitor
monitor parser engine supports reset and halt
1 parent 7c254e2 commit fe3ff0b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

simavr/sim/sim_gdb.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,32 @@ 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+
{
355+
args++;
356+
while(args != 0x00) {
357+
printf("%s",args);
358+
if (strncmp(args, "7265736574", 10) == 0) { // reset matched
359+
avr->state = cpu_StepDone;
360+
avr_reset(avr);
361+
args += 10;
362+
printf("Reset\n"); // Remove
363+
} else if (strncmp(args, "68616c74", 8) == 0) { // halt matched
364+
avr->state = cpu_Stopped;
365+
args += 8;
366+
printf("Halting\n"); // Remove
367+
} else if (strncmp(args, "20", 2) == 0) { // space matched
368+
args += 2;
369+
printf("Space\n"); // Remove
370+
}
371+
else{ // no match - end
372+
break;
373+
}
374+
}
375+
}
376+
gdb_send_reply(g, "OK");
351377
}
352378
gdb_send_reply(g, "");
353379
break;
@@ -496,6 +522,12 @@ gdb_handle_command(
496522
break;
497523
}
498524
} break;
525+
case 'K': // kill
526+
case 'D': { // detach
527+
avr->state = cpu_Done;
528+
gdb_send_reply(g, "OK");
529+
printf("Halted\n"); // Remove
530+
} break;
499531
default:
500532
gdb_send_reply(g, "");
501533
break;

0 commit comments

Comments
 (0)