/* Machine independent support for Solaris /proc (process file system) for GDB.
- Copyright (C) 1999-2020 Free Software Foundation, Inc.
+ Copyright (C) 1999-2021 Free Software Foundation, Inc.
Written by Michael Snyder at Cygnus Solutions.
Based on work by Fred Fish, Stu Grossman, Geoff Noer, and others.
if (pid == getpid ())
error (_("Attaching GDB to itself is not a good idea..."));
+ /* Push the target if needed, ensure it gets un-pushed it if attach fails. */
+ inferior *inf = current_inferior ();
+ target_unpush_up unpusher;
+ if (!inf->target_is_pushed (this))
+ {
+ inf->push_target (this);
+ unpusher.reset (this);
+ }
+
if (from_tty)
{
const char *exec_file = get_exec_file (0);
fflush (stdout);
}
+
do_attach (ptid_t (pid));
- if (!target_is_pushed (this))
- push_target (this);
+
+ /* Everything went fine, keep the target pushed. */
+ unpusher.release ();
}
void
shell_file = tryname;
}
- if (!target_is_pushed (this))
- push_target (this);
+ inferior *inf = current_inferior ();
+ if (!inf->target_is_pushed (this))
+ inf->push_target (this);
pid = fork_inferior (exec_file, allargs, env, procfs_set_exec_trap,
NULL, procfs_pre_trace, shell_file, NULL);
&thread_args);
gdb::optional<gdb::byte_vector> auxv =
- target_read_alloc (current_top_target (), TARGET_OBJECT_AUXV, NULL);
+ target_read_alloc (current_inferior ()->top_target (),
+ TARGET_OBJECT_AUXV, NULL);
if (auxv && !auxv->empty ())
note_data.reset (elfcore_write_note (obfd, note_data.release (), note_size,
"CORE", NT_AUXV, auxv->data (),