From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH 1/3] gdb: small simplification in dwarf2_locexpr_baton_eval
Date: Wed, 23 Mar 2022 11:59:56 +0000 [thread overview]
Message-ID: <d1f4dcf67c38644011ff126cea33bb98f014dd6c.1648036751.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1648036751.git.aburgess@redhat.com>
While examining the dwarf expression evaluator, I noticed that in
dwarf2_locexpr_baton_eval, whenever push_initial_value is true, the
addr_stack will never be nullptr.
This allows for a small cleanup, replacing an if/then/else with an
assertion.
There should be no user visible changes after this commit.
---
gdb/dwarf2/loc.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index d7863841a69..4c3d04b3226 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -1535,11 +1535,13 @@ dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame,
CORE_ADDR. FRAME is the frame in which the expression is
evaluated. ADDR_STACK is a context (location of a variable) and
might be needed to evaluate the location expression.
- PUSH_INITIAL_VALUE is true if the address (either from ADDR_STACK,
- or the default of 0) should be pushed on the DWARF expression
- evaluation stack before evaluating the expression; this is required
- by certain forms of DWARF expression. Returns 1 on success, 0
- otherwise. */
+
+ PUSH_INITIAL_VALUE is true if the first address from ADDR_STACK, should
+ be pushed on the DWARF expression evaluation stack before evaluating the
+ expression; this is required by certain forms of DWARF expression. When
+ PUSH_INITIAL_VALUE is true ADDR_STACK can't be nullptr.
+
+ Returns 1 on success, 0 otherwise. */
static int
dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
@@ -1561,10 +1563,8 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
if (push_initial_value)
{
- if (addr_stack != nullptr)
- ctx.push_address (addr_stack->addr, false);
- else
- ctx.push_address (0, false);
+ gdb_assert (addr_stack != nullptr);
+ ctx.push_address (addr_stack->addr, false);
}
try
--
2.25.4
next prev parent reply other threads:[~2022-03-23 12:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-19 17:57 [PATCH] Support for Fortran's ASSUMED RANK Potharla, Rupesh
2022-01-21 19:07 ` Andrew Burgess
2022-01-22 7:17 ` Potharla, Rupesh
2022-01-28 7:49 ` Potharla, Rupesh
2022-02-06 13:39 ` Andrew Burgess
2022-03-16 11:54 ` Potharla, Rupesh
2022-03-23 11:58 ` Andrew Burgess
2022-03-23 11:59 ` [PATCH 0/3] Fortran assumed rank array support Andrew Burgess
2022-03-23 11:59 ` Andrew Burgess [this message]
2022-04-01 19:11 ` [PATCH 1/3] gdb: small simplification in dwarf2_locexpr_baton_eval Tom Tromey
2022-03-23 11:59 ` [PATCH 2/3] gdb/dwarf: pass an array of values to the dwarf evaluator Andrew Burgess
2022-04-01 19:16 ` Tom Tromey
2022-03-23 11:59 ` [PATCH 3/3] gdb: add support for Fortran's ASSUMED RANK arrays Andrew Burgess
2022-04-01 19:38 ` Tom Tromey
2022-04-03 16:21 ` Andrew Burgess
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=d1f4dcf67c38644011ff126cea33bb98f014dd6c.1648036751.git.aburgess@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@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: 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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).