From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 30/31] Eliminate agent_expr_p; VEC -> std::vector in struct bp_target_info
Date: Wed, 19 Oct 2016 01:18:00 -0000 [thread overview]
Message-ID: <1476839539-8374-31-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1476839539-8374-1-git-send-email-palves@redhat.com>
After the previous patch, we end up with these two types with quite
similar, and potentially confusing names:
typedef gdb::unique_ptr<agent_expr> agent_expr_up;
/* Pointer to an agent_expr structure. */
typedef struct agent_expr *agent_expr_p;
The latter is only necessary to put agent_expr pointers in VECs. So
just eliminate it and use std::vector instead.
gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* ax.h (agent_expr_p): Delete.
(DEF_VEC_P (agent_expr_p)): Delete.
* breakpoint.c (build_target_condition_list)
(build_target_command_list): Adjust to use of std::vector.
(bp_location_dtor): Remove now unnecessary VEC_free calls.
* breakpoint.h: Include <vector>.
(struct bp_target_info) <conditions, tcommands>: Now
std::vector's.
* remote.c (remote_add_target_side_condition): bp_tgt->conditions
is now a std::vector; adjust.
(remote_add_target_side_commands, remote_insert_breakpoint):
bp_tgt->tcommands is now a std::vector; adjust.
---
gdb/ax.h | 6 ------
gdb/breakpoint.c | 27 +++++++++++++--------------
gdb/breakpoint.h | 13 +++++++------
gdb/remote.c | 28 +++++++++++-----------------
4 files changed, 31 insertions(+), 43 deletions(-)
diff --git a/gdb/ax.h b/gdb/ax.h
index 4b90229..85d2943 100644
--- a/gdb/ax.h
+++ b/gdb/ax.h
@@ -170,12 +170,6 @@ struct agent_expr
/* An agent_expr owning pointer. */
typedef gdb::unique_ptr<agent_expr> agent_expr_up;
-/* Pointer to an agent_expr structure. */
-typedef struct agent_expr *agent_expr_p;
-
-/* Vector of pointers to agent expressions. */
-DEF_VEC_P (agent_expr_p);
-
/* The actual values of the various bytecode operations. */
enum agent_op
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 77f551b..37c1dbd 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2298,7 +2298,7 @@ build_target_condition_list (struct bp_location *bl)
struct bp_location *loc;
/* Release conditions left over from a previous insert. */
- VEC_free (agent_expr_p, bl->target_info.conditions);
+ bl->target_info.conditions.clear ();
/* This is only meaningful if the target is
evaluating conditions and if the user has
@@ -2371,10 +2371,11 @@ build_target_condition_list (struct bp_location *bl)
&& loc->pspace->num == bl->pspace->num
&& loc->owner->enable_state == bp_enabled
&& loc->enabled)
- /* Add the condition to the vector. This will be used later to send the
- conditions to the target. */
- VEC_safe_push (agent_expr_p, bl->target_info.conditions,
- loc->cond_bytecode.get ());
+ {
+ /* Add the condition to the vector. This will be used later
+ to send the conditions to the target. */
+ bl->target_info.conditions.push_back (loc->cond_bytecode.get ());
+ }
}
return;
@@ -2481,8 +2482,8 @@ build_target_command_list (struct bp_location *bl)
int modified = bl->needs_update;
struct bp_location *loc;
- /* Release commands left over from a previous insert. */
- VEC_free (agent_expr_p, bl->target_info.tcommands);
+ /* Clear commands left over from a previous insert. */
+ bl->target_info.tcommands.clear ();
if (!target_can_run_breakpoint_commands ())
return;
@@ -2565,10 +2566,11 @@ build_target_command_list (struct bp_location *bl)
&& loc->pspace->num == bl->pspace->num
&& loc->owner->enable_state == bp_enabled
&& loc->enabled)
- /* Add the command to the vector. This will be used later
- to send the commands to the target. */
- VEC_safe_push (agent_expr_p, bl->target_info.tcommands,
- loc->cmd_bytecode.get ());
+ {
+ /* Add the command to the vector. This will be used later
+ to send the commands to the target. */
+ bl->target_info.tcommands.push_back (loc->cmd_bytecode.get ());
+ }
}
bl->target_info.persist = 0;
@@ -12867,9 +12869,6 @@ static void
bp_location_dtor (struct bp_location *self)
{
xfree (self->function_name);
-
- VEC_free (agent_expr_p, self->target_info.conditions);
- VEC_free (agent_expr_p, self->target_info.tcommands);
}
static const struct bp_location_ops bp_location_ops =
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 018dddb..bfd6351 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -26,6 +26,7 @@
#include "command.h"
#include "break-common.h"
#include "probe.h"
+#include <vector>
struct value;
struct block;
@@ -268,13 +269,13 @@ struct bp_target_info
the size to remove the breakpoint safely. */
int placed_size;
- /* Vector of conditions the target should evaluate if it supports target-side
- breakpoint conditions. */
- VEC(agent_expr_p) *conditions;
+ /* Conditions the target should evaluate if it supports target-side
+ breakpoint conditions. These are non-owning pointers. */
+ std::vector<agent_expr *> conditions;
- /* Vector of commands the target should evaluate if it supports
- target-side breakpoint commands. */
- VEC(agent_expr_p) *tcommands;
+ /* Commands the target should evaluate if it supports target-side
+ breakpoint commands. These are non-owning pointers. */
+ std::vector<agent_expr *> tcommands;
/* Flag that is true if the breakpoint should be left in place even
when GDB is not connected. */
diff --git a/gdb/remote.c b/gdb/remote.c
index 294d928..d090dc1 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -9193,10 +9193,7 @@ remote_add_target_side_condition (struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt, char *buf,
char *buf_end)
{
- struct agent_expr *aexpr = NULL;
- int i, ix;
-
- if (VEC_empty (agent_expr_p, bp_tgt->conditions))
+ if (bp_tgt->conditions.empty ())
return 0;
buf += strlen (buf);
@@ -9204,13 +9201,13 @@ remote_add_target_side_condition (struct gdbarch *gdbarch,
buf++;
/* Send conditions to the target and free the vector. */
- for (ix = 0;
- VEC_iterate (agent_expr_p, bp_tgt->conditions, ix, aexpr);
- ix++)
+ for (int ix = 0; ix < bp_tgt->conditions.size (); ix++)
{
+ struct agent_expr *aexpr = bp_tgt->conditions[ix];
+
xsnprintf (buf, buf_end - buf, "X%x,", aexpr->len);
buf += strlen (buf);
- for (i = 0; i < aexpr->len; ++i)
+ for (int i = 0; i < aexpr->len; ++i)
buf = pack_hex_byte (buf, aexpr->buf[i]);
*buf = '\0';
}
@@ -9221,10 +9218,7 @@ static void
remote_add_target_side_commands (struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt, char *buf)
{
- struct agent_expr *aexpr = NULL;
- int i, ix;
-
- if (VEC_empty (agent_expr_p, bp_tgt->tcommands))
+ if (bp_tgt->tcommands.empty ())
return;
buf += strlen (buf);
@@ -9234,13 +9228,13 @@ remote_add_target_side_commands (struct gdbarch *gdbarch,
/* Concatenate all the agent expressions that are commands into the
cmds parameter. */
- for (ix = 0;
- VEC_iterate (agent_expr_p, bp_tgt->tcommands, ix, aexpr);
- ix++)
+ for (int ix = 0; ix < bp_tgt->tcommands.size (); ix++)
{
+ struct agent_expr *aexpr = bp_tgt->tcommands[ix];
+
sprintf (buf, "X%x,", aexpr->len);
buf += strlen (buf);
- for (i = 0; i < aexpr->len; ++i)
+ for (int i = 0; i < aexpr->len; ++i)
buf = pack_hex_byte (buf, aexpr->buf[i]);
*buf = '\0';
}
@@ -9309,7 +9303,7 @@ remote_insert_breakpoint (struct target_ops *ops,
/* If this breakpoint has target-side commands but this stub doesn't
support Z0 packets, throw error. */
- if (!VEC_empty (agent_expr_p, bp_tgt->tcommands))
+ if (!bp_tgt->tcommands.empty ())
throw_error (NOT_SUPPORTED_ERROR, _("\
Target doesn't support breakpoints that have target side commands."));
--
2.5.5
next prev parent reply other threads:[~2016-10-19 1:18 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-19 1:13 [PATCH v2 00/31] More cleanup elimination & unlimited args to user-defined funcs Pedro Alves
2016-10-19 1:12 ` [PATCH v2 22/31] Use ui_file_as_string in gdb/c-exp.y Pedro Alves
2016-10-19 1:12 ` [PATCH v2 21/31] Use ui_file_as_string in gdb/compile/ Pedro Alves
2016-10-19 23:08 ` Simon Marchi
2016-10-19 23:48 ` Pedro Alves
2016-10-20 3:17 ` Simon Marchi
2016-10-20 12:13 ` Pedro Alves
2016-10-19 1:12 ` [PATCH v2 19/31] Use ui_file_as_string in gdb/remote.c Pedro Alves
2016-10-19 1:12 ` [PATCH v2 07/31] Clean up tracepoint.h/c:collection_list Pedro Alves
2016-10-19 1:12 ` [PATCH v2 24/31] Use ui_file_as_string in gdb/ada-lang.c Pedro Alves
2016-10-19 1:12 ` [PATCH v2 06/31] Introduce ui_file_as_string Pedro Alves
2016-10-19 1:12 ` [PATCH v2 20/31] Use ui_file_as_string in gdb/cli/cli-setshow.c Pedro Alves
2016-10-19 1:12 ` [PATCH v2 01/31] Introduce string_printf Pedro Alves
2016-10-19 13:43 ` Trevor Saunders
2016-10-19 14:41 ` Pedro Alves
2016-10-19 17:18 ` Simon Marchi
2016-10-19 21:02 ` Pedro Alves
2016-11-08 15:35 ` Pedro Alves
2016-10-19 1:12 ` [PATCH v2 12/31] Use ui_file_as_string in gdb/utils.c Pedro Alves
2016-10-19 1:13 ` [PATCH v2 23/31] Use ui_file_as_string in gdbarch.sh/gdbarch.c Pedro Alves
2016-10-19 1:13 ` [PATCH v2 26/31] Use ui_file_as_string in gdb/rust-lang.c Pedro Alves
2016-10-19 1:13 ` [PATCH v2 03/31] breakpoint.c:commands_command_1 constification and cleanup Pedro Alves
2016-10-19 1:13 ` [PATCH v2 14/31] Use ui_file_as_string in gdb/guile/ Pedro Alves
2016-10-19 1:13 ` [PATCH v2 29/31] 'struct agent_expr *' -> unique_ptr<agent_expr> Pedro Alves
2016-10-19 23:19 ` Simon Marchi
2016-10-19 23:58 ` Pedro Alves
2016-10-19 1:13 ` [PATCH v2 27/31] Use ui_file_as_string in gdb/language.c Pedro Alves
2016-10-19 1:13 ` [PATCH v2 15/31] Use ui_file_as_string in execute_command_to_string Pedro Alves
2016-10-19 1:13 ` [PATCH v2 08/31] Use ui_file_as_string in dwarf2_compute_name Pedro Alves
2016-10-19 1:13 ` [PATCH v2 31/31] Support an "unlimited" number of user-defined arguments Pedro Alves
2016-10-19 6:29 ` Eli Zaretskii
2016-10-19 11:33 ` Philipp Rudo
2016-10-19 12:47 ` Pedro Alves
2016-10-19 17:40 ` Philipp Rudo
2016-10-19 17:45 ` Pedro Alves
2016-11-08 15:41 ` Pedro Alves
2016-10-19 1:13 ` [PATCH v2 02/31] cli/cli-script.c: Remove some dead NULL checks Pedro Alves
2016-10-19 17:24 ` Simon Marchi
2016-10-19 21:18 ` Pedro Alves
2016-10-19 1:17 ` [PATCH v2 10/31] Use ui_file_as_string in gdb/ada-valprint.c Pedro Alves
2016-10-19 1:17 ` [PATCH v2 11/31] Use ui_file_as_string in gdb/ui-out.c Pedro Alves
2016-10-19 1:17 ` [PATCH v2 25/31] Use ui_file_as_string in gdb/infrun.c Pedro Alves
2016-10-19 1:17 ` [PATCH v2 09/31] Use ui_file_as_string in gdb/xtensa-tdep.c Pedro Alves
2016-10-19 1:18 ` [PATCH v2 05/31] 'struct expression *' -> gdb::unique_xmalloc_ptr<expression> Pedro Alves
2016-10-19 18:45 ` Simon Marchi
2016-10-19 21:50 ` Pedro Alves
2016-10-19 22:25 ` Simon Marchi
2016-10-19 22:36 ` Pedro Alves
2016-10-19 1:18 ` Pedro Alves [this message]
2016-10-19 1:19 ` [PATCH v2 04/31] cli-script.c: Simplify using std::string, eliminate cleanups Pedro Alves
2016-10-19 18:25 ` Simon Marchi
2016-10-19 21:45 ` Pedro Alves
2016-10-19 1:21 ` [PATCH v2 13/31] Use ui_file_as_string in gdb/arm-tdep.c Pedro Alves
2016-10-19 22:54 ` Simon Marchi
2016-10-19 1:21 ` [PATCH v2 18/31] Use ui_file_as_string in gdb/python/ Pedro Alves
2016-10-19 1:21 ` [PATCH v2 16/31] Use ui_file_as_string in gdb/top.c Pedro Alves
2016-10-19 1:21 ` [PATCH v2 17/31] Use ui_file_as_string in gdb/printcmd.c Pedro Alves
2016-10-20 13:08 ` [PATCH v2 28/31] Use ui_file_as_string throughout more Pedro Alves
2017-02-23 10:23 ` Yao Qi
2017-02-23 10:53 ` Pedro Alves
2017-02-23 10:35 ` Yao Qi
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=1476839539-8374-31-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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).