summaryrefslogtreecommitdiff
path: root/gdb/target.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/target.c')
-rw-r--r--gdb/target.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/gdb/target.c b/gdb/target.c
index b01e1ac645..ce630f43de 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -2108,7 +2108,7 @@ dispose_inferior (struct inferior *inf, void *args)
if (target_has_execution)
target_kill ();
else
- target_detach (0);
+ target_detach (inf, 0);
}
return 0;
@@ -2144,8 +2144,15 @@ target_preopen (int from_tty)
/* See target.h. */
void
-target_detach (int from_tty)
+target_detach (inferior *inf, int from_tty)
{
+ /* As long as some to_detach implementations rely on the current_inferior
+ (either directly, or indirectly, like through target_gdbarch or by
+ reading memory), INF needs to be the current inferior. When that
+ requirement will become no longer true, then we can remove this
+ assertion. */
+ gdb_assert (inf == current_inferior ());
+
if (gdbarch_has_global_breakpoints (target_gdbarch ()))
/* Don't remove global breakpoints here. They're removed on
disconnection from the target. */
@@ -2157,7 +2164,7 @@ target_detach (int from_tty)
prepare_for_detach ();
- current_target.to_detach (&current_target, from_tty);
+ current_target.to_detach (&current_target, inf, from_tty);
}
void