[PATCH v11 00/10] GDB support for DW_AT_trampoline

Abdul Basit Ijaz <[email protected]> Mon, 3 Aug 2026 21:34:39 +0200
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
Hi All,

please find attached a series of patches that attempts to enable GDB to handle the DW_AT_trampoline attribute on functions and inlined functions.

DW_AT_trampoline can be emitted by the compiler for functions that are compiler generated trampolines (e.g. wrapping other function calls).
In doing so, the compiler can specify a target as the value of DW_AT_trampoline which the trampoline is wrapping.

This series enables GDB to recognize the DW_AT_trampoline and store the target for a given function.  Patch 3 adapts GDB's stepping behavior when dealing with trampolines and attempts to - by default - hide these trampolines from the user.  When about to step into a trampoline, instead, GDB will try and step through the trampoline and directly towards the target.  For rest of the patches as the name of the patch indicates it implements skipping of trampolines for the command mentioned in the patch name.

A new setting has also been introduced in this change to turn off this modified stepping behavior or printing of stack for trampolines.

The motivation for these patches comes from ifx which emits the attribute for some of its compiler generated functions.  As I do not know of any other compiler (especially gcc/gfortran) emitting DW_AT_trampoline, I added a gdb.dwarf2 test to this series in order to test the trampoline handling within GDB.

No changes in the reviewed documentation since V8 patch:
https://sourceware.org/pipermail/gdb-patches/2024-May/209395.html
https://sourceware.org/pipermail/gdb-patches/2024-May/209396.html

Changes since V10:
  * Rebase and update copyright year to 2026 for newly added files in this patch.
  * Fix issue related to O2 and update test to cover both O0 & O2.

No regression seen on testing x64/(-m32)/x32 configurations.

Thanks & Best Regards
Abdul Basit Ijaz

Abdul Basit Ijaz (7):
  gdb: Skip trampoline frames for the backtrace command.
  gdb: Skip trampoline functions for the finish and reverse-finish
    commands.
  gdb: Skip trampoline functions for the up command.
  gdb: Skip trampoline functions for the return command.
  gdb, mi: Skip trampoline functions for the -stack-list-frames command.
  gdb, mi: Skip trampoline functions for the -stack-list-arguments
    command.
  gdb: Filter trampoline frames in backtrace when using Python
    frame-filters.

Nils-Christian Kempke (3):
  gdb, dwarf: add support for DW_AT_trampoline in DWARF reader
  gdb/symtab: add lookup for trampoline functions
  gdb: handle stepping through functions with DW_AT_trampoline

 gdb/NEWS                                      |  13 +
 gdb/doc/gdb.texinfo                           |  52 +++-
 gdb/dwarf2/read.c                             |  39 ++-
 gdb/gdbtypes.c                                |  34 ++-
 gdb/gdbtypes.h                                | 113 +++++++-
 gdb/infcmd.c                                  |  12 +
 gdb/infrun.c                                  | 103 +++++++-
 gdb/infrun.h                                  |  16 ++
 gdb/mi/mi-cmd-stack.c                         |  14 +
 gdb/python/py-frame.c                         |  11 +
 gdb/stack.c                                   |  26 ++
 gdb/symtab.c                                  | 139 ++++++++++
 gdb/symtab.h                                  |  29 +++
 .../gdb.dwarf2/dw2-function-trampolines.c     |  80 ++++++
 .../gdb.dwarf2/dw2-function-trampolines.exp   | 244 ++++++++++++++++++
 gdb/testsuite/gdb.fortran/func-trampoline.exp | 116 +++++++++
 gdb/testsuite/gdb.fortran/func-trampoline.f90 |  40 +++
 .../gdb.fortran/mixed-lang-stack.exp          |   8 +-
 gdb/testsuite/gdb.mi/mi-func-trampoline.exp   |  76 ++++++
 .../gdb.python/py-framefilter-trampoline.exp  |  77 ++++++
 .../gdb.python/py-framefilter-trampoline.py   |  31 +++
 .../gdb.reverse/finish-reverse-trampoline.exp |  56 ++++
 22 files changed, 1315 insertions(+), 14 deletions(-)
 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-function-trampolines.c
 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-function-trampolines.exp
 create mode 100644 gdb/testsuite/gdb.fortran/func-trampoline.exp
 create mode 100644 gdb/testsuite/gdb.fortran/func-trampoline.f90
 create mode 100644 gdb/testsuite/gdb.mi/mi-func-trampoline.exp
 create mode 100644 gdb/testsuite/gdb.python/py-framefilter-trampoline.exp
 create mode 100644 gdb/testsuite/gdb.python/py-framefilter-trampoline.py
 create mode 100644 gdb/testsuite/gdb.reverse/finish-reverse-trampoline.exp

-- 
2.34.1

________________________________________
Intel Deutschland GmbH 

Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany 

Tel: +49 (89) 99143-0 

www.intel.de 

Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman

Chairperson of the Supervisory Board: Sonja Pierer

Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.