public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH v2 1/5] [gdb/symtab] Factor out compunit_epilogue_unwind_valid
Date: Mon, 13 Feb 2023 15:23:05 +0100	[thread overview]
Message-ID: <20230213142309.24366-2-tdevries@suse.de> (raw)
In-Reply-To: <20230213142309.24366-1-tdevries@suse.de>

Factor out compunit_epilogue_unwind_valid from both
amd64_stack_frame_destroyed_p and i386_stack_frame_destroyed_p.  NFC.

Also add a comment in the new function about the assumption that in absence of
producer information, epilogue unwind info is invalid.
---
 gdb/amd64-tdep.c |  4 +---
 gdb/i386-tdep.c  |  4 +---
 gdb/symtab.h     | 13 +++++++++++++
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 328e001f5bb..d2e683b6fa8 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -2902,10 +2902,8 @@ static int
 amd64_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   gdb_byte insn;
-  struct compunit_symtab *cust;
 
-  cust = find_pc_compunit_symtab (pc);
-  if (cust != NULL && cust->epilogue_unwind_valid ())
+  if (compunit_epilogue_unwind_valid (find_pc_compunit_symtab (pc)))
     return 0;
 
   if (target_read_memory (pc, &insn, 1))
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 8dccae633f7..3fe548d8c68 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -2219,10 +2219,8 @@ static int
 i386_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   gdb_byte insn;
-  struct compunit_symtab *cust;
 
-  cust = find_pc_compunit_symtab (pc);
-  if (cust != NULL && cust->epilogue_unwind_valid ())
+  if (compunit_epilogue_unwind_valid (find_pc_compunit_symtab (pc)))
     return 0;
 
   if (target_read_memory (pc, &insn, 1))
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 11ff875c6b8..cd6b5f722fd 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1917,6 +1917,19 @@ is_main_symtab_of_compunit_symtab (struct symtab *symtab)
 {
   return symtab == symtab->compunit ()->primary_filetab ();
 }
+
+/* Return true if epilogue unwind info of CUST is valid.  */
+
+static inline bool
+compunit_epilogue_unwind_valid (struct compunit_symtab *cust)
+{
+  /* In absence of producer information, assume epilogue unwind info is
+     invalid.  */
+  if (cust == nullptr)
+    return false;
+
+  return cust->epilogue_unwind_valid ();
+}
 \f
 
 /* The virtual function table is now an array of structures which have the
-- 
2.35.3


  reply	other threads:[~2023-02-13 14:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-13 14:23 [PATCH v2 0/5] [gdb/symtab] Assume epilogue unwind info is valid unless gcc < 4.5.0 Tom de Vries
2023-02-13 14:23 ` Tom de Vries [this message]
2023-02-14 15:56   ` [PATCH v2 1/5] [gdb/symtab] Factor out compunit_epilogue_unwind_valid Tom Tromey
2023-02-14 22:36     ` Tom de Vries
2023-02-20 10:27       ` Tom de Vries
2023-02-13 14:23 ` [PATCH v2 2/5] [gdb/tdep] Fix amd64/i386_stack_frame_destroyed_p Tom de Vries
2023-02-13 14:23 ` [PATCH v2 3/5] [gdb/tdep] Add amd64/i386 epilogue override unwinders Tom de Vries
2023-02-13 14:23 ` [PATCH v2 4/5] [gdb/symtab] Trust epilogue unwind info for unknown producer (-g0 case) Tom de Vries
2023-02-13 14:23 ` [PATCH v2 5/5] [gdb/symtab] Trust epilogue unwind info for unknown or non-gcc producer Tom de Vries

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=20230213142309.24366-2-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).