diff options
author | Tom Tromey <tromey@redhat.com> | 2012-12-06 18:59:57 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2012-12-06 18:59:57 +0000 |
commit | 731145cb171b848d564a696e81153166524eb35a (patch) | |
tree | ab76e30954e6d4f133e8795e385d0fe84ecfd2b8 /gdb/testsuite/gdb.python/py-prettyprint.py | |
parent | cd6fa7fd8801453ab5caef588fc772d14cb1ee9a (diff) | |
download | binutils-gdb-731145cb171b848d564a696e81153166524eb35a.tar.gz |
2012-12-06 Jens Elmenthaler <jens.elmenthaler@advantest.com>
PR mi/14741:
* mi/mi-cmd-var.c (varobj_update_one): Take value of
attribute "dynamic" and "displayhint" from printed child,
not the root variable.
* gdb.python/py-mi.exp: Correct expected results for attribute
"dynamic" returned by -var-update.
Add test case for correct handling of "diplayhint" for children
of dynamic varobjs.
* gdb.python/py-prettyprint.c (set_itme): New function.
(bug_14741) New function.
(main) Add call to bug_14741().
* gdb.python/py-prettyprint.py (class ArrayPrinter): New class.
Diffstat (limited to 'gdb/testsuite/gdb.python/py-prettyprint.py')
-rw-r--r-- | gdb/testsuite/gdb.python/py-prettyprint.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.py b/gdb/testsuite/gdb.python/py-prettyprint.py index 6e960e6805d..65a7cabc886 100644 --- a/gdb/testsuite/gdb.python/py-prettyprint.py +++ b/gdb/testsuite/gdb.python/py-prettyprint.py @@ -54,6 +54,36 @@ class ContainerPrinter: def children(self): return self._iterator(self.val['elements'], self.val['len']) +# Treats a container as array. +class ArrayPrinter: + class _iterator: + def __init__ (self, pointer, len): + self.start = pointer + self.pointer = pointer + self.end = pointer + len + + def __iter__(self): + return self + + def next(self): + if self.pointer == self.end: + raise StopIteration + result = self.pointer + self.pointer = self.pointer + 1 + return ('[%d]' % int (result - self.start), result.dereference()) + + def __init__(self, val): + self.val = val + + def to_string(self): + return 'array %s with %d elements' % (self.val['name'], self.val['len']) + + def children(self): + return self._iterator(self.val['elements'], self.val['len']) + + def display_hint (self): + return 'array' + # Flag to make NoStringContainerPrinter throw an exception. exception_flag = False |