How to identify linkage namespaces for users and in expressions
Guinevere Larsen
guinevere@redhat.com
Tue Mar 25 17:09:04 GMT 2025
Hi GDB hackers and users!
I've recently started working to improve the user experience when one
debugs a program with multiple linkage namespaces, and while there are
several things to be improved, for this thread I'm mostly worried about
how GDB should display a linkage namespace identifier, and how to read
it from a user.
I have imposed a couple of constraints when trying to figure out a
syntax, that sound reasonable to me, but I'm open to hearing that these
aren't quite as important as I thought, I'm just sharing them so that we
are working from the same starting point. The constraints are:
* How GDB displays a namespace identifier should always be the same, and
should be the same as how a user uses them. This is to avoid forcing a
user to check the documentation when we could instead give all the
necessary information in a more straightforward way;
* The identifier should be prefixed on other symbols. This just follows
the convention of c++ namespaces, and considering the word "namespace"
is being re-use, I think following the convention would be good;
* By the same token, when explicitly searching for a symbol in a
namespace, I'd like to keep c++'s :: syntax, ie, <namespace>::<symbol>;
* Because of those 2 previous constraints, we need to use some symbol
that would make the namespace identifier not a valid identifier for c++
or ada namespaces;
* The symbol should be easily accessible in international keyboards.
Users shouldn't be forced to copy-paste from either GDB's output or an
internet search to find a symbol;
* The symbol should not clash with any existing operator or symbol. This
is because the parser is already very fragile, and having to worry about
whether this symbol is the binary operator or the namespace identifier
would worsen the situation.
I found only one symbol that fits all these constraints, the # symbol.
However, by playing some more with it, I noticed that there can be a
visual clash when printing a backtrace or frame information, where GDB
could output the following:
#0 #2::foo ()
I asked internally, and if I relax the last constraint, the suggestion
of using @ instead came up. This clearly clashes with the array printing
syntax, but of all possible binary operators, I think this one would be
hard but possible to implement (having done no research... hopefully
these aren't famous last words).
As of writing this email, I'm leaning towards keeping the #<id> syntax
as I think users dealing with multiple namespaces probably have a
reasonable amount of experience with GDB, however, I'm open to being
convinced any which way, especially if there is some symbol I completely
overlooked. Please reply with suggestions!
--
Cheers,
Guinevere Larsen
She/Her/Hers
More information about the Gdb
mailing list