aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/vl.c b/vl.c
index f211c71784..cd77852236 100644
--- a/vl.c
+++ b/vl.c
@@ -1857,8 +1857,10 @@ struct device_config {
DEV_PARALLEL, /* -parallel */
DEV_VIRTCON, /* -virtioconsole */
DEV_DEBUGCON, /* -debugcon */
+ DEV_GDB, /* -gdb, -s */
} type;
const char *cmdline;
+ Location loc;
QTAILQ_ENTRY(device_config) next;
};
QTAILQ_HEAD(, device_config) device_configs = QTAILQ_HEAD_INITIALIZER(device_configs);
@@ -1870,6 +1872,7 @@ static void add_device_config(int type, const char *cmdline)
conf = g_malloc0(sizeof(*conf));
conf->type = type;
conf->cmdline = cmdline;
+ loc_save(&conf->loc);
QTAILQ_INSERT_TAIL(&device_configs, conf, next);
}
@@ -1881,7 +1884,9 @@ static int foreach_device_config(int type, int (*func)(const char *cmdline))
QTAILQ_FOREACH(conf, &device_configs, next) {
if (conf->type != type)
continue;
+ loc_push_restore(&conf->loc);
rc = func(conf->cmdline);
+ loc_pop(&conf->loc);
if (0 != rc)
return rc;
}
@@ -2178,7 +2183,6 @@ int qemu_init_main_loop(void)
int main(int argc, char **argv, char **envp)
{
- const char *gdbstub_dev = NULL;
int i;
int snapshot, linux_boot;
const char *icount_option = NULL;
@@ -2603,10 +2607,10 @@ int main(int argc, char **argv, char **envp)
log_file = optarg;
break;
case QEMU_OPTION_s:
- gdbstub_dev = "tcp::" DEFAULT_GDBSTUB_PORT;
+ add_device_config(DEV_GDB, "tcp::" DEFAULT_GDBSTUB_PORT);
break;
case QEMU_OPTION_gdb:
- gdbstub_dev = optarg;
+ add_device_config(DEV_GDB, optarg);
break;
case QEMU_OPTION_L:
data_dir = optarg;
@@ -3496,9 +3500,7 @@ int main(int argc, char **argv, char **envp)
}
text_consoles_set_display(ds);
- if (gdbstub_dev && gdbserver_start(gdbstub_dev) < 0) {
- fprintf(stderr, "qemu: could not open gdbserver on device '%s'\n",
- gdbstub_dev);
+ if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) {
exit(1);
}