[v2,1/5,gdb/symtab] Factor out compunit_epilogue_unwind_valid
Commit Message
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(-)
Comments
>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
Tom> Factor out compunit_epilogue_unwind_valid from both
Tom> amd64_stack_frame_destroyed_p and i386_stack_frame_destroyed_p. NFC.
What does NFC means?
Tom> Also add a comment in the new function about the assumption that in absence of
Tom> producer information, epilogue unwind info is invalid.
Thanks.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
On 2/14/23 16:56, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Tom> Factor out compunit_epilogue_unwind_valid from both
> Tom> amd64_stack_frame_destroyed_p and i386_stack_frame_destroyed_p. NFC.
>
> What does NFC means?
>
No Functional Changes.
I guess I picked this up when working on clang/llvm.
Mentioned here: https://llvm.org/docs/Lexicon.html#n .
> Tom> Also add a comment in the new function about the assumption that in absence of
> Tom> producer information, epilogue unwind info is invalid.
>
> Thanks.
> Approved-By: Tom Tromey <tom@tromey.com>
>
Thanks.
- Tom
On 2/14/23 23:36, Tom de Vries via Gdb-patches wrote:
> On 2/14/23 16:56, Tom Tromey wrote:
>>>>>>> "Tom" == Tom de Vries via Gdb-patches
>>>>>>> <gdb-patches@sourceware.org> writes:
>>
>> Tom> Factor out compunit_epilogue_unwind_valid from both
>> Tom> amd64_stack_frame_destroyed_p and i386_stack_frame_destroyed_p.
>> NFC.
>>
>> What does NFC means?
>>
>
> No Functional Changes.
>
> I guess I picked this up when working on clang/llvm.
>
> Mentioned here: https://llvm.org/docs/Lexicon.html#n .
>
And grepping through the commit log, I see I used it before.
Anyway, replaced by "No functional changes".
>> Tom> Also add a comment in the new function about the assumption that
>> in absence of
>> Tom> producer information, epilogue unwind info is invalid.
>>
>> Thanks.
>> Approved-By: Tom Tromey <tom@tromey.com>
>>
Thanks, I've added the tag to this commit and will commit the series
after retesting.
Thanks,
- Tom
@@ -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))
@@ -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))
@@ -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 ();
+}
/* The virtual function table is now an array of structures which have the