Allow gdbstub to connect over any serial device.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2448 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
7bcc17dc02
commit
cfc3475a8d
32
gdbstub.c
32
gdbstub.c
@ -1216,10 +1216,26 @@ static void gdb_chr_event(void *opaque, int event)
|
||||
}
|
||||
}
|
||||
|
||||
int gdbserver_start(CharDriverState *chr)
|
||||
int gdbserver_start(const char *port)
|
||||
{
|
||||
GDBState *s;
|
||||
char gdbstub_port_name[128];
|
||||
int port_num;
|
||||
char *p;
|
||||
CharDriverState *chr;
|
||||
|
||||
if (!port || !*port)
|
||||
return -1;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
chr = qemu_chr_open(port);
|
||||
if (!chr)
|
||||
return -1;
|
||||
|
||||
@ -1234,18 +1250,4 @@ int gdbserver_start(CharDriverState *chr)
|
||||
qemu_add_vm_stop_handler(gdb_vm_stopped, s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int gdbserver_start_port(int port)
|
||||
{
|
||||
CharDriverState *chr;
|
||||
char gdbstub_port_name[128];
|
||||
|
||||
snprintf(gdbstub_port_name, sizeof(gdbstub_port_name),
|
||||
"tcp::%d,nowait,nodelay,server", port);
|
||||
chr = qemu_chr_open(gdbstub_port_name);
|
||||
if (!chr)
|
||||
return -EIO;
|
||||
return gdbserver_start(chr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef GDBSTUB_H
|
||||
#define GDBSTUB_H
|
||||
|
||||
#define DEFAULT_GDBSTUB_PORT 1234
|
||||
#define DEFAULT_GDBSTUB_PORT "1234"
|
||||
|
||||
typedef void (*gdb_syscall_complete_cb)(CPUState *env,
|
||||
target_ulong ret, target_ulong err);
|
||||
@ -13,8 +13,7 @@ int gdb_handlesig (CPUState *, int);
|
||||
void gdb_exit(CPUState *, int);
|
||||
int gdbserver_start(int);
|
||||
#else
|
||||
int gdbserver_start(CharDriverState *chr);
|
||||
int gdbserver_start_port(int port);
|
||||
int gdbserver_start(const char *port);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
12
monitor.c
12
monitor.c
@ -423,14 +423,14 @@ static void do_cont(void)
|
||||
}
|
||||
|
||||
#ifdef CONFIG_GDBSTUB
|
||||
static void do_gdbserver(int has_port, int port)
|
||||
static void do_gdbserver(const char *port)
|
||||
{
|
||||
if (!has_port)
|
||||
if (!port)
|
||||
port = DEFAULT_GDBSTUB_PORT;
|
||||
if (gdbserver_start_port(port) < 0) {
|
||||
qemu_printf("Could not open gdbserver socket on port %d\n", port);
|
||||
if (gdbserver_start(port) < 0) {
|
||||
qemu_printf("Could not open gdbserver socket on port '%s'\n", port);
|
||||
} else {
|
||||
qemu_printf("Waiting gdb connection on port %d\n", port);
|
||||
qemu_printf("Waiting gdb connection on port '%s'\n", port);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1216,7 +1216,7 @@ static term_cmd_t term_cmds[] = {
|
||||
{ "c|cont", "", do_cont,
|
||||
"", "resume emulation", },
|
||||
#ifdef CONFIG_GDBSTUB
|
||||
{ "gdbserver", "i?", do_gdbserver,
|
||||
{ "gdbserver", "s?", do_gdbserver,
|
||||
"[port]", "start gdbserver session (default port=1234)", },
|
||||
#endif
|
||||
{ "x", "/l", do_memory_dump,
|
||||
|
13
vl.c
13
vl.c
@ -6422,8 +6422,8 @@ void help(void)
|
||||
"-parallel dev redirect the parallel port 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 %d\n"
|
||||
"-p port change gdb connection port\n"
|
||||
"-s wait gdb connection to port\n"
|
||||
"-p port set gdb connection port [default=%s]\n"
|
||||
"-d item1,... output log to %s (use -d ? for a list of log items)\n"
|
||||
"-hdachs c,h,s[,t] force hard disk 0 physical geometry and the optional BIOS\n"
|
||||
" translation (t=none or lba) (usually qemu can guess them)\n"
|
||||
@ -6829,7 +6829,8 @@ static BOOL WINAPI qemu_ctrl_handler(DWORD type)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
#ifdef CONFIG_GDBSTUB
|
||||
int use_gdbstub, gdbstub_port;
|
||||
int use_gdbstub;
|
||||
const char *gdbstub_port;
|
||||
#endif
|
||||
int i, cdrom_index;
|
||||
int snapshot, linux_boot;
|
||||
@ -7143,7 +7144,7 @@ int main(int argc, char **argv)
|
||||
use_gdbstub = 1;
|
||||
break;
|
||||
case QEMU_OPTION_p:
|
||||
gdbstub_port = atoi(optarg);
|
||||
gdbstub_port = optarg;
|
||||
break;
|
||||
#endif
|
||||
case QEMU_OPTION_L:
|
||||
@ -7571,8 +7572,8 @@ int main(int argc, char **argv)
|
||||
if (use_gdbstub) {
|
||||
/* XXX: use standard host:port notation and modify options
|
||||
accordingly. */
|
||||
if (gdbserver_start_port(gdbstub_port) < 0) {
|
||||
fprintf(stderr, "qemu: could not open gdbstub device on port '%d'\n",
|
||||
if (gdbserver_start(gdbstub_port) < 0) {
|
||||
fprintf(stderr, "qemu: could not open gdbstub device on port '%s'\n",
|
||||
gdbstub_port);
|
||||
exit(1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user