aboutsummaryrefslogtreecommitdiff
path: root/gdb/ax-general.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-11-08 15:26:47 +0000
committerPedro Alves <palves@redhat.com>2016-11-08 15:26:47 +0000
commit833177a4a5c1a2a6cabe70bfe35ecf241b68d169 (patch)
treeda2e0cfdae4abf5ee493a243cae733166276f781 /gdb/ax-general.c
parent2f408ecb929bd56613e94cf1e84ace4692c78257 (diff)
downloadgdb-833177a4a5c1a2a6cabe70bfe35ecf241b68d169.zip
gdb-833177a4a5c1a2a6cabe70bfe35ecf241b68d169.tar.gz
gdb-833177a4a5c1a2a6cabe70bfe35ecf241b68d169.tar.bz2
'struct agent_expr *' -> unique_ptr<agent_expr>
This patch makes the gen_* functions return a unique_ptr instead of raw pointer: typedef gdb::unique_ptr<agent_expr> agent_expr_up; and then adjusts the codebase throughout to stop using make_cleanup_free_agent_expr. The cond_bytecode and cmd_bytecode fields of struct bp_location are owning pointers, so they're changed to be unique_ptr's instead of raw pointers. gdb/ChangeLog: 2016-11-08 Pedro Alves <palves@redhat.com> * ax-gdb.c (is_nontrivial_conversion): Use agent_expr_up. (gen_trace_for_var, gen_trace_for_expr, gen_eval_for_expr) (gen_trace_for_return_address, gen_printf): Use and return an agent_expr_up. Don't use make_cleanup_free_agent_expr. (agent_eval_command_one, maint_agent_printf_command): Use agent_expr_up. Don't use make_cleanup_free_agent_expr. * ax-gdb.h (gen_trace_for_expr, gen_trace_for_var) (gen_trace_for_return_address, gen_eval_for_expr, gen_printf): Use agent_expr_up. * ax-general.c (new_agent_expr): Rename to ... (agent_expr::agent_expr): ... this, and now a constructor. (free_agent_expr): Rename to ... (agent_expr::~agent_exp): ... this, and now a destructor. (do_free_agent_expr_cleanup, make_cleanup_free_agent_expr): Delete. * ax.h (struct agent_expr): Add ctor/dtor. (agent_expr_up): New typedef. (new_agent_expr, free_agent_expr, make_cleanup_free_agent_expr): Delete declarations. * breakpoint.c (parse_cond_to_aexpr): Use and return an agent_expr_up. Don't use make_cleanup_free_agent_expr. (build_target_condition_list): Adjust to use agent_expr_up. (parse_cmd_to_aexpr): Use and return an agent_expr_up. Don't use make_cleanup_free_agent_expr. (build_target_command_list): Adjust to use agent_expr_up. (force_breakpoint_reinsertion): Adjust to use agent_expr_up. (bp_location_dtor): Remove unnecessary free_agent_expr and xfree calls. * breakpoint.h (struct bp_target_info) <cond_bytecode, cmd_bytecode>: Now agent_expr_up's. * remote.c (remote_download_tracepoint): Adjust to use agent_expr_up and remove use of make_cleanup_free_agent_expr. * tracepoint.c (validate_actionline, collect_symbol): Adjust to use agent_expr_up and remove uses of make_cleanup_free_agent_expr. (collection_list::~collection_list): Call delete instead of free_agent_expr. (encode_actions_1): Adjust to use agent_expr_up and remove uses of make_cleanup_free_agent_expr. (add_aexpr): Change parameter type to agent_expr_up; Return a raw agent_expr pointer.
Diffstat (limited to 'gdb/ax-general.c')
-rw-r--r--gdb/ax-general.c48
1 files changed, 13 insertions, 35 deletions
diff --git a/gdb/ax-general.c b/gdb/ax-general.c
index 7f27a45..35225f6 100644
--- a/gdb/ax-general.c
+++ b/gdb/ax-general.c
@@ -37,52 +37,30 @@ static void generic_ext (struct agent_expr *x, enum agent_op op, int n);
/* Functions for building expressions. */
-/* Allocate a new, empty agent expression. */
-struct agent_expr *
-new_agent_expr (struct gdbarch *gdbarch, CORE_ADDR scope)
+agent_expr::agent_expr (struct gdbarch *gdbarch, CORE_ADDR scope)
{
- struct agent_expr *x = XNEW (struct agent_expr);
-
- x->len = 0;
- x->size = 1; /* Change this to a larger value once
+ this->len = 0;
+ this->size = 1; /* Change this to a larger value once
reallocation code is tested. */
- x->buf = (unsigned char *) xmalloc (x->size);
+ this->buf = (unsigned char *) xmalloc (this->size);
- x->gdbarch = gdbarch;
- x->scope = scope;
+ this->gdbarch = gdbarch;
+ this->scope = scope;
/* Bit vector for registers used. */
- x->reg_mask_len = 1;
- x->reg_mask = XCNEWVEC (unsigned char, x->reg_mask_len);
-
- x->tracing = 0;
- x->trace_string = 0;
+ this->reg_mask_len = 1;
+ this->reg_mask = XCNEWVEC (unsigned char, this->reg_mask_len);
- return x;
+ this->tracing = 0;
+ this->trace_string = 0;
}
-/* Free a agent expression. */
-void
-free_agent_expr (struct agent_expr *x)
+agent_expr::~agent_expr ()
{
- xfree (x->buf);
- xfree (x->reg_mask);
- xfree (x);
+ xfree (this->buf);
+ xfree (this->reg_mask);
}
-static void
-do_free_agent_expr_cleanup (void *x)
-{
- free_agent_expr ((struct agent_expr *) x);
-}
-
-struct cleanup *
-make_cleanup_free_agent_expr (struct agent_expr *x)
-{
- return make_cleanup (do_free_agent_expr_cleanup, x);
-}
-
-
/* Make sure that X has room for at least N more bytes. This doesn't
affect the length, just the allocated size. */
static void