From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] agent_expr_up: gdb::unique_ptr -> std::unique_ptr
Date: Wed, 09 Nov 2016 00:56:00 -0000 [thread overview]
Message-ID: <1478652972-11094-1-git-send-email-palves@redhat.com> (raw)
Now that we require C++11, use std::unique_ptr directly. This allows
simplifying collection_list a bit by placing unique pointers in the
vector directly, making the vector own its elements.
gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* ax-gdb.c (agent_eval_command_one): Use std::move instead of
gdb::move.
* ax.h (agent_expr_up): Use std::unique_ptr instead of
gdb::unique_ptr.
* breakpoint.c (parse_cond_to_aexpr): Use std::move instead of
gdb::move.
* tracepoint.c (collection_list::collect_symbol): Likewise.
(collection_list::~collection_list): Delete.
(encode_actions_1): Use std::move instead of gdb::move.
(collection_list::add_aexpr): Use std::move instead of
unique_ptr::release.
* tracepoint.h (collection_list) <~collection_list>: Delete
declaration.
<m_aexprs>: Now a vector of unique_ptr<agent_ptr>.
---
gdb/ax-gdb.c | 6 +++---
gdb/ax.h | 2 +-
gdb/breakpoint.c | 4 ++--
gdb/tracepoint.c | 16 +++++-----------
gdb/tracepoint.h | 4 +---
5 files changed, 12 insertions(+), 20 deletions(-)
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index 1816ba6..cd97585 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -2555,7 +2555,7 @@ agent_eval_command_one (const char *exp, int eval, CORE_ADDR pc)
arg = exp;
if (!eval && strcmp (arg, "$_ret") == 0)
{
- agent = gdb::move (gen_trace_for_return_address (pc, get_current_arch (),
+ agent = std::move (gen_trace_for_return_address (pc, get_current_arch (),
trace_string));
}
else
@@ -2565,10 +2565,10 @@ agent_eval_command_one (const char *exp, int eval, CORE_ADDR pc)
if (eval)
{
gdb_assert (trace_string == 0);
- agent = gdb::move (gen_eval_for_expr (pc, expr.get ()));
+ agent = std::move (gen_eval_for_expr (pc, expr.get ()));
}
else
- agent = gdb::move (gen_trace_for_expr (pc, expr.get (), trace_string));
+ agent = std::move (gen_trace_for_expr (pc, expr.get (), trace_string));
}
ax_reqs (agent.get ());
diff --git a/gdb/ax.h b/gdb/ax.h
index 85d2943..dbbfa0b 100644
--- a/gdb/ax.h
+++ b/gdb/ax.h
@@ -168,7 +168,7 @@ struct agent_expr
};
/* An agent_expr owning pointer. */
-typedef gdb::unique_ptr<agent_expr> agent_expr_up;
+typedef std::unique_ptr<agent_expr> agent_expr_up;
/* The actual values of the various bytecode operations. */
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index a3a81f7..245e078 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2268,7 +2268,7 @@ parse_cond_to_aexpr (CORE_ADDR scope, struct expression *cond)
that may show up. */
TRY
{
- aexpr = gdb::move (gen_eval_for_expr (scope, cond));
+ aexpr = std::move (gen_eval_for_expr (scope, cond));
}
CATCH (ex, RETURN_MASK_ERROR)
@@ -2452,7 +2452,7 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd)
that may show up. */
TRY
{
- aexpr = gdb::move (gen_printf (scope, gdbarch, 0, 0,
+ aexpr = std::move (gen_printf (scope, gdbarch, 0, 0,
format_start, format_end - format_start,
fpieces, nargs, argvec));
}
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 2a40b16..0cb12c7 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -1076,7 +1076,7 @@ collection_list::collect_symbol (struct symbol *sym,
}
}
- add_aexpr (gdb::move (aexpr));
+ add_aexpr (std::move (aexpr));
}
}
@@ -1180,12 +1180,6 @@ collection_list::collection_list ()
m_aexprs.reserve (128);
}
-collection_list::~collection_list ()
-{
- for (int ndx = 0; ndx < m_aexprs.size (); ndx++)
- delete m_aexprs[ndx];
-}
-
/* Reduce a collection list to string form (for gdb protocol). */
char **
@@ -1419,7 +1413,7 @@ encode_actions_1 (struct command_line *action,
}
}
- collect->add_aexpr (gdb::move (aexpr));
+ collect->add_aexpr (std::move (aexpr));
action_exp = strchr (action_exp, ','); /* more? */
}
else if (0 == strncasecmp ("$_sdata", action_exp, 7))
@@ -1508,7 +1502,7 @@ encode_actions_1 (struct command_line *action,
}
}
- collect->add_aexpr (gdb::move (aexpr));
+ collect->add_aexpr (std::move (aexpr));
collect->append_exp (exp.get ());
break;
} /* switch */
@@ -1538,7 +1532,7 @@ encode_actions_1 (struct command_line *action,
/* Even though we're not officially collecting, add
to the collect list anyway. */
- collect->add_aexpr (gdb::move (aexpr));
+ collect->add_aexpr (std::move (aexpr));
} /* do */
}
while (action_exp && *action_exp++ == ',');
@@ -1602,7 +1596,7 @@ encode_actions_rsp (struct bp_location *tloc, char ***tdp_actions,
void
collection_list::add_aexpr (agent_expr_up aexpr)
{
- m_aexprs.push_back (aexpr.release ());
+ m_aexprs.push_back (std::move (aexpr));
}
static void
diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h
index 7dfd8cc..87a74f9 100644
--- a/gdb/tracepoint.h
+++ b/gdb/tracepoint.h
@@ -243,7 +243,6 @@ class collection_list
{
public:
collection_list ();
- ~collection_list ();
void add_wholly_collected (const char *print_name);
@@ -282,8 +281,7 @@ private:
std::vector<memrange> m_memranges;
- /* Vector owns pointers. */
- std::vector<agent_expr *> m_aexprs;
+ std::vector<std::unique_ptr<agent_expr>> m_aexprs;
/* True is the user requested a collection of "$_sdata", "static
tracepoint data". */
--
2.5.5
next reply other threads:[~2016-11-09 0:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-09 0:56 Pedro Alves [this message]
2016-11-09 12:24 ` Yao Qi
2016-11-09 15:04 ` Pedro Alves
2016-11-09 23:03 ` Joel Brobecker
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=1478652972-11094-1-git-send-email-palves@redhat.com \
--to=palves@redhat.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