diff options
Diffstat (limited to 'gdb/testsuite/gdb.python')
-rw-r--r-- | gdb/testsuite/gdb.python/py-inferior.exp | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-mi-var-info-path-expression.py | 12 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-record-btrace.exp | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-send-packet.py | 58 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-shared.exp | 7 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-value.exp | 40 |
6 files changed, 28 insertions, 101 deletions
diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp index aa78a15..552f9b1 100644 --- a/gdb/testsuite/gdb.python/py-inferior.exp +++ b/gdb/testsuite/gdb.python/py-inferior.exp @@ -77,11 +77,7 @@ gdb_py_test_silent_cmd "python addr = gdb.selected_frame ().read_var ('str')" \ "read str address" 0 gdb_py_test_silent_cmd "python str = gdb.inferiors()\[0\].read_memory (addr, 5); print(str)" \ "read str contents" 1 -if { $gdb_py_is_py3k == 0 } { - gdb_py_test_silent_cmd "python a = 'a'" "" 0 -} else { - gdb_py_test_silent_cmd "python a = bytes('a', 'ascii')" "" 0 -} +gdb_py_test_silent_cmd "python a = bytes('a', 'ascii')" "" 0 gdb_py_test_silent_cmd "python str\[1\] = a" "change str" 0 gdb_py_test_silent_cmd "python gdb.inferiors()\[0\].write_memory (addr, str)" \ "write str" 1 diff --git a/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.py b/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.py index dfc2ebd..035478f 100644 --- a/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.py +++ b/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.py @@ -17,27 +17,23 @@ import sys import gdb import gdb.types -# Following is for Python 3 compatibility... -if sys.version_info[0] > 2: - long = int - class cons_pp(object): def __init__(self, val): self._val = val def to_string(self): - if long(self._val) == 0: + if int(self._val) == 0: return "nil" - elif long(self._val["type"]) == 0: + elif int(self._val["type"]) == 0: return "( . )" else: return "%d" % self._val["atom"]["ival"] def children(self): - if long(self._val) == 0: + if int(self._val) == 0: return [] - elif long(self._val["type"]) == 0: + elif int(self._val["type"]) == 0: return [("atom", self._val["atom"])] else: return [ diff --git a/gdb/testsuite/gdb.python/py-record-btrace.exp b/gdb/testsuite/gdb.python/py-record-btrace.exp index 8204577..e9fdd06 100644 --- a/gdb/testsuite/gdb.python/py-record-btrace.exp +++ b/gdb/testsuite/gdb.python/py-record-btrace.exp @@ -85,11 +85,7 @@ with_test_prefix "instruction " { gdb_test "python print(i.number)" "1" gdb_test "python print(i.sal)" "symbol and line for .*" gdb_test "python print(i.pc)" "$decimal" - if { $gdb_py_is_py3k == 0 } { - gdb_test "python print(repr(i.data))" "<read-only buffer for $hex,.*>" - } else { - gdb_test "python print(repr(i.data))" "<memory at $hex>" - } + gdb_test "python print(repr(i.data))" "<memory at $hex>" gdb_test "python print(i.decoded)" ".*" gdb_test "python print(i.size)" "$decimal" gdb_test "python print(i.is_speculative)" "False" diff --git a/gdb/testsuite/gdb.python/py-send-packet.py b/gdb/testsuite/gdb.python/py-send-packet.py index 4966688..a6adc82 100644 --- a/gdb/testsuite/gdb.python/py-send-packet.py +++ b/gdb/testsuite/gdb.python/py-send-packet.py @@ -81,17 +81,9 @@ def run_send_packet_test(): # the 'maint packet' command so that the output from the two sources # can be compared. def bytes_to_string(byte_array): - - # Python 2/3 compatibility. We need a function that can give us - # the value of a single element in BYTE_ARRAY as an integer. - if sys.version_info[0] > 2: - value_of_single_byte = int - else: - value_of_single_byte = ord - res = "" for b in byte_array: - b = value_of_single_byte(b) + b = int(b) if b >= 32 and b <= 126: res = res + ("%c" % b) else: @@ -136,39 +128,23 @@ def run_set_global_var_test(): res = conn.send_packet(b"X%x,4:\x02\x02\x02\x02" % addr) assert isinstance(res, bytes) check_global_var(0x02020202) - if sys.version_info[0] > 2: - # On Python 3 this first attempt will not work as we're - # passing a Unicode string containing non-ascii characters. - saw_error = False - try: - res = conn.send_packet("X%x,4:\xff\xff\xff\xff" % addr) - except UnicodeError: - saw_error = True - except: - assert False - assert saw_error - check_global_var(0x02020202) - # Now we pass a bytes object, which will work. - res = conn.send_packet(b"X%x,4:\xff\xff\xff\xff" % addr) - check_global_var(0xFFFFFFFF) - else: - # On Python 2 we need to force the creation of a Unicode - # string, but, with that done, we expect to see the same error - # as on Python 3; the unicode string contains non-ascii - # characters. - saw_error = False - try: - res = conn.send_packet(unicode("X%x,4:\xff\xff\xff\xff") % addr) - except UnicodeError: - saw_error = True - except: - assert False - assert saw_error - check_global_var(0x02020202) - # Now we pass a plain string, which, on Python 2, is the same - # as a bytes object, this, we expect to work. + + # This first attempt will not work as we're passing a Unicode string + # containing non-ascii characters. + saw_error = False + try: res = conn.send_packet("X%x,4:\xff\xff\xff\xff" % addr) - check_global_var(0xFFFFFFFF) + except UnicodeError: + saw_error = True + except: + assert False + + assert saw_error + check_global_var(0x02020202) + # Now we pass a bytes object, which will work. + res = conn.send_packet(b"X%x,4:\xff\xff\xff\xff" % addr) + check_global_var(0xFFFFFFFF) + print("set global_var test passed") diff --git a/gdb/testsuite/gdb.python/py-shared.exp b/gdb/testsuite/gdb.python/py-shared.exp index 61c057a..2d33902 100644 --- a/gdb/testsuite/gdb.python/py-shared.exp +++ b/gdb/testsuite/gdb.python/py-shared.exp @@ -57,14 +57,11 @@ runto [gdb_get_line_number "Break to end."] # Test gdb.solib_name gdb_test "p &func1" "" "func1 address" gdb_py_test_silent_cmd "python func1 = gdb.history(0)" "Aquire func1 address" 1 -if { $gdb_py_is_py3k == 1 } { - gdb_py_test_silent_cmd "python long = int" "" 0 -} -gdb_test "python print (gdb.solib_name(long(func1)))" "py-shared-sl.sl" "test func1 solib location" +gdb_test "python print (gdb.solib_name(int(func1)))" "py-shared-sl.sl" "test func1 solib location" gdb_test "p &main" "" "main address" gdb_py_test_silent_cmd "python main = gdb.history(0)" "Aquire main address" 1 -gdb_test "python print (gdb.solib_name(long(main)))" "None" "test main solib location" +gdb_test "python print (gdb.solib_name(int(main)))" "None" "test main solib location" if {[is_lp64_target]} { gdb_test "python print (len(\[gdb.solib_name(0xffffffffffffffff)\]))" "1" diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp index 60039c9..5d77b0c 100644 --- a/gdb/testsuite/gdb.python/py-value.exp +++ b/gdb/testsuite/gdb.python/py-value.exp @@ -47,33 +47,19 @@ proc build_inferior {exefile lang} { proc test_value_creation {} { global gdb_prompt - global gdb_py_is_py3k gdb_py_test_silent_cmd "python i = gdb.Value (True)" "create boolean value" 1 gdb_py_test_silent_cmd "python i = gdb.Value (5)" "create integer value" 1 gdb_py_test_silent_cmd "python i = gdb.Value (3,None)" "create integer value, with None type" 1 - if { $gdb_py_is_py3k == 0 } { - gdb_py_test_silent_cmd "python i = gdb.Value (5L)" "create long value" 1 - } gdb_py_test_silent_cmd "python l = gdb.Value(0xffffffff12345678)" "create large unsigned 64-bit value" 1 - if { $gdb_py_is_py3k == 0 } { - gdb_test "python print long(l)" "18446744069720004216" "large unsigned 64-bit int conversion to python" - } else { - gdb_test "python print (int(l))" "18446744069720004216" "large unsigned 64-bit int conversion to python" - } + gdb_test "python print (int(l))" "18446744069720004216" "large unsigned 64-bit int conversion to python" gdb_py_test_silent_cmd "python f = gdb.Value (1.25)" "create double value" 1 gdb_py_test_silent_cmd "python a = gdb.Value ('string test')" "create 8-bit string value" 1 gdb_test "python print (a)" "\"string test\"" "print 8-bit string" gdb_test "python print (a.__class__)" "<(type|class) 'gdb.Value'>" "verify type of 8-bit string" - if { $gdb_py_is_py3k == 0 } { - gdb_py_test_silent_cmd "python a = gdb.Value (u'unicode test')" "create unicode value" 1 - gdb_test "python print (a)" "\"unicode test\"" "print Unicode string" - gdb_test "python print (a.__class__)" "<(type|class) 'gdb.Value'>" "verify type of unicode string" - } - # Test address attribute is None in a non-addressable value gdb_test "python print ('result = %s' % i.address)" "= None" "test address attribute in non-addressable value" } @@ -92,7 +78,6 @@ proc test_value_reinit {} { proc test_value_numeric_ops {} { global gdb_prompt - global gdb_py_is_py3k gdb_py_test_silent_cmd "python i = gdb.Value (5)" "create first integer value" 0 gdb_py_test_silent_cmd "python j = gdb.Value (2)" "create second integer value" 0 @@ -144,9 +129,6 @@ proc test_value_numeric_ops {} { gdb_test_no_output "python b = gdb.history (0)" "" gdb_test "python print(int(b))" "5" "convert pointer to int" - if {!$gdb_py_is_py3k} { - gdb_test "python print(long(b))" "5" "convert pointer to long" - } gdb_test "python print ('result = ' + str(a+5))" " = 0x7( <.*>)?" "add pointer value with python integer" gdb_test "python print ('result = ' + str(b-2))" " = 0x3( <.*>)?" "subtract python integer from pointer value" @@ -156,17 +138,11 @@ proc test_value_numeric_ops {} { "result = r" "use value as string index" gdb_test "python print ('result = ' + str((1,2,3)\[gdb.Value(0)\]))" \ "result = 1" "use value as tuple index" - if {!$gdb_py_is_py3k} { - gdb_test "python print ('result = ' + str(\[1,2,3\]\[gdb.Value(0)\]))" \ - "result = 1" "use value as array index" - } + gdb_test "python print ('result = ' + str(\[1,2,3\]\[gdb.Value(0)\]))" \ + "result = 1" "use value as array index" gdb_test "python print('%x' % int(gdb.parse_and_eval('-1ull')))" \ "f+" "int conversion respect type sign" - if {!$gdb_py_is_py3k} { - gdb_test "python print('%x' % long(gdb.parse_and_eval('-1ull')))" \ - "f+" "long conversion respect type sign" - } # Test some invalid operations. @@ -242,7 +218,6 @@ proc test_value_compare {} { proc test_value_in_inferior {} { global gdb_prompt global testfile - global gdb_py_is_py3k gdb_breakpoint [gdb_get_line_number "break to inspect struct and union"] gdb_continue_to_breakpoint "break to inspect struct and union" @@ -253,9 +228,6 @@ proc test_value_in_inferior {} { gdb_py_test_silent_cmd "python s = gdb.history (0)" "get value s from history" 1 gdb_test "python print ('result = ' + str(s\['a'\]))" " = 3" "access element inside struct using 8-bit string name" - if { $gdb_py_is_py3k == 0 } { - gdb_test "python print ('result = ' + str(s\[u'a'\]))" " = 3" "access element inside struct using unicode name" - } # Test dereferencing the argv pointer @@ -533,13 +505,8 @@ proc test_value_hash {} { } proc test_float_conversion {} { - global gdb_py_is_py3k gdb_test "python print(int(gdb.Value(0)))" "0" gdb_test "python print(int(gdb.Value(2.5)))" "2" - if {!$gdb_py_is_py3k} { - gdb_test "python print(long(gdb.Value(0)))" "0" - gdb_test "python print(long(gdb.Value(2.5)))" "2" - } gdb_test "python print(float(gdb.Value(2.5)))" "2\\.5" gdb_test "python print(float(gdb.Value(0)))" "0\\.0" } @@ -565,7 +532,6 @@ proc prepare_type_and_buffer {} { proc test_value_from_buffer {} { global gdb_prompt - global gdb_py_is_py3k prepare_type_and_buffer gdb_test "python v=gdb.Value(b,tp); print(v)" "1" \ |