* Allow attaching to multiple processes
@ 2008-10-27 12:44 Pedro Alves
2008-10-27 23:29 ` Pedro Alves
0 siblings, 1 reply; 2+ messages in thread
From: Pedro Alves @ 2008-10-27 12:44 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 326 bytes --]
Now that the remote target supports debugging multiple inferiors
simultaneously, we need to allow/expose that to the command level. This
patch allows "attach"ing to multiple processes. ("run"ning will come later).
Not much rocket science here --- the comments/code should be
self-explanatory.
Checked in.
--
Pedro Alves
[-- Attachment #2: target_supports_multiprocess.diff --]
[-- Type: text/x-diff, Size: 4607 bytes --]
2008-10-27 Pedro Alves <pedro@codesourcery.com>
* target.h (struct target_ops) <to_supports_multi_process>: New
field.
(target_supports_multi_process): New define.
* target.c (update_current_target): Inherit and de_fault
to_supports_multi_process.
* infcmd.c (attach_command): Allow attaching to multiple processes
if the target supports it.
(detach_command): If the target claims there is still execution,
don't clear the thread list.
* remote.c (remote_supports_multi_process): New.
(init_remote_ops): Register remote_supports_multi_process.
---
gdb/infcmd.c | 12 ++++++++++--
gdb/remote.c | 8 ++++++++
gdb/target.c | 4 ++++
gdb/target.h | 10 ++++++++++
4 files changed, 32 insertions(+), 2 deletions(-)
Index: src/gdb/target.h
===================================================================
--- src.orig/gdb/target.h 2008-10-27 12:27:28.000000000 +0000
+++ src/gdb/target.h 2008-10-27 12:27:30.000000000 +0000
@@ -536,6 +536,10 @@ struct target_ops
/* Can target execute in reverse? */
int (*to_can_execute_reverse) ();
+ /* Does this target support debugging multiple processes
+ simultaneously? */
+ int (*to_supports_multi_process) (void);
+
int to_magic;
/* Need sub-structure for target machine related rather than comm related?
*/
@@ -647,6 +651,12 @@ extern void target_resume (ptid_t ptid,
#define target_prepare_to_store(regcache) \
(*current_target.to_prepare_to_store) (regcache)
+/* Returns true if this target can debug multiple processes
+ simultaneously. */
+
+#define target_supports_multi_process() \
+ (*current_target.to_supports_multi_process) ()
+
extern DCACHE *target_dcache;
extern int target_read_string (CORE_ADDR, char **, int, int *);
Index: src/gdb/target.c
===================================================================
--- src.orig/gdb/target.c 2008-10-27 12:27:28.000000000 +0000
+++ src/gdb/target.c 2008-10-27 12:27:30.000000000 +0000
@@ -471,6 +471,7 @@ update_current_target (void)
/* Do not inherit to_read_description. */
INHERIT (to_get_ada_task_ptid, t);
/* Do not inherit to_search_memory. */
+ INHERIT (to_supports_multi_process, t);
INHERIT (to_magic, t);
/* Do not inherit to_memory_map. */
/* Do not inherit to_flash_erase. */
@@ -638,6 +639,9 @@ update_current_target (void)
de_fault (to_get_ada_task_ptid,
(ptid_t (*) (long, long))
default_get_ada_task_ptid);
+ de_fault (to_supports_multi_process,
+ (int (*) (void))
+ return_zero);
#undef de_fault
/* Finally, position the target-stack beneath the squashed
Index: src/gdb/infcmd.c
===================================================================
--- src.orig/gdb/infcmd.c 2008-10-27 12:27:28.000000000 +0000
+++ src/gdb/infcmd.c 2008-10-27 12:32:26.000000000 +0000
@@ -2201,7 +2201,10 @@ attach_command (char *args, int from_tty
dont_repeat (); /* Not for the faint of heart */
- if (target_has_execution)
+ if (target_supports_multi_process ())
+ /* Don't complain if we can be attached to multiple processes. */
+ ;
+ else if (target_has_execution)
{
if (query ("A program is being debugged already. Kill it? "))
target_kill ();
@@ -2311,7 +2314,12 @@ detach_command (char *args, int from_tty
dont_repeat (); /* Not for the faint of heart. */
target_detach (args, from_tty);
no_shared_libraries (NULL, from_tty);
- init_thread_list ();
+
+ /* If the current target interface claims there's still execution,
+ then don't mess with threads of other processes. */
+ if (!target_has_execution)
+ init_thread_list ();
+
if (deprecated_detach_hook)
deprecated_detach_hook ();
}
Index: src/gdb/remote.c
===================================================================
--- src.orig/gdb/remote.c 2008-10-27 12:27:28.000000000 +0000
+++ src/gdb/remote.c 2008-10-27 12:27:30.000000000 +0000
@@ -8554,6 +8554,13 @@ remote_supports_non_stop (void)
return 1;
}
+static int
+remote_supports_multi_process (void)
+{
+ struct remote_state *rs = get_remote_state ();
+ return remote_multi_process_p (rs);
+}
+
static void
init_remote_ops (void)
{
@@ -8616,6 +8623,7 @@ Specify the serial device it is connecte
remote_ops.to_terminal_inferior = remote_terminal_inferior;
remote_ops.to_terminal_ours = remote_terminal_ours;
remote_ops.to_supports_non_stop = remote_supports_non_stop;
+ remote_ops.to_supports_multi_process = remote_supports_multi_process;
}
/* Set up the extended remote vector by making a copy of the standard
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: Allow attaching to multiple processes
2008-10-27 12:44 Allow attaching to multiple processes Pedro Alves
@ 2008-10-27 23:29 ` Pedro Alves
0 siblings, 0 replies; 2+ messages in thread
From: Pedro Alves @ 2008-10-27 23:29 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 446 bytes --]
On Monday 27 October 2008 12:44:05, Pedro Alves wrote:
> Now that the remote target supports debugging multiple inferiors
> simultaneously, we need to allow/expose that to the command level. This
> patch allows "attach"ing to multiple processes. ("run"ning will come later).
>
> Not much rocket science here --- the comments/code should be
> self-explanatory.
"kill" requires a similar treatment, like attached. Checked in.
--
Pedro Alves
[-- Attachment #2: kill_theres_execution.diff --]
[-- Type: text/x-diff, Size: 1437 bytes --]
2008-10-27 Pedro Alves <pedro@codesourcery.com>
* inflow.c (kill_command): If the target claims there is still
execution, don't clear the thread list.
---
gdb/inflow.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
Index: src/gdb/inflow.c
===================================================================
--- src.orig/gdb/inflow.c 2008-10-27 20:38:52.000000000 +0000
+++ src/gdb/inflow.c 2008-10-27 22:31:15.000000000 +0000
@@ -601,14 +601,19 @@ kill_command (char *arg, int from_tty)
error (_("Not confirmed."));
target_kill ();
- init_thread_list (); /* Destroy thread info */
-
- /* Killing off the inferior can leave us with a core file. If so,
- print the state we are left in. */
- if (target_has_stack)
- {
- printf_filtered (_("In %s,\n"), target_longname);
- print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
+ /* If the current target interface claims there's still execution,
+ then don't mess with threads of other processes. */
+ if (!target_has_execution)
+ {
+ init_thread_list (); /* Destroy thread info */
+
+ /* Killing off the inferior can leave us with a core file. If
+ so, print the state we are left in. */
+ if (target_has_stack)
+ {
+ printf_filtered (_("In %s,\n"), target_longname);
+ print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
+ }
}
bfd_cache_close_all ();
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-10-27 22:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-27 12:44 Allow attaching to multiple processes Pedro Alves
2008-10-27 23:29 ` Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox