* [patch] gdbserver: qXfer multiprocess
@ 2009-06-16 20:10 Aleksandar Ristovski
2009-06-16 21:09 ` Pedro Alves
0 siblings, 1 reply; 9+ messages in thread
From: Aleksandar Ristovski @ 2009-06-16 20:10 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 236 bytes --]
Hello,
This adds check for multiprocess before appending
'multiprocess' to reply.
Thanks,
--
Aleksandar Ristovski
QNX Software Systems
ChangeLog:
* server.c (handle_query): Use multi_process and output
multiprocess accordingly.
[-- Attachment #2: gdbserver-server.c-multiprocess-20090615.diff --]
[-- Type: text/x-patch, Size: 605 bytes --]
Index: server.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/server.c,v
retrieving revision 1.97
diff -u -p -r1.97 server.c
--- server.c 24 May 2009 21:06:53 -0000 1.97
+++ server.c 15 Jun 2009 18:36:36 -0000
@@ -1106,7 +1106,8 @@ handle_query (char *own_buf, int packet_
if (the_target->qxfer_osdata != NULL)
strcat (own_buf, ";qXfer:osdata:read+");
- strcat (own_buf, ";multiprocess+");
+ if (multi_process)
+ strcat (own_buf, ";multiprocess+");
if (target_supports_non_stop ())
strcat (own_buf, ";QNonStop+");
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [patch] gdbserver: qXfer multiprocess 2009-06-16 20:10 [patch] gdbserver: qXfer multiprocess Aleksandar Ristovski @ 2009-06-16 21:09 ` Pedro Alves 2009-06-17 0:56 ` Aleksandar Ristovski 0 siblings, 1 reply; 9+ messages in thread From: Pedro Alves @ 2009-06-16 21:09 UTC (permalink / raw) To: gdb-patches; +Cc: Aleksandar Ristovski On Tuesday 16 June 2009 21:10:14, Aleksandar Ristovski wrote: > This adds check for multiprocess before appending > 'multiprocess' to reply. I can see that from the patch. But, why? -- Pedro Alves ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] gdbserver: qXfer multiprocess 2009-06-16 21:09 ` Pedro Alves @ 2009-06-17 0:56 ` Aleksandar Ristovski 2009-06-17 1:04 ` Pedro Alves 0 siblings, 1 reply; 9+ messages in thread From: Aleksandar Ristovski @ 2009-06-17 0:56 UTC (permalink / raw) To: gdb-patches Pedro Alves wrote: > On Tuesday 16 June 2009 21:10:14, Aleksandar Ristovski wrote: > >> This adds check for multiprocess before appending >> 'multiprocess' to reply. > > I can see that from the patch. But, why? > If gdbserver doesn't have support for multiple processes, how will it report lack of that feature to GDB? I have created gdbserver for nto to be able to use gdb for nto/linux. One of things this server will not have (at least for now) is multi process support. It will only handle one process a time. -- Aleksandar Ristovski QNX Software Systems ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] gdbserver: qXfer multiprocess 2009-06-17 0:56 ` Aleksandar Ristovski @ 2009-06-17 1:04 ` Pedro Alves 2009-06-17 1:17 ` Aleksandar Ristovski 2009-06-17 17:19 ` Aleksandar Ristovski 0 siblings, 2 replies; 9+ messages in thread From: Pedro Alves @ 2009-06-17 1:04 UTC (permalink / raw) To: gdb-patches; +Cc: Aleksandar Ristovski On Wednesday 17 June 2009 01:56:06, Aleksandar Ristovski wrote: > Pedro Alves wrote: > > On Tuesday 16 June 2009 21:10:14, Aleksandar Ristovski wrote: > > > >> This adds check for multiprocess before appending > >> 'multiprocess' to reply. > > > > I can see that from the patch. But, why? > > > > If gdbserver doesn't have support for multiple processes, > how will it report lack of that feature to GDB? By querying the target, how else? Something like: + if (target_supports_multi_process ()) strcat (own_buf, ";multiprocess+"); if (target_supports_non_stop ()) strcat (own_buf, ";QNonStop+"); (that function doesn't exist today, but it should). > I have created gdbserver for nto to be able to use gdb for > nto/linux. One of things this server will not have (at least > for now) is multi process support. It will only handle one > process a time. That is different from (like your patch was doing) reporting multi_process support if GDB reports support as well, which is still broken in your example. (and now that you mention it, in all gdbserver targets but linux). -- Pedro Alves ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] gdbserver: qXfer multiprocess 2009-06-17 1:04 ` Pedro Alves @ 2009-06-17 1:17 ` Aleksandar Ristovski 2009-06-17 17:19 ` Aleksandar Ristovski 1 sibling, 0 replies; 9+ messages in thread From: Aleksandar Ristovski @ 2009-06-17 1:17 UTC (permalink / raw) To: gdb-patches Pedro Alves wrote: > On Wednesday 17 June 2009 01:56:06, Aleksandar Ristovski wrote: >> Pedro Alves wrote: >>> On Tuesday 16 June 2009 21:10:14, Aleksandar Ristovski wrote: >>> >>>> This adds check for multiprocess before appending >>>> 'multiprocess' to reply. >>> I can see that from the patch. But, why? >>> >> If gdbserver doesn't have support for multiple processes, >> how will it report lack of that feature to GDB? > > By querying the target, how else? Something like: > > + if (target_supports_multi_process ()) > strcat (own_buf, ";multiprocess+"); > > if (target_supports_non_stop ()) > strcat (own_buf, ";QNonStop+"); > > (that function doesn't exist today, but it should). > >> I have created gdbserver for nto to be able to use gdb for >> nto/linux. One of things this server will not have (at least >> for now) is multi process support. It will only handle one >> process a time. > > That is different from (like your patch was doing) reporting > multi_process support if GDB reports support as well, which is > still broken in your example. (and now that you mention it, > in all gdbserver targets but linux). > Yes, I realized when I saw your question and revisited the code. -- Aleksandar Ristovski QNX Software Systems ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] gdbserver: qXfer multiprocess 2009-06-17 1:04 ` Pedro Alves 2009-06-17 1:17 ` Aleksandar Ristovski @ 2009-06-17 17:19 ` Aleksandar Ristovski 2009-06-17 18:04 ` Pedro Alves 1 sibling, 1 reply; 9+ messages in thread From: Aleksandar Ristovski @ 2009-06-17 17:19 UTC (permalink / raw) To: Pedro Alves; +Cc: gdb-patches [-- Attachment #1: Type: text/plain, Size: 535 bytes --] Pedro Alves wrote: > > By querying the target, how else? Something like: > > + if (target_supports_multi_process ()) > strcat (own_buf, ";multiprocess+"); > Here is a patch that does what you described. Thanks, -- Aleksandar Ristovski QNX Software Systems ChangeLog: * target.h (supports_multiprocess): New function. * server.c (handle_query): Use supports_multiprocess and output multiprocess accordingly. * linux-low.c (linux_supports_multiprocess): New function. (linux_target_ops): Set supports_multiprocess. [-- Attachment #2: gdbserver-supports_multiprocess-20090617.diff --] [-- Type: text/x-patch, Size: 2243 bytes --] Index: target.h =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/target.h,v retrieving revision 1.36 diff -u -p -r1.36 target.h --- target.h 1 Apr 2009 22:50:24 -0000 1.36 +++ target.h 17 Jun 2009 17:12:04 -0000 @@ -275,6 +283,8 @@ struct target_ops /* Switch to non-stop (1) or all-stop (0) mode. Return 0 on success, -1 otherwise. */ int (*start_non_stop) (int); + + int (*supports_multiprocess) (void); }; extern struct target_ops *the_target; @@ -311,6 +321,10 @@ void set_target_ops (struct target_ops * #define target_async(enable) \ (the_target->async ? (*the_target->async) (enable) : 0) +#define target_supports_multiprocess() \ + (the_target->supports_multiprocess ? \ + (*the_target->supports_multiprocess) () : 0) + /* Start non-stop mode, returns 0 on success, -1 on failure. */ int start_non_stop (int nonstop); Index: server.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/server.c,v retrieving revision 1.97 diff -u -p -r1.97 server.c --- server.c 24 May 2009 21:06:53 -0000 1.97 +++ server.c 17 Jun 2009 17:12:04 -0000 @@ -1106,7 +1106,8 @@ handle_query (char *own_buf, int packet_ if (the_target->qxfer_osdata != NULL) strcat (own_buf, ";qXfer:osdata:read+"); - strcat (own_buf, ";multiprocess+"); + if (target_supports_multiprocess ()) + strcat (own_buf, ";multiprocess+"); if (target_supports_non_stop ()) strcat (own_buf, ";QNonStop+"); Index: linux-low.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/linux-low.c,v retrieving revision 1.105 diff -u -p -r1.105 linux-low.c --- linux-low.c 24 May 2009 17:44:19 -0000 1.105 +++ linux-low.c 17 Jun 2009 17:12:06 -0000 @@ -3008,6 +3008,12 @@ linux_start_non_stop (int nonstop) return 0; } +static int +linux_supports_multiprocess (void) +{ + return 1; +} + static struct target_ops linux_target_ops = { linux_create_inferior, linux_attach, @@ -3045,6 +3053,7 @@ static struct target_ops linux_target_op linux_supports_non_stop, linux_async, linux_start_non_stop, + linux_supports_multiprocess }; static void ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] gdbserver: qXfer multiprocess 2009-06-17 17:19 ` Aleksandar Ristovski @ 2009-06-17 18:04 ` Pedro Alves 2009-06-17 19:06 ` Aleksandar Ristovski 0 siblings, 1 reply; 9+ messages in thread From: Pedro Alves @ 2009-06-17 18:04 UTC (permalink / raw) To: gdb-patches; +Cc: Aleksandar Ristovski On Wednesday 17 June 2009 18:19:10, Aleksandar Ristovski wrote: > Here is a patch that does what you described. Thanks. This is still not complete, though. You need to make sure that the "multi_process" flag stays turned off if the backend doesn't support MP, otherwise, things like remote-utils.c:write_ptid will still misbehave (gdb will realize the target doesn't support multi-process, but the remote target will be replying with multi-process packets, how odd would that be?!). That flag is currently bound to GDB's multi-process support, because current gdbserver is assuming all backends support mp. /* Record if GDB knows about multiprocess support. */ if (strcmp (p, "multiprocess+") == 0) multi_process = 1; To see this in action, you can connect with "target extended-remote :foo"/"set debug remote 1", and make sure that the packets flowing in both directions don't use multi-process thread id extensions (e.g., 'p1.1' vs '1'). -- Pedro Alves ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] gdbserver: qXfer multiprocess 2009-06-17 18:04 ` Pedro Alves @ 2009-06-17 19:06 ` Aleksandar Ristovski 2009-06-19 13:41 ` Pedro Alves 0 siblings, 1 reply; 9+ messages in thread From: Aleksandar Ristovski @ 2009-06-17 19:06 UTC (permalink / raw) To: Pedro Alves; +Cc: gdb-patches [-- Attachment #1: Type: text/plain, Size: 1359 bytes --] Pedro Alves wrote: > On Wednesday 17 June 2009 18:19:10, Aleksandar Ristovski wrote: > >> Here is a patch that does what you described. > > Thanks. This is still not complete, though. > > You need to make sure that the "multi_process" flag stays turned off > if the backend doesn't support MP, otherwise, things like > remote-utils.c:write_ptid will still misbehave (gdb will realize the > target doesn't support multi-process, but the remote target will > be replying with multi-process packets, how odd would that be?!). > That flag is currently bound to GDB's multi-process support, > because current gdbserver is assuming all backends support mp. > > /* Record if GDB knows about multiprocess support. */ > if (strcmp (p, "multiprocess+") == 0) > multi_process = 1; > > > To see this in action, you can connect with > "target extended-remote :foo"/"set debug remote 1", and make sure that > the packets flowing in both directions don't use multi-process thread > id extensions (e.g., 'p1.1' vs '1'). > Ok, then something like this? -- Aleksandar Ristovski QNX Software Systems * target.h (supports_multiprocess): New function. * server.c (handle_query): Use supports_multiprocess and output multiprocess accordingly. * linux-low.c (linux_supports_multiprocess): New function. (linux_target_ops): Set supports_multiprocess. [-- Attachment #2: gdbserver-supports_multiprocess-20090617-1.diff --] [-- Type: text/x-patch, Size: 2340 bytes --] Index: target.h =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/target.h,v retrieving revision 1.36 diff -u -p -r1.36 target.h --- target.h 1 Apr 2009 22:50:24 -0000 1.36 +++ target.h 17 Jun 2009 18:57:30 -0000 @@ -275,6 +283,8 @@ struct target_ops /* Switch to non-stop (1) or all-stop (0) mode. Return 0 on success, -1 otherwise. */ int (*start_non_stop) (int); + + int (*supports_multiprocess) (void); }; extern struct target_ops *the_target; @@ -311,6 +321,10 @@ void set_target_ops (struct target_ops * #define target_async(enable) \ (the_target->async ? (*the_target->async) (enable) : 0) +#define target_supports_multiprocess() \ + (the_target->supports_multiprocess ? \ + (*the_target->supports_multiprocess) () : 0) + /* Start non-stop mode, returns 0 on success, -1 on failure. */ int start_non_stop (int nonstop); Index: server.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/server.c,v retrieving revision 1.97 diff -u -p -r1.97 server.c --- server.c 24 May 2009 21:06:53 -0000 1.97 +++ server.c 17 Jun 2009 18:57:30 -0000 @@ -1106,7 +1106,11 @@ handle_query (char *own_buf, int packet_ if (the_target->qxfer_osdata != NULL) strcat (own_buf, ";qXfer:osdata:read+"); - strcat (own_buf, ";multiprocess+"); + if (target_supports_multiprocess ()) + strcat (own_buf, ";multiprocess+"); + else + /* Override GDB's ability to support multiprocess. */ + multi_process = 0; if (target_supports_non_stop ()) strcat (own_buf, ";QNonStop+"); Index: linux-low.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/linux-low.c,v retrieving revision 1.105 diff -u -p -r1.105 linux-low.c --- linux-low.c 24 May 2009 17:44:19 -0000 1.105 +++ linux-low.c 17 Jun 2009 18:57:30 -0000 @@ -3008,6 +3008,12 @@ linux_start_non_stop (int nonstop) return 0; } +static int +linux_supports_multiprocess (void) +{ + return 1; +} + static struct target_ops linux_target_ops = { linux_create_inferior, linux_attach, @@ -3045,6 +3053,7 @@ static struct target_ops linux_target_op linux_supports_non_stop, linux_async, linux_start_non_stop, + linux_supports_multiprocess }; static void ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] gdbserver: qXfer multiprocess 2009-06-17 19:06 ` Aleksandar Ristovski @ 2009-06-19 13:41 ` Pedro Alves 0 siblings, 0 replies; 9+ messages in thread From: Pedro Alves @ 2009-06-19 13:41 UTC (permalink / raw) To: Aleksandar Ristovski; +Cc: gdb-patches On Wednesday 17 June 2009 20:05:38, Aleksandar Ristovski wrote: > Pedro Alves wrote: > > Thanks. This is still not complete, though. > > > > You need to make sure that the "multi_process" flag stays turned off > > if the backend doesn't support MP, otherwise, things like > > Ok, then something like this? > - strcat (own_buf, ";multiprocess+"); > + if (target_supports_multiprocess ()) > + strcat (own_buf, ";multiprocess+"); > + else > + /* Override GDB's ability to support multiprocess. */ > + multi_process = 0; Indentation is off here. I'd prefer if we didn't turn the flag on at all in the first place. Checked in as below. Thanks. -- Pedro Alves * target.h (struct target_ops) <supports_multi_process>: New callback. (target_supports_multi_process): New. * server.c (handle_query): Even if GDB reports support, only enable multi-process if the target also supports it. Report multi-process support only if the target backend supports it. * linux-low.c (linux_supports_multi_process): New function. (linux_target_ops): Install it as target_supports_multi_process callback. --- gdb/gdbserver/linux-low.c | 7 +++++++ gdb/gdbserver/server.c | 11 ++++++++--- gdb/gdbserver/target.h | 7 +++++++ 3 files changed, 22 insertions(+), 3 deletions(-) Index: src/gdb/gdbserver/target.h =================================================================== --- src.orig/gdb/gdbserver/target.h 2009-06-19 14:26:36.000000000 +0100 +++ src/gdb/gdbserver/target.h 2009-06-19 14:34:09.000000000 +0100 @@ -275,6 +275,9 @@ struct target_ops /* Switch to non-stop (1) or all-stop (0) mode. Return 0 on success, -1 otherwise. */ int (*start_non_stop) (int); + + /* Returns true if the target supports multi-process debugging. */ + int (*supports_multi_process) (void); }; extern struct target_ops *the_target; @@ -311,6 +314,10 @@ void set_target_ops (struct target_ops * #define target_async(enable) \ (the_target->async ? (*the_target->async) (enable) : 0) +#define target_supports_multi_process() \ + (the_target->supports_multi_process ? \ + (*the_target->supports_multi_process) () : 0) + /* Start non-stop mode, returns 0 on success, -1 on failure. */ int start_non_stop (int nonstop); Index: src/gdb/gdbserver/server.c =================================================================== --- src.orig/gdb/gdbserver/server.c 2009-06-19 14:26:36.000000000 +0100 +++ src/gdb/gdbserver/server.c 2009-06-19 14:34:09.000000000 +0100 @@ -1074,9 +1074,13 @@ handle_query (char *own_buf, int packet_ p != NULL; p = strtok (NULL, ";")) { - /* Record if GDB knows about multiprocess support. */ if (strcmp (p, "multiprocess+") == 0) - multi_process = 1; + { + /* GDB supports and wants multi-process support if + possible. */ + if (target_supports_multi_process ()) + multi_process = 1; + } } sprintf (own_buf, "PacketSize=%x;QPassSignals+", PBUFSIZ - 1); @@ -1106,7 +1110,8 @@ handle_query (char *own_buf, int packet_ if (the_target->qxfer_osdata != NULL) strcat (own_buf, ";qXfer:osdata:read+"); - strcat (own_buf, ";multiprocess+"); + if (target_supports_multi_process ()) + strcat (own_buf, ";multiprocess+"); if (target_supports_non_stop ()) strcat (own_buf, ";QNonStop+"); Index: src/gdb/gdbserver/linux-low.c =================================================================== --- src.orig/gdb/gdbserver/linux-low.c 2009-06-19 14:26:36.000000000 +0100 +++ src/gdb/gdbserver/linux-low.c 2009-06-19 14:34:09.000000000 +0100 @@ -3008,6 +3008,12 @@ linux_start_non_stop (int nonstop) return 0; } +static int +linux_supports_multi_process (void) +{ + return 1; +} + static struct target_ops linux_target_ops = { linux_create_inferior, linux_attach, @@ -3045,6 +3051,7 @@ static struct target_ops linux_target_op linux_supports_non_stop, linux_async, linux_start_non_stop, + linux_supports_multi_process }; static void 2009-06-19 Aleksandar Ristovski <aristovski@qnx.com> Pedro Alves <pedro@codesourcery.com> * target.h (struct target_ops) <supports_multi_process>: New callback. (target_supports_multi_process): New. * server.c (handle_query): Even if GDB reports support, only enable multi-process if the target also supports it. Report multi-process support only if the target backend supports it. * linux-low.c (linux_supports_multi_process): New function. (linux_target_ops): Install it as target_supports_multi_process callback. --- gdb/gdbserver/linux-low.c | 7 +++++++ gdb/gdbserver/server.c | 11 ++++++++--- gdb/gdbserver/target.h | 7 +++++++ 3 files changed, 22 insertions(+), 3 deletions(-) Index: src/gdb/gdbserver/target.h =================================================================== --- src.orig/gdb/gdbserver/target.h 2009-06-19 14:26:36.000000000 +0100 +++ src/gdb/gdbserver/target.h 2009-06-19 14:34:09.000000000 +0100 @@ -275,6 +275,9 @@ struct target_ops /* Switch to non-stop (1) or all-stop (0) mode. Return 0 on success, -1 otherwise. */ int (*start_non_stop) (int); + + /* Returns true if the target supports multi-process debugging. */ + int (*supports_multi_process) (void); }; extern struct target_ops *the_target; @@ -311,6 +314,10 @@ void set_target_ops (struct target_ops * #define target_async(enable) \ (the_target->async ? (*the_target->async) (enable) : 0) +#define target_supports_multi_process() \ + (the_target->supports_multi_process ? \ + (*the_target->supports_multi_process) () : 0) + /* Start non-stop mode, returns 0 on success, -1 on failure. */ int start_non_stop (int nonstop); Index: src/gdb/gdbserver/server.c =================================================================== --- src.orig/gdb/gdbserver/server.c 2009-06-19 14:26:36.000000000 +0100 +++ src/gdb/gdbserver/server.c 2009-06-19 14:34:09.000000000 +0100 @@ -1074,9 +1074,13 @@ handle_query (char *own_buf, int packet_ p != NULL; p = strtok (NULL, ";")) { - /* Record if GDB knows about multiprocess support. */ if (strcmp (p, "multiprocess+") == 0) - multi_process = 1; + { + /* GDB supports and wants multi-process support if + possible. */ + if (target_supports_multi_process ()) + multi_process = 1; + } } sprintf (own_buf, "PacketSize=%x;QPassSignals+", PBUFSIZ - 1); @@ -1106,7 +1110,8 @@ handle_query (char *own_buf, int packet_ if (the_target->qxfer_osdata != NULL) strcat (own_buf, ";qXfer:osdata:read+"); - strcat (own_buf, ";multiprocess+"); + if (target_supports_multi_process ()) + strcat (own_buf, ";multiprocess+"); if (target_supports_non_stop ()) strcat (own_buf, ";QNonStop+"); Index: src/gdb/gdbserver/linux-low.c =================================================================== --- src.orig/gdb/gdbserver/linux-low.c 2009-06-19 14:26:36.000000000 +0100 +++ src/gdb/gdbserver/linux-low.c 2009-06-19 14:34:09.000000000 +0100 @@ -3008,6 +3008,12 @@ linux_start_non_stop (int nonstop) return 0; } +static int +linux_supports_multi_process (void) +{ + return 1; +} + static struct target_ops linux_target_ops = { linux_create_inferior, linux_attach, @@ -3045,6 +3051,7 @@ static struct target_ops linux_target_op linux_supports_non_stop, linux_async, linux_start_non_stop, + linux_supports_multi_process }; static void ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-06-19 13:41 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2009-06-16 20:10 [patch] gdbserver: qXfer multiprocess Aleksandar Ristovski 2009-06-16 21:09 ` Pedro Alves 2009-06-17 0:56 ` Aleksandar Ristovski 2009-06-17 1:04 ` Pedro Alves 2009-06-17 1:17 ` Aleksandar Ristovski 2009-06-17 17:19 ` Aleksandar Ristovski 2009-06-17 18:04 ` Pedro Alves 2009-06-17 19:06 ` Aleksandar Ristovski 2009-06-19 13:41 ` Pedro Alves
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox