| Index: gdb/testsuite/gdb.python/py-inferior.exp
|
| diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp
|
| index b40a514396536c2bd6ca633d6d0fbe772d8b18b8..4c1dba7dc5b5b5d2d165fbfc5c0188b564eb930e 100644
|
| --- a/gdb/testsuite/gdb.python/py-inferior.exp
|
| +++ b/gdb/testsuite/gdb.python/py-inferior.exp
|
| @@ -1,4 +1,4 @@
|
| -# Copyright (C) 2009-2012 Free Software Foundation, Inc.
|
| +# Copyright (C) 2009-2013 Free Software Foundation, Inc.
|
|
|
| # This program is free software; you can redistribute it and/or modify
|
| # it under the terms of the GNU General Public License as published by
|
| @@ -20,7 +20,7 @@ load_lib gdb-python.exp
|
|
|
| standard_testfile
|
|
|
| -if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
|
| +if { [gdb_compile_pthreads ${srcdir}/${subdir}/${srcfile} ${binfile} executable {debug}] != "" } {
|
| return -1
|
| }
|
|
|
| @@ -48,30 +48,44 @@ if ![runto_main] then {
|
| return 0
|
| }
|
|
|
| -runto [gdb_get_line_number "Break here."]
|
| -
|
| # Test basic gdb.Inferior attributes and methods.
|
|
|
| gdb_py_test_silent_cmd "python inferiors = gdb.inferiors ()" "get inferiors list" 1
|
| -gdb_test "python print inferiors" "\\(<gdb.Inferior object at 0x\[\[:xdigit:\]\]+>,\\)" "verify inferiors list"
|
| +gdb_test "python print (inferiors)" "\\(<gdb.Inferior object at 0x\[\[:xdigit:\]\]+>,\\)" "verify inferiors list"
|
| gdb_py_test_silent_cmd "python i0 = inferiors\[0\]" "get first inferior" 0
|
|
|
| -gdb_test "python print 'result =', i0 == inferiors\[0\]" " = True" "test equality comparison (true)"
|
| -gdb_test "python print 'result =', i0.num" " = \[0-9\]+" "test Inferior.num"
|
| -gdb_test "python print 'result =', i0.pid" " = \[0-9\]+" "test Inferior.pid"
|
| -gdb_test "python print 'result =', i0.was_attached" " = False" "test Inferior.was_attached"
|
| -gdb_test "python print i0.threads ()" "\\(<gdb.InferiorThread object at 0x\[\[:xdigit:\]\]+>,\\)" "test Inferior.threads"
|
| +gdb_test "python print ('result = %s' % (i0 == inferiors\[0\]))" " = True" "test equality comparison (true)"
|
| +gdb_test "python print ('result = %s' % i0.num)" " = \[0-9\]+" "test Inferior.num"
|
| +gdb_test "python print ('result = %s' % i0.pid)" " = \[0-9\]+" "test Inferior.pid"
|
| +gdb_test "python print ('result = %s' % i0.was_attached)" " = False" "test Inferior.was_attached"
|
| +gdb_test "python print (i0.threads ())" "\\(<gdb.InferiorThread object at 0x\[\[:xdigit:\]\]+>,\\)" "test Inferior.threads"
|
| +
|
| +# Test the number of inferior threads.
|
| +
|
| +gdb_breakpoint check_threads
|
| +gdb_continue_to_breakpoint "cont to check_threads" ".*pthread_barrier_wait.*"
|
| +gdb_test "python print (len (i0.threads ()))" "\r\n9" "test Inferior.threads 2"
|
| +
|
| +# Proceed to the next test.
|
| +
|
| +gdb_breakpoint [gdb_get_line_number "Break here."]
|
| +gdb_continue_to_breakpoint "cont to Break here." ".*Break here\..*"
|
|
|
| # Test memory read and write operations.
|
|
|
| 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)" \
|
| +gdb_py_test_silent_cmd "python str = gdb.inferiors()\[0\].read_memory (addr, 5); print(str)" \
|
| "read str contents" 1
|
| -gdb_py_test_silent_cmd "python str\[1\] = 'a'" "change str" 0
|
| +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 str\[1\] = a" "change str" 0
|
| gdb_py_test_silent_cmd "python gdb.inferiors()\[0\].write_memory (addr, str)" \
|
| "write str" 1
|
| -gdb_test "print str" " = \"hallo, testsuite\"" \
|
| +gdb_test "print (str)" " = \"hallo, testsuite\"" \
|
| "ensure str was changed in the inferior"
|
|
|
| # Test memory search.
|
| @@ -90,18 +104,18 @@ gdb_test "py search_buf = gdb.selected_frame ().read_var ('int8_search_buf')" ""
|
| gdb_test_no_output "py start_addr = search_buf.address"
|
| gdb_test_no_output "py length = search_buf.type.sizeof"
|
|
|
| -gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length, 'aaa')" \
|
| +gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, length, 'aaa'))" \
|
| "${one_pattern_found}" "find string pattern"
|
|
|
| # Test not finding pattern because search range too small, with
|
| # potential find at the edge of the range.
|
|
|
| -gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, 10+3, 'aaaa')" \
|
| +gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, 10+3, 'aaaa'))" \
|
| "${pattern_not_found}" "pattern not found at end of range"
|
|
|
| # Increase the search range by 1 and we should find the pattern.
|
|
|
| -gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, 10+3+1, 'aaa')" \
|
| +gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, 10+3+1, 'aaa'))" \
|
| "${one_pattern_found}" "pattern found at end of range"
|
|
|
| # Import struct to pack the following patterns.
|
| @@ -115,7 +129,7 @@ gdb_test_no_output "py start_addr = search_buf.address"
|
| gdb_test_no_output "py length = search_buf.type.sizeof"
|
| gdb_test_no_output "py pattern = pack('${python_pack_char}H',0x1234)"
|
|
|
| -gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length, pattern)" \
|
| +gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, length, pattern))" \
|
| "${one_pattern_found}" "find 16-bit pattern, with value pattern"
|
|
|
| # Test 32-bit pattern.
|
| @@ -126,7 +140,7 @@ gdb_test_no_output "py start_addr = search_buf.address"
|
| gdb_test_no_output "py length = search_buf.type.sizeof"
|
| gdb_test_no_output "py pattern = pack('${python_pack_char}I',0x12345678)"
|
|
|
| -gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length, pattern)" \
|
| +gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, length, pattern))" \
|
| "${one_pattern_found}" "find 32-bit pattern, with python pattern"
|
|
|
| # Test 64-bit pattern.
|
| @@ -137,7 +151,7 @@ gdb_test_no_output "py start_addr = search_buf.address"
|
| gdb_test_no_output "py length = search_buf.type.sizeof"
|
| gdb_test_no_output "py pattern = pack('${python_pack_char}Q', 0xfedcba9876543210)"
|
|
|
| -gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length, pattern)" \
|
| +gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, length, pattern))" \
|
| "${one_pattern_found}" "find 64-bit pattern, with value pattern"
|
|
|
| # Test mixed-sized patterns.
|
| @@ -151,18 +165,18 @@ gdb_test_no_output "py pattern1 = pack('B', 0x62)"
|
| gdb_test_no_output "py pattern2 = pack('${python_pack_char}H', 0x6363)"
|
| gdb_test_no_output "py pattern3 = pack('${python_pack_char}I', 0x64646464)"
|
|
|
| -gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, 100, pattern1)" \
|
| +gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, 100, pattern1))" \
|
| "${one_pattern_found}" "find mixed-sized pattern"
|
| -gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, 100, pattern2)" \
|
| +gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, 100, pattern2))" \
|
| "${one_pattern_found}" "find mixed-sized pattern"
|
| -gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, 100, pattern3)" \
|
| +gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, 100, pattern3))" \
|
| "${one_pattern_found}" "find mixed-sized pattern"
|
|
|
| # Test search spanning a large range, in the particular case of native
|
| # targets, test the search spanning multiple chunks.
|
| # Remote targets may implement the search differently.
|
|
|
| -set CHUNK_SIZE 16000 ;
|
| +set CHUNK_SIZE 16000
|
|
|
| gdb_test_no_output "set *(int32_t*) &search_buf\[0*${CHUNK_SIZE}+100\] = 0x12345678"
|
| gdb_test_no_output "set *(int32_t*) &search_buf\[1*${CHUNK_SIZE}+100\] = 0x12345678"
|
| @@ -170,13 +184,13 @@ gdb_test_no_output "py start_addr = gdb.selected_frame ().read_var ('search_buf'
|
| gdb_test_no_output "py end_addr = start_addr + gdb.selected_frame ().read_var ('search_buf_size')"
|
| gdb_test_no_output "py pattern = pack('${python_pack_char}I', 0x12345678)"
|
| gdb_test_no_output "py first = gdb.inferiors()\[0\].search_memory (start_addr,end_addr - start_addr, pattern)"
|
| -gdb_test "py print first" "${one_pattern_found}" "search spanning large range 1st result"
|
| +gdb_test "py print (first)" "${one_pattern_found}" "search spanning large range 1st result"
|
| gdb_test_no_output "py start_addr = first + 1"
|
| gdb_test_no_output "py second = gdb.inferiors()\[0\].search_memory (start_addr, end_addr - start_addr, pattern)"
|
| -gdb_test "py print second" "${one_pattern_found}" "search spanning large range 2nd result"
|
| +gdb_test "py print (second)" "${one_pattern_found}" "search spanning large range 2nd result"
|
| gdb_test_no_output "py start_addr = second + 1"
|
| gdb_test_no_output "py third = gdb.inferiors()\[0\].search_memory (start_addr, end_addr - start_addr, pattern)"
|
| -gdb_test "py print third" "${pattern_not_found}" "search spanning large range 3rd result"
|
| +gdb_test "py print (third)" "${pattern_not_found}" "search spanning large range 3rd result"
|
|
|
| # For native targets, test a pattern straddling a chunk boundary.
|
|
|
| @@ -184,7 +198,7 @@ if [isnative] {
|
| gdb_test_no_output "set *(int32_t*) &search_buf\[${CHUNK_SIZE}-1\] = 0xfdb97531"
|
| gdb_test_no_output "py pattern = pack('${python_pack_char}I', 0xfdb97531)"
|
| gdb_test_no_output "py start_addr = gdb.selected_frame ().read_var ('search_buf')"
|
| - gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, end_addr - start_addr, pattern)" \
|
| + gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, end_addr - start_addr, pattern))" \
|
| "${one_pattern_found}" "find pattern straddling chunk boundary"
|
| }
|
|
|
| @@ -192,28 +206,28 @@ if [isnative] {
|
| # this testcase as it kills the inferior.
|
|
|
| gdb_py_test_silent_cmd "python inf_list = gdb.inferiors()" "get initial list" 1
|
| -gdb_test "python print len(inf_list)" "1" "Get inferior list length"
|
| -gdb_test "python print inf_list\[0\].is_valid()" "True" \
|
| +gdb_test "python print (len(inf_list))" "1" "Get inferior list length"
|
| +gdb_test "python print (inf_list\[0\].is_valid())" "True" \
|
| "Check inferior validity"
|
| gdb_test "add-inferior" "Added inferior 2.*" "add empty inferior 2"
|
| gdb_py_test_silent_cmd "python inf_list = gdb.inferiors()" "get new list" 1
|
| -gdb_test "python print len(inf_list)" "2" "Get inferior list length"
|
| -gdb_test "python print inf_list\[0\].is_valid()" "True" \
|
| +gdb_test "python print (len(inf_list))" "2" "Get inferior list length"
|
| +gdb_test "python print (inf_list\[0\].is_valid())" "True" \
|
| "Check inferior validity"
|
| -gdb_test "python print inf_list\[1\].is_valid()" "True" \
|
| +gdb_test "python print (inf_list\[1\].is_valid())" "True" \
|
| "Check inferior validity"
|
| gdb_test_no_output "remove-inferiors 2" "remove-inferiors 3"
|
| -gdb_test "python print inf_list\[0\].is_valid()" "False" \
|
| +gdb_test "python print (inf_list\[0\].is_valid())" "False" \
|
| "Check inferior validity"
|
| -gdb_test "python print inf_list\[1\].is_valid()" "True" \
|
| +gdb_test "python print (inf_list\[1\].is_valid())" "True" \
|
| "Check inferior validity"
|
|
|
| # Test gdb.selected_inferior()
|
| gdb_test "inferior 1" ".*" "Switch to first inferior"
|
| -gdb_test "py print gdb.selected_inferior().num" "1" "First inferior selected"
|
| +gdb_test "py print (gdb.selected_inferior().num)" "1" "First inferior selected"
|
|
|
| gdb_test "add-inferior" "Added inferior 3" "Create new inferior"
|
| gdb_test "inferior 3" ".*" "Switch to third inferior"
|
| -gdb_test "py print gdb.selected_inferior().num" "3" "Third inferior selected"
|
| +gdb_test "py print (gdb.selected_inferior().num)" "3" "Third inferior selected"
|
| gdb_test "inferior 1" ".*" "Switch to first inferior"
|
| gdb_test_no_output "remove-inferiors 3" "Remove second inferior"
|
|
|