2012-12-10 Paul Koning <paul_koning@dell.com>

* gdb.base/charset.exp: Change print syntax for Python 3
	compatibility.
	* gdb.python/py-block.exp: Ditto.
	* gdb.python/py-breakpoint.exp: Ditto.
	* gdb.python/py-cmd.exp: Ditto.
	* gdb.python/py-events.py: Ditto.
	* gdb.python/py-finish-breakpoint.py: Ditto.
	* gdb.python/py-finish-breakpoint2.exp: Ditto.
	* gdb.python/py-finish-breakpoint2.py: Ditto.
	* gdb.python/py-frame-inline.exp: Ditto.
	* gdb.python/py-frame.exp: Ditto.
	* gdb.python/py-infthread.exp: Ditto.
	* gdb.python/py-objfile.exp: Ditto.
	* gdb.python/py-parameter.exp: Ditto.
	* gdb.python/py-progspace.exp: Ditto.
	* gdb.python/py-prompt.exp: Ditto.
	* gdb.python/py-symbol.exp: Ditto.
	* gdb.python/py-symtab.exp: Ditto.
	* gdb.python/py-template.exp: Ditto.
	* gdb.python/py-value-cc.exp: Ditto.
	* gdb.python/python.exp: Ditto.
	* gdb.python/source2.py: Ditto.
	* gdb.python/lib-types.exp: Change print syntax for Python 3
	compatibility.
	Use sorted() function rather than sort() method.
	Accept either int or long values for enum values.
	* gdb.python/py-events.exp: Use exec(open(...).read()) instead of
	execfile for Python 3 compatibility.
	* gdb.python/py-evsignal.exp: Ditto.
	* gdb.python/py-evthreads.exp: Ditto.
	* gdb.python/py-mi.exp: Ditto.
	* gdb.python/py-pp-maint.exp: Ditto.
	* gdb.python/py-prettyprint.exp: Ditto.
	* gdb.python/py-finish-breakpoint.exp: Change print syntax for
	Python 3 compatibility.
	Skip tests for Python 2.4.
	* gdb.python/py-inferior.exp: Change print syntax for
	Python 3 compatibility.
	Use byte string rather than character string in memory write test
	if Python 3.
	* gdb.python/py-pp-maint.py: Change class declarations to "new
	class" syntax.
	* gdb.python/py-prettyprint.py: Change iterator class to generator
	function for Python 3 compatibility.
	Make all classes "new style".
	Fix indentation issue and stray semicolon.
	* gdb.python/py-shared.expChange print syntax for Python 3
	compatibility.
	Define "long" if Python 3.
	* gdb.python/py-type.exp: Change print syntax for Python 3
	compatibility.
	Accept either int or long values for enum values.
	* gdb.python/py-value.exp: Change print syntax for Python 3
	compatibility.
	Skip "long" and "unicode" tests if Python 3.
	Accept either "type" or "class" in type checks.
	* lib/gdb.exp (gdb_py_is_py3k): New flag set if Python 3.
	(gdb_py_is_py24): New flag set if Python 2.4 or 2.5.
This commit is contained in:
Paul Koning 2012-12-10 21:22:21 +00:00
parent c766f7ecdd
commit 9325cb04b5
37 changed files with 677 additions and 595 deletions

View file

