Bug 13269 - gdb.lookup_type of print of a type fails with anonymous namespaces
Summary: gdb.lookup_type of print of a type fails with anonymous namespaces
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2011-10-06 15:50 UTC by Fawzi Mohamed
Modified: 2012-11-07 08:16 UTC (History)
1 user (show)

See Also:
Last reconfirmed:

That fixed it for me (309 bytes, patch)
2012-11-07 08:16 UTC, Jens Elmenthaler
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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 .

#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