From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Berlin To: Benjamin Kosnik Cc: Daniel Berlin , gdb@sources.redhat.com Subject: Re: can't find class named `foo', as given by C++ RTTI Date: Wed, 27 Jun 2001 23:26:00 -0000 Message-id: <873d8li0hh.fsf@cgsoftware.com> References: X-SW-Source: 2001-06/msg00211.html Benjamin Kosnik writes: >> > (gdb) p *__fp >> > can't find class named `std::numpunct', as given by C++ RTTI >> This is no surprise. >> Without namespace support in the symbol table, sometimes the names >> aren't quite correct. >> 5 to 1 says ptype 'numpunct' works. > > Yeah but doesn't really help me in terms of a debugging strategy. > >:( > > What about the demangling bits in the ptype output? Are those > expected too? Dunno offhand. Does that occur with both dwarf2 and stabs? > > Is special namespace support really necessary? Special? You mean special as in "any whatsoever"? Yes. You have a namespace, and if you want all the symbols inside it named correctly, you need to support namespaces. At least you need to have them, and their names, and stop relying on mangled name hacks to get fully qualified names. > I mean, the namespace > qualified symbol *is* the correct name. Correct in what way? > Omitting the namespace is a > bug. No it's not, it's perfectly correct given that 1. STABS has no way to represent namespaces. Thus, they are ignored. 2. GCC doesn't output the namespace die named std of which those would be children. The dwarf2 standard doesn't say the names given are to be fully qualified. In fact, just the opposite is the general practice. If you want fully qualified names, you are expected to generate them, which isn't all that tricky to do. The only reason the others have the std:: in front of them is because of the mangled name hack. In fact, it would be bad to give fully qualified names there. Think of what happens if you have: DW_TAG_namespace: DW_AT_name "std" DW_TAG_class: DW_AT_name "std::numpunct" ... DW_TAG_namespace: DW_AT_name "danspace" DW_TAG_using: DW_AT_name "std" Now, if we don't change the symbol structures, and do this by copying all the symbols in std to the block for danspace, gdb will print out, and treat, the names as if they were "danspace::std::numpunct". It's only the symbol readers that do it wrong, AFAIK. The rest of GDB understands enough about scoping to handle namespaces through copying symbols to the right place if we really wanted to. And if you start going down the path of "Oh, well, i'll just remove the name we have in the using from the name in the namespace symbols the using is referring to", realize it would only work for two namespaces max, would get very confusing if you did "using namespace dan=fred", etc. This is why we need to generate the qualified names ourselves. The non-hack solution here is to add namespace support to gcc's dwarf2 output, and gdb's dwarf2 reader. At a minimum, you could get away with smashing together the names of the scopes in which a given die appears, if those scopes have names, seperated by the scope qualifier of "::", and using that as your name. This would at least be better than what we do now, which is rely on a non-standard extension to give us mangled names to get qualified names from, which isn't the right thing to be doing, is slow, non-standard, and wastes memory to boot. The only thing what we have now has going for it is that it kinda almost used to work for g++ < 3.0. > >> It's good to not have to worry about this stuff anymore. >> I think i'll go implement dwarf2.1 namespace support in gcc. >> That way, I can at least say "Well, we output the info, but gdb can't >> use it". > > Kind of depressing, but oh well. Any other takers? > > -benjamin -- "One day I got on the usual bus, and when I stepped in, I saw the most gorgeous blond Chinese girl... I sat beside her. I said, "Hi," and she said, "Hi," and then I said, "Nice day, isn't it?," and she said, "I saw my analyst today and he says I have a problem." So I asked, "What's the problem?" She replied, "I can't tell you. I don't even know you..." I said, "Well sometimes it's good to tell your problems to a perfect stranger on a bus." So she said, "Well, my analyst said I'm a nymphomaniac and I only like Jewish cowboys... By the way, my name is Denise." I said, "Hello, Denise. My name is Bucky Goldstein..." "-Steven Wright