This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
[python] [rfc] StdBitsetPrinter patch for printing bitsets representedby a single unsigned long.
- From: Phil Muldoon <pmuldoon at redhat dot com>
- To: Project Archer <archer at sourceware dot org>
- Date: Mon, 23 Feb 2009 18:19:07 +0000
- Subject: [python] [rfc] StdBitsetPrinter patch for printing bitsets representedby a single unsigned long.
The std::bitset printer within the libstdcxx pretty-printer library has
a bug where it assumes the data member: "_M_w" is always an array of
data. In some cases, the data member can be a single unsigned long.
This patches checks and converts the single unsigned long case to a
single element array, so the bit-extraction logic can work.
Regards
Phil
ChangeLog
2009-02-23 Phil Muldoon <pmuldoon@redhat.com>
* python/lib/gdb/libstdcxx/v6/printers.py
(StdBitsetPrinter.children): Check "_M_w" for int type. If it is an
int type, convert to array.
diff --git a/gdb/python/lib/gdb/libstdcxx/v6/printers.py b/gdb/python/lib/gdb/libstdcxx/v6/printers.py
index 701eec2..faa0d09 100644
--- a/gdb/python/lib/gdb/libstdcxx/v6/printers.py
+++ b/gdb/python/lib/gdb/libstdcxx/v6/printers.py
@@ -338,7 +338,16 @@ class StdBitsetPrinter:
def children (self):
words = self.val['_M_w']
wtype = words.type()
- tsize = wtype.target().sizeof()
+
+ # The _M_w member can be either an unsigned long, or an
+ # array. This depends on what template type was used. If it
+ # is a single long, convert to a single element list.
+ if wtype.code () == gdb.TYPE_CODE_ARRAY:
+ tsize = wtype.target ().sizeof ()
+ else:
+ words = [words]
+ tsize = wtype.sizeof ()
+
nwords = wtype.sizeof() / tsize
result = []
byte = 0