Bug 8434 - Maint command to enable/disable unwinders
Summary: Maint command to enable/disable unwinders
Status: ASSIGNED
Alias: None
Product: gdb
Classification: Unclassified
Component: backtrace (show other bugs)
Version: unknown
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-08-09 15:58 UTC by ac131313
Modified: 2025-01-17 14:50 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ac131313 2003-08-09 15:58:00 UTC
[Converted from Gnats 1329]

Should there be a command to explicitly enable/disable specific unwinders?

Release:
unknown
Comment 1 Sourceware Commits 2018-07-26 07:54:48 UTC
The master branch has been updated by Andrew Burgess <aburgess@sourceware.org>:

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

commit 3c3bb0580be0027a1c7187b78c747af74dcfa884
Author: Andrew Burgess <andrew.burgess@embecosm.com>
Date:   Fri Jul 13 12:01:16 2018 +0100

    gdb: Add switch to disable DWARF stack unwinders
    
    Add a maintenance command to disable the DWARF stack unwinders.
    Normal users would not need this feature, but it is useful to allow
    extended testing of fallback stack unwinding strategies, for example,
    prologue scanners.
    
    This is a partial implementation of the idea discussed in pr gdb/8434,
    which talks about a generic ability to disable any frame unwinder.
    
    Being able to arbitrarily disable any frame unwinder would be a more
    complex patch, and I was unsure how useful such a feature would really
    be, however, I can see (and have) a real need to disable DWARF
    unwinders.  That's why this patch only targets that specific set of
    unwinders.
    
    If in the future we find ourselves adding more switches to disable
    different unwinders, then we should probably move to a more generic
    solution, and remove this patch.
    
    gdb/ChangeLog:
    
    	* dwarf2-frame-tailcall.c (tailcall_frame_sniffer): Exit early if
    	DWARF unwinders are disabled.
    	* dwarf2-frame.c: Add dwarf2read.h include.
    	(dwarf2_frame_sniffer): Exit early if DWARF unwinders are
    	disabled.
    	(dwarf2_frame_unwinders_enabled_p): Define.
    	(show_dwarf_unwinders_enabled_p): New function.
    	(_initialize_dwarf2_frame): Register switch to control DWARF
    	unwinder use.
    	* dwarf2-frame.h (dwarf2_frame_unwinders_enabled_p): Declare.
    	* dwarf2read.c (set_dwarf_cmdlist): Remove static keyword.
    	(show_dwarf_cmdlist): Remove static keyword.
    	* dwarf2read.h (set_dwarf_cmdlist): Declare.
    	(show_dwarf_cmdlist): Declare.
    	* NEWS: Document new feature.
    
    gdb/doc/ChangeLog:
    
    	* gdb.texinfo (Maintenance Commands): Add description of
    	maintenance command to control dwarf unwinders.
    
    gdb/testsuite/ChangeLog:
    
    	* gdb.base/maint.exp: Add check that dwarf unwinders control flag
    	is visible.
Comment 2 Sourceware Commits 2025-01-17 14:50:13 UTC
The master branch has been updated by Guinevere Larsen <guinevere@sourceware.org>:

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

commit b49f56d0aa0bcd8d73e87e6e17ff4fb0efa4c090
Author: Guinevere Larsen <guinevere@redhat.com>
Date:   Thu Mar 14 16:14:28 2024 +0100

    gdb: introduce ability to disable frame unwinders
    
    Sometimes, in the GDB testsuite, we want to test the ability of specific
    unwinders to handle some piece of code. Usually this is done by trying
    to outsmart GDB, or by coercing the compiler to remove information that
    GDB would rely on.  Both approaches have problems as GDB gets smarter
    with time, and that compilers might differ in version and behavior, or
    simply introduce new useful information. This was requested back in 2003
    in PR backtrace/8434.
    
    To improve our ability to thoroughly test GDB, this patch introduces a
    new maintenance command that allows a user to disable some unwinders,
    based on either the name of the unwinder or on its class. With this
    change, it will now be possible for GDB to not find any frame unwinders
    for a given frame, which would previously cause GDB to assert. GDB will
    now check if any frame unwinder has been disabled, and if some has, it
    will just error out instead of asserting.
    
    Unwinders can be disabled or re-enabled in 3 different ways:
    * Disabling/enabling all at once (using '-all').
    * By specifying an unwinder class to be disabled (option '-class').
    * By specifying the name of an unwinder (option '-name').
    
    If you give no options to the command, GDB assumes the input is an
    unwinder class. '-class' would make no difference if used, is just here
    for completeness.
    
    This command is meant to be used once the inferior is already at the
    desired location for the test. An example session would be:
    
    (gdb) start
    Temporary breakpoint 1, main () at omp.c:17
    17          func();
    (gdb) maint frame-unwinder disable ARCH
    (gdb) bt
    \#0  main () at omp.c:17
    (gdb) maint frame-unwinder enable ARCH
    (gdb) cont
    Continuing.
    
    This commit is a more generic version of commit 3c3bb0580be0,
    and so, based on the final paragraph of the commit message:
        gdb: Add switch to disable DWARF stack unwinders
    <...>
        If in the future we find ourselves adding more switches to disable
        different unwinders, then we should probably move to a more generic
        solution, and remove this patch.
    this patch also reverts 3c3bb0580be0
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=8434
    Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
    Reviewed-By: Eli Zaretskii <eliz@gnu.org>
    Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
    Approved-By: Andrew Burgess <aburgess@redhat.com>
    
    temp adding completion