diff --git a/gdb.c b/gdb.c index 6c8989c..52efd6f 100644 --- a/gdb.c +++ b/gdb.c @@ -666,6 +666,9 @@ static int cmd_gdb(cproc_t cp, char **arg) { char *port_text = get_arg(arg); int port = 2000; + int want_loop = 0; + + cproc_get_int(cp, "gdb_loop", &want_loop); if (port_text) port = atoi(port_text); @@ -675,7 +678,12 @@ static int cmd_gdb(cproc_t cp, char **arg) return -1; } - return gdb_server(cproc_device(cp), port); + do { + if (gdb_server(cproc_device(cp), port) < 0) + return -1; + } while (want_loop); + + return 0; } static const struct cproc_command command_gdb = { @@ -686,7 +694,19 @@ static const struct cproc_command command_gdb = { " Run a GDB remote stub on the given TCP/IP port.\n" }; +static const struct cproc_option option_gdb = { + .name = "gdb_loop", + .type = CPROC_OPTION_BOOL, + .help = +"Automatically restart the GDB server after disconnection. If this\n" +"option is set, then the GDB server keeps running until an error occurs,\n" +"or the user interrupts with Ctrl+C.\n" +}; + int gdb_register(cproc_t cp) { + if (cproc_register_options(cp, &option_gdb, 1) < 0) + return -1; + return cproc_register_commands(cp, &command_gdb, 1); } diff --git a/mspdebug.man b/mspdebug.man index 2b34e02..3147059 100644 --- a/mspdebug.man +++ b/mspdebug.man @@ -349,6 +349,10 @@ The following are all valid examples of address expressions: MSPDebug's behaviour can be configured via the following variables: .IP "\fBcolor\fR (boolean)" If true, MSPDebug will colorize debugging output. +.IP "\fBgdb_loop\fR (boolean)" +Automatically restart the GDB server after disconnection. If this +option is set, then the GDB server keeps running until an error occurs, +or the user interrupts with Ctrl+C. .SH BUGS If you find any bugs, you should report them to the author at daniel@tortek.co.nz. It would help if you could include a transcript