This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 05/12] Remove cleanup from linux-nat.c
- From: Tom Tromey <tom at tromey dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tom at tromey dot com>
- Date: Tue, 8 Jan 2019 20:34:19 -0700
- Subject: [PATCH 05/12] Remove cleanup from linux-nat.c
- References: <20190109033426.16062-1-tom@tromey.com>
This removes a cleanup from linux-nat.c, replacing it with a
cleanup_function.
gdb/ChangeLog
2019-01-08 Tom Tromey <tom@tromey.com>
* linux-nat.c (cleanup_target_stop): Remove.
(linux_nat_target::static_tracepoint_markers_by_strid): Use
cleanup_function.
---
gdb/ChangeLog | 6 ++++++
gdb/linux-nat.c | 23 ++++++++---------------
2 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 73d4fd193a..d1c4707b4b 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -66,6 +66,7 @@
#include "objfiles.h"
#include "nat/linux-namespaces.h"
#include "fileio.h"
+#include "common/cleanup-function.h"
#ifndef SPUFS_MAGIC
#define SPUFS_MAGIC 0x23c9b64e
@@ -4223,22 +4224,10 @@ linux_nat_xfer_osdata (enum target_object object,
return TARGET_XFER_OK;
}
-static void
-cleanup_target_stop (void *arg)
-{
- ptid_t *ptid = (ptid_t *) arg;
-
- gdb_assert (arg != NULL);
-
- /* Unpause all */
- target_continue_no_signal (*ptid);
-}
-
std::vector<static_tracepoint_marker>
linux_nat_target::static_tracepoint_markers_by_strid (const char *strid)
{
char s[IPA_CMD_BUF_SIZE];
- struct cleanup *old_chain;
int pid = inferior_ptid.pid ();
std::vector<static_tracepoint_marker> markers;
const char *p = s;
@@ -4253,7 +4242,13 @@ linux_nat_target::static_tracepoint_markers_by_strid (const char *strid)
agent_run_command (pid, s, strlen (s) + 1);
- old_chain = make_cleanup (cleanup_target_stop, &ptid);
+ auto continue_func
+ = [=] ()
+ {
+ /* Unpause all */
+ target_continue_no_signal (ptid);
+ };
+ cleanup_function continue_at_end (continue_func);
while (*p++ == 'm')
{
@@ -4272,8 +4267,6 @@ linux_nat_target::static_tracepoint_markers_by_strid (const char *strid)
p = s;
}
- do_cleanups (old_chain);
-
return markers;
}
--
2.17.2