Created attachment 406385 [details] tiny C++ program to demonstrate the problem Description of problem: When trying to print an std::string variable in gdb one gets something like the following: File "/usr/lib64/../share/gdb/python/libstdcxx/v6/printers.py", line 549, in to_string return self.val['_M_dataplus']['_M_p'].lazy_string (length = len) AttributeError: 'gdb.Value' object has no attribute 'lazy_string' Version-Release number of selected component (if applicable): gdb: 7.0.1.43.fc12 How reproducible: Always. Steps to Reproduce: 1. Compile the attached program with -g option (e.g., "g++ -g -o string string.cpp") 2. open in gdb, break in main and step through 8 3. issue "print str" in gdb, observe the above error Actual results: (gdb) break main Breakpoint 1 at 0x40075f: file string.cpp, line 7. (gdb) run Starting program: /home/igor/code/Junk/string Breakpoint 1, main () at string.cpp:7 7 string str = "foobar"; (gdb) n 8 return 0; (gdb) print str $1 = Traceback (most recent call last): File "/usr/lib64/../share/gdb/python/libstdcxx/v6/printers.py", line 549, in to_string return self.val['_M_dataplus']['_M_p'].lazy_string (length = len) AttributeError: 'gdb.Value' object has no attribute 'lazy_string' Expected results: I expected the string's value, i.e., "foobar" in this case, to be printed. Additional info: It sounds like this might be relevant: http://old.nabble.com/-Bug-python-11248--New:-Error-while-printing-std::string-with-printers-td27451999.html
Created attachment 406386 [details] quick hack of a patch For those who need a quick patch to make this work before a proper fix is available, the attached one fixed the problem for me. YMMV.
lazy_string() does not appear to be in the F12 GDB Python API, but the libstdc++ printers use it. The solution here is either to temporarily revert to using string() or import a newer GDB from upstream. This bug was caused by (my) request for Jan to import the std::tuple printer into F12. This brought with in this one unwanted change in as well. GCC patch that changed std::string from using string to lazy_string: http://gcc.gnu.org/viewcvs?view=revision&revision=155951 diff: http://gcc.gnu.org/viewcvs/trunk/libstdc%2B%2B-v3/python/libstdcxx/v6/printers.py?r1=155951&r2=155950&pathrev=155951 Jan, maybe you can reverse the string -> lazy_strings patch for F12?
Thanks, verified as applicable: (gdb) p str $1 = Traceback (most recent call last): File "/usr/lib64/../share/gdb/python/libstdcxx/v6/printers.py", line 549, in to_string return self.val['_M_dataplus']['_M_p'].lazy_string (length = len) AttributeError: 'gdb.Value' object has no attribute 'lazy_string' -> (gdb) p str $1 = "foobar"
gdb-7.0.1-44.fc12 has been submitted as an update for Fedora 12. http://admin.fedoraproject.org/updates/gdb-7.0.1-44.fc12
gdb-7.0.1-44.fc12 has been pushed to the Fedora 12 stable repository. If problems still persist, please make note of it in this bug report.