diff options
author | Tom Tromey <tom@tromey.com> | 2017-08-15 23:36:09 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-08-18 11:06:26 -0600 |
commit | 2989a3651d3f6ad8c7cffb225f77f4fca8868890 (patch) | |
tree | 8eefedd30fba1827d138d783ab7e621b838d0994 /gdb/linux-tdep.c | |
parent | e60eb2880368b4e4752577c626ab0dadf0499cb5 (diff) | |
download | gdb-2989a3651d3f6ad8c7cffb225f77f4fca8868890.zip gdb-2989a3651d3f6ad8c7cffb225f77f4fca8868890.tar.gz gdb-2989a3651d3f6ad8c7cffb225f77f4fca8868890.tar.bz2 |
Remove save_inferior_ptid
This removes save_inferior_ptid, a cleanup function, in favor of
scoped_restore.
This also fixes a possible (it seems unlikely that it could happen in
practice) memory leak -- save_inferior_ptid should have used
make_cleanup_dtor, because it allocated memory.
I tested this on the buildbot. However, there are two caveats to
this. First, sometimes it seems I misread the results. Second, I
think this patch touches some platforms that can't be tested by the
buildbot. So, extra care seems warranted.
ChangeLog
2017-08-18 Tom Tromey <tom@tromey.com>
Pedro Alves <palves@redhat.com>
* spu-multiarch.c (parse_spufs_run): Use scoped_restore.
* sol-thread.c (sol_thread_resume, sol_thread_wait)
(sol_thread_xfer_partial, rw_common): Use scoped_restore.
* procfs.c (procfs_do_thread_registers): Use scoped_restore.
* proc-service.c (ps_xfer_memory): Use scoped_restore.
* linux-tdep.c (linux_corefile_thread): Remove a cleanup.
(linux_get_siginfo_data): Add "thread" argument. Use
scoped_restore.
* linux-nat.c (linux_child_follow_fork)
(check_stopped_by_watchpoint): Use scoped_restore.
* infrun.c (displaced_step_prepare_throw, write_memory_ptid)
(THREAD_STOPPED_BY, handle_signal_stop): Use scoped_restore.
(restore_inferior_ptid, save_inferior_ptid): Remove.
* btrace.c (btrace_fetch): Use scoped_restore.
* bsd-uthread.c (bsd_uthread_fetch_registers)
(bsd_uthread_store_registers): Use scoped_restore.
* breakpoint.c (reattach_breakpoints, detach_breakpoints): Use
scoped_restore.
* aix-thread.c (aix_thread_resume, aix_thread_wait)
(aix_thread_xfer_partial): Use scoped_restore.
* inferior.h (save_inferior_ptid): Remove.
Diffstat (limited to 'gdb/linux-tdep.c')
-rw-r--r-- | gdb/linux-tdep.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index 5c7f8a0..f5389a0 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -1649,14 +1649,15 @@ linux_collect_thread_registers (const struct regcache *regcache, return data.note_data; } -/* Fetch the siginfo data for the current thread, if it exists. If +/* Fetch the siginfo data for the specified thread, if it exists. If there is no data, or we could not read it, return NULL. Otherwise, return a newly malloc'd buffer holding the data and fill in *SIZE with the size of the data. The caller is responsible for freeing the data. */ static gdb_byte * -linux_get_siginfo_data (struct gdbarch *gdbarch, LONGEST *size) +linux_get_siginfo_data (thread_info *thread, struct gdbarch *gdbarch, + LONGEST *size) { struct type *siginfo_type; gdb_byte *buf; @@ -1666,6 +1667,9 @@ linux_get_siginfo_data (struct gdbarch *gdbarch, LONGEST *size) if (!gdbarch_get_siginfo_type_p (gdbarch)) return NULL; + scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid); + inferior_ptid = thread->ptid; + siginfo_type = gdbarch_get_siginfo_type (gdbarch); buf = (gdb_byte *) xmalloc (TYPE_LENGTH (siginfo_type)); @@ -1710,11 +1714,8 @@ linux_corefile_thread (struct thread_info *info, regcache = get_thread_arch_regcache (info->ptid, args->gdbarch); - old_chain = save_inferior_ptid (); - inferior_ptid = info->ptid; target_fetch_registers (regcache, -1); - siginfo_data = linux_get_siginfo_data (args->gdbarch, &siginfo_size); - do_cleanups (old_chain); + siginfo_data = linux_get_siginfo_data (info, args->gdbarch, &siginfo_size); old_chain = make_cleanup (xfree, siginfo_data); |