Skip to contentSkip to conversation

Gdbstub user mode -gdb dev option/unix sockets

PATCH Philippe Waille 1 participant 1 message Apr 15, 2009

lore
Share & tools
lore
#0 lore raw

New patch release, takes Jan comments into account. Philippe

This patch removes the -g portnumber option in user mode.
Adds a -gdb device option as in the system mode.

-gdb tcp:host:port or -gdb tcp::port
-gdb unix:socketname[,unlink]

Missing tests :
+ system mode regression test (I don't have a "hello world" example
for system mode)
+ _WIN32 mode

main.c +14 -10
Index: linux-user/main.c
===================================================================
@@ -2208,7 +2208,12 @@
            "\n"
            "Standard options:\n"
            "-h                print this help\n"
-           "-g port           wait gdb connection to port\n"
+           "-gdb device       wait gdb connection to device\n"
+           "     device syntax          use gdb target remote command \n"
+           "     tcp:host:port          remote host:port\n"
+           "     tcp::port              remote :port\n"
+           "     unix:sockname[,unlink] remote | socat stdio unix:sockname\n"
+           "                            unlink : removes sockname after connection\n"
            "-L path           set the elf interpreter prefix (default=%s)\n"
            "-s size           set the stack size in bytes (default=%ld)\n"
            "-cpu model        select CPU (-cpu ? for list)\n"
@@ -2265,7 +2270,6 @@
     CPUState *env;
     int optind;
     const char *r;
-    int gdbstub_port = 0;
     char **target_environ, **wrk;
     char **target_argv;
     int target_argc;
@@ -2353,10 +2357,13 @@
                 fprintf(stderr, "page size must be a power of two\n");
                 exit(1);
             }
-        } else if (!strcmp(r, "g")) {
-            if (optind >= argc)
-                break;
-            gdbstub_port = atoi(argv[optind++]);
+        } else if (!strcmp(r, "gdb")) {
+            if (optind >= argc) {
+                usage ();
+            }
+            if (gdbserver_start(argv[optind++]) < 0) {
+                usage ();
+            }
 	} else if (!strcmp(r, "r")) {
 	    qemu_uname_release = argv[optind++];
         } else if (!strcmp(r, "cpu")) {
@@ -2742,10 +2749,7 @@
     ts->heap_limit = 0;
 #endif
 
-    if (gdbstub_port) {
-        gdbserver_start (gdbstub_port);
-        gdb_handlesig(env, 0);
-    }
+    gdbserver_accept (env);
     cpu_loop(env);
     /* never exits */
     return 0;
gdbstub.c +313 -135

577 lines not on this page · raw message

gdbstub.h +4 -3
Index: gdbstub.h
===================================================================
@@ -16,16 +16,17 @@
 void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...);
 int use_gdb_syscalls(void);
 void gdb_set_stop_cpu(CPUState *env);
+
 #ifdef CONFIG_USER_ONLY
 int gdb_queuesig (void);
 int gdb_handlesig (CPUState *, int);
 void gdb_exit(CPUState *, int);
 void gdb_signalled(CPUState *, int);
-int gdbserver_start(int);
 void gdbserver_fork(CPUState *);
-#else
-int gdbserver_start(const char *port);
+void gdbserver_accept (CPUState *);
 #endif
+
+int gdbserver_start (const char *device);
 /* Get or set a register.  Returns the size of the register.  */
 typedef int (*gdb_reg_cb)(CPUState *env, uint8_t *buf, int reg);
 void gdb_register_coprocessor(CPUState *env,
Signature · 7 lines
-----------------------------------------------------------------------------
Philippe WAILLE                            email :    [email protected]
IMAG ID (Informatique et distribution)       Tel :    04 76 61 20 13
ENSIMAG - antenne de Montbonnot          Foreign :  33 4 76 61 20 13
INOVALLEE					     Fax :    04 76 61 20 99
51, avenue Jean Kuntzmann
38330 MONTBONNOT SAINT MARTIN