Last active
February 27, 2017 11:12
-
-
Save ojura/6c5f984d1d9840bc6fb5ed7d1c396d52 to your computer and use it in GitHub Desktop.
patch which enables expanding of pointers in an IDE which uses gdb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- printers.py | |
+++ printers.py | |
@@ -106,6 +106,10 @@ class SharedPointerPrinter: | |
def __init__ (self, typename, val): | |
self.typename = typename | |
self.val = val | |
+ self.pointer = val['_M_ptr'] | |
+ | |
+ def children (self): | |
+ return [('get()', self.pointer)] | |
def to_string (self): | |
state = 'empty' | |
@@ -116,20 +120,22 @@ class SharedPointerPrinter: | |
if usecount == 0: | |
state = 'expired, weak %d' % weakcount | |
else: | |
- state = 'count %d, weak %d' % (usecount, weakcount - 1) | |
- return '%s (%s) %s' % (self.typename, state, self.val['_M_ptr']) | |
+ state = 'use count = %d, weak count = %d' % (usecount, weakcount - 1) | |
+ return '%s<%s> (%s)' % (self.typename, str(self.pointer.type.target()), state) | |
class UniquePointerPrinter: | |
"Print a unique_ptr" | |
def __init__ (self, typename, val): | |
self.val = val | |
+ self.pointer = self.val['_M_t']['_M_head_impl'] | |
- def to_string (self): | |
- v = self.val['_M_t']['_M_head_impl'] | |
- return ('std::unique_ptr<%s> containing %s' % (str(v.type.target()), | |
- str(v))) | |
+ def children (self): | |
+ return [('get()', self.pointer)] | |
+ | |
+ def to_string (self): | |
+ return ('std::unique_ptr<%s>' % (str(self.pointer.type.target()))) | |
def get_value_from_list_node(node): | |
"""Returns the value held in an _List_node<_Val>""" | |
try: | |
@@ -322,9 +328,17 @@ class StdVectorIteratorPrinter: | |
def __init__(self, typename, val): | |
self.val = val | |
+ self.pointer = self.val['_M_current'] | |
+ | |
+ def children(self): | |
+ if not self.pointer: | |
+ return [] | |
+ return [('operator->()', self.pointer)] | |
def to_string(self): | |
- return self.val['_M_current'].dereference() | |
+ if not self.pointer: | |
+ return 'non-dereferenceable iterator for std::vector' | |
+ return ('std::vector<%s>::iterator' % (str(self.pointer.type.target()))) | |
class StdTuplePrinter: | |
"Print a std::tuple" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment