GNOME Bugzilla – Bug 574212
gdb ptype command doesn't work with type names containing '::'
Last modified: 2020-03-10 11:55:35 UTC
Log entry from a trying to get the type of std::string::npos: |{|bool nemiver::GDBMIParser::parse_out_of_band_record(size_t, size_t&, nemiver::Output::OutOfBandRecord&):{ |I|void nemiver::remove_stream_record_trailing_chars(nemiver::common::UString&):nmv-gdbmi-parser.cc:2685:stream record: 'ptype std::string::npos\n' size=25 |}|bool nemiver::GDBMIParser::parse_out_of_band_record(size_t, size_t&, nemiver::Output::OutOfBandRecord&):}elapsed: 3.6108e-05secs |{|bool nemiver::GDBMIParser::parse_out_of_band_record(size_t, size_t&, nemiver::Output::OutOfBandRecord&):{ |I|void nemiver::remove_stream_record_trailing_chars(nemiver::common::UString&):nmv-gdbmi-parser.cc:2685:stream record: 'No type \"string\" within class or namespace \"std\".\n' size=55 |}|bool nemiver::GDBMIParser::parse_out_of_band_record(size_t, size_t&, nemiver::Output::OutOfBandRecord&):}elapsed: 3.7295e-05secs however, if we had surrounded std::string::npos with single quotes, gdb would have happily given us its type. Patch soon.
Created attachment 130093 [details] [review] patch to quote arguments to -data-evaluate-expression, and ptype
pushed
I think this fix leads to subtle regressions. suppose you have this program: 1 int 2 main () 3 { 4 int i = 0; 5 i++; 6 i++; 7 } Then look at this gdb session: 4 int i = 0; (gdb) n 5 i++; (gdb) p i $1 = 0 (gdb) p 'i' $2 = 105 'i' (gdb) ptype i type = int (gdb) ptype 'i' type = char What happens is that quoting i like in 'i' changes the type of the i expression. i is of type int, but 'i' is of type char. This leads to subtle bugs in the Nemiver interface if you quote the arguments of either ptype or -data-evaluate-expression. It leads to many regressions actually. So I reopening the bug and I will revert the changes. Having '::' to be properly understood by GDB requires a bugfix in GDB, I believe. I think we should change the title of the bug as well.
Yes, I think I've seen some regressions as well, so we probably should revert it for now.
Okay, I have reverted the changes of the commit and added a regression test to catch that regression. The commit hash is 800d796c34aa
Changing the title of the bug from "gdb apparently requires arguments to 'ptype', etc to be quoted" to gdb ptype command doesn't work with type names containing '::'
Closing all open Nemiver tasks as this project does not seem to be maintained anymore. Please see https://gitlab.gnome.org/Infrastructure/Infrastructure/issues/235#note_732192 for further information. Thanks!