aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);