[0/5] Template type parameter resolution

Message ID 20251229151518.475440-1-christina.schimpe@intel.com
Headers
Series Template type parameter resolution |

Message

Schimpe, Christina Dec. 29, 2025, 3:15 p.m. UTC
  Hi all,

The DWARF Version 5 Debugging Format Standard describes the following
for a template type parameter:

"A template type parameter is represented by a debugging information entry
with the tag DW_TAG_template_type_parameter."

This has already been described for GDB:
https://sourceware.org/bugzilla/show_bug.cgi?id=20540

and for GCC:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57006

This series teaches GDB to resolve template types correctly when the
DWARF format described above is available. It also improves the printing
of function templates and templated class/struct members.

This new DWARF format was previously proposed for upstreaming to LLVM
under a switch "-Xclang -fdebug-template-parameter-as-type", but upstream
rejected the switch and asked for a consumer. As a result, we can expect
upstream Clang to support the feature without the switch once this DWARF
format is supported by debuggers such as GDB and LLDB.

This is the PR that has since been closed, mainly due to missing debugger
support:
https://github.com/llvm/llvm-project/pull/127654

I am looking forward to your feedback!

Christina


Christina Schimpe (5):
  gdb: Update comment of c_type_print_template_args.
  gdb: Support new DWARF for template type parameters.
  gdb: Enable correct template type resolution.
  gdb: Print target type and name of template members.
  gdb: Print template arguments of function templates.

 gdb/c-lang.c                                  |   8 +
 gdb/c-lang.h                                  |  20 +
 gdb/c-typeprint.c                             |  96 +++-
 gdb/c-valprint.c                              |   7 +
 gdb/cp-valprint.c                             |   6 +
 gdb/dwarf2/read.c                             |  79 ++-
 gdb/gdbtypes.c                                |  11 +-
 gdb/gdbtypes.h                                |   8 +
 gdb/guile/lib/gdb.scm                         |   1 +
 gdb/testsuite/gdb.cp/cp-relocate.exp          |   4 +-
 gdb/testsuite/gdb.cp/cpexprs.exp.tcl          |  46 +-
 .../gdb.cp/template-type-parameters.cc        | 103 ++++
 .../gdb.cp/template-type-parameters.exp       | 204 ++++++++
 .../gdb.dwarf2/self-referential-templates.exp | 117 +++++
 .../template-specification-full-name.exp      |   3 +-
 .../gdb.dwarf2/template-type-resolution.cc    |  42 ++
 .../gdb.dwarf2/template-type-resolution.exp   | 467 ++++++++++++++++++
 gdb/type-codes.def                            |   3 +
 gdb/typeprint.c                               |   9 +-
 gdb/typeprint.h                               |   9 +-
 gdb/valprint.c                                |  11 +
 21 files changed, 1202 insertions(+), 52 deletions(-)
 create mode 100644 gdb/testsuite/gdb.cp/template-type-parameters.cc
 create mode 100644 gdb/testsuite/gdb.cp/template-type-parameters.exp
 create mode 100644 gdb/testsuite/gdb.dwarf2/self-referential-templates.exp
 create mode 100644 gdb/testsuite/gdb.dwarf2/template-type-resolution.cc
 create mode 100644 gdb/testsuite/gdb.dwarf2/template-type-resolution.exp