+2013-07-25 Tom Tromey <tromey@redhat.com>
+
+ PR remote/15256, PR remote/15266:
+ * bfd-target.c (target_bfd_reopen): Initialize to_magic.
+ * monitor.c (monitor_detach): Use unpush_target.
+ * remote-m32r-sdi.c (m32r_detach): Use unpush_target.
+ * remote-mips.c (mips_detach): Use unpush_target. Don't
+ call mips_close.
+ * remote-sim.c (gdbsim_detach): Use unpush_target.
+ * target.c (pop_target): Remove.
+ (pop_all_targets_above): Don't call target_close.
+ (target_close): Assert that the target is unpushed.
+ * target.h (pop_target): Don't declare.
+ * tracepoint.c (tfile_open): Use unpush_target.
+
2013-07-25 Tom Tromey <tromey@redhat.com>
* linux-thread-db.c (init_thread_db_ops): Call
t->to_xfer_partial = target_bfd_xfer_partial;
t->to_xclose = target_bfd_xclose;
t->to_data = data;
+ t->to_magic = OPS_MAGIC;
return t;
}
static void
monitor_detach (struct target_ops *ops, char *args, int from_tty)
{
- pop_target (); /* calls monitor_close to do the real work. */
+ unpush_target (ops); /* calls monitor_close to do the real work. */
if (from_tty)
printf_unfiltered (_("Ending remote %s debugging\n"), target_shortname);
}
m32r_resume (ops, inferior_ptid, 0, GDB_SIGNAL_0);
/* Calls m32r_close to do the real work. */
- pop_target ();
+ unpush_target (ops);
if (from_tty)
fprintf_unfiltered (gdb_stdlog, "Ending remote %s debugging\n",
target_shortname);
if (args)
error (_("Argument given to \"detach\" when remotely debugging."));
- pop_target ();
-
- mips_close ();
+ unpush_target (ops);
if (from_tty)
printf_unfiltered ("Ending remote MIPS debugging.\n");
if (remote_debug)
printf_filtered ("gdbsim_detach: args \"%s\"\n", args);
- pop_target (); /* calls gdbsim_close to do the real work */
+ unpush_target (ops); /* calls gdbsim_close to do the real work */
if (from_tty)
printf_filtered ("Ending simulator %s debugging\n", target_shortname);
}
return 1;
}
-void
-pop_target (void)
-{
- target_close (target_stack); /* Let it clean up. */
- if (unpush_target (target_stack) == 1)
- return;
-
- fprintf_unfiltered (gdb_stderr,
- "pop_target couldn't find target %s\n",
- current_target.to_shortname);
- internal_error (__FILE__, __LINE__,
- _("failed internal consistency check"));
-}
-
void
pop_all_targets_above (enum strata above_stratum)
{
while ((int) (current_target.to_stratum) > (int) above_stratum)
{
- target_close (target_stack);
if (!unpush_target (target_stack))
{
fprintf_unfiltered (gdb_stderr,
void
target_close (struct target_ops *targ)
{
+ gdb_assert (!target_is_pushed (targ));
+
if (targ->to_xclose != NULL)
targ->to_xclose (targ);
else if (targ->to_close != NULL)
unpush_target: Remove this from the stack of currently used targets,
no matter where it is on the list. Returns 0 if no
- change, 1 if removed from stack.
-
- pop_target: Remove the top thing on the stack of current targets. */
+ change, 1 if removed from stack. */
extern void add_target (struct target_ops *);
extern void target_preopen (int);
-extern void pop_target (void);
-
/* Does whatever cleanup is required to get rid of all pushed targets. */
extern void pop_all_targets (void);
}
if (ex.reason < 0)
{
- /* Pop the partially set up target. */
- pop_target ();
+ /* Remove the partially set up target. */
+ unpush_target (&tfile_ops);
throw_exception (ex);
}