mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-20 01:50:24 +08:00
* gdb.python/py-prettyprint.py (_iterator): Remove exception_flag
exception. (_iterator_except): New function. (ArrayPrinter): Use _iterator function instead of local _iterator class for Python 3 compatibility. (NoStringContainerPrinter): Use _iterator_except instead of _iterator. * gdb.python/py-typeprint.exp: Use exec(open(...).read()) instead of execfile for Python 3 compatibility. * gdb.python/python.exp: Handle Python 2.4 exception traceback format in error_prompt test.
This commit is contained in:
@ -1,3 +1,17 @@
|
|||||||
|
2012-12-11 Paul Koning <paul_koning@dell.com>
|
||||||
|
|
||||||
|
* gdb.python/py-prettyprint.py (_iterator): Remove exception_flag
|
||||||
|
exception.
|
||||||
|
(_iterator_except): New function.
|
||||||
|
(ArrayPrinter): Use _iterator function instead of local _iterator
|
||||||
|
class for Python 3 compatibility.
|
||||||
|
(NoStringContainerPrinter): Use _iterator_except instead of
|
||||||
|
_iterator.
|
||||||
|
* gdb.python/py-typeprint.exp: Use exec(open(...).read()) instead of
|
||||||
|
execfile for Python 3 compatibility.
|
||||||
|
* gdb.python/python.exp: Handle Python 2.4 exception traceback
|
||||||
|
format in error_prompt test.
|
||||||
|
|
||||||
2012-12-10 Paul Koning <paul_koning@dell.com>
|
2012-12-10 Paul Koning <paul_koning@dell.com>
|
||||||
|
|
||||||
* gdb.base/charset.exp: Change print syntax for Python 3
|
* gdb.base/charset.exp: Change print syntax for Python 3
|
||||||
|
@ -20,6 +20,14 @@ import re
|
|||||||
import gdb
|
import gdb
|
||||||
|
|
||||||
def _iterator (pointer, len):
|
def _iterator (pointer, len):
|
||||||
|
start = pointer
|
||||||
|
end = pointer + len
|
||||||
|
while pointer != end:
|
||||||
|
yield ('[%d]' % int (pointer - start), pointer.dereference())
|
||||||
|
pointer += 1
|
||||||
|
|
||||||
|
# Same as _iterator but can be told to raise an exception.
|
||||||
|
def _iterator_except (pointer, len):
|
||||||
start = pointer
|
start = pointer
|
||||||
end = pointer + len
|
end = pointer + len
|
||||||
while pointer != end:
|
while pointer != end:
|
||||||
@ -49,23 +57,7 @@ class ContainerPrinter (object):
|
|||||||
return _iterator(self.val['elements'], self.val['len'])
|
return _iterator(self.val['elements'], self.val['len'])
|
||||||
|
|
||||||
# Treats a container as array.
|
# Treats a container as array.
|
||||||
class ArrayPrinter:
|
class ArrayPrinter (object):
|
||||||
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):
|
def __init__(self, val):
|
||||||
self.val = val
|
self.val = val
|
||||||
|
|
||||||
@ -73,7 +65,7 @@ class ArrayPrinter:
|
|||||||
return 'array %s with %d elements' % (self.val['name'], self.val['len'])
|
return 'array %s with %d elements' % (self.val['name'], self.val['len'])
|
||||||
|
|
||||||
def children(self):
|
def children(self):
|
||||||
return self._iterator(self.val['elements'], self.val['len'])
|
return _iterator(self.val['elements'], self.val['len'])
|
||||||
|
|
||||||
def display_hint (self):
|
def display_hint (self):
|
||||||
return 'array'
|
return 'array'
|
||||||
@ -90,7 +82,7 @@ class NoStringContainerPrinter (object):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def children(self):
|
def children(self):
|
||||||
return _iterator(self.val['elements'], self.val['len'])
|
return _iterator_except (self.val['elements'], self.val['len'])
|
||||||
|
|
||||||
class pp_s (object):
|
class pp_s (object):
|
||||||
def __init__(self, val):
|
def __init__(self, val):
|
||||||
|
@ -28,7 +28,7 @@ if { [skip_python_tests] } { continue }
|
|||||||
|
|
||||||
set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py]
|
set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py]
|
||||||
|
|
||||||
gdb_test_no_output "python execfile ('${remote_python_file}')"
|
gdb_test_no_output "python exec (open ('${remote_python_file}').read ())"
|
||||||
|
|
||||||
cp_test_ptype_class s "basic test" "class" "templ<string>" {
|
cp_test_ptype_class s "basic test" "class" "templ<string>" {
|
||||||
{ field public "T x;" }
|
{ field public "T x;" }
|
||||||
|
@ -362,7 +362,7 @@ gdb_py_test_multiple "prompt substitution readline" \
|
|||||||
"end" ""
|
"end" ""
|
||||||
|
|
||||||
gdb_test_multiple "python gdb.prompt_hook = error_prompt" "set the hook" {
|
gdb_test_multiple "python gdb.prompt_hook = error_prompt" "set the hook" {
|
||||||
-re "Python Exception <(type 'exceptions.|class ')RuntimeError'> Python exception called.*" {
|
-re "Python Exception (exceptions.RuntimeError|<(type 'exceptions.|class ')RuntimeError'>) Python exception called.*" {
|
||||||
pass "set hook"
|
pass "set hook"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user