summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/ip.py14
-rw-r--r--src/main-gdb-head.py4
-rw-r--r--src/strings/vstring.py17
-rw-r--r--src/strings/xstring.py18
4 files changed, 52 insertions, 1 deletions
diff --git a/src/common/ip.py b/src/common/ip.py
new file mode 100644
index 0000000..e6a8183
--- /dev/null
+++ b/src/common/ip.py
@@ -0,0 +1,14 @@
+class IP4Address(object):
+ ''' print an IP4Address
+ '''
+ __slots__ = ('_value')
+ name = 'IP4Address'
+ enabled = True
+
+ def __init__(self, value):
+ self._value = value
+
+ def to_string(self):
+ addr = self._value['_addr']
+ addr = tuple(int(addr[i]) for i in range(4))
+ return '%d.%d.%d.%d' % addr
diff --git a/src/main-gdb-head.py b/src/main-gdb-head.py
index 44c1c2e..75e43bf 100644
--- a/src/main-gdb-head.py
+++ b/src/main-gdb-head.py
@@ -60,13 +60,15 @@ class FastPrinters(object):
def add_printer(self, cls):
assert hasattr(cls, 'enabled')
+ # TODO: check if the class name exists
+ # this is really hard since templates are involved
self.printers[cls.name] = cls
@property
def subprinters(self):
return self.printers.values()
- def strip_templates(self, name, __pattern=re.compile('<[^<>]>')):
+ def strip_templates(self, name, __pattern=re.compile('<[^<>]*>')):
# TODO what about '<' and '>' as non-type template parameters?
changed = 1
while changed:
diff --git a/src/strings/vstring.py b/src/strings/vstring.py
new file mode 100644
index 0000000..39e657b
--- /dev/null
+++ b/src/strings/vstring.py
@@ -0,0 +1,17 @@
+class VString(object):
+ ''' print a VString
+ '''
+ __slots__ = ('_value')
+ name = 'strings::VString'
+ enabled = True
+
+ def __init__(self, value):
+ self._value = value
+
+ def to_string(self):
+ b = self._value['_data']
+ b = b.cast(b.type.target().pointer())
+ n = self._value.type.template_argument(0)
+ s = self._value['_special']
+ d = n - s
+ return b.lazy_string(length=d)
diff --git a/src/strings/xstring.py b/src/strings/xstring.py
new file mode 100644
index 0000000..92cb78b
--- /dev/null
+++ b/src/strings/xstring.py
@@ -0,0 +1,18 @@
+class XString(object):
+ ''' print a XString
+ '''
+ __slots__ = ('_value')
+ name = 'strings::XString'
+ enabled = True
+
+ def __init__(self, value):
+ self._value = value
+
+ def children(self):
+ yield 'base', self._value['_base']
+
+ def to_string(self):
+ b = self._value['_b']['_ptr']
+ e = self._value['_e']['_ptr']
+ d = e - b
+ return b.lazy_string(length=d)