From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 2/9] Remove make_cleanup_restore_current_thread from gdbserver
Date: Wed, 07 Feb 2018 22:04:00 -0000 [thread overview]
Message-ID: <20180207220434.6045-3-tom@tromey.com> (raw)
In-Reply-To: <20180207220434.6045-1-tom@tromey.com>
This removes make_cleanup_restore_current_thread from gdbserver,
replacing it with a use of scoped_restore.
2018-02-07 Tom Tromey <tom@tromey.com>
* linux-low.c (install_software_single_step_breakpoints): Use
make_scoped_restore.
* inferiors.c (make_cleanup_restore_current_thread): Remove.
(do_restore_current_thread_cleanup): Remove.
* gdbthread.h (make_cleanup_restore_current_thread): Don't
declare.
---
gdb/gdbserver/ChangeLog | 9 +++++++++
gdb/gdbserver/gdbthread.h | 3 ---
gdb/gdbserver/inferiors.c | 12 ------------
gdb/gdbserver/linux-low.c | 6 +++---
4 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 902ee7c7fd..0213edb1ee 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,14 @@
2018-02-07 Tom Tromey <tom@tromey.com>
+ * linux-low.c (install_software_single_step_breakpoints): Use
+ make_scoped_restore.
+ * inferiors.c (make_cleanup_restore_current_thread): Remove.
+ (do_restore_current_thread_cleanup): Remove.
+ * gdbthread.h (make_cleanup_restore_current_thread): Don't
+ declare.
+
+2018-02-07 Tom Tromey <tom@tromey.com>
+
* mem-break.c (set_raw_breakpoint_at): Use
gdb::unique_xmalloc_ptr.
diff --git a/gdb/gdbserver/gdbthread.h b/gdb/gdbserver/gdbthread.h
index 9a8c72e780..0edf870c56 100644
--- a/gdb/gdbserver/gdbthread.h
+++ b/gdb/gdbserver/gdbthread.h
@@ -224,7 +224,4 @@ lwpid_of (const thread_info *thread)
return thread->id.lwp ();
}
-/* Create a cleanup to restore current_thread. */
-struct cleanup *make_cleanup_restore_current_thread (void);
-
#endif /* GDB_THREAD_H */
diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c
index 600bf201bf..ad3df648f5 100644
--- a/gdb/gdbserver/inferiors.c
+++ b/gdb/gdbserver/inferiors.c
@@ -213,18 +213,6 @@ current_process (void)
return get_thread_process (current_thread);
}
-static void
-do_restore_current_thread_cleanup (void *arg)
-{
- current_thread = (struct thread_info *) arg;
-}
-
-struct cleanup *
-make_cleanup_restore_current_thread (void)
-{
- return make_cleanup (do_restore_current_thread_cleanup, current_thread);
-}
-
/* See common/common-gdbthread.h. */
void
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 38142bba03..b6b660ea96 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -50,6 +50,7 @@
#include "common-inferior.h"
#include "nat/fork-inferior.h"
#include "environ.h"
+#include "common/scoped_restore.h"
#ifndef ELFMAG0
/* Don't include <linux/elf.h> here. If it got included by gdb_proc_service.h
then ELFMAG0 will have been defined. If it didn't get included by
@@ -4207,15 +4208,14 @@ install_software_single_step_breakpoints (struct lwp_info *lwp)
{
struct thread_info *thread = get_lwp_thread (lwp);
struct regcache *regcache = get_thread_regcache (thread, 1);
- struct cleanup *old_chain = make_cleanup_restore_current_thread ();
+
+ scoped_restore save_current_thread = make_scoped_restore (¤t_thread);
current_thread = thread;
std::vector<CORE_ADDR> next_pcs = the_low_target.get_next_pcs (regcache);
for (CORE_ADDR pc : next_pcs)
set_single_step_breakpoint (pc, current_ptid);
-
- do_cleanups (old_chain);
}
/* Single step via hardware or software single step.
--
2.13.6
next prev parent reply other threads:[~2018-02-07 22:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-07 22:04 [RFA 0/9] more cleanup removal Tom Tromey
2018-02-07 22:04 ` [RFA 6/9] Remove cleanups from macro_define_command Tom Tromey
2018-02-07 22:04 ` [RFA 5/9] Use std::string in maybe_expand Tom Tromey
2018-02-07 22:04 ` [RFA 7/9] Use std::vector in find_source_lines Tom Tromey
2018-02-09 13:00 ` Tom Tromey
2018-02-09 13:11 ` Pedro Alves
2018-02-07 22:04 ` [RFA 1/9] Remove a cleanup from gdbserver Tom Tromey
2018-02-07 22:04 ` [RFA 8/9] Use unique_xmalloc_ptr in build_id_to_debug_bfd Tom Tromey
2018-02-07 22:04 ` [RFA 9/9] Remove cleanups from solib.c Tom Tromey
2018-02-07 22:04 ` [RFA 3/9] Return unique_xmalloc_ptr from macro scope functions Tom Tromey
2018-02-07 22:04 ` [RFA 4/9] Class-ify macro_buffer Tom Tromey
2018-02-07 22:04 ` Tom Tromey [this message]
2018-02-08 16:42 ` [RFA 0/9] more cleanup removal Pedro Alves
2018-02-08 18:45 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180207220434.6045-3-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).