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/10710] New: libstdc++ UniquePointerPrinter GDB Python printer does not work


Given this example:

std::unique_ptr<char[]> t_uptr (new char[1]);
t_uptr[0] = 'z';

The output from the pretty printer reads:

t_uptr = {
  <std::_Tuple_impl<0ul, char*, std::default_delete<char []> >> = {
    <std::_Tuple_impl<1ul, std::default_delete<char []> >> = {
      <std::_Tuple_impl<2ul>> = {<No data fields>},
      <std::_Head_base<1ul, std::default_delete<char []>, true>> = {
        <std::default_delete<char []>> = {<No data fields>}, <No data fields>},
<No data fields>},
    <std::_Head_base<0ul, char*, false>> = {
      _M_head_impl = 0x61b7b0 "z"
    }, <No data fields>}, <No data fields>}

Which is incorrect. It seems the printer needs to access _M_head_impl. The
following trivial patch fixes it in this simple case, but I've not tested this
at all beyond my one case. If this patch is applied, the output is:

(gdb) p t_uptr 
$1 = 0x61b7b0 "z"


Index: libstdc++-v3/python/libstdcxx/v6/printers.py
===================================================================
--- libstdc++-v3/python/libstdcxx/v6/printers.py	(revision 152325)
+++ libstdc++-v3/python/libstdcxx/v6/printers.py	(working copy)
@@ -40,7 +40,7 @@
         self.val = val
 
     def to_string (self):
-        return self.val['_M_t']
+        return self.val['_M_t']['_M_head_impl']
 
 class StdListPrinter:
     "Print a std::list"

-- 
           Summary: libstdc++ UniquePointerPrinter GDB Python printer does
                    not work
           Product: gdb
           Version: archer
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: python
        AssignedTo: unassigned at sourceware dot org
        ReportedBy: pmuldoon at redhat dot com
                CC: gdb-prs at sourceware dot org


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

------- 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]