aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Koning <paul_koning@dell.com>2015-10-26 15:53:37 -0400
committerPaul Koning <paul_koning@dell.com>2015-10-26 15:53:37 -0400
commite0063bdcde2623cfb17c1f517f42c8924d463c2b (patch)
treef2573263724205f2fb8f7ccffc5a82d949affd92
parent357d8270b141ee35d60fc6e01d0a17b9cd9b45fa (diff)
downloadgdb-e0063bdcde2623cfb17c1f517f42c8924d463c2b.zip
gdb-e0063bdcde2623cfb17c1f517f42c8924d463c2b.tar.gz
gdb-e0063bdcde2623cfb17c1f517f42c8924d463c2b.tar.bz2
fix exec_close to be multi-target-aware
This changes exec_close so it doesn't close inferiors from other targets. 2014-07-29 Tom Tromey <tromey@redhat.com> * target.h (target_stack_decref_cleanup): Declare. * exec.c (exec_xclose_1): Skip program spaces from other targets. * target.c (target_stack_decref_cleanup): New function.
-rw-r--r--gdb/exec.c10
-rw-r--r--gdb/target.c8
-rw-r--r--gdb/target.h4
3 files changed, 21 insertions, 1 deletions
diff --git a/gdb/exec.c b/gdb/exec.c
index a2b2942..3091cda 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -113,10 +113,18 @@ exec_xclose_1 (struct target_ops *self)
{
struct program_space *ss;
struct cleanup *old_chain;
+ struct target_stack *tstack = target_stack_incref ();
+
+ old_chain = make_cleanup (target_stack_decref_cleanup, tstack);
+ save_current_program_space ();
- old_chain = save_current_program_space ();
ALL_PSPACES (ss)
{
+ /* Skip program spaces that are associated with some other
+ target. */
+ if (ss->target_stack != tstack)
+ continue;
+
set_current_program_space (ss);
clear_section_table (current_target_sections);
exec_close ();
diff --git a/gdb/target.c b/gdb/target.c
index 1d7a4cf..d3fc6c5 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3927,6 +3927,14 @@ target_stack_decref (struct target_stack *tstack)
/* See target.h. */
void
+target_stack_decref_cleanup (void *arg)
+{
+ target_stack_decref (arg);
+}
+
+/* See target.h. */
+
+void
target_stack_set_current (struct target_stack *tstack)
{
target_stack = tstack;
diff --git a/gdb/target.h b/gdb/target.h
index 78610bf..13865a2 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1265,6 +1265,10 @@ extern struct target_stack *target_stack_incref (void);
extern void target_stack_decref (struct target_stack *);
+/* A wrapper for target_stack_decref suitable for use as a cleanup. */
+
+extern void target_stack_decref_cleanup (void *arg);
+
/* Set target_stack and current_target from TSTACK. */
extern void target_stack_set_current (struct target_stack *tstack);