From: Jan Kiszka <jan.kiszka@siemens.com>
To: qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH 2/2] gdbstub: Rework configuration via command line and monitor
Date: Wed, 18 Mar 2009 12:10:11 +0100 [thread overview]
Message-ID: <49C0D693.2030301@siemens.com> (raw)
Introduce a more powerful gdbstub configuration (system emulation olny)
via new switch '-gdb dev'. Keep '-s' as shorthand for '-gdb tcp::1234'.
Use the same syntax also for the corresponding monitor command
'gdbserver'. Its default also remains to listen on port 1234.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
gdbstub.c | 25 +++++++++++--------------
monitor.c | 19 ++++++++++---------
vl.c | 33 ++++++++++++---------------------
3 files changed, 33 insertions(+), 44 deletions(-)
diff --git a/gdbstub.c b/gdbstub.c
index e8ceaae..b6d41bb 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -2395,27 +2395,24 @@ static int gdb_monitor_write(CharDriverState *chr, const uint8_t *buf, int len)
return len;
}
-int gdbserver_start(const char *port)
+int gdbserver_start(const char *device)
{
GDBState *s;
- char gdbstub_port_name[128];
- int port_num;
- char *p;
+ char gdbstub_device_name[128];
CharDriverState *chr = NULL;
CharDriverState *mon_chr;
- if (!port || !*port)
- return -1;
- if (strcmp(port, "none") != 0) {
- port_num = strtol(port, &p, 10);
- if (*p == 0) {
- /* A numeric value is interpreted as a port number. */
- snprintf(gdbstub_port_name, sizeof(gdbstub_port_name),
- "tcp::%d,nowait,nodelay,server", port_num);
- port = gdbstub_port_name;
+ if (!device)
+ return -1;
+ if (strcmp(device, "none") != 0) {
+ if (strstart(device, "tcp:", NULL)) {
+ /* enforce required TCP attributes */
+ snprintf(gdbstub_device_name, sizeof(gdbstub_device_name),
+ "%s,nowait,nodelay,server", device);
+ device = gdbstub_device_name;
}
- chr = qemu_chr_open("gdb", port, NULL);
+ chr = qemu_chr_open("gdb", device, NULL);
if (!chr)
return -1;
diff --git a/monitor.c b/monitor.c
index c6fe968..75c8663 100644
--- a/monitor.c
+++ b/monitor.c
@@ -570,17 +570,18 @@ static void encrypted_bdrv_it(void *opaque, BlockDriverState *bs)
}
#ifdef CONFIG_GDBSTUB
-static void do_gdbserver(Monitor *mon, const char *port)
-{
- if (!port)
- port = DEFAULT_GDBSTUB_PORT;
- if (gdbserver_start(port) < 0) {
- monitor_printf(mon, "Could not open gdbserver socket on port '%s'\n",
- port);
- } else if (strcmp(port, "none") == 0) {
+static void do_gdbserver(Monitor *mon, const char *device)
+{
+ if (!device)
+ device = "tcp::" DEFAULT_GDBSTUB_PORT;
+ if (gdbserver_start(device) < 0) {
+ monitor_printf(mon, "Could not open gdbserver on device '%s'\n",
+ device);
+ } else if (strcmp(device, "none") == 0) {
monitor_printf(mon, "Disabled gdbserver\n");
} else {
- monitor_printf(mon, "Waiting gdb connection on port '%s'\n", port);
+ monitor_printf(mon, "Waiting for gdb connection on device '%s'\n",
+ device);
}
}
#endif
diff --git a/vl.c b/vl.c
index b62a2d4..d5c9e02 100644
--- a/vl.c
+++ b/vl.c
@@ -4073,8 +4073,8 @@ static void help(int exitcode)
"-monitor dev redirect the monitor to char device 'dev'\n"
"-pidfile file write PID to 'file'\n"
"-S freeze CPU at startup (use 'c' to start execution)\n"
- "-s wait gdb connection to port\n"
- "-p port set gdb connection port [default=%s]\n"
+ "-gdb dev wait for gdb connection on 'dev'\n"
+ "-s shorthand for -gdb tcp::%s\n"
"-d item1,... output log to %s (use -d ? for a list of log items)\n"
"-hdachs c,h,s[,t]\n"
" force hard disk 0 physical geometry and the optional BIOS\n"
@@ -4214,7 +4214,7 @@ enum {
QEMU_OPTION_pidfile,
QEMU_OPTION_S,
QEMU_OPTION_s,
- QEMU_OPTION_p,
+ QEMU_OPTION_gdb,
QEMU_OPTION_d,
QEMU_OPTION_hdachs,
QEMU_OPTION_L,
@@ -4336,7 +4336,7 @@ static const QEMUOption qemu_options[] = {
{ "pidfile", HAS_ARG, QEMU_OPTION_pidfile },
{ "S", 0, QEMU_OPTION_S },
{ "s", 0, QEMU_OPTION_s },
- { "p", HAS_ARG, QEMU_OPTION_p },
+ { "gdb", HAS_ARG, QEMU_OPTION_gdb },
{ "d", HAS_ARG, QEMU_OPTION_d },
{ "hdachs", HAS_ARG, QEMU_OPTION_hdachs },
{ "L", HAS_ARG, QEMU_OPTION_L },
@@ -4607,8 +4607,7 @@ static void termsig_setup(void)
int main(int argc, char **argv, char **envp)
{
#ifdef CONFIG_GDBSTUB
- int use_gdbstub;
- const char *gdbstub_port;
+ const char *gdbstub_dev = NULL;
#endif
uint32_t boot_devices_bitmap = 0;
int i;
@@ -4687,10 +4686,6 @@ int main(int argc, char **argv, char **envp)
initrd_filename = NULL;
ram_size = 0;
vga_ram_size = VGA_RAM_SIZE;
-#ifdef CONFIG_GDBSTUB
- use_gdbstub = 0;
- gdbstub_port = DEFAULT_GDBSTUB_PORT;
-#endif
snapshot = 0;
nographic = 0;
curses = 0;
@@ -5023,10 +5018,10 @@ int main(int argc, char **argv, char **envp)
break;
#ifdef CONFIG_GDBSTUB
case QEMU_OPTION_s:
- use_gdbstub = 1;
+ gdbstub_dev = "tcp::" DEFAULT_GDBSTUB_PORT;
break;
- case QEMU_OPTION_p:
- gdbstub_port = optarg;
+ case QEMU_OPTION_gdb:
+ gdbstub_dev = optarg;
break;
#endif
case QEMU_OPTION_L:
@@ -5731,14 +5726,10 @@ int main(int argc, char **argv, char **envp)
}
#ifdef CONFIG_GDBSTUB
- if (use_gdbstub) {
- /* XXX: use standard host:port notation and modify options
- accordingly. */
- if (gdbserver_start(gdbstub_port) < 0) {
- fprintf(stderr, "qemu: could not open gdbstub device on port '%s'\n",
- gdbstub_port);
- exit(1);
- }
+ if (gdbstub_dev && gdbserver_start(gdbstub_dev) < 0) {
+ fprintf(stderr, "qemu: could not open gdbserver on device '%s'\n",
+ gdbstub_dev);
+ exit(1);
}
#endif
next reply other threads:[~2009-03-18 11:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-18 11:10 Jan Kiszka [this message]
2009-03-21 9:48 ` [Qemu-devel] [PATCH 2/2 -v2] gdbstub: Rework configuration via command line and monitor Jan Kiszka
2009-03-21 10:36 ` [Qemu-devel] [PATCH 2/2 -v3] " Jan Kiszka
2009-03-24 13:10 ` [Qemu-devel] [PATCH 2/2 -v2] " Paul Brook
2009-03-24 17:29 ` Jan Kiszka
2009-03-28 18:05 ` [Qemu-devel] [PATCH 2/2] " Anthony Liguori
2009-03-30 16:05 ` [Qemu-devel] [PATCH v4] " Jan Kiszka
2009-04-05 18:44 ` Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49C0D693.2030301@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).