From: Tom Tromey <tromey@redhat.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Ulrich Weigand <uweigand@de.ibm.com>, gdb-patches@sourceware.org
Subject: Re: Regression: Re: RFC: implement typed DWARF stack
Date: Fri, 13 May 2011 15:44:00 -0000 [thread overview]
Message-ID: <m3iptek3m8.fsf@fleche.redhat.com> (raw)
In-Reply-To: <20110513075220.GA7000@host1.jankratochvil.net> (Jan Kratochvil's message of "Fri, 13 May 2011 09:52:20 +0200")
Jan> This is 15MB .sum diff of regressions, nothing works now.
Yeah, I apologize for that. I didn't run the final version through the
tester, neglecting that I had made a major change.
Here is the fix I am checking in. The bug was that we were calling
value_free_to_mark but then using values from the value list. The fix
is to be more careful about ordering cleanups.
Built and regtested on the buildbot.
Jan> +# This test can only be run on x86 targets.
Jan> +if { ![istarget i?86-*] } {
Jan> + return 0
Jan> +}
Jan> It will not run on x86_64 box with -m32 while it could, I would
Jan> prefer there also x86_64 target with is_ilp32_target conditional.
I will make this change separately.
Tom
2011-05-13 Tom Tromey <tromey@redhat.com>
* utils.c (do_value_free): New function.
(make_cleanup_value_free): Likewise.
* dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Handle value
freeing correctly.
(dwarf2_loc_desc_needs_frame): Call
make_cleanup_value_free_to_mark.
* dwarf2expr.h (struct dwarf_expr_context) <mark>: Remove field.
* dwarf2expr.c (free_dwarf_expr_context): Don't call
value_free_to_mark.
(new_dwarf_expr_context): Don't call value_mark.
* dwarf2-frame.c (execute_stack_op): Call
make_cleanup_value_free_to_mark.
* defs.h (make_cleanup_value_free): Declare.
diff --git a/gdb/defs.h b/gdb/defs.h
index 771d3ad..38a2fcf 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -362,6 +362,7 @@ extern struct cleanup *
make_cleanup_restore_ui_file (struct ui_file **variable);
extern struct cleanup *make_cleanup_value_free_to_mark (struct value *);
+extern struct cleanup *make_cleanup_value_free (struct value *);
extern struct cleanup *make_final_cleanup (make_cleanup_ftype *, void *);
diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c
index 4e4e6d9..fe48713 100644
--- a/gdb/dwarf2-frame.c
+++ b/gdb/dwarf2-frame.c
@@ -402,6 +402,7 @@ execute_stack_op (const gdb_byte *exp, ULONGEST len, int addr_size,
ctx = new_dwarf_expr_context ();
old_chain = make_cleanup_free_dwarf_expr_context (ctx);
+ make_cleanup_value_free_to_mark (value_mark ());
ctx->gdbarch = get_frame_arch (this_frame);
ctx->addr_size = addr_size;
diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c
index 0c0760b..b42f289 100644
--- a/gdb/dwarf2expr.c
+++ b/gdb/dwarf2expr.c
@@ -104,7 +104,6 @@ new_dwarf_expr_context (void)
retval->num_pieces = 0;
retval->pieces = 0;
retval->max_recursion_depth = 0x100;
- retval->mark = value_mark ();
return retval;
}
@@ -113,7 +112,6 @@ new_dwarf_expr_context (void)
void
free_dwarf_expr_context (struct dwarf_expr_context *ctx)
{
- value_free_to_mark (ctx->mark);
xfree (ctx->stack);
xfree (ctx->pieces);
xfree (ctx);
diff --git a/gdb/dwarf2expr.h b/gdb/dwarf2expr.h
index 281c65b..676b54b 100644
--- a/gdb/dwarf2expr.h
+++ b/gdb/dwarf2expr.h
@@ -81,10 +81,6 @@ struct dwarf_expr_context
/* Offset used to relocate DW_OP_addr argument. */
CORE_ADDR offset;
- /* The evaluator is value-based, and frees values up to this point
- when the expression context is destroyed. */
- struct value *mark;
-
/* An opaque argument provided by the caller, which will be passed
to all of the callback functions. */
void *baton;
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 04f16e9..64cc5e5 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -1086,7 +1086,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
struct value *retval;
struct dwarf_expr_baton baton;
struct dwarf_expr_context *ctx;
- struct cleanup *old_chain;
+ struct cleanup *old_chain, *value_chain;
struct objfile *objfile = dwarf2_per_cu_objfile (per_cu);
volatile struct gdb_exception ex;
@@ -1106,6 +1106,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
ctx = new_dwarf_expr_context ();
old_chain = make_cleanup_free_dwarf_expr_context (ctx);
+ value_chain = make_cleanup_value_free_to_mark (value_mark ());
ctx->gdbarch = get_objfile_arch (objfile);
ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
@@ -1128,6 +1129,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
{
if (ex.error == NOT_AVAILABLE_ERROR)
{
+ do_cleanups (old_chain);
retval = allocate_value (type);
mark_value_bytes_unavailable (retval, 0, TYPE_LENGTH (type));
return retval;
@@ -1150,6 +1152,9 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
c = allocate_piece_closure (per_cu, ctx->num_pieces, ctx->pieces,
ctx->addr_size);
+ /* We must clean up the value chain after creating the piece
+ closure but before allocating the result. */
+ do_cleanups (value_chain);
retval = allocate_computed_value (type, &pieced_value_funcs, c);
VALUE_FRAME_ID (retval) = frame_id;
set_value_offset (retval, byte_offset);
@@ -1166,6 +1171,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
if (byte_offset != 0)
error (_("cannot use offset on synthetic pointer to register"));
+ do_cleanups (value_chain);
if (gdb_regnum != -1)
retval = value_from_register (type, gdb_regnum, frame);
else
@@ -1179,6 +1185,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
CORE_ADDR address = dwarf_expr_fetch_address (ctx, 0);
int in_stack_memory = dwarf_expr_fetch_in_stack_memory (ctx, 0);
+ do_cleanups (value_chain);
retval = allocate_value_lazy (type);
VALUE_LVAL (retval) = lval_memory;
if (in_stack_memory)
@@ -1201,6 +1208,13 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
val_bytes += byte_offset;
n -= byte_offset;
+ /* Preserve VALUE because we are going to free values back
+ to the mark, but we still need the value contents
+ below. */
+ value_incref (value);
+ do_cleanups (value_chain);
+ make_cleanup_value_free (value);
+
retval = allocate_value (type);
contents = value_contents_raw (retval);
if (n > TYPE_LENGTH (type))
@@ -1218,6 +1232,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
if (byte_offset + TYPE_LENGTH (type) > n)
invalid_synthetic_pointer ();
+ do_cleanups (value_chain);
retval = allocate_value (type);
contents = value_contents_raw (retval);
@@ -1231,6 +1246,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
break;
case DWARF_VALUE_OPTIMIZED_OUT:
+ do_cleanups (value_chain);
retval = allocate_value (type);
VALUE_LVAL (retval) = not_lval;
set_value_optimized_out (retval, 1);
@@ -1353,6 +1369,7 @@ dwarf2_loc_desc_needs_frame (const gdb_byte *data, unsigned short size,
ctx = new_dwarf_expr_context ();
old_chain = make_cleanup_free_dwarf_expr_context (ctx);
+ make_cleanup_value_free_to_mark (value_mark ());
ctx->gdbarch = get_objfile_arch (objfile);
ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
diff --git a/gdb/utils.c b/gdb/utils.c
index 3e4a54d..6fd220a 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -448,6 +448,22 @@ make_cleanup_value_free_to_mark (struct value *mark)
return make_my_cleanup (&cleanup_chain, do_value_free_to_mark, mark);
}
+/* Helper for make_cleanup_value_free. */
+
+static void
+do_value_free (void *value)
+{
+ value_free (value);
+}
+
+/* Free VALUE. */
+
+struct cleanup *
+make_cleanup_value_free (struct value *value)
+{
+ return make_my_cleanup (&cleanup_chain, do_value_free, value);
+}
+
struct cleanup *
make_my_cleanup2 (struct cleanup **pmy_chain, make_cleanup_ftype *function,
void *arg, void (*free_arg) (void *))
next prev parent reply other threads:[~2011-05-13 15:44 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-04 20:48 Tom Tromey
2011-05-05 16:47 ` Tom Tromey
2011-05-05 18:07 ` Ulrich Weigand
2011-05-05 18:38 ` Tom Tromey
2011-05-05 20:15 ` Tom Tromey
2011-05-09 22:02 ` Ulrich Weigand
2011-05-10 14:15 ` Tom Tromey
2011-05-11 0:15 ` Ulrich Weigand
2011-05-11 14:59 ` Tom Tromey
2011-05-11 19:44 ` Tom Tromey
2011-05-12 0:03 ` Ulrich Weigand
2011-05-12 16:33 ` Tom Tromey
2011-05-13 7:52 ` Regression: " Jan Kratochvil
2011-05-13 15:44 ` Tom Tromey [this message]
2011-05-15 8:26 ` gdbindex crash: " Jan Kratochvil
2011-05-16 17:37 ` Tom Tromey
2011-05-17 17:01 ` Tom Tromey
2011-05-13 17:17 ` Tom Tromey
2011-05-13 17:34 ` Jan Kratochvil
2011-05-12 19:32 ` Tom Tromey
2011-05-16 15:50 ` Ulrich Weigand
2011-05-16 18:09 ` Tom Tromey
2011-05-17 8:35 ` Jakub Jelinek
2011-06-03 13:52 ` Tom Tromey
2011-05-10 16:39 ` Tom Tromey
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=m3iptek3m8.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=uweigand@de.ibm.com \
/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