]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/tdep] Fix amd64/i386_stack_frame_destroyed_p
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)
The use of compunit_epilogue_unwind_valid in both amd64_stack_frame_destroyed_p
and i386_stack_frame_destroyed_p is problematic, in the sense that the
functions no longer match their documented behaviour.

Fix this by moving the use of compunit_epilogue_unwind_valid to
amd64_epilogue_frame_sniffer and i386_epilogue_frame_sniffer.  No functional
changes.

gdb/amd64-tdep.c
gdb/i386-tdep.c

index 08f906be123f018ebd96a7a4541693a76f741985..75ab1b23ccfd7a099bed9849c41b2ac55a75ef3c 100644 (file)
@@ -2903,9 +2903,6 @@ amd64_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   gdb_byte insn;
 
-  if (compunit_epilogue_unwind_valid (find_pc_compunit_symtab (pc)))
-    return 0;
-
   if (target_read_memory (pc, &insn, 1))
     return 0;   /* Can't read memory at pc.  */
 
@@ -2920,11 +2917,19 @@ amd64_epilogue_frame_sniffer (const struct frame_unwind *self,
                              frame_info_ptr this_frame,
                              void **this_prologue_cache)
 {
-  if (frame_relative_level (this_frame) == 0)
-    return amd64_stack_frame_destroyed_p (get_frame_arch (this_frame),
-                                         get_frame_pc (this_frame));
-  else
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  CORE_ADDR pc = get_frame_pc (this_frame);
+
+  if (frame_relative_level (this_frame) != 0)
+    /* We're not in the inner frame, so assume we're not in an epilogue.  */
     return 0;
+
+  if (compunit_epilogue_unwind_valid (find_pc_compunit_symtab (pc)))
+    /* Don't override the symtab unwinders.  */
+    return 0;
+
+  /* Check whether we're in an epilogue.  */
+  return amd64_stack_frame_destroyed_p (gdbarch, pc);
 }
 
 static struct amd64_frame_cache *
index 19358ca66b977c193d45ecd50b794b0126acfd85..032fcc4dd76e671f1613639cbb98da65822734a8 100644 (file)
@@ -2219,10 +2219,6 @@ static int
 i386_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   gdb_byte insn;
-
-  if (compunit_epilogue_unwind_valid (find_pc_compunit_symtab (pc)))
-    return 0;
-
   if (target_read_memory (pc, &insn, 1))
     return 0;  /* Can't read memory at pc.  */
 
@@ -2237,11 +2233,19 @@ i386_epilogue_frame_sniffer (const struct frame_unwind *self,
                             frame_info_ptr this_frame,
                             void **this_prologue_cache)
 {
-  if (frame_relative_level (this_frame) == 0)
-    return i386_stack_frame_destroyed_p (get_frame_arch (this_frame),
-                                        get_frame_pc (this_frame));
-  else
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  CORE_ADDR pc = get_frame_pc (this_frame);
+
+  if (frame_relative_level (this_frame) != 0)
+    /* We're not in the inner frame, so assume we're not in an epilogue.  */
+    return 0;
+
+  if (compunit_epilogue_unwind_valid (find_pc_compunit_symtab (pc)))
+    /* Don't override the symtab unwinders.  */
     return 0;
+
+  /* Check whether we're in an epilogue.  */
+  return i386_stack_frame_destroyed_p (gdbarch, pc);
 }
 
 static struct i386_frame_cache *