Commit c636bb66cc9043032caf20cb067bf9c818b7d17e
1 parent
84f2e8ef
gdbserver fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2393 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
4 changed files
with
24 additions
and
16 deletions
gdbstub.c
... | ... | @@ -1234,4 +1234,18 @@ int gdbserver_start(CharDriverState *chr) |
1234 | 1234 | qemu_add_vm_stop_handler(gdb_vm_stopped, s); |
1235 | 1235 | return 0; |
1236 | 1236 | } |
1237 | + | |
1238 | +int gdbserver_start_port(int port) | |
1239 | +{ | |
1240 | + CharDriverState *chr; | |
1241 | + char gdbstub_port_name[128]; | |
1242 | + | |
1243 | + snprintf(gdbstub_port_name, sizeof(gdbstub_port_name), | |
1244 | + "tcp::%d,nowait,nodelay,server", port); | |
1245 | + chr = qemu_chr_open(gdbstub_port_name); | |
1246 | + if (!chr) | |
1247 | + return -EIO; | |
1248 | + return gdbserver_start(chr); | |
1249 | +} | |
1250 | + | |
1237 | 1251 | #endif | ... | ... |
gdbstub.h
monitor.c
... | ... | @@ -423,7 +423,7 @@ static void do_gdbserver(int has_port, int port) |
423 | 423 | { |
424 | 424 | if (!has_port) |
425 | 425 | port = DEFAULT_GDBSTUB_PORT; |
426 | - if (gdbserver_start(port) < 0) { | |
426 | + if (gdbserver_start_port(port) < 0) { | |
427 | 427 | qemu_printf("Could not open gdbserver socket on port %d\n", port); |
428 | 428 | } else { |
429 | 429 | qemu_printf("Waiting gdb connection on port %d\n", port); | ... | ... |
vl.c
... | ... | @@ -6499,8 +6499,7 @@ static BOOL WINAPI qemu_ctrl_handler(DWORD type) |
6499 | 6499 | int main(int argc, char **argv) |
6500 | 6500 | { |
6501 | 6501 | #ifdef CONFIG_GDBSTUB |
6502 | - int use_gdbstub; | |
6503 | - char gdbstub_port_name[128]; | |
6502 | + int use_gdbstub, gdbstub_port; | |
6504 | 6503 | #endif |
6505 | 6504 | int i, cdrom_index; |
6506 | 6505 | int snapshot, linux_boot; |
... | ... | @@ -6568,7 +6567,7 @@ int main(int argc, char **argv) |
6568 | 6567 | bios_size = BIOS_SIZE; |
6569 | 6568 | #ifdef CONFIG_GDBSTUB |
6570 | 6569 | use_gdbstub = 0; |
6571 | - sprintf(gdbstub_port_name, "%d", DEFAULT_GDBSTUB_PORT); | |
6570 | + gdbstub_port = DEFAULT_GDBSTUB_PORT; | |
6572 | 6571 | #endif |
6573 | 6572 | snapshot = 0; |
6574 | 6573 | nographic = 0; |
... | ... | @@ -6812,7 +6811,7 @@ int main(int argc, char **argv) |
6812 | 6811 | use_gdbstub = 1; |
6813 | 6812 | break; |
6814 | 6813 | case QEMU_OPTION_p: |
6815 | - pstrcpy(gdbstub_port_name, sizeof(gdbstub_port_name), optarg); | |
6814 | + gdbstub_port = atoi(optarg); | |
6816 | 6815 | break; |
6817 | 6816 | #endif |
6818 | 6817 | case QEMU_OPTION_L: |
... | ... | @@ -7220,19 +7219,13 @@ int main(int argc, char **argv) |
7220 | 7219 | |
7221 | 7220 | #ifdef CONFIG_GDBSTUB |
7222 | 7221 | if (use_gdbstub) { |
7223 | - CharDriverState *chr; | |
7224 | - int port; | |
7225 | - | |
7226 | - port = atoi(gdbstub_port_name); | |
7227 | - if (port != 0) | |
7228 | - sprintf(gdbstub_port_name, "tcp::%d,nowait,nodelay,server", port); | |
7229 | - chr = qemu_chr_open(gdbstub_port_name); | |
7230 | - if (!chr) { | |
7231 | - fprintf(stderr, "qemu: could not open gdbstub device '%s'\n", | |
7232 | - gdbstub_port_name); | |
7222 | + /* XXX: use standard host:port notation and modify options | |
7223 | + accordingly. */ | |
7224 | + if (gdbserver_start_port(gdbstub_port) < 0) { | |
7225 | + fprintf(stderr, "qemu: could not open gdbstub device on port '%d'\n", | |
7226 | + gdbstub_port); | |
7233 | 7227 | exit(1); |
7234 | 7228 | } |
7235 | - gdbserver_start(chr); | |
7236 | 7229 | } else |
7237 | 7230 | #endif |
7238 | 7231 | if (loadvm) | ... | ... |