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/10707] New: c++ pretty-printer barfing on a vector


When I try to compile the following C++ code:

#include <string>
#include <vector>

int main() {
  std::string s1("foo");
  std::string s2("bar");
  std::string s3("baz");

  std::vector<std::string> strings;
  strings.push_back(s1);
  strings.push_back(s2);
  strings.push_back(s3);
}

with GCC 4.1.2 (Linux, x86_64)

then, if I set a breakpoint on the next-to-last-line and print out strings, things look normal:

12	  strings.push_back(s3);
(gdb) p strings
$9 = std::vector of length 2, capacity 2 = {"foo", "bar"}

But if I go to the closing brace, I get this:

(gdb) p strings
$10 = std::vector of length 3, capacity 4 = {Traceback (most recent call last):
  File "/home/dcarlton/gdb-c++-python/libstdcxx/v6/printers.py", line 469, in to_string
    return self.val['_M_dataplus']['_M_p'].string (encoding, length = len)
RuntimeError: Cannot access memory at address 0xffffffffffffffe8
, Traceback (most recent call last):
  File "/home/dcarlton/gdb-c++-python/libstdcxx/v6/printers.py", line 469, in to_string
    return self.val['_M_dataplus']['_M_p'].string (encoding, length = len)
RuntimeError: Error reading string from inferior: Input/output error
, Traceback (most recent call last):
  File "/home/dcarlton/gdb-c++-python/libstdcxx/v6/printers.py", line 469, in to_string
    return self.val['_M_dataplus']['_M_p'].string (encoding, length = len)
RuntimeError: Error reading string from inferior: Input/output error
}

(I assume destructors shouldn't have been run at that line yet, right?  Or have they?)

I'm using the pretty-printers from GCC svn head as of today.  (Rev 152291.)

-- 
           Summary: c++ pretty-printer barfing on a vector
           Product: gdb
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: python
        AssignedTo: unassigned at sourceware dot org
        ReportedBy: carlton at bactrian dot org
                CC: gdb-prs at sourceware dot org


http://sourceware.org/bugzilla/show_bug.cgi?id=10707

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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