@ -19,8 +19,17 @@
import re
import gdb
def _iterator (pointer, len):
start = pointer
end = pointer + len
while pointer != end:
if exception_flag:
raise gdb.MemoryError ('hi bob')
yield ('[%d]' % int (pointer - start), pointer.dereference())
pointer += 1
# Test returning a Value from a printer.
class string_print:
class string_print (object):
def __init__(self, val):
self.val = val
@ -28,22 +37,7 @@ class string_print:
return self.val['whybother']['contents']
# Test a class-based printer.
class ContainerPrinter:
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())
class ContainerPrinter (object):
def __init__(self, val):
self.val = val
@ -52,7 +46,7 @@ class ContainerPrinter:
return 'container %s with %d elements' % (self.val['name'], self.val['len'])
def children(self):
return self._iterator(self.val['elements'], self.val['len'])
return _iterator(self.val['elements'], self.val['len'])
# Treats a container as array.
class ArrayPrinter:
@ -88,25 +82,7 @@ class ArrayPrinter:
exception_flag = False
# Test a printer where to_string is None
class NoStringContainerPrinter:
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
if exception_flag:
raise gdb.MemoryError, 'hi bob'
result = self.pointer
self.pointer = self.pointer + 1
return ('[%d]' % int (result - self.start), result.dereference())
class NoStringContainerPrinter (object):
def __init__(self, val):
self.val = val
@ -114,9 +90,9 @@ class NoStringContainerPrinter:
return None
def children(self):
return self._iterator(self.val['elements'], self.val['len'])
return _iterator(self.val['elements'], self.val['len'])
class pp_s:
class pp_s (object):
def __init__(self, val):
self.val = val
@ -127,42 +103,42 @@ class pp_s:
raise Exception("&a(%s) != b(%s)" % (str(a.address), str(b)))
return " a=<" + str(self.val["a"]) + "> b=<" + str(self.val["b"]) + ">"
class pp_ss:
class pp_ss (object):
def __init__(self, val):
self.val = val
def to_string(self):
return "a=<" + str(self.val["a"]) + "> b=<" + str(self.val["b"]) + ">"
class pp_sss:
class pp_sss (object):
def __init__(self, val):
self.val = val
def to_string(self):
return "a=<" + str(self.val['a']) + "> b=<" + str(self.val["b"]) + ">"
class pp_multiple_virtual:
class pp_multiple_virtual (object):
def __init__ (self, val):
self.val = val
def to_string (self):
return "pp value variable is: " + str (self.val['value'])
class pp_vbase1:
class pp_vbase1 (object):
def __init__ (self, val):
self.val = val
def to_string (self):
return "pp class name: " + self.val.type.tag
class pp_nullstr:
class pp_nullstr (object):
def __init__(self, val):
self.val = val
def to_string(self):
return self.val['s'].string(gdb.target_charset())
class pp_ns:
class pp_ns (object):
"Print a std::basic_string of some kind"
def __init__(self, val):
@ -177,7 +153,7 @@ class pp_ns:
pp_ls_encoding = None
class pp_ls:
class pp_ls (object):
"Print a std::basic_string of some kind"
def __init__(self, val):
@ -192,7 +168,7 @@ class pp_ls:
def display_hint (self):
return 'string'
class pp_hint_error:
class pp_hint_error (object):
"Throw error from display_hint"
def __init__(self, val):
@ -204,7 +180,7 @@ class pp_hint_error:
def display_hint (self):
raise Exception("hint failed")
class pp_children_as_list:
class pp_children_as_list (object):
"Throw error from display_hint"
def __init__(self, val):
@ -216,7 +192,7 @@ class pp_children_as_list:
def children (self):
return [('one', 1)]
class pp_outer:
class pp_outer (object):
"Print struct outer"
def __init__ (self, val):
@ -229,24 +205,24 @@ class pp_outer:
yield 's', self.val['s']
yield 'x', self.val['x']
class MemoryErrorString:
class MemoryErrorString (object):
"Raise an error"
def __init__(self, val):
self.val = val
def to_string(self):
raise gdb.MemoryError ("Cannot access memory.");
raise gdb.MemoryError ("Cannot access memory.")
def display_hint (self):
return 'string'
class pp_eval_type:
class pp_eval_type (object):
def __init__(self, val):
self.val = val
def to_string(self):
gdb.execute("bt", to_string=True)
gdb.execute("bt", to_string=True)
return "eval=<" + str(gdb.parse_and_eval("eval_func (123456789, 2, 3, 4, 5, 6, 7, 8)")) + ">"
def lookup_function (val):