aboutsummaryrefslogtreecommitdiff
path: root/gdb/procfs.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2020-06-18 21:28:22 +0100
committerPedro Alves <palves@redhat.com>2020-06-18 23:06:03 +0100
commit7fb43e53d57d5d1c47fad8a2dece7b90d20b3fd3 (patch)
treea76e70ff466f281f09981344f451141e43635405 /gdb/procfs.c
parent18493a005acc8fbccbee4a2b767334eaaf636dd2 (diff)
downloadgdb-7fb43e53d57d5d1c47fad8a2dece7b90d20b3fd3.zip
gdb-7fb43e53d57d5d1c47fad8a2dece7b90d20b3fd3.tar.gz
gdb-7fb43e53d57d5d1c47fad8a2dece7b90d20b3fd3.tar.bz2
Don't write to inferior_ptid in procfs.c
The inferior_ptid write in procfs_do_thread_registers should be unnecessary because the target_fetch_registers method should (and does) extract the ptid from the regcache. Not tested. gdb/ChangeLog: 2020-06-18 Pedro Alves <palves@redhat.com> * procfs.c (procfs_target::attach): Don't write to inferior_ptid. (procfs_target::detach): Use switch_to_no_thread instead of writing to inferior_ptid directly. (do_attach): Change return type to void. Switch to the added thread. (procfs_target::create_inferior): Switch to the added thread. (procfs_do_thread_registers): Don't write to inferior_ptid.
Diffstat (limited to 'gdb/procfs.c')
-rw-r--r--gdb/procfs.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/gdb/procfs.c b/gdb/procfs.c
index f6c6b0e..71472a5 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -1726,7 +1726,7 @@ proc_iterate_over_threads (procinfo *pi,
/* Here are all of the gdb target vector functions and their
friends. */
-static ptid_t do_attach (ptid_t ptid);
+static void do_attach (ptid_t ptid);
static void do_detach ();
static void proc_trace_syscalls_1 (procinfo *pi, int syscallnum,
int entry_or_exit, int mode, int from_tty);
@@ -1815,7 +1815,7 @@ procfs_target::attach (const char *args, int from_tty)
fflush (stdout);
}
- inferior_ptid = do_attach (ptid_t (pid));
+ do_attach (ptid_t (pid));
if (!target_is_pushed (this))
push_target (this);
}
@@ -1839,12 +1839,12 @@ procfs_target::detach (inferior *inf, int from_tty)
do_detach ();
- inferior_ptid = null_ptid;
+ switch_to_no_thread ();
detach_inferior (inf);
maybe_unpush_target ();
}
-static ptid_t
+static void
do_attach (ptid_t ptid)
{
procinfo *pi;
@@ -1912,9 +1912,8 @@ do_attach (ptid_t ptid)
/* Add it to gdb's thread list. */
ptid = ptid_t (pi->pid, lwpid, 0);
- add_thread (&the_procfs_target, ptid);
-
- return ptid;
+ thread_info *thr = add_thread (&the_procfs_target, ptid);
+ switch_to_thread (thr);
}
static void
@@ -3013,7 +3012,8 @@ procfs_target::create_inferior (const char *exec_file,
/* We have something that executes now. We'll be running through
the shell at this point (if startup-with-shell is true), but the
pid shouldn't change. */
- add_thread_silent (this, ptid_t (pid));
+ thread_info *thr = add_thread_silent (this, ptid_t (pid));
+ switch_to_thread (thr);
procfs_init_inferior (pid);
}
@@ -3676,8 +3676,6 @@ procfs_do_thread_registers (bfd *obfd, ptid_t ptid,
once it is implemented in this platform:
gdbarch_iterate_over_regset_sections(). */
- scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
- inferior_ptid = ptid;
target_fetch_registers (regcache, -1);
fill_gregset (regcache, &gregs, -1);