[v7,0/5] Introduce syntax for linker-namespace specific symbols

Message ID 20260601192251.60958-1-guinevere@redhat.com
Headers
Series Introduce syntax for linker-namespace specific symbols |

Message

Guinevere Larsen June 1, 2026, 7:22 p.m. UTC
  This series adds support for the syntax [[N]]::foo to find symbols that
belong to specific namespaces, while also making GDB's behavior more
consistent when a namespace is not specified. This needs 2 preparatory
patches and 2 patches actually implementing this feature, and one final
patch to make symtab searching more consistent with the [[N]]::foo
syntax.

Patch 1 is a small refactor, creating a function to figure out the
current linker namespace. Patch 2 is an essential fix, updating how we
calculate a variable's copy relocation to take linker namespaces into
account.

Patches 3 and 4 implement the new syntax, adding the necessary
supporting code and updating error messages when symbols can't be found
- where it made sense. Patch 5 is a small change to the find_symtab
function, to prefer symtabs from the current linker namespace.

Changes for v7:
* Added 2 new patches to the series, one to solve Andrew's feedback and
  another to fix an inconsistency I found.
* Minor cosmetic fixes
* rebased on master

Changes for v6:
* Rebased on master
* Fixed a crash when using the [[N]]::foo syntax before starting the
  inferior

Changes for v5:
* fixed crash when getting the value of a variable before the inferior
  starts.
* Rebased on master

Changes for v4:
* Fixed final documentation feedback from Eli.
* Changed error message when [[N]]::foo::bar fails to find 'foo'.
* Fixed build breakage.

Changes for v3:
* Removed previous patches 1 and 2, as Simon's recently merged patches
  already did those in a better way.
* parser_state now also takes the current solib_ops, since that can't be
  obtained from gdbarch anymore.

Changes for v2:
* solib_supports_linker_namespaces now always expects a pointer.
* Previous patches 2 and 3 were dropped.
* lookup_minimal_symbol_linkage now takes an array_view.
* created new tokens for [[ and ]], to ensure that [[N]] looks like
  that.
* Fixed formatting nits from Eli.


Guinevere Larsen (5):
  gdb: Create helper function for the current namespace
  gdb: make lookup_minimal_symbol_linkage work with linker namespaces
  gdb: Make the parser recognize the [[N]] syntax for variables
  gdb: extend the [[N]]::foo syntax for files
  gdb: prefer symtabs for the current linker namespace

 gdb/NEWS                                     |   5 +
 gdb/c-exp.y                                  |  93 ++++++++++---
 gdb/doc/gdb.texinfo                          |   6 +
 gdb/dwarf2/ada-imported.c                    |   8 +-
 gdb/linespec.c                               |   4 +-
 gdb/minsyms.c                                | 137 ++++++++++++-------
 gdb/minsyms.h                                |  21 ++-
 gdb/parse.c                                  |   3 +-
 gdb/parser-defs.h                            |  50 ++++++-
 gdb/rust-parse.c                             |   3 +-
 gdb/solib-svr4.c                             |  20 ---
 gdb/solib.c                                  | 108 +++++++++++++--
 gdb/solib.h                                  |  29 ++++
 gdb/symtab.c                                 |  94 +++++++++++--
 gdb/symtab.h                                 |  12 +-
 gdb/testsuite/gdb.base/dlmopen-ns-ids-lib.c  |  14 ++
 gdb/testsuite/gdb.base/dlmopen-ns-ids-main.c |   8 ++
 gdb/testsuite/gdb.base/dlmopen-ns-ids.exp    |  83 +++++++++++
 18 files changed, 570 insertions(+), 128 deletions(-)


base-commit: 909db30adab1688870e978c85d014d4a36641f4e