diff options
Diffstat (limited to 'gdb/testsuite/gdb.base/jit.exp')
-rw-r--r-- | gdb/testsuite/gdb.base/jit.exp | 71 |
1 files changed, 63 insertions, 8 deletions
diff --git a/gdb/testsuite/gdb.base/jit.exp b/gdb/testsuite/gdb.base/jit.exp index 3e12301cc6f..da9449b867a 100644 --- a/gdb/testsuite/gdb.base/jit.exp +++ b/gdb/testsuite/gdb.base/jit.exp @@ -66,7 +66,49 @@ proc compile_jit_test {testname binsuffix options} { return 0 } -proc one_jit_test {count match_str} { +# Detach, restart GDB, and re-attach to the program. + +proc clean_reattach {} { + global decimal gdb_prompt srcfile testfile + + # Get PID of test program. + set testpid -1 + set test "get inferior process ID" + gdb_test_multiple "p mypid" $test { + -re ".* = ($decimal).*$gdb_prompt $" { + set testpid $expect_out(1,string) + pass $test + } + } + + gdb_test_no_output "set var wait_for_gdb = 1" + gdb_test "detach" "Detaching from .*" + + clean_restart $testfile + + set test "attach" + gdb_test_multiple "attach $testpid" "$test" { + -re "Attaching to program.*.*main.*at .*$srcfile:.*$gdb_prompt $" { + pass "$test" + } + } + + gdb_test_no_output "set var wait_for_gdb = 0" +} + +# Continue to LOCATION in the program. If REATTACH, detach and +# re-attach to the program from scratch. +proc continue_to_test_location {location reattach} { + gdb_breakpoint [gdb_get_line_number $location] + gdb_continue_to_breakpoint $location + if {$reattach} { + with_test_prefix "$location" { + clean_reattach + } + } +} + +proc one_jit_test {count match_str reattach} { with_test_prefix "one_jit_test-$count" { global verbose testfile solib_binfile_target solib_binfile_test_msg @@ -91,8 +133,7 @@ proc one_jit_test {count match_str} { gdb_test_no_output "set var libname = \"$solib_binfile_target\"" "set var libname = \"$solib_binfile_test_msg\"" gdb_test_no_output "set var count = $count" - gdb_breakpoint [gdb_get_line_number "break here 1"] - gdb_continue_to_breakpoint "break here 1" + continue_to_test_location "break here 1" $reattach gdb_test "info function ^jit_function" "$match_str" @@ -102,8 +143,8 @@ proc one_jit_test {count match_str} { gdb_test "maintenance info break" } - gdb_breakpoint [gdb_get_line_number "break here 2"] - gdb_continue_to_breakpoint "break here 2" + continue_to_test_location "break here 2" $reattach + # All jit librares must have been unregistered gdb_test "info function jit_function" \ "All functions matching regular expression \"jit_function\":" @@ -113,8 +154,22 @@ proc one_jit_test {count match_str} { if {[compile_jit_test jit.exp "" {}] < 0} { return } -one_jit_test 1 "${hex} jit_function_0000" -one_jit_test 2 "${hex} jit_function_0000\[\r\n\]+${hex} jit_function_0001" +one_jit_test 1 "${hex} jit_function_0000" 0 +one_jit_test 2 "${hex} jit_function_0000\[\r\n\]+${hex} jit_function_0001" 0 + +# Test attaching to an inferior with some JIT libraries already +# registered. We reuse the normal test, and detach/reattach at +# specific interesting points. +if {[can_spawn_for_attach]} { + if {[compile_jit_test "jit.exp attach tests" \ + "-attach" {additional_flags=-DATTACH=1}] < 0} { + return + } + + with_test_prefix attach { + one_jit_test 2 "${hex} jit_function_0000\[\r\n\]+${hex} jit_function_0001" 1 + } +} with_test_prefix PIE { if {[compile_jit_test "jit.exp PIE tests" \ @@ -122,5 +177,5 @@ with_test_prefix PIE { return } - one_jit_test 1 "${hex} jit_function_0000" + one_jit_test 1 "${hex} jit_function_0000" 0 } |