This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: what parts of GDB handle variables with compound names?


David Carlton <carlton@math.stanford.edu> writes:
> Right now, if you're debugging C++ code like this
> 
> namespace C {
>   int x;
>   void f();
> }
> 
> then, to get at C::x or C::f from within GDB, you usually enclose them
> in single quotes.  This (I believe) causes GDB to pretend that you
> have a variable whose name is 'C::x' or 'C::f', so lookup_symbol (or
> whatever) eventually gets passed that name.
> 
> Eventually, it would be desirable for various reasons (including both
> cleanliness and correctness) for such lookups to consist of a two-part
> process: first look up 'C' to get some sort of namespace object, and
> then look up x in the namespace given by C.  This is (I assume!) the
> same sort of thing that happens with classes: at some point, you might
> call lookup_symbol with "C" as the name and with STRUCT_NAMESPACE as
> the namespace, but the resulting symbol would have type
> TYPE_CODE_NAMESPACE (or whatever) instead of TYPE_CODE_CLASS.

Can you expand on that "cleanliness and correctness" assertion a bit?
I understand the compiler itself simply uses fully qualified names in
its symbol tables, and it apparently does just fine.  And it seems to
me that the effect of "using namespace" directives is best described
in terms of having a list of prefixes one searches under; it's hard
for me to make sense of Stroustrup TC++PL C.10.1 otherwise.  These
argue that putting fully qualified names in the symbol table directly
is actualy the right approach.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]