Bug 13269

Summary: gdb.lookup_type of print of a type fails with anonymous namespaces
Product: gdb Reporter: Fawzi Mohamed <fawzi>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: jens.elmenthaler
Priority: P2    
Version: HEAD   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:
Attachments: That fixed it for me

Description Fawzi Mohamed 2011-10-06 15:50:37 UTC
print of a types describes anonymous namespaces with <unnamed> whereas lookup.type needs (anonymous namespace).

This is related with the fix done in 7933 .

example:
-------------------
#include <map>
 
namespace { struct S { int a; S(): a(42) {} }; }
 
int main()
{
  std::map<int, S> h;
  S s;
  h[1] = s;
  return s.a;
}
----------------------
python print gdb.parse_and_eval("h").type reports

std::map<int, <unnamed>::S, std::less<int>, std::allocator<std::pair<const int, <unnamed>::S> > >

The '<unnamed>::S' cannot fed into  gdb.lookup_type, whereas  gdb.lookup_type('(anonymous namespace)::S') works.

gcc 4.4.5, gdb 7.2 and current git 

incidentally, python print gdb.parse_and_eval("h").type.template_argument(0) seems to break with   RuntimeError: syntax error, near `<unnamed>::S, std::less<int>, std::al' it is really cut off at std::al (but that might be simply because it just prints x char of context, if that is the case a colon would make it clearer).
Comment 1 Jens Elmenthaler 2012-11-07 08:16:49 UTC
Created attachment 6723 [details]
That fixed it for me