aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2expr.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2016-09-25 16:28:03 -0600
committerTom Tromey <tom@tromey.com>2016-10-21 14:17:37 -0600
commit718b962660007c529f4ff4c5e940119da21e05a7 (patch)
treeaec64a64fc7753e25948ddc5555b989a359853bd /gdb/dwarf2expr.c
parent5841433461e2ce9da41292a49af4cc3c6b1e1f2d (diff)
downloadgdb-718b962660007c529f4ff4c5e940119da21e05a7.zip
gdb-718b962660007c529f4ff4c5e940119da21e05a7.tar.gz
gdb-718b962660007c529f4ff4c5e940119da21e05a7.tar.bz2
Initial conversion of dwarf_expr_ctx
This is the first step in the conversion of dwarf_expr_ctx to a C++ class. This conversion is done in steps to make the patches, and the reviews, a bit simpler. This patch changes dwarf_expr_ctx to be stack-allocated and removes the associated cleanup. 2016-10-21 Tom Tromey <tom@tromey.com> * dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Stack-allocate dwarf_expr_context. Remove cleanups. (dwarf2_locexpr_baton_eval) (dwarf2_loc_desc_get_symbol_read_needs): Likewise. * dwarf2expr.h (dwarf_expr_context, ~dwarf_expr_context): Add constructors and destructors. (new_dwarf_expr_context, free_dwarf_expr_context) (make_cleanup_free_dwarf_expr_context): Don't declare. * dwarf2-frame.c (execute_stack_op): Stack-allocate dwarf_expr_context. Remove cleanups. (dwarf_expr_context): Rename from new_dwarf_expr_context. Turn into constructor. (free_dwarf_expr_context, free_dwarf_expr_context_cleanup): Remove. (~dwarf_expr_context): Rename from make_cleanup_free_dwarf_expr_context. Turn into destructor.
Diffstat (limited to 'gdb/dwarf2expr.c')
-rw-r--r--gdb/dwarf2expr.c55
1 files changed, 21 insertions, 34 deletions
diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c
index 90e4e25..e8487a6 100644
--- a/gdb/dwarf2expr.c
+++ b/gdb/dwarf2expr.c
@@ -91,45 +91,32 @@ dwarf_expr_address_type (struct dwarf_expr_context *ctx)
/* Create a new context for the expression evaluator. */
-struct dwarf_expr_context *
-new_dwarf_expr_context (void)
+dwarf_expr_context::dwarf_expr_context ()
+: stack (NULL),
+ stack_len (0),
+ stack_allocated (10),
+ gdbarch (NULL),
+ addr_size (0),
+ ref_addr_size (0),
+ offset (0),
+ recursion_depth (0),
+ max_recursion_depth (0x100),
+ location (DWARF_VALUE_MEMORY),
+ len (0),
+ data (NULL),
+ initialized (0),
+ num_pieces (0),
+ pieces (NULL)
{
- struct dwarf_expr_context *retval;
-
- retval = XCNEW (struct dwarf_expr_context);
- retval->stack_len = 0;
- retval->stack_allocated = 10;
- retval->stack = XNEWVEC (struct dwarf_stack_value, retval->stack_allocated);
- retval->num_pieces = 0;
- retval->pieces = 0;
- retval->max_recursion_depth = 0x100;
- return retval;
+ this->stack = XNEWVEC (struct dwarf_stack_value, this->stack_allocated);
}
-/* Release the memory allocated to CTX. */
+/* Clean up a dwarf_expr_context. */
-void
-free_dwarf_expr_context (struct dwarf_expr_context *ctx)
-{
- xfree (ctx->stack);
- xfree (ctx->pieces);
- xfree (ctx);
-}
-
-/* Helper for make_cleanup_free_dwarf_expr_context. */
-
-static void
-free_dwarf_expr_context_cleanup (void *arg)
-{
- free_dwarf_expr_context ((struct dwarf_expr_context *) arg);
-}
-
-/* Return a cleanup that calls free_dwarf_expr_context. */
-
-struct cleanup *
-make_cleanup_free_dwarf_expr_context (struct dwarf_expr_context *ctx)
+dwarf_expr_context::~dwarf_expr_context ()
{
- return make_cleanup (free_dwarf_expr_context_cleanup, ctx);
+ xfree (this->stack);
+ xfree (this->pieces);
}
/* Expand the memory allocated to CTX's stack to contain at least