/usr/share/gcc-4.6/python/libstdcxx/v6/printers.py is in libstdc++6-4.6-dbg 4.6.4-6ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 | # Pretty-printers for libstc++.
# Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import gdb
import itertools
import re
class StdPointerPrinter:
"Print a smart pointer of some kind"
def __init__ (self, typename, val):
self.typename = typename
self.val = val
def to_string (self):
if self.val['_M_refcount']['_M_pi'] == 0:
return '%s (empty) %s' % (self.typename, self.val['_M_ptr'])
return '%s (count %d) %s' % (self.typename,
self.val['_M_refcount']['_M_pi']['_M_use_count'],
self.val['_M_ptr'])
class UniquePointerPrinter:
"Print a unique_ptr"
def __init__ (self, val):
self.val = val
def to_string (self):
return self.val['_M_t']
class StdListPrinter:
"Print a std::list"
class _iterator:
def __init__(self, nodetype, head):
self.nodetype = nodetype
self.base = head['_M_next']
self.head = head.address
self.count = 0
def __iter__(self):
return self
def next(self):
if self.base == self.head:
raise StopIteration
elt = self.base.cast(self.nodetype).dereference()
self.base = elt['_M_next']
count = self.count
self.count = self.count + 1
return ('[%d]' % count, elt['_M_data'])
def __init__(self, typename, val):
self.typename = typename
self.val = val
def children(self):
itype = self.val.type.template_argument(0)
# If the inferior program is compiled with -D_GLIBCXX_DEBUG
# some of the internal implementation details change.
if self.typename == "std::list":
nodetype = gdb.lookup_type('std::_List_node<%s>' % itype).pointer()
elif self.typename == "std::__debug::list":
nodetype = gdb.lookup_type('std::__norm::_List_node<%s>' % itype).pointer()
else:
raise ValueError, "Cannot cast list node for list printer."
return self._iterator(nodetype, self.val['_M_impl']['_M_node'])
def to_string(self):
if self.val['_M_impl']['_M_node'].address == self.val['_M_impl']['_M_node']['_M_next']:
return 'empty %s' % (self.typename)
return '%s' % (self.typename)
class StdListIteratorPrinter:
"Print std::list::iterator"
def __init__(self, typename, val):
self.val = val
self.typename = typename
def to_string(self):
itype = self.val.type.template_argument(0)
# If the inferior program is compiled with -D_GLIBCXX_DEBUG
# some of the internal implementation details change.
if self.typename == "std::_List_iterator" or self.typename == "std::_List_const_iterator":
nodetype = gdb.lookup_type('std::_List_node<%s>' % itype).pointer()
elif self.typename == "std::__norm::_List_iterator" or self.typename == "std::__norm::_List_const_iterator":
nodetype = gdb.lookup_type('std::__norm::_List_node<%s>' % itype).pointer()
else:
raise ValueError, "Cannot cast list node for list iterator printer."
return self.val['_M_node'].cast(nodetype).dereference()['_M_data']
class StdSlistPrinter:
"Print a __gnu_cxx::slist"
class _iterator:
def __init__(self, nodetype, head):
self.nodetype = nodetype
self.base = head['_M_head']['_M_next']
self.count = 0
def __iter__(self):
return self
def next(self):
if self.base == 0:
raise StopIteration
elt = self.base.cast(self.nodetype).dereference()
self.base = elt['_M_next']
count = self.count
self.count = self.count + 1
return ('[%d]' % count, elt['_M_data'])
def __init__(self, val):
self.val = val
def children(self):
itype = self.val.type.template_argument(0)
nodetype = gdb.lookup_type('__gnu_cxx::_Slist_node<%s>' % itype).pointer()
return self._iterator(nodetype, self.val)
def to_string(self):
if self.val['_M_head']['_M_next'] == 0:
return 'empty __gnu_cxx::slist'
return '__gnu_cxx::slist'
class StdSlistIteratorPrinter:
"Print __gnu_cxx::slist::iterator"
def __init__(self, val):
self.val = val
def to_string(self):
itype = self.val.type.template_argument(0)
nodetype = gdb.lookup_type('__gnu_cxx::_Slist_node<%s>' % itype).pointer()
return self.val['_M_node'].cast(nodetype).dereference()['_M_data']
class StdVectorPrinter:
"Print a std::vector"
class _iterator:
def __init__ (self, start, finish, bitvec):
self.bitvec = bitvec
if bitvec:
self.item = start['_M_p']
self.so = start['_M_offset']
self.finish = finish['_M_p']
self.fo = finish['_M_offset']
itype = self.item.dereference().type
self.isize = 8 * itype.sizeof
else:
self.item = start
self.finish = finish
self.count = 0
def __iter__(self):
return self
def next(self):
count = self.count
self.count = self.count + 1
if self.bitvec:
if self.item == self.finish and self.so >= self.fo:
raise StopIteration
elt = self.item.dereference()
if elt & (1 << self.so):
obit = 1
else:
obit = 0
self.so = self.so + 1
if self.so >= self.isize:
self.item = self.item + 1
self.so = 0
return ('[%d]' % count, obit)
else:
if self.item == self.finish:
raise StopIteration
elt = self.item.dereference()
self.item = self.item + 1
return ('[%d]' % count, elt)
def __init__(self, typename, val):
self.typename = typename
self.val = val
self.is_bool = val.type.template_argument(0).code == gdb.TYPE_CODE_BOOL
def children(self):
return self._iterator(self.val['_M_impl']['_M_start'],
self.val['_M_impl']['_M_finish'],
self.is_bool)
def to_string(self):
start = self.val['_M_impl']['_M_start']
finish = self.val['_M_impl']['_M_finish']
end = self.val['_M_impl']['_M_end_of_storage']
if self.is_bool:
start = self.val['_M_impl']['_M_start']['_M_p']
so = self.val['_M_impl']['_M_start']['_M_offset']
finish = self.val['_M_impl']['_M_finish']['_M_p']
fo = self.val['_M_impl']['_M_finish']['_M_offset']
itype = start.dereference().type
bl = 8 * itype.sizeof
length = (bl - so) + bl * ((finish - start) - 1) + fo
capacity = bl * (end - start)
return ('%s<bool> of length %d, capacity %d'
% (self.typename, int (length), int (capacity)))
else:
return ('%s of length %d, capacity %d'
% (self.typename, int (finish - start), int (end - start)))
def display_hint(self):
return 'array'
class StdVectorIteratorPrinter:
"Print std::vector::iterator"
def __init__(self, val):
self.val = val
def to_string(self):
return self.val['_M_current'].dereference()
class StdTuplePrinter:
"Print a std::tuple"
class _iterator:
def __init__ (self, head):
self.head = head
# Set the base class as the initial head of the
# tuple.
nodes = self.head.type.fields ()
if len (nodes) != 1:
raise ValueError, "Top of tuple tree does not consist of a single node."
# Set the actual head to the first pair.
self.head = self.head.cast (nodes[0].type)
self.count = 0
def __iter__ (self):
return self
def next (self):
nodes = self.head.type.fields ()
# Check for further recursions in the inheritance tree.
if len (nodes) == 0:
raise StopIteration
# Check that this iteration has an expected structure.
if len (nodes) != 2:
raise ValueError, "Cannot parse more than 2 nodes in a tuple tree."
# - Left node is the next recursion parent.
# - Right node is the actual class contained in the tuple.
# Process right node.
impl = self.head.cast (nodes[1].type)
# Process left node and set it as head.
self.head = self.head.cast (nodes[0].type)
self.count = self.count + 1
# Finally, check the implementation. If it is
# wrapped in _M_head_impl return that, otherwise return
# the value "as is".
fields = impl.type.fields ()
if len (fields) < 1 or fields[0].name != "_M_head_impl":
return ('[%d]' % self.count, impl)
else:
return ('[%d]' % self.count, impl['_M_head_impl'])
def __init__ (self, typename, val):
self.typename = typename
self.val = val;
def children (self):
return self._iterator (self.val)
def to_string (self):
return '%s containing' % (self.typename)
class StdStackOrQueuePrinter:
"Print a std::stack or std::queue"
def __init__ (self, typename, val):
self.typename = typename
self.visualizer = gdb.default_visualizer(val['c'])
def children (self):
return self.visualizer.children()
def to_string (self):
return '%s wrapping: %s' % (self.typename,
self.visualizer.to_string())
def display_hint (self):
if hasattr (self.visualizer, 'display_hint'):
return self.visualizer.display_hint ()
return None
class RbtreeIterator:
def __init__(self, rbtree):
self.size = rbtree['_M_t']['_M_impl']['_M_node_count']
self.node = rbtree['_M_t']['_M_impl']['_M_header']['_M_left']
self.count = 0
def __iter__(self):
return self
def __len__(self):
return int (self.size)
def next(self):
if self.count == self.size:
raise StopIteration
result = self.node
self.count = self.count + 1
if self.count < self.size:
# Compute the next node.
node = self.node
if node.dereference()['_M_right']:
node = node.dereference()['_M_right']
while node.dereference()['_M_left']:
node = node.dereference()['_M_left']
else:
parent = node.dereference()['_M_parent']
while node == parent.dereference()['_M_right']:
node = parent
parent = parent.dereference()['_M_parent']
if node.dereference()['_M_right'] != parent:
node = parent
self.node = node
return result
# This is a pretty printer for std::_Rb_tree_iterator (which is
# std::map::iterator), and has nothing to do with the RbtreeIterator
# class above.
class StdRbtreeIteratorPrinter:
"Print std::map::iterator"
def __init__ (self, val):
self.val = val
def to_string (self):
valuetype = self.val.type.template_argument(0)
nodetype = gdb.lookup_type('std::_Rb_tree_node < %s >' % valuetype)
nodetype = nodetype.pointer()
return self.val.cast(nodetype).dereference()['_M_value_field']
class StdDebugIteratorPrinter:
"Print a debug enabled version of an iterator"
def __init__ (self, val):
self.val = val
# Just strip away the encapsulating __gnu_debug::_Safe_iterator
# and return the wrapped iterator value.
def to_string (self):
itype = self.val.type.template_argument(0)
return self.val['_M_current'].cast(itype)
class StdMapPrinter:
"Print a std::map or std::multimap"
# Turn an RbtreeIterator into a pretty-print iterator.
class _iter:
def __init__(self, rbiter, type):
self.rbiter = rbiter
self.count = 0
self.type = type
def __iter__(self):
return self
def next(self):
if self.count % 2 == 0:
n = self.rbiter.next()
n = n.cast(self.type).dereference()['_M_value_field']
self.pair = n
item = n['first']
else:
item = self.pair['second']
result = ('[%d]' % self.count, item)
self.count = self.count + 1
return result
def __init__ (self, typename, val):
self.typename = typename
self.val = val
def to_string (self):
return '%s with %d elements' % (self.typename,
len (RbtreeIterator (self.val)))
def children (self):
keytype = self.val.type.template_argument(0).const()
valuetype = self.val.type.template_argument(1)
nodetype = gdb.lookup_type('std::_Rb_tree_node< std::pair< %s, %s > >' % (keytype, valuetype))
nodetype = nodetype.pointer()
return self._iter (RbtreeIterator (self.val), nodetype)
def display_hint (self):
return 'map'
class StdSetPrinter:
"Print a std::set or std::multiset"
# Turn an RbtreeIterator into a pretty-print iterator.
class _iter:
def __init__(self, rbiter, type):
self.rbiter = rbiter
self.count = 0
self.type = type
def __iter__(self):
return self
def next(self):
item = self.rbiter.next()
item = item.cast(self.type).dereference()['_M_value_field']
# FIXME: this is weird ... what to do?
# Maybe a 'set' display hint?
result = ('[%d]' % self.count, item)
self.count = self.count + 1
return result
def __init__ (self, typename, val):
self.typename = typename
self.val = val
def to_string (self):
return '%s with %d elements' % (self.typename,
len (RbtreeIterator (self.val)))
def children (self):
keytype = self.val.type.template_argument(0)
nodetype = gdb.lookup_type('std::_Rb_tree_node< %s >' % keytype).pointer()
return self._iter (RbtreeIterator (self.val), nodetype)
class StdBitsetPrinter:
"Print a std::bitset"
def __init__(self, typename, val):
self.typename = typename
self.val = val
def to_string (self):
# If template_argument handled values, we could print the
# size. Or we could use a regexp on the type.
return '%s' % (self.typename)
def children (self):
words = self.val['_M_w']
wtype = words.type
# The _M_w member can be either an unsigned long, or an
# array. This depends on the template specialization 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
while byte < nwords:
w = words[byte]
bit = 0
while w != 0:
if (w & 1) != 0:
# Another spot where we could use 'set'?
result.append(('[%d]' % (byte * tsize * 8 + bit), 1))
bit = bit + 1
w = w >> 1
byte = byte + 1
return result
class StdDequePrinter:
"Print a std::deque"
class _iter:
def __init__(self, node, start, end, last, buffer_size):
self.node = node
self.p = start
self.end = end
self.last = last
self.buffer_size = buffer_size
self.count = 0
def __iter__(self):
return self
def next(self):
if self.p == self.last:
raise StopIteration
result = ('[%d]' % self.count, self.p.dereference())
self.count = self.count + 1
# Advance the 'cur' pointer.
self.p = self.p + 1
if self.p == self.end:
# If we got to the end of this bucket, move to the
# next bucket.
self.node = self.node + 1
self.p = self.node[0]
self.end = self.p + self.buffer_size
return result
def __init__(self, typename, val):
self.typename = typename
self.val = val
self.elttype = val.type.template_argument(0)
size = self.elttype.sizeof
if size < 512:
self.buffer_size = int (512 / size)
else:
self.buffer_size = 1
def to_string(self):
start = self.val['_M_impl']['_M_start']
end = self.val['_M_impl']['_M_finish']
delta_n = end['_M_node'] - start['_M_node'] - 1
delta_s = start['_M_last'] - start['_M_cur']
delta_e = end['_M_cur'] - end['_M_first']
size = self.buffer_size * delta_n + delta_s + delta_e
return '%s with %d elements' % (self.typename, long (size))
def children(self):
start = self.val['_M_impl']['_M_start']
end = self.val['_M_impl']['_M_finish']
return self._iter(start['_M_node'], start['_M_cur'], start['_M_last'],
end['_M_cur'], self.buffer_size)
def display_hint (self):
return 'array'
class StdDequeIteratorPrinter:
"Print std::deque::iterator"
def __init__(self, val):
self.val = val
def to_string(self):
return self.val['_M_cur'].dereference()
class StdStringPrinter:
"Print a std::basic_string of some kind"
def __init__(self, val):
self.val = val
def to_string(self):
# Make sure &string works, too.
type = self.val.type
if type.code == gdb.TYPE_CODE_REF:
type = type.target ()
# Calculate the length of the string so that to_string returns
# the string according to length, not according to first null
# encountered.
ptr = self.val ['_M_dataplus']['_M_p']
realtype = type.unqualified ().strip_typedefs ()
reptype = gdb.lookup_type (str (realtype) + '::_Rep').pointer ()
header = ptr.cast(reptype) - 1
len = header.dereference ()['_M_length']
if hasattr(ptr, "lazy_string"):
return ptr.lazy_string (length = len)
return ptr.string (length = len)
def display_hint (self):
return 'string'
class Tr1HashtableIterator:
def __init__ (self, hash):
self.count = 0
self.n_buckets = hash['_M_element_count']
if self.n_buckets == 0:
self.node = False
else:
self.bucket = hash['_M_buckets']
self.node = self.bucket[0]
self.update ()
def __iter__ (self):
return self
def update (self):
# If we advanced off the end of the chain, move to the next
# bucket.
while self.node == 0:
self.bucket = self.bucket + 1
self.node = self.bucket[0]
# If we advanced off the end of the bucket array, then
# we're done.
if self.count == self.n_buckets:
self.node = False
else:
self.count = self.count + 1
def next (self):
if not self.node:
raise StopIteration
result = self.node.dereference()['_M_v']
self.node = self.node.dereference()['_M_next']
self.update ()
return result
class Tr1UnorderedSetPrinter:
"Print a tr1::unordered_set"
def __init__ (self, typename, val):
self.typename = typename
self.val = val
def to_string (self):
return '%s with %d elements' % (self.typename, self.val['_M_element_count'])
@staticmethod
def format_count (i):
return '[%d]' % i
def children (self):
counter = itertools.imap (self.format_count, itertools.count())
return itertools.izip (counter, Tr1HashtableIterator (self.val))
class Tr1UnorderedMapPrinter:
"Print a tr1::unordered_map"
def __init__ (self, typename, val):
self.typename = typename
self.val = val
def to_string (self):
return '%s with %d elements' % (self.typename, self.val['_M_element_count'])
@staticmethod
def flatten (list):
for elt in list:
for i in elt:
yield i
@staticmethod
def format_one (elt):
return (elt['first'], elt['second'])
@staticmethod
def format_count (i):
return '[%d]' % i
def children (self):
counter = itertools.imap (self.format_count, itertools.count())
# Map over the hash table and flatten the result.
data = self.flatten (itertools.imap (self.format_one, Tr1HashtableIterator (self.val)))
# Zip the two iterators together.
return itertools.izip (counter, data)
def display_hint (self):
return 'map'
def register_libstdcxx_printers (obj):
"Register libstdc++ pretty-printers with objfile Obj."
if obj == None:
obj = gdb
obj.pretty_printers.append (lookup_function)
def lookup_function (val):
"Look-up and return a pretty-printer that can print val."
# Get the type.
type = val.type
# If it points to a reference, get the reference.
if type.code == gdb.TYPE_CODE_REF:
type = type.target ()
# Get the unqualified type, stripped of typedefs.
type = type.unqualified ().strip_typedefs ()
# Get the type name.
typename = type.tag
if typename == None:
return None
# Iterate over local dictionary of types to determine
# if a printer is registered for that type. Return an
# instantiation of the printer if found.
for function in pretty_printers_dict:
if function.search (typename):
return pretty_printers_dict[function] (val)
# Cannot find a pretty printer. Return None.
return None
def build_libstdcxx_dictionary ():
# libstdc++ objects requiring pretty-printing.
# In order from:
# http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01847.html
pretty_printers_dict[re.compile('^std::basic_string<.*>$')] = lambda val: StdStringPrinter(val)
pretty_printers_dict[re.compile('^std::bitset<.*>$')] = lambda val: StdBitsetPrinter("std::bitset", val)
pretty_printers_dict[re.compile('^std::deque<.*>$')] = lambda val: StdDequePrinter("std::deque", val)
pretty_printers_dict[re.compile('^std::list<.*>$')] = lambda val: StdListPrinter("std::list", val)
pretty_printers_dict[re.compile('^std::map<.*>$')] = lambda val: StdMapPrinter("std::map", val)
pretty_printers_dict[re.compile('^std::multimap<.*>$')] = lambda val: StdMapPrinter("std::multimap", val)
pretty_printers_dict[re.compile('^std::multiset<.*>$')] = lambda val: StdSetPrinter("std::multiset", val)
pretty_printers_dict[re.compile('^std::priority_queue<.*>$')] = lambda val: StdStackOrQueuePrinter("std::priority_queue", val)
pretty_printers_dict[re.compile('^std::queue<.*>$')] = lambda val: StdStackOrQueuePrinter("std::queue", val)
pretty_printers_dict[re.compile('^std::tuple<.*>$')] = lambda val: StdTuplePrinter("std::tuple", val)
pretty_printers_dict[re.compile('^std::set<.*>$')] = lambda val: StdSetPrinter("std::set", val)
pretty_printers_dict[re.compile('^std::stack<.*>$')] = lambda val: StdStackOrQueuePrinter("std::stack", val)
pretty_printers_dict[re.compile('^std::unique_ptr<.*>$')] = UniquePointerPrinter
pretty_printers_dict[re.compile('^std::vector<.*>$')] = lambda val: StdVectorPrinter("std::vector", val)
# vector<bool>
# Printer registrations for classes compiled with -D_GLIBCXX_DEBUG.
pretty_printers_dict[re.compile('^std::__debug::bitset<.*>$')] = lambda val: StdBitsetPrinter("std::__debug::bitset", val)
pretty_printers_dict[re.compile('^std::__debug::deque<.*>$')] = lambda val: StdDequePrinter("std::__debug::deque", val)
pretty_printers_dict[re.compile('^std::__debug::list<.*>$')] = lambda val: StdListPrinter("std::__debug::list", val)
pretty_printers_dict[re.compile('^std::__debug::map<.*>$')] = lambda val: StdMapPrinter("std::__debug::map", val)
pretty_printers_dict[re.compile('^std::__debug::multimap<.*>$')] = lambda val: StdMapPrinter("std::__debug::multimap", val)
pretty_printers_dict[re.compile('^std::__debug::multiset<.*>$')] = lambda val: StdSetPrinter("std::__debug::multiset", val)
pretty_printers_dict[re.compile('^std::__debug::priority_queue<.*>$')] = lambda val: StdStackOrQueuePrinter("std::__debug::priority_queue", val)
pretty_printers_dict[re.compile('^std::__debug::queue<.*>$')] = lambda val: StdStackOrQueuePrinter("std::__debug::queue", val)
pretty_printers_dict[re.compile('^std::__debug::set<.*>$')] = lambda val: StdSetPrinter("std::__debug::set", val)
pretty_printers_dict[re.compile('^std::__debug::stack<.*>$')] = lambda val: StdStackOrQueuePrinter("std::__debug::stack", val)
pretty_printers_dict[re.compile('^std::__debug::unique_ptr<.*>$')] = UniquePointerPrinter
pretty_printers_dict[re.compile('^std::__debug::vector<.*>$')] = lambda val: StdVectorPrinter("std::__debug::vector", val)
# These are the TR1 and C++0x printers.
# For array - the default GDB pretty-printer seems reasonable.
pretty_printers_dict[re.compile('^std::shared_ptr<.*>$')] = lambda val: StdPointerPrinter ('std::shared_ptr', val)
pretty_printers_dict[re.compile('^std::weak_ptr<.*>$')] = lambda val: StdPointerPrinter ('std::weak_ptr', val)
pretty_printers_dict[re.compile('^std::unordered_map<.*>$')] = lambda val: Tr1UnorderedMapPrinter ('std::unordered_map', val)
pretty_printers_dict[re.compile('^std::unordered_set<.*>$')] = lambda val: Tr1UnorderedSetPrinter ('std::unordered_set', val)
pretty_printers_dict[re.compile('^std::unordered_multimap<.*>$')] = lambda val: Tr1UnorderedMapPrinter ('std::unordered_multimap', val)
pretty_printers_dict[re.compile('^std::unordered_multiset<.*>$')] = lambda val: Tr1UnorderedSetPrinter ('std::unordered_multiset', val)
pretty_printers_dict[re.compile('^std::tr1::shared_ptr<.*>$')] = lambda val: StdPointerPrinter ('std::tr1::shared_ptr', val)
pretty_printers_dict[re.compile('^std::tr1::weak_ptr<.*>$')] = lambda val: StdPointerPrinter ('std::tr1::weak_ptr', val)
pretty_printers_dict[re.compile('^std::tr1::unordered_map<.*>$')] = lambda val: Tr1UnorderedMapPrinter ('std::tr1::unordered_map', val)
pretty_printers_dict[re.compile('^std::tr1::unordered_set<.*>$')] = lambda val: Tr1UnorderedSetPrinter ('std::tr1::unordered_set', val)
pretty_printers_dict[re.compile('^std::tr1::unordered_multimap<.*>$')] = lambda val: Tr1UnorderedMapPrinter ('std::tr1::unordered_multimap', val)
pretty_printers_dict[re.compile('^std::tr1::unordered_multiset<.*>$')] = lambda val: Tr1UnorderedSetPrinter ('std::tr1::unordered_multiset', val)
# These are the C++0x printer registrations for -D_GLIBCXX_DEBUG cases.
# The tr1 namespace printers do not seem to have any debug
# equivalents, so do no register them.
pretty_printers_dict[re.compile('^std::__debug::unordered_map<.*>$')] = lambda val: Tr1UnorderedMapPrinter ('std::__debug::unordered_map', val)
pretty_printers_dict[re.compile('^std::__debug::unordered_set<.*>$')] = lambda val: Tr1UnorderedSetPrinter ('std::__debug::unordered_set', val)
pretty_printers_dict[re.compile('^std::__debug::unordered_multimap<.*>$')] = lambda val: Tr1UnorderedMapPrinter ('std::__debug::unordered_multimap', val)
pretty_printers_dict[re.compile('^std::__debug::unordered_multiset<.*>$')] = lambda val: Tr1UnorderedSetPrinter ('std::__debug:unordered_multiset', val)
# Extensions.
pretty_printers_dict[re.compile('^__gnu_cxx::slist<.*>$')] = StdSlistPrinter
if True:
# These shouldn't be necessary, if GDB "print *i" worked.
# But it often doesn't, so here they are.
pretty_printers_dict[re.compile('^std::_List_iterator<.*>$')] = lambda val: StdListIteratorPrinter("std::_List_iterator",val)
pretty_printers_dict[re.compile('^std::_List_const_iterator<.*>$')] = lambda val: StdListIteratorPrinter("std::_List_const_iterator",val)
pretty_printers_dict[re.compile('^std::_Rb_tree_iterator<.*>$')] = lambda val: StdRbtreeIteratorPrinter(val)
pretty_printers_dict[re.compile('^std::_Rb_tree_const_iterator<.*>$')] = lambda val: StdRbtreeIteratorPrinter(val)
pretty_printers_dict[re.compile('^std::_Deque_iterator<.*>$')] = lambda val: StdDequeIteratorPrinter(val)
pretty_printers_dict[re.compile('^std::_Deque_const_iterator<.*>$')] = lambda val: StdDequeIteratorPrinter(val)
pretty_printers_dict[re.compile('^__gnu_cxx::__normal_iterator<.*>$')] = lambda val: StdVectorIteratorPrinter(val)
pretty_printers_dict[re.compile('^__gnu_cxx::_Slist_iterator<.*>$')] = lambda val: StdSlistIteratorPrinter(val)
# Debug (compiled with -D_GLIBCXX_DEBUG) printer registrations.
# The Rb_tree debug iterator when unwrapped from the encapsulating __gnu_debug::_Safe_iterator
# does not have the __norm namespace. Just use the existing printer registration for that.
pretty_printers_dict[re.compile('^__gnu_debug::_Safe_iterator<.*>$')] = lambda val: StdDebugIteratorPrinter(val)
pretty_printers_dict[re.compile('^std::__norm::_List_iterator<.*>$')] = lambda val: StdListIteratorPrinter ("std::__norm::_List_iterator",val)
pretty_printers_dict[re.compile('^std::__norm::_List_const_iterator<.*>$')] = lambda val: StdListIteratorPrinter ("std::__norm::_List_const_iterator",val)
pretty_printers_dict[re.compile('^std::__norm::_Deque_const_iterator<.*>$')] = lambda val: StdDequeIteratorPrinter(val)
pretty_printers_dict[re.compile('^std::__norm::_Deque_iterator<.*>$')] = lambda val: StdDequeIteratorPrinter(val)
pretty_printers_dict = {}
build_libstdcxx_dictionary ()
|