]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/symtab] Factor out compunit_epilogue_unwind_valid
authorTom de Vries <tdevries@suse.de>
Mon, 20 Feb 2023 11:20:14 +0000 (12:20 +0100)
committerTom de Vries <tdevries@suse.de>
Mon, 20 Feb 2023 11:20:14 +0000 (12:20 +0100)
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>
gdb/amd64-tdep.c
gdb/i386-tdep.c
gdb/symtab.h

index 9ce3e37a1596677cbdf3948aafe67cf11739c601..08f906be123f018ebd96a7a4541693a76f741985 100644 (file)
@@ -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))
index acf22dba98ded0a027d794e3f967479c5e88598d..19358ca66b977c193d45ecd50b794b0126acfd85 100644 (file)
@@ -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))
index 11ff875c6b89e8536c4fba3fd5b8c8c57b7ebe85..cd6b5f722fd8670d157426ef2bc76039d7b64978 100644 (file)
@@ -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