This is the mail archive of the gdb-prs@sourceware.org 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]

[Bug python/22686] gdb.lookup_type fails for array types


https://sourceware.org/bugzilla/show_bug.cgi?id=22686

--- Comment #2 from Jonathan Wakely <jwakely.gcc at gmail dot com> ---
I see. The place I hit this limitation I don't know the type to lookup, I just
have a string "int []" and am trying to find out what its type is.

The specific situation is something like:

std::vector<std::unique_ptr<int[]>> v;

GDB (quite correctly) says the real type is:

std::vector<std::unique_ptr<int [], std::default_delete<int []> >,
std::allocator<std::unique_ptr<int [], std::default_delete<int []> > > >

This is ugly, and not what the user wrote, so the libstdc++ pretty printers
apply type  printers to remove the default template arguments, so it's
displayed as simply std::vector<std::unique_ptr<int[]>>.

See
https://gcc.gnu.org/viewcvs/gcc/trunk/libstdc%2B%2B-v3/python/libstdcxx/v6/printers.py?revision=256400&view=markup#l1295

This is done with regular expressions, and recursively applying type printers
to the remaining template arguments. So first I turn vector<T, allocator<T>>
into vector<T>, then I process T, which turns unique_ptr<int[],
default_delete<int[]>> into unique_ptr<int[]>. Then I try to do the same to
"int[]" as well, which is when I try to look that up. Because I'm using a regex
I only have strings, not gdb.Type objects.

I suppose I could use a regex to match the type in the first place, but do the
actual substitutions using gdb.Type not regex substitutions.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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