public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] [gdb/symtab] Factor out compunit_epilogue_unwind_valid
@ 2023-02-20 11:20 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2023-02-20 11:20 UTC (permalink / raw)
  To: gdb-cvs

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

commit cb911672fb70233f3ef127f68fc0a43d7f339a62
Author: Tom de Vries <tdevries@suse.de>
Date:   Mon Feb 20 12:20:14 2023 +0100

    [gdb/symtab] Factor out compunit_epilogue_unwind_valid
    
    Factor out compunit_epilogue_unwind_valid from both
    amd64_stack_frame_destroyed_p and i386_stack_frame_destroyed_p.  No functional
    changes.
    
    Also add a comment in the new function about the assumption that in absence of
    producer information, epilogue unwind info is invalid.
    
    Approved-By: Tom Tromey <tom@tromey.com>

Diff:
---
 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 9ce3e37a159..08f906be123 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 acf22dba98d..19358ca66b9 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-20 11:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-20 11:20 [binutils-gdb] [gdb/symtab] Factor out compunit_epilogue_unwind_valid Tom de Vries

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).