+2016-11-08 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.
+
2016-11-08 Pedro Alves <palves@redhat.com>
* ax-gdb.c (is_nontrivial_conversion): Use agent_expr_up.
/* 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
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
&& 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;
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;
&& 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;
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 =
#include "command.h"
#include "break-common.h"
#include "probe.h"
+#include <vector>
struct value;
struct block;
packets. */
int kind;
- /* 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. */
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);
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';
}
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);
/* 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';
}
/* 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."));