public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Allow DWARF expression to push the initial address Date: Fri, 24 Apr 2020 20:22:10 +0000 (GMT) [thread overview] Message-ID: <20200424202210.3B80D389365C@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=61122aa9ed4096c3d85b01d52a0c0f67fb441533 commit 61122aa9ed4096c3d85b01d52a0c0f67fb441533 Author: Tom Tromey <tromey@adacore.com> Date: Fri Apr 24 13:40:31 2020 -0600 Allow DWARF expression to push the initial address Some DWARF expressions must be evaluated by first pushing the object address onto the evaluation stack. This patch adds this ability. This functionality is not used yet, but it will be used in a later patch. This is split out for easier review and also because it improved the patch series ordering. gdb/ChangeLog 2020-04-24 Tom Tromey <tromey@adacore.com> * dwarf2/loc.c (dwarf2_locexpr_baton_eval): Add "push_initial_value" parameter. (dwarf2_evaluate_property): Likewise. * dwarf2/loc.h (dwarf2_evaluate_property): Update. Diff: --- gdb/ChangeLog | 7 +++++++ gdb/dwarf2/loc.c | 15 +++++++++++---- gdb/dwarf2/loc.h | 8 ++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b5128802cd2..5db26a60947 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2020-04-24 Tom Tromey <tromey@adacore.com> + + * dwarf2/loc.c (dwarf2_locexpr_baton_eval): Add + "push_initial_value" parameter. + (dwarf2_evaluate_property): Likewise. + * dwarf2/loc.h (dwarf2_evaluate_property): Update. + 2020-04-24 Tom Tromey <tromey@adacore.com> * gdbtypes.c (is_dynamic_type_internal): Check for variant parts. diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index b9456bc9dfb..8df655f660a 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -2388,13 +2388,16 @@ dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame, that the dwarf expression only produces a single CORE_ADDR. FRAME is the frame in which the expression is evaluated. ADDR is a context (location of a variable) and might be needed to evaluate the location expression. - Returns 1 on success, 0 otherwise. */ + PUSH_INITIAL_VALUE is true if ADDR should be pushed on the stack + before evaluating the expression; this is required by certain + forms of DWARF expression. Returns 1 on success, 0 otherwise. */ static int dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, struct frame_info *frame, CORE_ADDR addr, - CORE_ADDR *valp) + CORE_ADDR *valp, + bool push_initial_value) { struct objfile *objfile; @@ -2414,6 +2417,9 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, ctx.ref_addr_size = dlbaton->per_cu->ref_addr_size (); ctx.offset = dlbaton->per_cu->text_offset (); + if (push_initial_value) + ctx.push_address (addr, false); + try { ctx.eval (dlbaton->data, dlbaton->size); @@ -2462,7 +2468,8 @@ bool dwarf2_evaluate_property (const struct dynamic_prop *prop, struct frame_info *frame, const struct property_addr_info *addr_stack, - CORE_ADDR *value) + CORE_ADDR *value, + bool push_initial_value) { if (prop == NULL) return false; @@ -2480,7 +2487,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop, if (dwarf2_locexpr_baton_eval (&baton->locexpr, frame, addr_stack ? addr_stack->addr : 0, - value)) + value, push_initial_value)) { if (baton->locexpr.is_reference) { diff --git a/gdb/dwarf2/loc.h b/gdb/dwarf2/loc.h index a59d3f998fd..6ff9b79dc03 100644 --- a/gdb/dwarf2/loc.h +++ b/gdb/dwarf2/loc.h @@ -92,12 +92,16 @@ struct property_addr_info be NULL. Returns true if PROP could be converted and the static value is passed - back into VALUE, otherwise returns false. */ + back into VALUE, otherwise returns false. + + If PUSH_INITIAL_VALUE is true, then the top value of ADDR_STACK + will be pushed before evaluating a location expression. */ bool dwarf2_evaluate_property (const struct dynamic_prop *prop, struct frame_info *frame, const struct property_addr_info *addr_stack, - CORE_ADDR *value); + CORE_ADDR *value, + bool push_initial_value = false); /* A helper for the compiler interface that compiles a single dynamic property to C code.
reply other threads:[~2020-04-24 20:22 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20200424202210.3B80D389365C@sourceware.org \ --to=tromey@sourceware.org \ --cc=gdb-cvs@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: linkBe 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).