public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] gdb: small simplification in dwarf2_locexpr_baton_eval
Date: Sun,  3 Apr 2022 16:18:43 +0000 (GMT)	[thread overview]
Message-ID: <20220403161843.93A5C3858D37@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=22480d7c3977df6a111a1c1ab56982372732f4e5

commit 22480d7c3977df6a111a1c1ab56982372732f4e5
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Wed Mar 16 15:32:50 2022 +0000

    gdb: small simplification in dwarf2_locexpr_baton_eval
    
    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.

Diff:
---
 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 73de3112876..634b51ef279 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -1569,11 +1569,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,
@@ -1595,10 +1597,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


                 reply	other threads:[~2022-04-03 16:18 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=20220403161843.93A5C3858D37@sourceware.org \
    --to=aburgess@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: 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).