diff options
author | Yao Qi <yao@codesourcery.com> | 2013-03-15 01:41:29 +0000 |
---|---|---|
committer | Yao Qi <yao@codesourcery.com> | 2013-03-15 01:41:29 +0000 |
commit | 0a251e08fa4e7130f05462ecc9f60e6683cdefca (patch) | |
tree | c79ccfc1f502d7e7d48c54b67720381603201b98 | |
parent | 2c415c0f382fd6361d9d702ebdd71cd6d6a06d19 (diff) | |
download | gdb-0a251e08fa4e7130f05462ecc9f60e6683cdefca.zip gdb-0a251e08fa4e7130f05462ecc9f60e6683cdefca.tar.gz gdb-0a251e08fa4e7130f05462ecc9f60e6683cdefca.tar.bz2 |
gdb/testsuite/
* gdb.threads/non-ldr-exc-1.exp (do_test): Fix the indent of
using with_test_prefix.
* gdb.threads/non-ldr-exc-2.exp (do_test): Likewise.
* gdb.threads/non-ldr-exc-3.exp (do_test): Likewise.
* gdb.threads/non-ldr-exc-4.exp (do_test): Likewise.
* gdb.threads/watchpoint-fork.exp (test): Likewise.
* gdb.base/break-interp.exp (test_core): Likewise.
(test_attach_gdb): Likewise.
* gdb.base/catch-load.exp (one_catch_load_test): Likewise.
* gdb.base/disp-step-syscall.exp (disp_step_cross_syscall):
Likewise.
* gdb.base/jit-so.exp (one_jit_test): Likewise.
* gdb.base/jit.exp (one_jit_test): Likewise.
* gdb.base/sepdebug.exp (test_different_dir): Likewise.
* gdb.dwarf2/dw2-dir-file-name.exp (test): Likewise.
* gdb.dwarf2/dw2-noloc.exp (file_symbols): Likewise.
* gdb.mi/mi-breakpoint-changed.exp (test_pending_resolved):
Likewise.
* gdb.mi/mi-cmd-param-changed.exp (test_command_param_changed):
Likewise.
* gdb.mi/mi-watch.exp test_watchpoint_all): Likewise.
* gdb.mi/pr11022.exp (test_memory_changed_observer): Likewise.
* gdb.trace/change-loc.exp (tracepoint_change_loc_1): Likewise.
(tracepoint_change_loc_2): Likewise.
* gdb.trace/disconnected-tracing.exp (disconnected_tracing):
Likewise.
(disconnected_tfind): Likewise.
* gdb.trace/mi-traceframe-changed.exp (test_tfind_tfile):
Likewise.
(test_tfind_remote): Likewise.
* gdb.trace/mi-tracepoint-changed.exp (test_reconnect):
Likewise.
(test_pending_resolved): Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv):
Likewise.
(test_upload_tsv): Likewise.
* gdb.trace/pending.exp (pending_tracepoint_resolved):
Likewise.
(pending_tracepoint_works): Likewise.
* gdb.trace/report.exp (use_collected_data): Likewise.
* gdb.trace/status-stop.exp (test_tstart_tstop_tstart):
Likewise.
(test_tstart_tstart, test_buffer_full_tstart): Likewise.
* gdb.trace/strace.exp (strace_info_marker): Likewise.
(strace_trace_on_same_addr): Likewise.
(strace_trace_on_diff_addr): Likewise.
* gdb.trace/unavailable.exp (gdb_collect_args_test): Likewise.
(gdb_collect_locals_test): Likewise.
(gdb_unavailable_registers_test): Likewise.
(gdb_collect_globals_test): Likewise.
28 files changed, 2409 insertions, 2245 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 2b86ab0..2cf7345 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,58 @@ 2013-03-15 Yao Qi <yao@codesourcery.com> + * gdb.threads/non-ldr-exc-1.exp (do_test): Fix the indent of + using with_test_prefix. + * gdb.threads/non-ldr-exc-2.exp (do_test): Likewise. + * gdb.threads/non-ldr-exc-3.exp (do_test): Likewise. + * gdb.threads/non-ldr-exc-4.exp (do_test): Likewise. + * gdb.threads/watchpoint-fork.exp (test): Likewise. + * gdb.base/break-interp.exp (test_core): Likewise. + (test_attach_gdb): Likewise. + * gdb.base/catch-load.exp (one_catch_load_test): Likewise. + * gdb.base/disp-step-syscall.exp (disp_step_cross_syscall): + Likewise. + * gdb.base/jit-so.exp (one_jit_test): Likewise. + * gdb.base/jit.exp (one_jit_test): Likewise. + * gdb.base/sepdebug.exp (test_different_dir): Likewise. + * gdb.dwarf2/dw2-dir-file-name.exp (test): Likewise. + * gdb.dwarf2/dw2-noloc.exp (file_symbols): Likewise. + * gdb.mi/mi-breakpoint-changed.exp (test_pending_resolved): + Likewise. + * gdb.mi/mi-cmd-param-changed.exp (test_command_param_changed): + Likewise. + * gdb.mi/mi-watch.exp test_watchpoint_all): Likewise. + * gdb.mi/pr11022.exp (test_memory_changed_observer): Likewise. + * gdb.trace/change-loc.exp (tracepoint_change_loc_1): Likewise. + (tracepoint_change_loc_2): Likewise. + * gdb.trace/disconnected-tracing.exp (disconnected_tracing): + Likewise. + (disconnected_tfind): Likewise. + * gdb.trace/mi-traceframe-changed.exp (test_tfind_tfile): + Likewise. + (test_tfind_remote): Likewise. + * gdb.trace/mi-tracepoint-changed.exp (test_reconnect): + Likewise. + (test_pending_resolved): Likewise. + * gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): + Likewise. + (test_upload_tsv): Likewise. + * gdb.trace/pending.exp (pending_tracepoint_resolved): + Likewise. + (pending_tracepoint_works): Likewise. + * gdb.trace/report.exp (use_collected_data): Likewise. + * gdb.trace/status-stop.exp (test_tstart_tstop_tstart): + Likewise. + (test_tstart_tstart, test_buffer_full_tstart): Likewise. + * gdb.trace/strace.exp (strace_info_marker): Likewise. + (strace_trace_on_same_addr): Likewise. + (strace_trace_on_diff_addr): Likewise. + * gdb.trace/unavailable.exp (gdb_collect_args_test): Likewise. + (gdb_collect_locals_test): Likewise. + (gdb_unavailable_registers_test): Likewise. + (gdb_collect_globals_test): Likewise. + +2013-03-15 Yao Qi <yao@codesourcery.com> + * gdb.base/condbreak.exp: Add semicolon back which was removed by my previous commit. diff --git a/gdb/testsuite/gdb.base/break-interp.exp b/gdb/testsuite/gdb.base/break-interp.exp index 7a8a1f6..1010afa 100644 --- a/gdb/testsuite/gdb.base/break-interp.exp +++ b/gdb/testsuite/gdb.base/break-interp.exp @@ -190,103 +190,107 @@ proc reach {func command displacement} { } } -proc test_core {file displacement} { with_test_prefix "core" { - global srcdir subdir gdb_prompt expect_out +proc test_core {file displacement} { + with_test_prefix "core" { + global srcdir subdir gdb_prompt expect_out - set corefile [core_find $file {} "segv"] - if {$corefile == ""} { - return - } + set corefile [core_find $file {} "segv"] + if {$corefile == ""} { + return + } - gdb_exit - gdb_start - # Clear it to never find any separate debug infos in $debug_root. - gdb_test_no_output "set debug-file-directory" \ - "set debug-file-directory for core" - gdb_reinitialize_dir $srcdir/$subdir - gdb_load $file + gdb_exit + gdb_start + # Clear it to never find any separate debug infos in $debug_root. + gdb_test_no_output "set debug-file-directory" \ + "set debug-file-directory for core" + gdb_reinitialize_dir $srcdir/$subdir + gdb_load $file - # Print the "PIE (Position Independent Executable) displacement" message. - gdb_test_no_output "set verbose on" + # Print the "PIE (Position Independent Executable) displacement" message. + gdb_test_no_output "set verbose on" - set test "core loaded" - set test_displacement "seen displacement message as $displacement" - gdb_test_multiple "core-file $corefile" $test { - -re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " { - # Missing "$gdb_prompt $" is intentional. - if {$expect_out(1,string) == "0x0"} { - set case "ZERO" - } else { - set case "NONZERO" + set test "core loaded" + set test_displacement "seen displacement message as $displacement" + gdb_test_multiple "core-file $corefile" $test { + -re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " { + # Missing "$gdb_prompt $" is intentional. + if {$expect_out(1,string) == "0x0"} { + set case "ZERO" + } else { + set case "NONZERO" + } + if {$displacement == $case || $displacement == "PRESENT"} { + pass $test_displacement + set displacement "FOUND-$displacement" + } else { + fail $test_displacement + } + exp_continue } - if {$displacement == $case || $displacement == "PRESENT"} { - pass $test_displacement - set displacement "FOUND-$displacement" - } else { - fail $test_displacement + -re "Core was generated by .*\r\n#0 .*$gdb_prompt $" { + # Do not check the binary filename as it may be truncated. + pass $test } - exp_continue } - -re "Core was generated by .*\r\n#0 .*$gdb_prompt $" { - # Do not check the binary filename as it may be truncated. - pass $test + if ![regexp {^(NONE|FOUND-.*)$} $displacement] { + fail $test_displacement } + + gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "core main bt" } - if ![regexp {^(NONE|FOUND-.*)$} $displacement] { - fail $test_displacement - } +} - gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "core main bt" -}} +proc test_attach_gdb {file pid displacement prefix} { + with_test_prefix "$prefix" { + global gdb_prompt expect_out -proc test_attach_gdb {file pid displacement prefix} { with_test_prefix "$prefix" { - global gdb_prompt expect_out - - gdb_exit - gdb_start + gdb_exit + gdb_start - # Print the "PIE (Position Independent Executable) displacement" message. - gdb_test_no_output "set verbose on" + # Print the "PIE (Position Independent Executable) displacement" message. + gdb_test_no_output "set verbose on" - gdb_test "file $file" "Reading symbols from .*done\\." "file" + gdb_test "file $file" "Reading symbols from .*done\\." "file" - set test "attach" - gdb_test_multiple "attach $pid" $test { - -re "Attaching to (program: .*, )?process $pid\r\n" { - # Missing "$gdb_prompt $" is intentional. - pass $test + set test "attach" + gdb_test_multiple "attach $pid" $test { + -re "Attaching to (program: .*, )?process $pid\r\n" { + # Missing "$gdb_prompt $" is intentional. + pass $test + } } - } - set test "attach final prompt" - set test_displacement "seen displacement message as $displacement" - gdb_test_multiple "" $test { - -re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " { - # Missing "$gdb_prompt $" is intentional. - if {$expect_out(1,string) == "0x0"} { - set case "ZERO" - } else { - set case "NONZERO" + set test "attach final prompt" + set test_displacement "seen displacement message as $displacement" + gdb_test_multiple "" $test { + -re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " { + # Missing "$gdb_prompt $" is intentional. + if {$expect_out(1,string) == "0x0"} { + set case "ZERO" + } else { + set case "NONZERO" + } + if {$displacement == $case || $displacement == "PRESENT"} { + pass $test_displacement + set displacement "FOUND-$displacement" + } else { + fail $test_displacement + } + exp_continue } - if {$displacement == $case || $displacement == "PRESENT"} { - pass $test_displacement - set displacement "FOUND-$displacement" - } else { - fail $test_displacement + -re "$gdb_prompt $" { + pass $test } - exp_continue } - -re "$gdb_prompt $" { - pass $test + if ![regexp {^(NONE|FOUND-.*)$} $displacement] { + fail $test_displacement } - } - if ![regexp {^(NONE|FOUND-.*)$} $displacement] { - fail $test_displacement - } - gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "attach main bt" - gdb_exit -}} + gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "attach main bt" + gdb_exit + } +} proc test_attach {file displacement {relink_args ""}} { global board_info diff --git a/gdb/testsuite/gdb.base/catch-load.exp b/gdb/testsuite/gdb.base/catch-load.exp index 75a9707..c66318e 100644 --- a/gdb/testsuite/gdb.base/catch-load.exp +++ b/gdb/testsuite/gdb.base/catch-load.exp @@ -46,54 +46,56 @@ if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcfile2}" ${binfile2} {debug}] ! # names. # KIND is passed to the "catch" command. # MATCH is a boolean saying whether we expect the catchpoint to be hit. -proc one_catch_load_test {scenario kind match sostop} { with_test_prefix "${scenario}" { - global verbose testfile testfile2 binfile2 binfile2_dlopen - global srcfile - global decimal gdb_prompt +proc one_catch_load_test {scenario kind match sostop} { + with_test_prefix "${scenario}" { + global verbose testfile testfile2 binfile2 binfile2_dlopen + global srcfile + global decimal gdb_prompt - clean_restart $testfile - gdb_load_shlibs $binfile2 + clean_restart $testfile + gdb_load_shlibs $binfile2 - if {![runto_main]} { - fail "can't run to main" - return - } + if {![runto_main]} { + fail "can't run to main" + return + } - gdb_breakpoint [gdb_get_line_number "final breakpoint here"] - gdb_test_no_output "set var libname = \"$binfile2_dlopen\"" - gdb_test_no_output "set stop-on-solib-events $sostop" - gdb_test "catch $kind" "Catchpoint $decimal \\(.*\\)" + gdb_breakpoint [gdb_get_line_number "final breakpoint here"] + gdb_test_no_output "set var libname = \"$binfile2_dlopen\"" + gdb_test_no_output "set stop-on-solib-events $sostop" + gdb_test "catch $kind" "Catchpoint $decimal \\(.*\\)" - gdb_test_multiple "continue" "continue" { - -re "Catchpoint $decimal\r\n.*loaded .*/$testfile2.*\r\n.*$gdb_prompt $" { - if {$match} { - pass "continue" - } else { - fail "continue" + gdb_test_multiple "continue" "continue" { + -re "Catchpoint $decimal\r\n.*loaded .*/$testfile2.*\r\n.*$gdb_prompt $" { + if {$match} { + pass "continue" + } else { + fail "continue" + } } - } - -re "Stopped due to shared library event.*\r\n$gdb_prompt $" { - if {$sostop} { - pass "continue" - } else { - fail "continue" + -re "Stopped due to shared library event.*\r\n$gdb_prompt $" { + if {$sostop} { + pass "continue" + } else { + fail "continue" + } } - } - -re "Breakpoint $decimal, .*\r\n$gdb_prompt $" { - if {!$match} { - pass "continue" - } else { - fail "continue" + -re "Breakpoint $decimal, .*\r\n$gdb_prompt $" { + if {!$match} { + pass "continue" + } else { + fail "continue" + } } - } - -re ".*$gdb_prompt $" { - fail "continue" + -re ".*$gdb_prompt $" { + fail "continue" + } } } -}} +} one_catch_load_test "plain load" "load" 1 0 one_catch_load_test "plain load with stop-on-solib-events" "load" 1 1 diff --git a/gdb/testsuite/gdb.base/disp-step-syscall.exp b/gdb/testsuite/gdb.base/disp-step-syscall.exp index 56c9ab2..ddbb905 100644 --- a/gdb/testsuite/gdb.base/disp-step-syscall.exp +++ b/gdb/testsuite/gdb.base/disp-step-syscall.exp @@ -30,128 +30,130 @@ if { [istarget "i\[34567\]86-*-linux*"] || [istarget "x86_64-*-linux*"] } { return -1 } -proc disp_step_cross_syscall { syscall } { with_test_prefix "$syscall" { - global syscall_insn - global gdb_prompt +proc disp_step_cross_syscall { syscall } { + with_test_prefix "$syscall" { + global syscall_insn + global gdb_prompt - set testfile "disp-step-$syscall" + set testfile "disp-step-$syscall" - if [prepare_for_testing ${testfile}.exp ${testfile} ${testfile}.c {debug}] { - untested ${testfile}.exp - return -1 - } + if [prepare_for_testing ${testfile}.exp ${testfile} ${testfile}.c {debug}] { + untested ${testfile}.exp + return -1 + } - if { ![runto main] } then { - fail "run to main ($syscall)" - return - } + if { ![runto main] } then { + fail "run to main ($syscall)" + return + } - # Delete the breakpoint on main. - gdb_test_no_output "delete break 1" + # Delete the breakpoint on main. + gdb_test_no_output "delete break 1" - gdb_test "break marker" "Breakpoint.*at.* file .*${testfile}.c, line.*" - gdb_test_no_output "set displaced-stepping off" + gdb_test "break marker" "Breakpoint.*at.* file .*${testfile}.c, line.*" + gdb_test_no_output "set displaced-stepping off" - set syscall_bp 0 - gdb_test_multiple "break $syscall" "break $syscall" { - -re "Breakpoint (\[0-9\]*) at .*$gdb_prompt $" { - set syscall_bp $expect_out(1,string) - pass "break $syscall" + set syscall_bp 0 + gdb_test_multiple "break $syscall" "break $syscall" { + -re "Breakpoint (\[0-9\]*) at .*$gdb_prompt $" { + set syscall_bp $expect_out(1,string) + pass "break $syscall" + } } - } - gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in |__libc_|)$syscall \\(\\).*" \ - "continue to $syscall (1st time)" - # Hit the breakpoint on $syscall for the first time. In this time, we will let PLT - # resolution done, and the number single steps we will do later will be - # reduced. + gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in |__libc_|)$syscall \\(\\).*" \ + "continue to $syscall (1st time)" + # Hit the breakpoint on $syscall for the first time. In this time, we will let PLT + # resolution done, and the number single steps we will do later will be + # reduced. - gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in |__libc_|)$syscall \\(\\).*" \ - "continue to $syscall (2nd time)" - # Hit the breakpoint on $syscall for the second time. In this time, the address - # of syscall insn and next insn of syscall are recorded. + gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in |__libc_|)$syscall \\(\\).*" \ + "continue to $syscall (2nd time)" + # Hit the breakpoint on $syscall for the second time. In this time, the address + # of syscall insn and next insn of syscall are recorded. - gdb_test "display/i \$pc" ".*" + gdb_test "display/i \$pc" ".*" - # Single step until we see sysall insn or we reach the upper bound of loop - # iterations. - set see_syscall_insn 0 + # Single step until we see sysall insn or we reach the upper bound of loop + # iterations. + set see_syscall_insn 0 - for {set i 0} {$i < 1000 && $see_syscall_insn == 0} {incr i} { - send_gdb "stepi\n" - gdb_expect { - -re ".*$syscall_insn.*$gdb_prompt $" { - set see_syscall_insn 1 + for {set i 0} {$i < 1000 && $see_syscall_insn == 0} {incr i} { + send_gdb "stepi\n" + gdb_expect { + -re ".*$syscall_insn.*$gdb_prompt $" { + set see_syscall_insn 1 + } + -re ".*$gdb_prompt $" {} } - -re ".*$gdb_prompt $" {} } - } - if {$see_syscall_insn == 0} then { - fail "find syscall insn in $syscall" - return -1 - } + if {$see_syscall_insn == 0} then { + fail "find syscall insn in $syscall" + return -1 + } - set syscall_insn_addr [get_hexadecimal_valueof "\$pc" "0"] - gdb_test "stepi" ".*" "stepi $syscall insn" - set syscall_insn_next_addr [get_hexadecimal_valueof "\$pc" "0"] + set syscall_insn_addr [get_hexadecimal_valueof "\$pc" "0"] + gdb_test "stepi" ".*" "stepi $syscall insn" + set syscall_insn_next_addr [get_hexadecimal_valueof "\$pc" "0"] - gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in |__libc_|)$syscall \\(\\).*" \ - "continue to $syscall (3rd time)" + gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in |__libc_|)$syscall \\(\\).*" \ + "continue to $syscall (3rd time)" - # Hit the breakpoint on $syscall for the third time. In this time, we'll set - # breakpoint on the syscall insn we recorded previously, and single step over it. + # Hit the breakpoint on $syscall for the third time. In this time, we'll set + # breakpoint on the syscall insn we recorded previously, and single step over it. - set syscall_insn_bp 0 - gdb_test_multiple "break \*$syscall_insn_addr" "break on syscall insn" { - -re "Breakpoint (\[0-9\]*) at .*$gdb_prompt $" { - set syscall_insn_bp $expect_out(1,string) - pass "break on syscall insns" + set syscall_insn_bp 0 + gdb_test_multiple "break \*$syscall_insn_addr" "break on syscall insn" { + -re "Breakpoint (\[0-9\]*) at .*$gdb_prompt $" { + set syscall_insn_bp $expect_out(1,string) + pass "break on syscall insns" + } } - } - gdb_test_no_output "delete $syscall_bp" "delete break $syscall" + gdb_test_no_output "delete $syscall_bp" "delete break $syscall" - gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, .*" \ - "continue to syscall insn $syscall" + gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, .*" \ + "continue to syscall insn $syscall" - gdb_test_no_output "set displaced-stepping on" + gdb_test_no_output "set displaced-stepping on" - # Check the address of next instruction of syscall. - if {$syscall == "vfork" && [is_remote target]} { - setup_kfail server/13796 "*-*-*" - } - set test "single step over $syscall" - gdb_test_multiple "stepi" $test { - -re "Program terminated with signal SIGILL,.*\r\n$gdb_prompt $" { - fail $test - return + # Check the address of next instruction of syscall. + if {$syscall == "vfork" && [is_remote target]} { + setup_kfail server/13796 "*-*-*" } - -re "\\\[Inferior .* exited normally\\\].*\r\n$gdb_prompt $" { - fail $test - return + set test "single step over $syscall" + gdb_test_multiple "stepi" $test { + -re "Program terminated with signal SIGILL,.*\r\n$gdb_prompt $" { + fail $test + return + } + -re "\\\[Inferior .* exited normally\\\].*\r\n$gdb_prompt $" { + fail $test + return + } + -re "\r\n$gdb_prompt $" { + pass $test + } } - -re "\r\n$gdb_prompt $" { + + set syscall_insn_next_addr_found [get_hexadecimal_valueof "\$pc" "0"] + + set test "single step over $syscall final pc" + if {$syscall_insn_next_addr != 0 + && $syscall_insn_next_addr == $syscall_insn_next_addr_found} { pass $test + } else { + fail $test } - } - set syscall_insn_next_addr_found [get_hexadecimal_valueof "\$pc" "0"] + # Delete breakpoint syscall insns to avoid interference to other syscalls. + gdb_test_no_output "delete $syscall_insn_bp" "delete break $syscall insn" - set test "single step over $syscall final pc" - if {$syscall_insn_next_addr != 0 - && $syscall_insn_next_addr == $syscall_insn_next_addr_found} { - pass $test - } else { - fail $test + gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, marker \\(\\) at.*" \ + "continue to marker ($syscall)" } - - # Delete breakpoint syscall insns to avoid interference to other syscalls. - gdb_test_no_output "delete $syscall_insn_bp" "delete break $syscall insn" - - gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, marker \\(\\) at.*" \ - "continue to marker ($syscall)" -}} +} disp_step_cross_syscall "fork" disp_step_cross_syscall "vfork" diff --git a/gdb/testsuite/gdb.base/jit-so.exp b/gdb/testsuite/gdb.base/jit-so.exp index 9928449..e3a3728 100644 --- a/gdb/testsuite/gdb.base/jit-so.exp +++ b/gdb/testsuite/gdb.base/jit-so.exp @@ -63,55 +63,57 @@ if { [gdb_compile_shlib ${solib_srcfile} ${solib_binfile} {}] != "" } { set solib_binfile_target [gdb_download ${solib_binfile}] -proc one_jit_test {count match_str} { with_test_prefix "one_jit_test-$count" { - global verbose testfile srcfile2 binfile2 binfile2_dlopen solib_binfile_target solib_binfile_test_msg - - clean_restart $testfile - gdb_load_shlibs $binfile2 - - # This is just to help debugging when things fail - if {$verbose > 0} { - gdb_test "set debug jit 1" - } - - if { ![runto_main] } { - fail "Can't run to main" - return - } - - gdb_breakpoint [gdb_get_line_number "break here before-dlopen" ] - gdb_continue_to_breakpoint "break here before-dlopen" - # Poke desired values directly into inferior instead of using "set args" - # because "set args" does not work under gdbserver. - gdb_test_no_output "set var jit_libname = \"$binfile2_dlopen\"" - - gdb_breakpoint [gdb_get_line_number "break here after-dlopen" ] - gdb_continue_to_breakpoint "break here after-dlopen" - - gdb_breakpoint "$srcfile2:[gdb_get_line_number {break here 0} $srcfile2]" - gdb_continue_to_breakpoint "break here 0" - - gdb_test_no_output "set var argc = 2" - 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 "$srcfile2:[gdb_get_line_number {break here 1} $srcfile2]" - gdb_continue_to_breakpoint "break here 1" - - gdb_test "info function jit_function" "$match_str" - - # This is just to help debugging when things fail - if {$verbose > 0} { - gdb_test "maintenance print objfiles" - gdb_test "maintenance info break" +proc one_jit_test {count match_str} { + with_test_prefix "one_jit_test-$count" { + global verbose testfile srcfile2 binfile2 binfile2_dlopen solib_binfile_target solib_binfile_test_msg + + clean_restart $testfile + gdb_load_shlibs $binfile2 + + # This is just to help debugging when things fail + if {$verbose > 0} { + gdb_test "set debug jit 1" + } + + if { ![runto_main] } { + fail "Can't run to main" + return + } + + gdb_breakpoint [gdb_get_line_number "break here before-dlopen" ] + gdb_continue_to_breakpoint "break here before-dlopen" + # Poke desired values directly into inferior instead of using "set args" + # because "set args" does not work under gdbserver. + gdb_test_no_output "set var jit_libname = \"$binfile2_dlopen\"" + + gdb_breakpoint [gdb_get_line_number "break here after-dlopen" ] + gdb_continue_to_breakpoint "break here after-dlopen" + + gdb_breakpoint "$srcfile2:[gdb_get_line_number {break here 0} $srcfile2]" + gdb_continue_to_breakpoint "break here 0" + + gdb_test_no_output "set var argc = 2" + 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 "$srcfile2:[gdb_get_line_number {break here 1} $srcfile2]" + gdb_continue_to_breakpoint "break here 1" + + gdb_test "info function jit_function" "$match_str" + + # This is just to help debugging when things fail + if {$verbose > 0} { + gdb_test "maintenance print objfiles" + gdb_test "maintenance info break" + } + + gdb_breakpoint "$srcfile2:[gdb_get_line_number {break here 2} $srcfile2]" + gdb_continue_to_breakpoint "break here 2" + # All jit librares must have been unregistered + gdb_test "info function jit_function" \ + "All functions matching regular expression \"jit_function\":" } - - gdb_breakpoint "$srcfile2:[gdb_get_line_number {break here 2} $srcfile2]" - gdb_continue_to_breakpoint "break here 2" - # All jit librares must have been unregistered - gdb_test "info function jit_function" \ - "All functions matching regular expression \"jit_function\":" -}} +} one_jit_test 1 "${hex} jit_function_0000" one_jit_test 2 "${hex} jit_function_0000\[\r\n\]+${hex} jit_function_0001" diff --git a/gdb/testsuite/gdb.base/jit.exp b/gdb/testsuite/gdb.base/jit.exp index 35840be..e5151c6 100644 --- a/gdb/testsuite/gdb.base/jit.exp +++ b/gdb/testsuite/gdb.base/jit.exp @@ -61,47 +61,49 @@ proc compile_jit_test {testname options} { return 0 } -proc one_jit_test {count match_str} { with_test_prefix "one_jit_test-$count" { - global verbose testfile solib_binfile_target solib_binfile_test_msg - - clean_restart $testfile - - # This is just to help debugging when things fail - if {$verbose > 0} { - gdb_test "set debug jit 1" +proc one_jit_test {count match_str} { + with_test_prefix "one_jit_test-$count" { + global verbose testfile solib_binfile_target solib_binfile_test_msg + + clean_restart $testfile + + # This is just to help debugging when things fail + if {$verbose > 0} { + gdb_test "set debug jit 1" + } + + if { ![runto_main] } { + fail "Can't run to main" + return + } + + gdb_breakpoint [gdb_get_line_number "break here 0"] + gdb_continue_to_breakpoint "break here 0" + + # Poke desired values directly into inferior instead of using "set args" + # because "set args" does not work under gdbserver. + gdb_test_no_output "set var argc = 2" + 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" + + gdb_test "info function jit_function" "$match_str" + + # This is just to help debugging when things fail + if {$verbose > 0} { + gdb_test "maintenance print objfiles" + gdb_test "maintenance info break" + } + + gdb_breakpoint [gdb_get_line_number "break here 2"] + gdb_continue_to_breakpoint "break here 2" + # All jit librares must have been unregistered + gdb_test "info function jit_function" \ + "All functions matching regular expression \"jit_function\":" } - - if { ![runto_main] } { - fail "Can't run to main" - return - } - - gdb_breakpoint [gdb_get_line_number "break here 0"] - gdb_continue_to_breakpoint "break here 0" - - # Poke desired values directly into inferior instead of using "set args" - # because "set args" does not work under gdbserver. - gdb_test_no_output "set var argc = 2" - 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" - - gdb_test "info function jit_function" "$match_str" - - # This is just to help debugging when things fail - if {$verbose > 0} { - gdb_test "maintenance print objfiles" - gdb_test "maintenance info break" - } - - gdb_breakpoint [gdb_get_line_number "break here 2"] - gdb_continue_to_breakpoint "break here 2" - # All jit librares must have been unregistered - gdb_test "info function jit_function" \ - "All functions matching regular expression \"jit_function\":" -}} +} if {[compile_jit_test jit.exp {}] < 0} { return diff --git a/gdb/testsuite/gdb.base/sepdebug.exp b/gdb/testsuite/gdb.base/sepdebug.exp index 8e3709a..1e63835 100644 --- a/gdb/testsuite/gdb.base/sepdebug.exp +++ b/gdb/testsuite/gdb.base/sepdebug.exp @@ -648,101 +648,103 @@ test_next_with_recursion #******** -proc test_different_dir {type test_different_dir xfail} { with_test_prefix "$type" { - global srcdir subdir objdir binfile srcfile timeout gdb_prompt - global bp_location6 decimal hex - - gdb_exit - gdb_start - gdb_reinitialize_dir $srcdir/$subdir - gdb_test_no_output "set debug-file-directory ${test_different_dir}" \ - "set separate debug location" - gdb_load ${binfile} - - # - # test break at function - # - if {$xfail} { - setup_xfail "*-*-*" - } - gdb_test "break main" \ - "Breakpoint.*at.* file .*$srcfile, line.*" \ - "breakpoint function, optimized file" - - # - # test break at function - # - if {$xfail} { - setup_xfail "*-*-*" - } - gdb_test "break marker4" \ - "Breakpoint.*at.* file .*$srcfile, line.*" \ - "breakpoint small function, optimized file" - - # - # run until the breakpoint at main is hit. For non-stubs-using targets. - # - gdb_run_cmd - if {$xfail} { - setup_xfail "*-*-*" - } - gdb_expect { - -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $" { - pass "run until function breakpoint, optimized file" +proc test_different_dir {type test_different_dir xfail} { + with_test_prefix "$type" { + global srcdir subdir objdir binfile srcfile timeout gdb_prompt + global bp_location6 decimal hex + + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_test_no_output "set debug-file-directory ${test_different_dir}" \ + "set separate debug location" + gdb_load ${binfile} + + # + # test break at function + # + if {$xfail} { + setup_xfail "*-*-*" } - -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $" { - pass "run until function breakpoint, optimized file (code motion)" + gdb_test "break main" \ + "Breakpoint.*at.* file .*$srcfile, line.*" \ + "breakpoint function, optimized file" + + # + # test break at function + # + if {$xfail} { + setup_xfail "*-*-*" } - -re "$gdb_prompt $" { - fail "run until function breakpoint, optimized file" + gdb_test "break marker4" \ + "Breakpoint.*at.* file .*$srcfile, line.*" \ + "breakpoint small function, optimized file" + + # + # run until the breakpoint at main is hit. For non-stubs-using targets. + # + gdb_run_cmd + if {$xfail} { + setup_xfail "*-*-*" } - timeout { - fail "run until function breakpoint, optimized file (timeout)" + gdb_expect { + -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $" { + pass "run until function breakpoint, optimized file" + } + -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $" { + pass "run until function breakpoint, optimized file (code motion)" + } + -re "$gdb_prompt $" { + fail "run until function breakpoint, optimized file" + } + timeout { + fail "run until function breakpoint, optimized file (timeout)" + } } - } - - # - # run until the breakpoint at a small function - # - - # - # Add a second pass pattern. The behavior differs here between stabs - # and dwarf for one-line functions. Stabs preserves two line symbols - # (one before the prologue and one after) with the same line number, - # but dwarf regards these as duplicates and discards one of them. - # Therefore the address after the prologue (where the breakpoint is) - # has no exactly matching line symbol, and GDB reports the breakpoint - # as if it were in the middle of a line rather than at the beginning. - - set bp_location13 [gdb_get_line_number "set breakpoint 13 here"] - set bp_location14 [gdb_get_line_number "set breakpoint 14 here"] - if {$xfail} { - setup_xfail "*-*-*" - } - gdb_test_multiple "continue" "run until breakpoint set at small function, optimized file" { - -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*$gdb_prompt $" { - pass "run until breakpoint set at small function, optimized file" - } - -re "Breakpoint $decimal, $hex in marker4 \\(d=177601976\\) at .*$srcfile:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*$gdb_prompt $" { - pass "run until breakpoint set at small function, optimized file" + # + # run until the breakpoint at a small function + # + + # + # Add a second pass pattern. The behavior differs here between stabs + # and dwarf for one-line functions. Stabs preserves two line symbols + # (one before the prologue and one after) with the same line number, + # but dwarf regards these as duplicates and discards one of them. + # Therefore the address after the prologue (where the breakpoint is) + # has no exactly matching line symbol, and GDB reports the breakpoint + # as if it were in the middle of a line rather than at the beginning. + + set bp_location13 [gdb_get_line_number "set breakpoint 13 here"] + set bp_location14 [gdb_get_line_number "set breakpoint 14 here"] + if {$xfail} { + setup_xfail "*-*-*" } - -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile:$bp_location14\[\r\n\]+$bp_location14\[\t \]+void marker4.*$gdb_prompt $" { - # marker4() is defined at line 46 when compiled with -DPROTOTYPES - pass "run until breakpoint set at small function, optimized file (line bp_location14)" + + gdb_test_multiple "continue" "run until breakpoint set at small function, optimized file" { + -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*$gdb_prompt $" { + pass "run until breakpoint set at small function, optimized file" + } + -re "Breakpoint $decimal, $hex in marker4 \\(d=177601976\\) at .*$srcfile:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*$gdb_prompt $" { + pass "run until breakpoint set at small function, optimized file" + } + -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile:$bp_location14\[\r\n\]+$bp_location14\[\t \]+void marker4.*$gdb_prompt $" { + # marker4() is defined at line 46 when compiled with -DPROTOTYPES + pass "run until breakpoint set at small function, optimized file (line bp_location14)" + } } - } - # Reset the default arguments for VxWorks - if [istarget "*-*-vxworks*"] { - set timeout 10 - verbose "Timeout is now $timeout seconds" 2 - gdb_test_no_output "set args main" - } + # Reset the default arguments for VxWorks + if [istarget "*-*-vxworks*"] { + set timeout 10 + verbose "Timeout is now $timeout seconds" 2 + gdb_test_no_output "set args main" + } -# proc test_different_dir -}} + # proc test_different_dir + } +} # now move the .debug file to a different location so that we can test diff --git a/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp b/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp index 8f5d50f..2602aef 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp @@ -335,34 +335,36 @@ if ![runto_main] { gdb_test "cd ${srcabsdir}/rdir" "Working directory [string_to_regexp ${srcabsdir}]/rdir\\." "cd .../rdir" -proc test { func compdir filename } { with_test_prefix "$func" { - # Clear the GDB cache. - gdb_test_no_output "set directories" "" +proc test { func compdir filename } { + with_test_prefix "$func" { + # Clear the GDB cache. + gdb_test_no_output "set directories" "" - if {$compdir == ""} { - set absolute "$filename" - } else { - set absolute "$compdir/$filename" - } - if {[string index $absolute 0] != "/"} { - error "not absolute" - } + if {$compdir == ""} { + set absolute "$filename" + } else { + set absolute "$compdir/$filename" + } + if {[string index $absolute 0] != "/"} { + error "not absolute" + } - gdb_breakpoint $func - gdb_continue_to_breakpoint $func "$func \\(\\) at .*" + gdb_breakpoint $func + gdb_continue_to_breakpoint $func "$func \\(\\) at .*" - gdb_test_no_output "set filename-display absolute" - verbose -log "expect: ${absolute}" - gdb_test "frame" " in $func \\(\\) at [string_to_regexp ${absolute}]:999" "absolute" + gdb_test_no_output "set filename-display absolute" + verbose -log "expect: ${absolute}" + gdb_test "frame" " in $func \\(\\) at [string_to_regexp ${absolute}]:999" "absolute" - gdb_test_no_output "set filename-display basename" - verbose -log "expect: [file tail $filename]" - gdb_test "frame" " in $func \\(\\) at [string_to_regexp [file tail $filename]]:999" "basename" + gdb_test_no_output "set filename-display basename" + verbose -log "expect: [file tail $filename]" + gdb_test "frame" " in $func \\(\\) at [string_to_regexp [file tail $filename]]:999" "basename" - gdb_test_no_output "set filename-display relative" - verbose -log "expect: $filename" - gdb_test "frame" " in $func \\(\\) at [string_to_regexp $filename]:999" "relative" -}} + gdb_test_no_output "set filename-display relative" + verbose -log "expect: $filename" + gdb_test "frame" " in $func \\(\\) at [string_to_regexp $filename]:999" "relative" + } +} set bdir "${srcabsdir}" set file "${srctmpfile}" diff --git a/gdb/testsuite/gdb.dwarf2/dw2-noloc.exp b/gdb/testsuite/gdb.dwarf2/dw2-noloc.exp index 09621d3..f7d7efe 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-noloc.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-noloc.exp @@ -33,49 +33,51 @@ if { [prepare_for_testing dw2-noloc.exp "dw2-noloc" {dw2-noloc-main.c dw2-noloc. # unresolvable: .symtab entry does not exist for this symbol name. # DW_AT_declaration is not present in any of these DIEs. -proc file_symbols {type} { with_test_prefix "$type" { +proc file_symbols {type} { + with_test_prefix "$type" { - global gdb_prompt + global gdb_prompt - gdb_test "print file_locaddr_resolvable" "= 1234567890" - gdb_test "ptype file_locaddr_resolvable" "type = int" + gdb_test "print file_locaddr_resolvable" "= 1234567890" + gdb_test "ptype file_locaddr_resolvable" "type = int" - gdb_test "print file_locaddr_unresolvable" "= 1234567890" - gdb_test "ptype file_locaddr_unresolvable" "type = int" + gdb_test "print file_locaddr_unresolvable" "= 1234567890" + gdb_test "ptype file_locaddr_unresolvable" "type = int" - gdb_test "print file_locempty_resolvable" "= <optimized out>" - gdb_test "ptype file_locempty_resolvable" "type = int" + gdb_test "print file_locempty_resolvable" "= <optimized out>" + gdb_test "ptype file_locempty_resolvable" "type = int" - gdb_test "print file_locempty_unresolvable" "= <optimized out>" - gdb_test "ptype file_locempty_unresolvable" "type = int" + gdb_test "print file_locempty_unresolvable" "= <optimized out>" + gdb_test "ptype file_locempty_unresolvable" "type = int" - gdb_test "print file_locno_resolvable" "= <optimized out>" - gdb_test "ptype file_locno_resolvable" "type = int" + gdb_test "print file_locno_resolvable" "= <optimized out>" + gdb_test "ptype file_locno_resolvable" "type = int" - gdb_test "print file_locno_unresolvable" "= <optimized out>" - gdb_test "ptype file_locno_unresolvable" "type = int" + gdb_test "print file_locno_unresolvable" "= <optimized out>" + gdb_test "ptype file_locno_unresolvable" "type = int" - gdb_test "print file_extern_locaddr_resolvable" "= 1234567890" - gdb_test "ptype file_extern_locaddr_resolvable" "type = int" + gdb_test "print file_extern_locaddr_resolvable" "= 1234567890" + gdb_test "ptype file_extern_locaddr_resolvable" "type = int" - gdb_test "print file_extern_locaddr_unresolvable" "= 1234567890" - gdb_test "ptype file_extern_locaddr_unresolvable" "type = int" + gdb_test "print file_extern_locaddr_unresolvable" "= 1234567890" + gdb_test "ptype file_extern_locaddr_unresolvable" "type = int" - gdb_test "print file_extern_locempty_resolvable" "= <optimized out>" - gdb_test "ptype file_extern_locempty_resolvable" "type = int" + gdb_test "print file_extern_locempty_resolvable" "= <optimized out>" + gdb_test "ptype file_extern_locempty_resolvable" "type = int" - gdb_test "print file_extern_locempty_unresolvable" "= <optimized out>" - gdb_test "ptype file_extern_locempty_unresolvable" "type = int" + gdb_test "print file_extern_locempty_unresolvable" "= <optimized out>" + gdb_test "ptype file_extern_locempty_unresolvable" "type = int" - gdb_test "print file_extern_locno_resolvable" "= 1234567890" - gdb_test "ptype file_extern_locno_resolvable" "type = int" + gdb_test "print file_extern_locno_resolvable" "= 1234567890" + gdb_test "ptype file_extern_locno_resolvable" "type = int" - # `print file_extern_locno_unresolvable' currently prints - # Address of symbol "file_extern_locno_unresolvable" is unknown. - # As DW_AT_declaration is not present in this DIE - # it should print <optimized out>. As usefulness of such DIE is not - # clear its resolution is not being tested. -}} + # `print file_extern_locno_unresolvable' currently prints + # Address of symbol "file_extern_locno_unresolvable" is unknown. + # As DW_AT_declaration is not present in this DIE + # it should print <optimized out>. As usefulness of such DIE is not + # clear its resolution is not being tested. + } +} file_symbols no-run diff --git a/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp b/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp index fd32698..04a5636 100644 --- a/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp +++ b/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp @@ -138,98 +138,100 @@ test_insert_delete_modify # Test 'breakpoint-modified' notification is emited when pending breakpoints are # resolved. -proc test_pending_resolved { } { with_test_prefix "pending resolved" { - global decimal hex - global srcdir - global subdir - global binfile - global lib_sl1 lib_sl2 - global mi_gdb_prompt - - gdb_exit - if [mi_gdb_start] { - continue - } - mi_gdb_reinitialize_dir $srcdir/$subdir - mi_gdb_load ${binfile} - mi_load_shlibs $lib_sl1 $lib_sl2 - - # Create a pending breakpoint on pendfunc1 - mi_gdb_test "-break-insert -f pendfunc1" \ - {.*\^done,bkpt=.*addr=\"<PENDING>\".*} \ - "insert breakpoint on pendfunc1" - mi_run_cmd - - set test "breakpoint on pendfunc1 resolved" - gdb_expect { - -re ".*=breakpoint-modified,bkpt=\{number=\"1\".*addr=\"${hex}\".*,times=\"0\"" { - pass $test - exp_continue +proc test_pending_resolved { } { + with_test_prefix "pending resolved" { + global decimal hex + global srcdir + global subdir + global binfile + global lib_sl1 lib_sl2 + global mi_gdb_prompt + + gdb_exit + if [mi_gdb_start] { + continue } - -re ".*=breakpoint-modified,bkpt=\{number=\"1\".*addr=\"${hex}\".*,times=\"1\"" { - pass "$test: hit_count is updated" + mi_gdb_reinitialize_dir $srcdir/$subdir + mi_gdb_load ${binfile} + mi_load_shlibs $lib_sl1 $lib_sl2 + + # Create a pending breakpoint on pendfunc1 + mi_gdb_test "-break-insert -f pendfunc1" \ + {.*\^done,bkpt=.*addr=\"<PENDING>\".*} \ + "insert breakpoint on pendfunc1" + mi_run_cmd + + set test "breakpoint on pendfunc1 resolved" + gdb_expect { + -re ".*=breakpoint-modified,bkpt=\{number=\"1\".*addr=\"${hex}\".*,times=\"0\"" { + pass $test + exp_continue + } + -re ".*=breakpoint-modified,bkpt=\{number=\"1\".*addr=\"${hex}\".*,times=\"1\"" { + pass "$test: hit_count is updated" + } + -re ".*${mi_gdb_prompt}$" { + fail $test + } + timeout { + fail "$test (timeout)" + } } - -re ".*${mi_gdb_prompt}$" { - fail $test - } - timeout { - fail "$test (timeout)" + mi_expect_stop "breakpoint-hit" "pendfunc1" ""\ + ".*" ".*" {"" "disp=\"keep\""} \ + "continue to pendfunc1 breakpoint" + + # Delete breakpoint on pendfunc1 + mi_gdb_test "-break-delete 1" {\^done} \ + "delete breakpoint on pendfunc1" + # Insert breakpoint on marker + mi_gdb_test "-break-insert marker" {.*\^done,bkpt=.*} \ + "insert breakpoint on marker" + # Create a pending breakpoint on pendfunc3 + mi_gdb_test "-break-insert -f pendfunc3" \ + {.*\^done,bkpt=.*addr=\"<PENDING>\".*} \ + "insert breakpoint on pendfunc3" + + mi_execute_to "exec-continue" "breakpoint-hit" "marker" ".*" ".*" ".*" \ + {"" "disp=\"keep\""} "continue to marker 1" + + mi_send_resuming_command "exec-continue" "continuing execution to marker" + + set test "breakpoint on pendfunc3 resolved" + gdb_expect { + -re ".*=breakpoint-modified,bkpt=\{number=\"2\".*addr=\"${hex}\",.*func=\"marker\",.*times=\"1\"" { + pass "$test: hit_count is updated" + exp_continue + } + -re ".*=breakpoint-modified,bkpt=\{number=\"3\".*addr=\"${hex}\",.*func=\"pendfunc3\",.*times=\"0\"" { + pass $test + } + -re ".*${mi_gdb_prompt}$" { + fail $test + } + timeout { + fail "$test (timeout)" + } } - } - mi_expect_stop "breakpoint-hit" "pendfunc1" ""\ - ".*" ".*" {"" "disp=\"keep\""} \ - "continue to pendfunc1 breakpoint" - - # Delete breakpoint on pendfunc1 - mi_gdb_test "-break-delete 1" {\^done} \ - "delete breakpoint on pendfunc1" - # Insert breakpoint on marker - mi_gdb_test "-break-insert marker" {.*\^done,bkpt=.*} \ - "insert breakpoint on marker" - # Create a pending breakpoint on pendfunc3 - mi_gdb_test "-break-insert -f pendfunc3" \ - {.*\^done,bkpt=.*addr=\"<PENDING>\".*} \ - "insert breakpoint on pendfunc3" - - mi_execute_to "exec-continue" "breakpoint-hit" "marker" ".*" ".*" ".*" \ - {"" "disp=\"keep\""} "continue to marker 1" - - mi_send_resuming_command "exec-continue" "continuing execution to marker" - - set test "breakpoint on pendfunc3 resolved" - gdb_expect { - -re ".*=breakpoint-modified,bkpt=\{number=\"2\".*addr=\"${hex}\",.*func=\"marker\",.*times=\"1\"" { - pass "$test: hit_count is updated" - exp_continue - } - -re ".*=breakpoint-modified,bkpt=\{number=\"3\".*addr=\"${hex}\",.*func=\"pendfunc3\",.*times=\"0\"" { - pass $test + mi_expect_stop "breakpoint-hit" "marker" ".*" ".*" ".*" \ + {"" "disp=\"keep\""} "continue to marker 2" + + mi_send_resuming_command "exec-continue" "continuing to exit" + set test "breakpoint on pendfunc3 pending again" + gdb_expect { + -re ".*=breakpoint-modified,bkpt=\{number=\"3\".*addr=\"<PENDING>\"" { + pass $test + } + -re ".*${mi_gdb_prompt}$" { + fail $test + } + timeout { + fail "$test (timeout)" + } } - -re ".*${mi_gdb_prompt}$" { - fail $test - } - timeout { - fail "$test (timeout)" - } - } - mi_expect_stop "breakpoint-hit" "marker" ".*" ".*" ".*" \ - {"" "disp=\"keep\""} "continue to marker 2" - mi_send_resuming_command "exec-continue" "continuing to exit" - set test "breakpoint on pendfunc3 pending again" - gdb_expect { - -re ".*=breakpoint-modified,bkpt=\{number=\"3\".*addr=\"<PENDING>\"" { - pass $test - } - -re ".*${mi_gdb_prompt}$" { - fail $test - } - timeout { - fail "$test (timeout)" - } + mi_expect_stop "exited-normally" "" "" "" "" "" "" } - - mi_expect_stop "exited-normally" "" "" "" "" "" "" -}} +} test_pending_resolved diff --git a/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp b/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp index 69a3d6e..7fc025f 100644 --- a/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp +++ b/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp @@ -23,78 +23,80 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb return -1 } -proc test_command_param_changed { } { with_test_prefix "cmd param" { - if [mi_gdb_start] { - return - } - mi_run_to_main - - foreach opt { "on" "off" "step" } { - mi_gdb_test "set scheduler-locking ${opt}" \ - ".*=cmd-param-changed,param=\"scheduler-locking\",value=\"${opt}\".*\\^done" \ - "\"set scheduler-locking ${opt}\"" - } - foreach opt { "on" "off" "step" } { - mi_gdb_test "interpreter-exec console \"set scheduler-locking ${opt}\"" \ - ".*=cmd-param-changed,param=\"scheduler-locking\",value=\"${opt}\".*\\^done" \ - "interpreter-exec \"set scheduler-locking ${opt}\"" - } - # Don't emit MI notification for request from MI. - mi_gdb_test "-gdb-set scheduler-locking on" \ - {\^done} \ - "\"set scheduler-locking on\" no event (requested by MI)" - - mi_gdb_test "interpreter-exec mi \"-gdb-set scheduler-locking step\"" \ - "\\&\"interpreter-exec mi .*\"-gdb-set scheduler-locking step.*\"\\\\n\"\r\n\\^done\r\n\\^done" \ - "\"set scheduler-locking step\" no event (requested by MI interp)" - mi_gdb_test "set scheduler-locking step" \ - "\\&\"set scheduler-locking step\\\\n\"\r\n\\^done" \ - "\"set scheduler-locking stepr\" no event" +proc test_command_param_changed { } { + with_test_prefix "cmd param" { + if [mi_gdb_start] { + return + } + mi_run_to_main + foreach opt { "on" "off" "step" } { + mi_gdb_test "set scheduler-locking ${opt}" \ + ".*=cmd-param-changed,param=\"scheduler-locking\",value=\"${opt}\".*\\^done" \ + "\"set scheduler-locking ${opt}\"" + } + foreach opt { "on" "off" "step" } { + mi_gdb_test "interpreter-exec console \"set scheduler-locking ${opt}\"" \ + ".*=cmd-param-changed,param=\"scheduler-locking\",value=\"${opt}\".*\\^done" \ + "interpreter-exec \"set scheduler-locking ${opt}\"" + } + # Don't emit MI notification for request from MI. + mi_gdb_test "-gdb-set scheduler-locking on" \ + {\^done} \ + "\"set scheduler-locking on\" no event (requested by MI)" + + mi_gdb_test "interpreter-exec mi \"-gdb-set scheduler-locking step\"" \ + "\\&\"interpreter-exec mi .*\"-gdb-set scheduler-locking step.*\"\\\\n\"\r\n\\^done\r\n\\^done" \ + "\"set scheduler-locking step\" no event (requested by MI interp)" + mi_gdb_test "set scheduler-locking step" \ + "\\&\"set scheduler-locking step\\\\n\"\r\n\\^done" \ + "\"set scheduler-locking stepr\" no event" + + + foreach command { "remotecache" "check type" } { + + # The default value of each command option may be different, so we first + # set it to 'off', and this may or may not trigger MI notification. + mi_gdb_test "set ${command} off" ".*\\^done" "\"set ${command}\" warmup" + + foreach boolean_opt { "on" "off" } { + mi_gdb_test "set ${command} ${boolean_opt}" \ + ".*=cmd-param-changed,param=\"${command}\",value=\"${boolean_opt}\".*\\^done" \ + "\"set ${command} ${boolean_opt}\"" + } + mi_gdb_test "set ${command} off" \ + "\\&\"set ${command} off\\\\n\"\r\n\\^done" \ + "\"set ${command}\" no event" + } - foreach command { "remotecache" "check type" } { - # The default value of each command option may be different, so we first - # set it to 'off', and this may or may not trigger MI notification. - mi_gdb_test "set ${command} off" ".*\\^done" "\"set ${command}\" warmup" + foreach command { "trace-notes" "remote exec-file" } { + foreach str_opt { "foo" "bar" } { + mi_gdb_test "set ${command} ${str_opt}" \ + ".*=cmd-param-changed,param=\"${command}\",value=\"${str_opt}\".*\\^done" \ + "\"set ${command} ${str_opt}\"" + } + mi_gdb_test "set ${command} bar" \ + "\\&\"set ${command} bar\\\\n\"\r\n(\\&\"warning.*|)\\^done" \ + "\"set ${command} bar\" no event" + } + # No notification is emitted for 'maint set' commands. foreach boolean_opt { "on" "off" } { - mi_gdb_test "set ${command} ${boolean_opt}" \ - ".*=cmd-param-changed,param=\"${command}\",value=\"${boolean_opt}\".*\\^done" \ - "\"set ${command} ${boolean_opt}\"" + mi_gdb_test "maint set profile ${boolean_opt}" \ + "\\&\"maint set profile ${boolean_opt}\\\\n\"\r\n\\^done" \ + "\"maint set profile ${boolean_opt}\"" } - mi_gdb_test "set ${command} off" \ - "\\&\"set ${command} off\\\\n\"\r\n\\^done" \ - "\"set ${command}\" no event" - } + # Full command parameters are included in the notification when a + # abbreviated one is typed. + mi_gdb_test "set ch type on" \ + ".*=cmd-param-changed,param=\"check type\",value=\"on\".*\\^done" \ + "\"set ch type on\"" - foreach command { "trace-notes" "remote exec-file" } { - foreach str_opt { "foo" "bar" } { - mi_gdb_test "set ${command} ${str_opt}" \ - ".*=cmd-param-changed,param=\"${command}\",value=\"${str_opt}\".*\\^done" \ - "\"set ${command} ${str_opt}\"" - } - mi_gdb_test "set ${command} bar" \ - "\\&\"set ${command} bar\\\\n\"\r\n(\\&\"warning.*|)\\^done" \ - "\"set ${command} bar\" no event" - } - - # No notification is emitted for 'maint set' commands. - foreach boolean_opt { "on" "off" } { - mi_gdb_test "maint set profile ${boolean_opt}" \ - "\\&\"maint set profile ${boolean_opt}\\\\n\"\r\n\\^done" \ - "\"maint set profile ${boolean_opt}\"" + mi_gdb_exit } - - # Full command parameters are included in the notification when a - # abbreviated one is typed. - mi_gdb_test "set ch type on" \ - ".*=cmd-param-changed,param=\"check type\",value=\"on\".*\\^done" \ - "\"set ch type on\"" - - mi_gdb_exit -}} +} test_command_param_changed diff --git a/gdb/testsuite/gdb.mi/mi-watch.exp b/gdb/testsuite/gdb.mi/mi-watch.exp index 858a8c1..199c43c 100644 --- a/gdb/testsuite/gdb.mi/mi-watch.exp +++ b/gdb/testsuite/gdb.mi/mi-watch.exp @@ -141,21 +141,23 @@ proc test_watchpoint_triggering {type} { clear_xfail *-*-* } -proc test_watchpoint_all {type} { with_test_prefix "$type" { - upvar srcdir srcdir - upvar subdir subdir - upvar binfile binfile - - mi_delete_breakpoints - mi_gdb_reinitialize_dir $srcdir/$subdir - mi_gdb_load ${binfile} - - mi_runto callee4 - test_watchpoint_creation_and_listing $type - #test_rwatch_creation_and_listing $type - #test_awatch_creation_and_listing $type - test_watchpoint_triggering $type -}} +proc test_watchpoint_all {type} { + with_test_prefix "$type" { + upvar srcdir srcdir + upvar subdir subdir + upvar binfile binfile + + mi_delete_breakpoints + mi_gdb_reinitialize_dir $srcdir/$subdir + mi_gdb_load ${binfile} + + mi_runto callee4 + test_watchpoint_creation_and_listing $type + #test_rwatch_creation_and_listing $type + #test_awatch_creation_and_listing $type + test_watchpoint_triggering $type + } +} # Run the tests twice, once using software watchpoints... mi_gdb_test "567-gdb-set can-use-hw-watchpoints 0" \ diff --git a/gdb/testsuite/gdb.mi/pr11022.exp b/gdb/testsuite/gdb.mi/pr11022.exp index 0390980..8e1a0d0 100644 --- a/gdb/testsuite/gdb.mi/pr11022.exp +++ b/gdb/testsuite/gdb.mi/pr11022.exp @@ -27,39 +27,41 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb return } -proc test_memory_changed_observer { mi_command } { with_test_prefix "${mi_command}" { - global srcfile +proc test_memory_changed_observer { mi_command } { + with_test_prefix "${mi_command}" { + global srcfile - if [mi_gdb_start] { - return - } - mi_run_to_main + if [mi_gdb_start] { + return + } + mi_run_to_main - set line_number [gdb_get_line_number "break here"] - mi_gdb_test "-break-insert ${srcfile}:${line_number}" \ - {\^done,bkpt=.number="2",type="breakpoint".*\}} \ - "set breakpoint" + set line_number [gdb_get_line_number "break here"] + mi_gdb_test "-break-insert ${srcfile}:${line_number}" \ + {\^done,bkpt=.number="2",type="breakpoint".*\}} \ + "set breakpoint" - mi_gdb_test "watch x" ".*" "set watchpoint" + mi_gdb_test "watch x" ".*" "set watchpoint" - mi_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*" ".*" \ - { "" "disp=\"keep\"" } "breakpoint hit" + mi_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*" ".*" \ + { "" "disp=\"keep\"" } "breakpoint hit" - mi_execute_to "exec-continue" "watchpoint-trigger" "main" "" ".*" ".*" \ - { "" "wpt=\{number=\"3\",exp=\"x\"\},value=\{old=\"0\",new=\"42\"\}" } \ - "watchpoint hit" + mi_execute_to "exec-continue" "watchpoint-trigger" "main" "" ".*" ".*" \ + { "" "wpt=\{number=\"3\",exp=\"x\"\},value=\{old=\"0\",new=\"42\"\}" } \ + "watchpoint hit" - mi_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*" ".*" \ - { "" "disp=\"keep\"" } "breakpoint hit 2" + mi_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*" ".*" \ + { "" "disp=\"keep\"" } "breakpoint hit 2" - mi_gdb_test "-${mi_command}" {\^done} "set x" + mi_gdb_test "-${mi_command}" {\^done} "set x" - mi_execute_to "exec-continue" "watchpoint-trigger" "main" "" ".*" ".*" \ - { "" "wpt=\{number=\"3\",exp=\"x\"\},value=\{old=\"1\",new=\"42\"\}" } \ - "watchpoint hit 2" + mi_execute_to "exec-continue" "watchpoint-trigger" "main" "" ".*" ".*" \ + { "" "wpt=\{number=\"3\",exp=\"x\"\},value=\{old=\"1\",new=\"42\"\}" } \ + "watchpoint hit 2" - mi_gdb_exit -}} + mi_gdb_exit + } +} test_memory_changed_observer "data-write-memory-bytes &x \"01\"" # We want to trigger a target memory write here, so the word size (4 or 8) diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp index 7412fa2..9697071 100644 --- a/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp +++ b/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp @@ -28,29 +28,31 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab return -1 } -proc do_test { lock_sched } { with_test_prefix "lock-sched$lock_sched" { - global executable +proc do_test { lock_sched } { + with_test_prefix "lock-sched$lock_sched" { + global executable - clean_restart ${executable} + clean_restart ${executable} - if ![runto_main] { - return -1 - } + if ![runto_main] { + return -1 + } - gdb_breakpoint [gdb_get_line_number "break-here"] - gdb_continue_to_breakpoint "break-here" ".* break-here .*" + gdb_breakpoint [gdb_get_line_number "break-here"] + gdb_continue_to_breakpoint "break-here" ".* break-here .*" - # Also test with sched-lock to make sure we can follow the - # non-leader thread execing even though the main thread wasn't - # resumed before the exec. - if { $lock_sched } { - gdb_test_no_output "set scheduler-locking on" - } + # Also test with sched-lock to make sure we can follow the + # non-leader thread execing even though the main thread wasn't + # resumed before the exec. + if { $lock_sched } { + gdb_test_no_output "set scheduler-locking on" + } - gdb_test "continue" \ - ".*is executing new program.*Breakpoint 1, main.* at .*" \ - "continue over exec" -}} + gdb_test "continue" \ + ".*is executing new program.*Breakpoint 1, main.* at .*" \ + "continue over exec" + } +} do_test 0 do_test 1 diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp index 789bcf3..5b08fd1 100644 --- a/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp +++ b/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp @@ -29,33 +29,35 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab return -1 } -proc do_test { lock_sched } { with_test_prefix "lock-sched$lock_sched" { - global executable +proc do_test { lock_sched } { + with_test_prefix "lock-sched$lock_sched" { + global executable - clean_restart ${executable} + clean_restart ${executable} - if ![runto_main] { - return -1 - } + if ![runto_main] { + return -1 + } - gdb_breakpoint [gdb_get_line_number "break-here"] - gdb_continue_to_breakpoint "break-here" ".* break-here .*" + gdb_breakpoint [gdb_get_line_number "break-here"] + gdb_continue_to_breakpoint "break-here" ".* break-here .*" - gdb_test "info threads" \ - "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*" \ - "single thread left" + gdb_test "info threads" \ + "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*" \ + "single thread left" - # Also test with sched-lock to make sure we can follow the - # non-leader thread execing even though the main thread wasn't - # resumed before the exec. - if { $lock_sched } { - gdb_test_no_output "set scheduler-locking on" - } + # Also test with sched-lock to make sure we can follow the + # non-leader thread execing even though the main thread wasn't + # resumed before the exec. + if { $lock_sched } { + gdb_test_no_output "set scheduler-locking on" + } - gdb_test "continue" \ - ".*is executing new program.*Breakpoint 1, main.* at .*" \ - "continue over exec" -}} + gdb_test "continue" \ + ".*is executing new program.*Breakpoint 1, main.* at .*" \ + "continue over exec" + } +} do_test 0 do_test 1 diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp index 1b132e0..53c5e06 100644 --- a/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp +++ b/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp @@ -31,29 +31,31 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab return -1 } -proc do_test { lock_sched } { with_test_prefix "lock-sched$lock_sched" { - global executable +proc do_test { lock_sched } { + with_test_prefix "lock-sched$lock_sched" { + global executable - clean_restart ${executable} + clean_restart ${executable} - if ![runto_main] { - return -1 - } + if ![runto_main] { + return -1 + } - gdb_breakpoint [gdb_get_line_number "break-here"] - gdb_continue_to_breakpoint "break-here" ".* break-here .*" + gdb_breakpoint [gdb_get_line_number "break-here"] + gdb_continue_to_breakpoint "break-here" ".* break-here .*" - # Also test with sched-lock to make sure we can follow the - # non-leader thread execing even though the main thread wasn't - # resumed before the exec. - if { $lock_sched } { - gdb_test_no_output "set scheduler-locking on" - } + # Also test with sched-lock to make sure we can follow the + # non-leader thread execing even though the main thread wasn't + # resumed before the exec. + if { $lock_sched } { + gdb_test_no_output "set scheduler-locking on" + } - gdb_test "continue" \ - ".*is executing new program.*Breakpoint 1, main.* at .*" \ - "continue over exec" -}} + gdb_test "continue" \ + ".*is executing new program.*Breakpoint 1, main.* at .*" \ + "continue over exec" + } +} do_test 0 do_test 1 diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp index be0ac73..9ce5a1b 100644 --- a/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp +++ b/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp @@ -30,29 +30,31 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab return -1 } -proc do_test { lock_sched } { with_test_prefix "lock-sched$lock_sched" { - global executable +proc do_test { lock_sched } { + with_test_prefix "lock-sched$lock_sched" { + global executable - clean_restart ${executable} + clean_restart ${executable} - if ![runto_main] { - return -1 - } + if ![runto_main] { + return -1 + } - gdb_breakpoint [gdb_get_line_number "break-here"] - gdb_continue_to_breakpoint "break-here" ".* break-here .*" + gdb_breakpoint [gdb_get_line_number "break-here"] + gdb_continue_to_breakpoint "break-here" ".* break-here .*" - # Also test with sched-lock to make sure we can follow the - # non-leader thread execing even though the main thread wasn't - # resumed before the exec. - if { $lock_sched } { - gdb_test_no_output "set scheduler-locking on" - } + # Also test with sched-lock to make sure we can follow the + # non-leader thread execing even though the main thread wasn't + # resumed before the exec. + if { $lock_sched } { + gdb_test_no_output "set scheduler-locking on" + } - gdb_test "continue" \ - ".*is executing new program.*Breakpoint 1, main.* at .*" \ - "continue over exec" -}} + gdb_test "continue" \ + ".*is executing new program.*Breakpoint 1, main.* at .*" \ + "continue over exec" + } +} do_test 0 do_test 1 diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork.exp b/gdb/testsuite/gdb.threads/watchpoint-fork.exp index c975710..0372e47 100644 --- a/gdb/testsuite/gdb.threads/watchpoint-fork.exp +++ b/gdb/testsuite/gdb.threads/watchpoint-fork.exp @@ -22,120 +22,122 @@ if [is_remote target] { return } -proc test {type symbol} { with_test_prefix "$type" { - global testfile subdir srcdir gdb_prompt - - set srcfile_type ${srcdir}/${subdir}/${testfile}-${type}.c - - # no threads - - with_test_prefix "singlethreaded" { - set executable ${testfile}-${type}-st - set srcfile_main ${testfile}-st.c - if {[build_executable $testfile.exp $executable \ - [list $srcfile_main ${testfile}-${type}.c] \ - [list debug additional_flags=-D$symbol]] == -1} { - return -1 +proc test {type symbol} { + with_test_prefix "$type" { + global testfile subdir srcdir gdb_prompt + + set srcfile_type ${srcdir}/${subdir}/${testfile}-${type}.c + + # no threads + + with_test_prefix "singlethreaded" { + set executable ${testfile}-${type}-st + set srcfile_main ${testfile}-st.c + if {[build_executable $testfile.exp $executable \ + [list $srcfile_main ${testfile}-${type}.c] \ + [list debug additional_flags=-D$symbol]] == -1} { + return -1 + } + + clean_restart $executable + + if [target_info exists gdb,no_hardware_watchpoints] { + # The software watchpoint functionality is in GDB an unrelated test. + gdb_test_no_output "set can-use-hw-watchpoints 0" + } + + gdb_test "show detach-on-fork" "Whether gdb will detach the child of a fork is on\\." + gdb_test_no_output "set follow-fork-mode $type" + gdb_test "show follow-fork-mode" "Debugger response to a program call of fork or vfork is \"$type\"\\." + # Testcase uses it for the `follow-fork-mode child' type. + gdb_test "handle SIGUSR1 nostop noprint pass" "No\[ \t\]+No\[ \t\]+Yes.*" + + if ![runto_main] { + return + } + + gdb_test "watch var" "atchpoint \[0-9\]+: var" "Set the watchpoint" + + # It is never hit but it should not be left over in the fork()ed-off child. + if [skip_hw_breakpoint_tests] { + set hbreak "break" + } else { + set hbreak "hbreak" + } + gdb_test "$hbreak marker" + + gdb_breakpoint "mark_exit" + + gdb_test "continue" \ + "reakpoint \[0-9\]+, marker.*" "hardware breakpoints work" + gdb_test "continue" \ + "atchpoint \[0-9\]+: var.*Old value = 0.*New value = 1.*forkoff *\\(1\\).*" "watchpoints work" + gdb_test "continue" \ + "reakpoint \[0-9\]+, marker.*" "breakpoint after the first fork" + gdb_test "continue" \ + "atchpoint \[0-9\]+: var.*Old value = 1.*New value = 2.*forkoff *\\(2\\).*" "watchpoint after the first fork" + gdb_test "continue" \ + "reakpoint \[0-9\]+, marker.*" "breakpoint after the second fork" + gdb_test "continue" \ + "atchpoint \[0-9\]+: var.*Old value = 2.*New value = 3.*mark_exit \\(\\);" "watchpoint after the second fork" + gdb_test "continue" "Continuing\\..*\r\nBreakpoint \[0-9\]+, mark_exit .*" "finish" } - clean_restart $executable + # threads if [target_info exists gdb,no_hardware_watchpoints] { - # The software watchpoint functionality is in GDB an unrelated test. - gdb_test_no_output "set can-use-hw-watchpoints 0" - } - - gdb_test "show detach-on-fork" "Whether gdb will detach the child of a fork is on\\." - gdb_test_no_output "set follow-fork-mode $type" - gdb_test "show follow-fork-mode" "Debugger response to a program call of fork or vfork is \"$type\"\\." - # Testcase uses it for the `follow-fork-mode child' type. - gdb_test "handle SIGUSR1 nostop noprint pass" "No\[ \t\]+No\[ \t\]+Yes.*" - - if ![runto_main] { - return - } - - gdb_test "watch var" "atchpoint \[0-9\]+: var" "Set the watchpoint" - - # It is never hit but it should not be left over in the fork()ed-off child. - if [skip_hw_breakpoint_tests] { - set hbreak "break" - } else { - set hbreak "hbreak" - } - gdb_test "$hbreak marker" - - gdb_breakpoint "mark_exit" - - gdb_test "continue" \ - "reakpoint \[0-9\]+, marker.*" "hardware breakpoints work" - gdb_test "continue" \ - "atchpoint \[0-9\]+: var.*Old value = 0.*New value = 1.*forkoff *\\(1\\).*" "watchpoints work" - gdb_test "continue" \ - "reakpoint \[0-9\]+, marker.*" "breakpoint after the first fork" - gdb_test "continue" \ - "atchpoint \[0-9\]+: var.*Old value = 1.*New value = 2.*forkoff *\\(2\\).*" "watchpoint after the first fork" - gdb_test "continue" \ - "reakpoint \[0-9\]+, marker.*" "breakpoint after the second fork" - gdb_test "continue" \ - "atchpoint \[0-9\]+: var.*Old value = 2.*New value = 3.*mark_exit \\(\\);" "watchpoint after the second fork" - gdb_test "continue" "Continuing\\..*\r\nBreakpoint \[0-9\]+, mark_exit .*" "finish" - } - - # threads - - if [target_info exists gdb,no_hardware_watchpoints] { - # Watchpoint hits would get detected in unexpected threads. - return - } - - with_test_prefix "multithreaded" { - set executable ${testfile}-${type}-mt - set srcfile_main ${srcdir}/${subdir}/${testfile}-mt.c - if { [gdb_compile_pthreads "${srcfile_main} ${srcfile_type}" [standard_output_file ${executable}] executable [list debug "additional_flags=-D$symbol -DTHREAD"]] != "" } { - untested ${testfile}.exp + # Watchpoint hits would get detected in unexpected threads. return } - clean_restart $executable - - gdb_test_no_output "set follow-fork-mode $type" - # Testcase uses it for the `follow-fork-mode child' type. - gdb_test "handle SIGUSR1 nostop noprint pass" "No\[ \t\]+No\[ \t\]+Yes.*" - if ![runto_main] { - return + with_test_prefix "multithreaded" { + set executable ${testfile}-${type}-mt + set srcfile_main ${srcdir}/${subdir}/${testfile}-mt.c + if { [gdb_compile_pthreads "${srcfile_main} ${srcfile_type}" [standard_output_file ${executable}] executable [list debug "additional_flags=-D$symbol -DTHREAD"]] != "" } { + untested ${testfile}.exp + return + } + clean_restart $executable + + gdb_test_no_output "set follow-fork-mode $type" + # Testcase uses it for the `follow-fork-mode child' type. + gdb_test "handle SIGUSR1 nostop noprint pass" "No\[ \t\]+No\[ \t\]+Yes.*" + + if ![runto_main] { + return + } + + gdb_test "watch var" "atchpoint \[0-9\]+: var" "Set the watchpoint" + + # It should not be left over in the fork()ed-off child. + gdb_test "$hbreak marker" {reakpoint [0-9]+.*} + + gdb_breakpoint "mark_exit" + + gdb_test "continue" \ + "reakpoint \[0-9\]+, marker.*" "hardware breakpoints work" + gdb_test "continue" \ + "atchpoint \[0-9\]+: var.*Old value = 0.*New value = 1.*validity-first.*" "singlethread watchpoints work" + gdb_test "continue" \ + "atchpoint \[0-9\]+: var.*Old value = 1.*New value = 2.*validity-thread-A.*" "multithreaded watchpoints work at A" + gdb_test "continue" \ + "atchpoint \[0-9\]+: var.*Old value = 2.*New value = 3.*validity-thread-B.*" "multithreaded watchpoints work at B" + gdb_test "continue" \ + "reakpoint \[0-9\]+, marker.*" "breakpoint (A) after the first fork" + gdb_test "continue" \ + "atchpoint \[0-9\]+: var.*Old value = 3.*New value = 4.*after-fork1-A.*" "watchpoint A after the first fork" + gdb_test "continue" \ + "atchpoint \[0-9\]+: var.*Old value = 4.*New value = 5.*after-fork1-B.*" "watchpoint B after the first fork" + gdb_test "continue" \ + "reakpoint \[0-9\]+, marker.*" "breakpoint (A) after the second fork" + gdb_test "continue" \ + "atchpoint \[0-9\]+: var.*Old value = 5.*New value = 6.*after-fork2-A.*" "watchpoint A after the second fork" + gdb_test "continue" \ + "atchpoint \[0-9\]+: var.*Old value = 6.*New value = 7.*after-fork2-B.*" "watchpoint B after the second fork" + gdb_test "continue" "Continuing\\..*\r\nBreakpoint \[0-9\]+, mark_exit .*" "finish" } - - gdb_test "watch var" "atchpoint \[0-9\]+: var" "Set the watchpoint" - - # It should not be left over in the fork()ed-off child. - gdb_test "$hbreak marker" {reakpoint [0-9]+.*} - - gdb_breakpoint "mark_exit" - - gdb_test "continue" \ - "reakpoint \[0-9\]+, marker.*" "hardware breakpoints work" - gdb_test "continue" \ - "atchpoint \[0-9\]+: var.*Old value = 0.*New value = 1.*validity-first.*" "singlethread watchpoints work" - gdb_test "continue" \ - "atchpoint \[0-9\]+: var.*Old value = 1.*New value = 2.*validity-thread-A.*" "multithreaded watchpoints work at A" - gdb_test "continue" \ - "atchpoint \[0-9\]+: var.*Old value = 2.*New value = 3.*validity-thread-B.*" "multithreaded watchpoints work at B" - gdb_test "continue" \ - "reakpoint \[0-9\]+, marker.*" "breakpoint (A) after the first fork" - gdb_test "continue" \ - "atchpoint \[0-9\]+: var.*Old value = 3.*New value = 4.*after-fork1-A.*" "watchpoint A after the first fork" - gdb_test "continue" \ - "atchpoint \[0-9\]+: var.*Old value = 4.*New value = 5.*after-fork1-B.*" "watchpoint B after the first fork" - gdb_test "continue" \ - "reakpoint \[0-9\]+, marker.*" "breakpoint (A) after the second fork" - gdb_test "continue" \ - "atchpoint \[0-9\]+: var.*Old value = 5.*New value = 6.*after-fork2-A.*" "watchpoint A after the second fork" - gdb_test "continue" \ - "atchpoint \[0-9\]+: var.*Old value = 6.*New value = 7.*after-fork2-B.*" "watchpoint B after the second fork" - gdb_test "continue" "Continuing\\..*\r\nBreakpoint \[0-9\]+, mark_exit .*" "finish" } -}} +} test parent FOLLOW_PARENT diff --git a/gdb/testsuite/gdb.trace/change-loc.exp b/gdb/testsuite/gdb.trace/change-loc.exp index b02cf27..3a79b10 100644 --- a/gdb/testsuite/gdb.trace/change-loc.exp +++ b/gdb/testsuite/gdb.trace/change-loc.exp @@ -69,208 +69,218 @@ if [is_amd64_regs_target] { # Set tracepoint during tracing experiment. -proc tracepoint_change_loc_1 { trace_type } { with_test_prefix "1 $trace_type" { - global testfile - global srcfile - global pcreg - global gdb_prompt - - clean_restart ${testfile} - if ![runto_main] { - fail "Can't run to main" - return -1 - } - gdb_test_no_output "delete break 1" - - # Set a tracepoint we'll never meet. Just to avoid the complain after - # type `tstart' later. - gdb_test "next" ".*" - gdb_test "trace main" "Tracepoint \[0-9\] at.* file .*$srcfile, line.*" \ - "set tracepoint on main" - - gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \ - "breakpoint on marker" - - gdb_test_no_output "tstart" - - gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \ - "continue to marker 1" - # Set a tracepoint during tracing. - set test "set tracepoint on set_tracepoint" - gdb_test_multiple "${trace_type} set_tracepoint" $test { - -re "Target returns error code .* too far .*$gdb_prompt $" { - if [string equal $trace_type "ftrace"] { - # The target was unable to install the fast tracepoint - # (e.g., jump pad too far from tracepoint). - pass "$test (too far)" - } else { - fail $test - } +proc tracepoint_change_loc_1 { trace_type } { + with_test_prefix "1 $trace_type" { + global testfile + global srcfile + global pcreg + global gdb_prompt + + clean_restart ${testfile} + if ![runto_main] { + fail "Can't run to main" + return -1 } - -re "\r\n$gdb_prompt $" { - pass $test + gdb_test_no_output "delete break 1" + + # Set a tracepoint we'll never meet. Just to avoid the + # complain after type `tstart' later. + gdb_test "next" ".*" + gdb_test "trace main" \ + "Tracepoint \[0-9\] at.* file .*$srcfile, line.*" \ + "set tracepoint on main" + + gdb_test "break marker" \ + "Breakpoint.*at.* file .*$srcfile, line.*" \ + "breakpoint on marker" + + gdb_test_no_output "tstart" + + gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \ + "continue to marker 1" + # Set a tracepoint during tracing. + set test "set tracepoint on set_tracepoint" + gdb_test_multiple "${trace_type} set_tracepoint" $test { + -re "Target returns error code .* too far .*$gdb_prompt $" { + if [string equal $trace_type "ftrace"] { + # The target was unable to install the fast tracepoint + # (e.g., jump pad too far from tracepoint). + pass "$test (too far)" + } else { + fail $test + } + } + -re "\r\n$gdb_prompt $" { + pass $test + } } - } - gdb_trace_setactions "set action for tracepoint" "" \ - "collect \$$pcreg" "^$" + gdb_trace_setactions "set action for tracepoint" "" \ + "collect \$$pcreg" "^$" - # tracepoint has two locations after shlib change-loc-1 is loaded. - gdb_test "info trace" \ - "Num Type\[ \]+Disp Enb Address\[ \]+What.* + # tracepoint has two locations after shlib change-loc-1 is loaded. + gdb_test "info trace" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*" \ - "tracepoint with two locations" - - set test "continue to marker 2" - gdb_test_multiple "continue" $test { - -re "Target returns error code .* too far .*$gdb_prompt $" { - if [string equal $trace_type "ftrace"] { - # Expected if the target was unable to install the - # fast tracepoint (e.g., jump pad too far from - # tracepoint). - pass "$test (too far)" - # Skip the rest of the tests. - return - } else { - fail "continue to marker 2" - fail $test - } - - } - -re ".*Breakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" { - pass "continue to marker 2" - } - } + "tracepoint with two locations" + + set test "continue to marker 2" + gdb_test_multiple "continue" $test { + -re "Target returns error code .* too far .*$gdb_prompt $" { + if [string equal $trace_type "ftrace"] { + # Expected if the target was unable to install the + # fast tracepoint (e.g., jump pad too far from + # tracepoint). + pass "$test (too far)" + # Skip the rest of the tests. + return + } else { + fail "continue to marker 2" + fail $test + } - # tracepoint has three locations after shlib change-loc-2 is loaded. - gdb_test "info trace" \ - "Num Type\[ \]+Disp Enb Address\[ \]+What.* + } + -re ".*Breakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" { + pass "continue to marker 2" + } + } + + # tracepoint has three locations after shlib change-loc-2 is + # loaded. + gdb_test "info trace" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*4\.3.* in func4 .*" \ - "tracepoint with three locations" + "tracepoint with three locations" - gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \ - "continue to marker 3" + gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \ + "continue to marker 3" - # shlib is unloaded, there are still three locations, but one is pending. - gdb_test "info trace" \ - "Num Type\[ \]+Disp Enb Address\[ \]+What.* + # shlib is unloaded, there are still three locations, but one + # is pending. + gdb_test "info trace" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.* 4\.1.* in func4.*\tinstalled on target\r\n(4\.2.* in func4.*\tinstalled on target\r\n4\.3.* \<PENDING\>\[\t \]+set_tracepoint|4\.2.* \<PENDING\>\[\t \]+set_tracepoint.*4\.3.* in func4.*\tinstalled on target).*" \ - "tracepoint with two locations (unload)" + "tracepoint with two locations (unload)" - gdb_test_no_output "tstop" + gdb_test_no_output "tstop" - gdb_test "tfind" "Found trace frame 0, tracepoint 4.*" "tfind frame 0" - gdb_test "tfind" "Target failed to find requested trace frame\\..*" -}} + gdb_test "tfind" "Found trace frame 0, tracepoint 4.*" \ + "tfind frame 0" + gdb_test "tfind" \ + "Target failed to find requested trace frame\\..*" + } +} # Set pending tracepoint. -proc tracepoint_change_loc_2 { trace_type } { with_test_prefix "2 $trace_type" { - global srcdir - global srcfile - global subdir - global pcreg - global binfile - global gdb_prompt - - gdb_exit - gdb_start - gdb_reinitialize_dir $srcdir/$subdir - - gdb_test_multiple "${trace_type} set_tracepoint" "set pending tracepoint" { - -re ".*Make \(|fast \)tracepoint pending.*y or \\\[n\\\]. $" { - gdb_test "y" "\(Fast t|T\)racepoint.*set_tracepoint.*pending." "set pending tracepoint" +proc tracepoint_change_loc_2 { trace_type } { + with_test_prefix "2 $trace_type" { + global srcdir + global srcfile + global subdir + global pcreg + global binfile + global gdb_prompt + + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + + gdb_test_multiple "${trace_type} set_tracepoint" "set pending tracepoint" { + -re ".*Make \(|fast \)tracepoint pending.*y or \\\[n\\\]. $" { + gdb_test "y" "\(Fast t|T\)racepoint.*set_tracepoint.*pending." "set pending tracepoint" + } } - } - gdb_trace_setactions "set action for tracepoint" "" \ - "collect \$$pcreg" "^$" + gdb_trace_setactions "set action for tracepoint" "" \ + "collect \$$pcreg" "^$" - # tracepoint has no location information now. Make sure nothing - # else is displayed. - gdb_test "info trace" \ - "Num Type\[ \]+Disp Enb Address\[ \]+What.* + # tracepoint has no location information now. Make sure nothing + # else is displayed. + gdb_test "info trace" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*PENDING.*set_tracepoint\r\n\[\t \]+collect \\$$pcreg\r" \ - "single pending tracepoint info (without symbols)" + "single pending tracepoint info (without symbols)" - gdb_load ${binfile} - # tracepoint has one location after executable is loaded. - gdb_test "info trace" \ - "Num Type\[ \]+Disp Enb Address\[ \]+What.* + gdb_load ${binfile} + # tracepoint has one location after executable is loaded. + gdb_test "info trace" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*func4.*" \ - "tracepoint with one location" + "tracepoint with one location" - set main_bp 0 - gdb_test_multiple "break main" "set breakpoint on main" { - -re "Breakpoint (\[0-9\]*) at .*, line.*$gdb_prompt $" { - set main_bp $expect_out(1,string) + set main_bp 0 + gdb_test_multiple "break main" "set breakpoint on main" { + -re "Breakpoint (\[0-9\]*) at .*, line.*$gdb_prompt $" { + set main_bp $expect_out(1,string) + } } - } - gdb_run_cmd + gdb_run_cmd - gdb_test "" \ - ".*Breakpoint.*main.*at.*$srcfile.*" \ - "run to main" - gdb_test_no_output "delete break $main_bp" + gdb_test "" \ + ".*Breakpoint.*main.*at.*$srcfile.*" \ + "run to main" + gdb_test_no_output "delete break $main_bp" - # tracepoint has two locations after shlib change-loc-1 is loaded. - gdb_test "info trace" \ - "Num Type\[ \]+Disp Enb Address\[ \]+What.* + # tracepoint has two locations after shlib change-loc-1 is loaded. + gdb_test "info trace" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*1\.1.* in func4.*1\.2.* in func4.*" \ - "tracepoint with two locations" - - gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \ - "breakpoint on marker" - - # tracepoint with two locations will be downloaded and installed. - set test "tstart" - gdb_test_multiple "tstart" $test { - -re "^tstart\r\n$gdb_prompt $" { - pass "tstart" - } - -re "Target returns error code .* too far .*$gdb_prompt $" { - if [string equal $trace_type "ftrace"] { - # The target was unable to install the fast tracepoint - # (e.g., jump pad too far from tracepoint). - pass "$test (too far)" - # Skip the rest of the tests. - return - } else { - fail $test - } + "tracepoint with two locations" + + gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \ + "breakpoint on marker" + + # tracepoint with two locations will be downloaded and installed. + set test "tstart" + gdb_test_multiple "tstart" $test { + -re "^tstart\r\n$gdb_prompt $" { + pass "tstart" + } + -re "Target returns error code .* too far .*$gdb_prompt $" { + if [string equal $trace_type "ftrace"] { + # The target was unable to install the fast tracepoint + # (e.g., jump pad too far from tracepoint). + pass "$test (too far)" + # Skip the rest of the tests. + return + } else { + fail $test + } + } } - } - gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \ - "continue to marker 1" + gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \ + "continue to marker 1" - gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \ - "continue to marker 2" + gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \ + "continue to marker 2" - # tracepoint has three locations after shlib change-loc-2 is loaded. - gdb_test "info trace" \ - "Num Type\[ \]+Disp Enb Address\[ \]+What.* + # tracepoint has three locations after shlib change-loc-2 is loaded. + gdb_test "info trace" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*1\.1.* in func4.*1\.2.* in func4.*1\.3.* in func4 .*" \ - "tracepoint with three locations" + "tracepoint with three locations" - gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \ - "continue to marker 3" + gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \ + "continue to marker 3" - # shlib is unloaded, there are still three locations, but one is pending. - gdb_test "info trace" \ - "Num Type\[ \]+Disp Enb Address\[ \]+What.* + # shlib is unloaded, there are still three locations, but one is pending. + gdb_test "info trace" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.* 1\.1.* in func4.*\tinstalled on target\r\n(1\.2.* in func4.*\tinstalled on target\r\n1\.3.* \<PENDING\>\[\t \]+set_tracepoint|1\.2.* \<PENDING\>\[\t \]+set_tracepoint\r\n1\.3.* in func4.*\tinstalled on target).*" \ - "tracepoint with two locations (unload)" + "tracepoint with two locations (unload)" - gdb_test_no_output "tstop" + gdb_test_no_output "tstop" - gdb_test "tfind" "Found trace frame 0, tracepoint 1.*" "tfind frame 0" - gdb_test "tfind" "Found trace frame 1, tracepoint 1.*" "tfind frame 1" - gdb_test "tfind" "Found trace frame 2, tracepoint 1.*" "tfind frame 2" - gdb_test "tfind" "Target failed to find requested trace frame\\..*" -}} + gdb_test "tfind" "Found trace frame 0, tracepoint 1.*" "tfind frame 0" + gdb_test "tfind" "Found trace frame 1, tracepoint 1.*" "tfind frame 1" + gdb_test "tfind" "Found trace frame 2, tracepoint 1.*" "tfind frame 2" + gdb_test "tfind" "Target failed to find requested trace frame\\..*" + } +} tracepoint_change_loc_1 "trace" tracepoint_change_loc_2 "trace" diff --git a/gdb/testsuite/gdb.trace/disconnected-tracing.exp b/gdb/testsuite/gdb.trace/disconnected-tracing.exp index bec016e..03d7d09 100644 --- a/gdb/testsuite/gdb.trace/disconnected-tracing.exp +++ b/gdb/testsuite/gdb.trace/disconnected-tracing.exp @@ -45,101 +45,105 @@ if ![gdb_target_supports_trace] { # Disconnect in tracing. -proc disconnected_tracing { } { with_test_prefix "trace" { - global executable - global decimal - global srcfile - - # Start with a fresh gdb. - clean_restart ${executable} - if ![runto_main] { - fail "Can't run to main" - return -1 - } - - gdb_test_no_output "set confirm off" - gdb_test_no_output "set disconnected-tracing on" - gdb_test "trace start" ".*" - gdb_trace_setactions "collect on tracepoint 2" "2" \ - "collect foo" "^$" - gdb_test "break end" "Breakpoint ${decimal} at .*" - - gdb_test_no_output "tstart" - - gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" - gdb_test_no_output "tstop" - - gdb_test "info tracepoints" ".*in start at.*" \ - "first info tracepoints" - - gdb_test "disconnect" "Ending remote debugging\\." "first disconnect" - if { [gdb_reconnect] == 0 } { - pass "first reconnect after unload" - } else { - fail "first reconnect after unload" - return 0 - } - gdb_test "info tracepoints" ".*in start at.*" \ - "second info tracepoints" - - delete_breakpoints - gdb_test "info tracepoints" ".*No tracepoints..*" \ - "third info tracepoints" - - gdb_test "disconnect" "Ending remote debugging\\." "second disconnect" - if { [gdb_reconnect] == 0 } { - pass "second reconnect after unload" - } else { - fail "second reconnect after unload" - return 0 - } - gdb_test "tstatus" - gdb_test "info tracepoints" \ - "Num Type\[ \]+Disp Enb Address\[ \]+What.* +proc disconnected_tracing { } { + with_test_prefix "trace" { + global executable + global decimal + global srcfile + + # Start with a fresh gdb. + clean_restart ${executable} + if ![runto_main] { + fail "Can't run to main" + return -1 + } + + gdb_test_no_output "set confirm off" + gdb_test_no_output "set disconnected-tracing on" + gdb_test "trace start" ".*" + gdb_trace_setactions "collect on tracepoint 2" "2" \ + "collect foo" "^$" + gdb_test "break end" "Breakpoint ${decimal} at .*" + + gdb_test_no_output "tstart" + + gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" + gdb_test_no_output "tstop" + + gdb_test "info tracepoints" ".*in start at.*" \ + "first info tracepoints" + + gdb_test "disconnect" "Ending remote debugging\\." "first disconnect" + if { [gdb_reconnect] == 0 } { + pass "first reconnect after unload" + } else { + fail "first reconnect after unload" + return 0 + } + gdb_test "info tracepoints" ".*in start at.*" \ + "second info tracepoints" + + delete_breakpoints + gdb_test "info tracepoints" ".*No tracepoints..*" \ + "third info tracepoints" + + gdb_test "disconnect" "Ending remote debugging\\." "second disconnect" + if { [gdb_reconnect] == 0 } { + pass "second reconnect after unload" + } else { + fail "second reconnect after unload" + return 0 + } + gdb_test "tstatus" + gdb_test "info tracepoints" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* \[0-9\]+\[\t \]+tracepoint keep y.* in start at .*$srcfile:\[0-9\]+. \[\t \]+tracepoint already hit 1 time. \[\t \]+trace buffer usage ${decimal} bytes. \[\t \]+collect foo.*" \ - "fourth info tracepoints" -}} + "fourth info tracepoints" + } +} disconnected_tracing # Disconnected in tfind -proc disconnected_tfind { } { with_test_prefix "tfind" { - global executable - global decimal - - # Start with a fresh gdb. - clean_restart ${executable} - if ![runto_main] { - fail "Can't run to main" - return -1 +proc disconnected_tfind { } { + with_test_prefix "tfind" { + global executable + global decimal + + # Start with a fresh gdb. + clean_restart ${executable} + if ![runto_main] { + fail "Can't run to main" + return -1 + } + + gdb_test_no_output "set confirm off" + gdb_test_no_output "set disconnected-tracing on" + gdb_test "trace start" ".*" + gdb_test_no_output "tstart" + + gdb_test "break end" "Breakpoint ${decimal} at .*" + gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" + gdb_test_no_output "tstop" + + gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0" + gdb_test "p \$trace_frame" ".*\\\$${decimal} = 0.*" \ + "p \$trace_frame before disconnected" + gdb_test "p \$tracepoint" ".*\\\$${decimal} = 2.*" \ + "p \$tracepoint before disconnected" + + gdb_test "disconnect" "Ending remote debugging\\." "first disconnect" + + gdb_test "p \$trace_frame" ".*\\\$${decimal} = -1.*" + gdb_test "p \$tracepoint" ".*\\\$${decimal} = -1.*" + gdb_test "p \$trace_line" ".*\\\$${decimal} = -1.*" + gdb_test "p \$trace_file" ".*\\\$${decimal} = void.*" + gdb_test "p \$trace_func" ".*\\\$${decimal} = void.*" } - - gdb_test_no_output "set confirm off" - gdb_test_no_output "set disconnected-tracing on" - gdb_test "trace start" ".*" - gdb_test_no_output "tstart" - - gdb_test "break end" "Breakpoint ${decimal} at .*" - gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" - gdb_test_no_output "tstop" - - gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0" - gdb_test "p \$trace_frame" ".*\\\$${decimal} = 0.*" \ - "p \$trace_frame before disconnected" - gdb_test "p \$tracepoint" ".*\\\$${decimal} = 2.*" \ - "p \$tracepoint before disconnected" - - gdb_test "disconnect" "Ending remote debugging\\." "first disconnect" - - gdb_test "p \$trace_frame" ".*\\\$${decimal} = -1.*" - gdb_test "p \$tracepoint" ".*\\\$${decimal} = -1.*" - gdb_test "p \$trace_line" ".*\\\$${decimal} = -1.*" - gdb_test "p \$trace_file" ".*\\\$${decimal} = void.*" - gdb_test "p \$trace_func" ".*\\\$${decimal} = void.*" -}} +} disconnected_tfind diff --git a/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp b/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp index 42dbe19..7849a7e 100644 --- a/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp +++ b/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp @@ -34,39 +34,41 @@ remote_exec target "$binfile" # Copy tracefile from target to host. remote_download host [remote_upload target basic.tf] basic.tf -proc test_tfind_tfile { } { with_test_prefix "tfile" { - global binfile - global decimal - - if [mi_gdb_start] { - return +proc test_tfind_tfile { } { + with_test_prefix "tfile" { + global binfile + global decimal + + if [mi_gdb_start] { + return + } + mi_gdb_load ${binfile} + + mi_gdb_test "-target-select tfile basic.tf" \ + ".*=breakpoint-created,bkpt=\{number=\"${decimal}\",type=\"tracepoint\",disp=\"keep\",enabled=\"y\",.*,func=\"write_basic_trace_file\".*\\^connected" \ + "select trace file" + + mi_gdb_test "tfind 0" \ + ".*=traceframe-changed,num=\"0\",tracepoint=\"${decimal}\".*\\^done" \ + "tfind 0" + + # No MI notification is sent because traceframe is not changed. + mi_gdb_test "tfind 0" \ + "\\&\"tfind 0\\\\n\"\r\n\~\"Found.*\\^done" \ + "tfind 0 again" + + mi_gdb_test "tfind end" \ + ".*=traceframe-changed,end.*\\^done" \ + "tfind end" + + # No MI notification is send because request is from MI command. + mi_gdb_test "-trace-find frame-number 0" \ + "-trace-find frame-number 0\r\n\\^done,found=\"1\",tracepoint=\"${decimal}\",traceframe=\"0\",frame=\{.*" \ + "-trace-find frame-number 0" + + mi_gdb_exit } - mi_gdb_load ${binfile} - - mi_gdb_test "-target-select tfile basic.tf" \ - ".*=breakpoint-created,bkpt=\{number=\"${decimal}\",type=\"tracepoint\",disp=\"keep\",enabled=\"y\",.*,func=\"write_basic_trace_file\".*\\^connected" \ - "select trace file" - - mi_gdb_test "tfind 0" \ - ".*=traceframe-changed,num=\"0\",tracepoint=\"${decimal}\".*\\^done" \ - "tfind 0" - - # No MI notification is sent because traceframe is not changed. - mi_gdb_test "tfind 0" \ - "\\&\"tfind 0\\\\n\"\r\n\~\"Found.*\\^done" \ - "tfind 0 again" - - mi_gdb_test "tfind end" \ - ".*=traceframe-changed,end.*\\^done" \ - "tfind end" - - # No MI notification is send because request is from MI command. - mi_gdb_test "-trace-find frame-number 0" \ - "-trace-find frame-number 0\r\n\\^done,found=\"1\",tracepoint=\"${decimal}\",traceframe=\"0\",frame=\{.*" \ - "-trace-find frame-number 0" - - mi_gdb_exit -}} +} test_tfind_tfile @@ -99,38 +101,40 @@ if ![gdb_target_supports_trace] { gdb_exit -proc test_tfind_remote { } { with_test_prefix "remote" { - global decimal +proc test_tfind_remote { } { + with_test_prefix "remote" { + global decimal - if [mi_gdb_start] { - return - } - mi_run_to_main + if [mi_gdb_start] { + return + } + mi_run_to_main - mi_gdb_test "-break-insert end" "\\^done.*" "break end" - mi_gdb_test "-break-insert -a func2" "\\^done.*" "break func2" - mi_gdb_test "-trace-start" "=breakpoint-modified,bkpt={.*installed=\"y\".*}.*\\^done.*" \ - "trace start" + mi_gdb_test "-break-insert end" "\\^done.*" "break end" + mi_gdb_test "-break-insert -a func2" "\\^done.*" "break func2" + mi_gdb_test "-trace-start" "=breakpoint-modified,bkpt={.*installed=\"y\".*}.*\\^done.*" \ + "trace start" - mi_execute_to "exec-continue" "breakpoint-hit" end "" ".*" ".*" \ - { "" "disp=\"keep\"" } \ - "continue to end" - mi_gdb_test "-trace-stop" "\\^done.*" "trace stop" + mi_execute_to "exec-continue" "breakpoint-hit" end "" ".*" ".*" \ + { "" "disp=\"keep\"" } \ + "continue to end" + mi_gdb_test "-trace-stop" "\\^done.*" "trace stop" - mi_gdb_test "tfind 0" \ - ".*=traceframe-changed,num=\"0\",tracepoint=\"${decimal}\".*\\^done" \ - "tfind 0" + mi_gdb_test "tfind 0" \ + ".*=traceframe-changed,num=\"0\",tracepoint=\"${decimal}\".*\\^done" \ + "tfind 0" - mi_gdb_test "tfind" \ - ".*=traceframe-changed,num=\"1\",tracepoint=\"${decimal}\".*\\^done" \ - "tfind" + mi_gdb_test "tfind" \ + ".*=traceframe-changed,num=\"1\",tracepoint=\"${decimal}\".*\\^done" \ + "tfind" - mi_gdb_test "tfind end" \ - ".*=traceframe-changed,end.*\\^done" \ - "tfind end" + mi_gdb_test "tfind end" \ + ".*=traceframe-changed,end.*\\^done" \ + "tfind end" - mi_gdb_exit -}} + mi_gdb_exit + } +} test_tfind_remote diff --git a/gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp b/gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp index c706979..d0a7a1e 100644 --- a/gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp +++ b/gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp @@ -49,192 +49,195 @@ set MIFLAGS "-i=mi" # remote stub can be uploaded to GDB, and GDB emits MI notification if # new tracepoints are created. -proc test_reconnect { } { with_test_prefix "reconnect" { +proc test_reconnect { } { + with_test_prefix "reconnect" { - global gdbserver_reconnect_p - global gdb_prompt - global executable - global lib_sl1 lib_sl2 + global gdbserver_reconnect_p + global gdb_prompt + global executable + global lib_sl1 lib_sl2 - set gdbserver_reconnect_p 1 - if { [info proc gdb_reconnect] == "" } { - return 0 - } + set gdbserver_reconnect_p 1 + if { [info proc gdb_reconnect] == "" } { + return 0 + } - clean_restart $executable - gdb_load_shlibs $lib_sl1 - gdb_load_shlibs $lib_sl2 - if ![runto_main] then { - fail "Can't run to main" - return 0 - } - # Create tracepoints on marker and main, and leave them in the - # remote stub. - gdb_test "trace marker" "Tracepoint.*at.* file .*" \ - "tracepoint on marker" - gdb_test "trace main" "Tracepoint.*at.* file .*" \ - "tracepoint on main" - gdb_test_no_output "tstart" "start trace experiment" - - set test "disconnect" - gdb_test_multiple "disconnect" $test { - -re "Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" { - pass $test - - set test "disconnected" - gdb_test_multiple "y" $test { - -re "$gdb_prompt $" { - pass "$test" + clean_restart $executable + gdb_load_shlibs $lib_sl1 + gdb_load_shlibs $lib_sl2 + if ![runto_main] then { + fail "Can't run to main" + return 0 + } + # Create tracepoints on marker and main, and leave them in the + # remote stub. + gdb_test "trace marker" "Tracepoint.*at.* file .*" \ + "tracepoint on marker" + gdb_test "trace main" "Tracepoint.*at.* file .*" \ + "tracepoint on main" + gdb_test_no_output "tstart" "start trace experiment" + + set test "disconnect" + gdb_test_multiple "disconnect" $test { + -re "Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" { + pass $test + + set test "disconnected" + gdb_test_multiple "y" $test { + -re "$gdb_prompt $" { + pass "$test" + } } } } - } - - gdb_exit - if [mi_gdb_start] { - return - } + gdb_exit - global srcdir - global subdir - global binfile - - mi_gdb_reinitialize_dir $srcdir/$subdir - mi_gdb_load ${binfile} - - global gdbserver_protocol - global gdbserver_gdbport - - # Create tracepoints on marker and pendfunc2. - mi_gdb_test "-break-insert -a -f pendfunc2" \ - {.*\^done,bkpt=.*addr=\"<PENDING>\".*} \ - "insert tracepoint on pendfunc2" - mi_gdb_test "-break-insert -a marker" {.*\^done,bkpt=.*\".*} \ - "insert tracepoint on marker" - - # Connect to the remote stub again, and make sure GDB merges the - # tracepoints of both sides correctly. - send_gdb "47-target-select $gdbserver_protocol $gdbserver_gdbport\n" - - global mi_gdb_prompt - set test "tracepoint created" - gdb_expect { - -re "=breakpoint-created,bkpt=\{number=\"1\",type=\"tracepoint\"" { - # Tracepoint 1 in GDB, which has already existed before - # connecting, should have been merged with a tracepoint on - # the target, so we shouldn't see a =breakpoint-created - # notification for it. - fail "$test: 1" - exp_continue - } - -re "=breakpoint-created,bkpt=\{number=\"2\",type=\"tracepoint\"" { - # Similar to above. - fail "$test: 2" - exp_continue + if [mi_gdb_start] { + return } - -re "=breakpoint-created,bkpt=\{number=\"3\",type=\"tracepoint\",disp=\"keep\",enabled=\"y\",\[^\n\]+,func=\"main\"\[^\n\]+,installed=\"y\"" { - # A tracepoint on main was defined in the stub, not in GDB, - # so we should see a =breakpoint-created notification. - pass $test + + global srcdir + global subdir + global binfile + + mi_gdb_reinitialize_dir $srcdir/$subdir + mi_gdb_load ${binfile} + + global gdbserver_protocol + global gdbserver_gdbport + + # Create tracepoints on marker and pendfunc2. + mi_gdb_test "-break-insert -a -f pendfunc2" \ + {.*\^done,bkpt=.*addr=\"<PENDING>\".*} \ + "insert tracepoint on pendfunc2" + mi_gdb_test "-break-insert -a marker" {.*\^done,bkpt=.*\".*} \ + "insert tracepoint on marker" + + # Connect to the remote stub again, and make sure GDB merges the + # tracepoints of both sides correctly. + send_gdb "47-target-select $gdbserver_protocol $gdbserver_gdbport\n" + + global mi_gdb_prompt + set test "tracepoint created" + gdb_expect { + -re "=breakpoint-created,bkpt=\{number=\"1\",type=\"tracepoint\"" { + # Tracepoint 1 in GDB, which has already existed before + # connecting, should have been merged with a tracepoint on + # the target, so we shouldn't see a =breakpoint-created + # notification for it. + fail "$test: 1" + exp_continue + } + -re "=breakpoint-created,bkpt=\{number=\"2\",type=\"tracepoint\"" { + # Similar to above. + fail "$test: 2" + exp_continue + } + -re "=breakpoint-created,bkpt=\{number=\"3\",type=\"tracepoint\",disp=\"keep\",enabled=\"y\",\[^\n\]+,func=\"main\"\[^\n\]+,installed=\"y\"" { + # A tracepoint on main was defined in the stub, not in GDB, + # so we should see a =breakpoint-created notification. + pass $test + } } - } - # Tracepoint on marker is defined. After the sync, we know that - # the tracepoint is in remote stub. Mark it 'installed'. - set test "tracepoint on marker is installed" - gdb_expect { - -re "=breakpoint-modified,bkpt=\{number=\"2\".*,func=\"marker\".*installed=\"y\".*${mi_gdb_prompt}$" { - pass "$test" + # Tracepoint on marker is defined. After the sync, we know that + # the tracepoint is in remote stub. Mark it 'installed'. + set test "tracepoint on marker is installed" + gdb_expect { + -re "=breakpoint-modified,bkpt=\{number=\"2\".*,func=\"marker\".*installed=\"y\".*${mi_gdb_prompt}$" { + pass "$test" + } } - } - # Check that tracepoint 1 is still pending. - mi_gdb_test "-break-info 1" \ - {.*\^done,BreakpointTable=.*addr=\"<PENDING>\".*} \ - "break-info 1" - - set gdbserver_reconnect_p 0 -}} + # Check that tracepoint 1 is still pending. + mi_gdb_test "-break-info 1" \ + {.*\^done,BreakpointTable=.*addr=\"<PENDING>\".*} \ + "break-info 1" + set gdbserver_reconnect_p 0 + } +} # Test 'breakpoint-modified' notification is emited when pending tracepoints are # resolved. -proc test_pending_resolved { } { with_test_prefix "pending resolved" { - global decimal hex - global executable - global srcdir - global subdir - global binfile - global lib_sl1 lib_sl2 - global mi_gdb_prompt - - gdb_exit - if [mi_gdb_start] { - continue - } +proc test_pending_resolved { } { + with_test_prefix "pending resolved" { + global decimal hex + global executable + global srcdir + global subdir + global binfile + global lib_sl1 lib_sl2 + global mi_gdb_prompt + + gdb_exit + if [mi_gdb_start] { + continue + } - mi_gdb_reinitialize_dir $srcdir/$subdir - mi_gdb_load ${binfile} - mi_load_shlibs $lib_sl1 $lib_sl2 - - # Create a pending tracepoint on pendfunc2 - mi_gdb_test "-break-insert -a -f pendfunc2" \ - {.*\^done,bkpt=.*addr=\"<PENDING>\".*} \ - "insert breakpoint on pendfunc2" - # Insert breakpoint on marker - mi_gdb_test "-break-insert marker" {.*\^done,bkpt=.*} \ - "insert breakpoint on marker" - - mi_run_cmd - mi_expect_stop "breakpoint-hit" "marker" ""\ - ".*" ".*" {"" "disp=\"keep\""} \ - "continue to marker breakpoint" - mi_gdb_test "-trace-start" {\^done} "trace start" - - mi_send_resuming_command "exec-continue" "continuing execution to marker 1" - - # It is expected to get two "=breakpoint-modified" notifications. - # Pending tracepoint is resolved. - set test "tracepoint on pendfunc2 resolved" - gdb_expect { - -re "=breakpoint-modified,bkpt=\{number=\"1\",type=\"tracepoint\".*.*times=\"0\".*installed=\"n\"" { - pass "$test" + mi_gdb_reinitialize_dir $srcdir/$subdir + mi_gdb_load ${binfile} + mi_load_shlibs $lib_sl1 $lib_sl2 + + # Create a pending tracepoint on pendfunc2 + mi_gdb_test "-break-insert -a -f pendfunc2" \ + {.*\^done,bkpt=.*addr=\"<PENDING>\".*} \ + "insert breakpoint on pendfunc2" + # Insert breakpoint on marker + mi_gdb_test "-break-insert marker" {.*\^done,bkpt=.*} \ + "insert breakpoint on marker" + + mi_run_cmd + mi_expect_stop "breakpoint-hit" "marker" ""\ + ".*" ".*" {"" "disp=\"keep\""} \ + "continue to marker breakpoint" + mi_gdb_test "-trace-start" {\^done} "trace start" + + mi_send_resuming_command "exec-continue" "continuing execution to marker 1" + + # It is expected to get two "=breakpoint-modified" notifications. + # Pending tracepoint is resolved. + set test "tracepoint on pendfunc2 resolved" + gdb_expect { + -re "=breakpoint-modified,bkpt=\{number=\"1\",type=\"tracepoint\".*.*times=\"0\".*installed=\"n\"" { + pass "$test" + } } - } - # Resolved tracepoint is installed. - set test "tracepoint on pendfunc2 installed" - gdb_expect { - -re "=breakpoint-modified,bkpt=\{number=\"1\",type=\"tracepoint\".*.*times=\"0\".*installed=\"y\"" { - pass "$test" + # Resolved tracepoint is installed. + set test "tracepoint on pendfunc2 installed" + gdb_expect { + -re "=breakpoint-modified,bkpt=\{number=\"1\",type=\"tracepoint\".*.*times=\"0\".*installed=\"y\"" { + pass "$test" + } } - } - mi_expect_stop "breakpoint-hit" "marker" ".*" ".*" ".*" \ - {"" "disp=\"keep\""} "continue to marker" + mi_expect_stop "breakpoint-hit" "marker" ".*" ".*" ".*" \ + {"" "disp=\"keep\""} "continue to marker" - mi_gdb_test "-trace-stop" {\^done,.*} "trace stop" - mi_gdb_test "-trace-find frame-number 0" \ - "-trace-find frame-number 0\r\n\\^done,found=\"1\",tracepoint=\"${decimal}\",traceframe=\"0\",frame=\{.*" \ - "-trace-find frame-number 0" - mi_gdb_test "-trace-find none" {\^done,found="0"} "back to live inferior" + mi_gdb_test "-trace-stop" {\^done,.*} "trace stop" + mi_gdb_test "-trace-find frame-number 0" \ + "-trace-find frame-number 0\r\n\\^done,found=\"1\",tracepoint=\"${decimal}\",traceframe=\"0\",frame=\{.*" \ + "-trace-find frame-number 0" + mi_gdb_test "-trace-find none" {\^done,found="0"} "back to live inferior" - mi_send_resuming_command "exec-continue" "continuing to exit" - set test "tracepoint on pendfunc2 becomes pending again" - gdb_expect { - -re ".*=breakpoint-modified,bkpt=\{number=\"1\",type=\"tracepoint\".*addr=\"<PENDING>\",.*times=\"0\"" { - pass "$test" - } - -re ".*${mi_gdb_prompt}$" { - fail $test - } - timeout { - fail "$test (timeout)" + mi_send_resuming_command "exec-continue" "continuing to exit" + set test "tracepoint on pendfunc2 becomes pending again" + gdb_expect { + -re ".*=breakpoint-modified,bkpt=\{number=\"1\",type=\"tracepoint\".*addr=\"<PENDING>\",.*times=\"0\"" { + pass "$test" + } + -re ".*${mi_gdb_prompt}$" { + fail $test + } + timeout { + fail "$test (timeout)" + } } - } - mi_expect_stop "exited-normally" "" "" "" "" "" "" -}} + mi_expect_stop "exited-normally" "" "" "" "" "" "" + } +} # Test target supports tracepoints or not. diff --git a/gdb/testsuite/gdb.trace/mi-tsv-changed.exp b/gdb/testsuite/gdb.trace/mi-tsv-changed.exp index a8ed9fc..4ca46e1 100644 --- a/gdb/testsuite/gdb.trace/mi-tsv-changed.exp +++ b/gdb/testsuite/gdb.trace/mi-tsv-changed.exp @@ -25,202 +25,206 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ # Test notifications on creating, deleting and modifying TSV. -proc test_create_delete_modify_tsv { } {with_test_prefix "create delete modify" { - global binfile - global decimal - global testfile - global srcdir subdir - global mi_gdb_prompt - - if [mi_gdb_start] { - return - } - mi_gdb_load ${binfile} - - mi_gdb_test "tvariable \$tvar1" \ - ".*=tsv-created,name=\"tvar1\",initial=\"0\"\\\\n.*\\^done" \ - "tvariable \$tvar1" - mi_gdb_test "tvariable \$tvar1 = 1" \ - ".*=tsv-modified,name=\"tvar1\",initial=\"1\".*\\^done" \ - "tvariable \$tvar1 modified" - # No "=tsv-modified" notification is emitted, because the initial - # value is not changed. - mi_gdb_test "tvariable \$tvar1 = 1" \ - ".*\\\$tvar1 = 1\\\\n\"\r\n~\"Trace state .*\\\\n.*\\^done" \ - "tvariable \$tvar1 modified without notification" - mi_gdb_test "tvariable \$tvar2 = 45" \ - ".*=tsv-created,name=\"tvar2\",initial=\"45\"\\\\n.*\\^done" \ - "tvariable \$tvar2" - - mi_gdb_test "delete tvariable \$tvar2" \ - ".*=tsv-deleted,name=\"tvar2\"\\\\n.*\\^done" \ - "delete tvariable \$tvar2" - - mi_gdb_test "delete tvariable" \ - ".*=tsv-deleted\\\\n.*\\^done" \ - "delete all tvariables" - - # Test target supports tracepoints or not. - clean_restart $testfile - - if ![runto_main] { - fail "Can't run to main to check for trace support" - return -1 - } - - if ![gdb_target_supports_trace] { - unsupported "Current target does not support trace" - return -1 - } - gdb_exit - if [mi_gdb_start] { - continue - } +proc test_create_delete_modify_tsv { } { + with_test_prefix "create delete modify" { + global binfile + global decimal + global testfile + global srcdir subdir + global mi_gdb_prompt + + if [mi_gdb_start] { + return + } + mi_gdb_load ${binfile} + + mi_gdb_test "tvariable \$tvar1" \ + ".*=tsv-created,name=\"tvar1\",initial=\"0\"\\\\n.*\\^done" \ + "tvariable \$tvar1" + mi_gdb_test "tvariable \$tvar1 = 1" \ + ".*=tsv-modified,name=\"tvar1\",initial=\"1\".*\\^done" \ + "tvariable \$tvar1 modified" + # No "=tsv-modified" notification is emitted, because the initial + # value is not changed. + mi_gdb_test "tvariable \$tvar1 = 1" \ + ".*\\\$tvar1 = 1\\\\n\"\r\n~\"Trace state .*\\\\n.*\\^done" \ + "tvariable \$tvar1 modified without notification" + mi_gdb_test "tvariable \$tvar2 = 45" \ + ".*=tsv-created,name=\"tvar2\",initial=\"45\"\\\\n.*\\^done" \ + "tvariable \$tvar2" + + mi_gdb_test "delete tvariable \$tvar2" \ + ".*=tsv-deleted,name=\"tvar2\"\\\\n.*\\^done" \ + "delete tvariable \$tvar2" + + mi_gdb_test "delete tvariable" \ + ".*=tsv-deleted\\\\n.*\\^done" \ + "delete all tvariables" + + # Test target supports tracepoints or not. + clean_restart $testfile + + if ![runto_main] { + fail "Can't run to main to check for trace support" + return -1 + } - mi_gdb_reinitialize_dir $srcdir/$subdir - mi_gdb_load ${binfile} - - mi_gdb_test "tvariable \$tvar3 = 3" \ - ".*=tsv-created,name=\"tvar3\",initial=\"3\".*\\^done" \ - "tvariable \$tvar3 modified" - mi_gdb_test "-break-insert -a gdb_c_test" \ - {.*\^done,bkpt=.*} \ - "insert tracepoint on gdb_c_test" - # Define an action that increases $tvar3 - send_gdb "actions\n" - gdb_expect { - -re "End with" { + if ![gdb_target_supports_trace] { + unsupported "Current target does not support trace" + return -1 } - } - send_gdb "collect \$tvar3 += 3\nend\n" - set test "define actions" - gdb_expect { - -re ".*${mi_gdb_prompt}$" { - pass $test + gdb_exit + if [mi_gdb_start] { + continue } - timeout { - fail "$test (timeout)" + + mi_gdb_reinitialize_dir $srcdir/$subdir + mi_gdb_load ${binfile} + + mi_gdb_test "tvariable \$tvar3 = 3" \ + ".*=tsv-created,name=\"tvar3\",initial=\"3\".*\\^done" \ + "tvariable \$tvar3 modified" + mi_gdb_test "-break-insert -a gdb_c_test" \ + {.*\^done,bkpt=.*} \ + "insert tracepoint on gdb_c_test" + # Define an action that increases $tvar3 + send_gdb "actions\n" + gdb_expect { + -re "End with" { + } } - } + send_gdb "collect \$tvar3 += 3\nend\n" + set test "define actions" + gdb_expect { + -re ".*${mi_gdb_prompt}$" { + pass $test + } + timeout { + fail "$test (timeout)" + } + } + + mi_gdb_test "-break-insert begin" \ + {.*\^done,bkpt=.*} \ + "insert tracepoint on begin" + mi_gdb_test "-break-insert end" \ + {.*\^done,bkpt=.*} \ + "insert tracepoint on end" + mi_run_cmd + + mi_expect_stop "breakpoint-hit" "begin" ""\ + ".*" ".*" {"" "disp=\"keep\""} \ + "continue to begin breakpoint" + mi_gdb_test "-trace-start" {.*\^done} "trace start" + mi_send_resuming_command "exec-continue" "continuing to end" + mi_gdb_test "-trace-stop" {.*} "trace stop" + # Force GDB to get the current value of trace state variable. + mi_gdb_test "-trace-list-variables" ".*" "list trace variables" + mi_gdb_test "tvariable \$tvar3 = 2" \ + ".*=tsv-modified,name=\"tvar3\",initial=\"2\",current=\"6\".*\\^done" \ + "tvariable \$tvar3 modified" - mi_gdb_test "-break-insert begin" \ - {.*\^done,bkpt=.*} \ - "insert tracepoint on begin" - mi_gdb_test "-break-insert end" \ - {.*\^done,bkpt=.*} \ - "insert tracepoint on end" - mi_run_cmd - - mi_expect_stop "breakpoint-hit" "begin" ""\ - ".*" ".*" {"" "disp=\"keep\""} \ - "continue to begin breakpoint" - mi_gdb_test "-trace-start" {.*\^done} "trace start" - mi_send_resuming_command "exec-continue" "continuing to end" - mi_gdb_test "-trace-stop" {.*} "trace stop" - # Force GDB to get the current value of trace state variable. - mi_gdb_test "-trace-list-variables" ".*" "list trace variables" - mi_gdb_test "tvariable \$tvar3 = 2" \ - ".*=tsv-modified,name=\"tvar3\",initial=\"2\",current=\"6\".*\\^done" \ - "tvariable \$tvar3 modified" - -}} + } +} # Test when GDB connects to a disconnected stub, existing TSVs in # remote stub can be uploaded to GDB, and GDB emits MI notification # for new uploaded TSVs. -proc test_upload_tsv { } { with_test_prefix "upload" { +proc test_upload_tsv { } { + with_test_prefix "upload" { - global gdbserver_reconnect_p - global gdb_prompt - global testfile - global decimal + global gdbserver_reconnect_p + global gdb_prompt + global testfile + global decimal - set gdbserver_reconnect_p 1 - if { [info proc gdb_reconnect] == "" } { - return 0 - } + set gdbserver_reconnect_p 1 + if { [info proc gdb_reconnect] == "" } { + return 0 + } - clean_restart $testfile - if ![runto_main] then { - fail "Can't run to main" - return 0 - } + clean_restart $testfile + if ![runto_main] then { + fail "Can't run to main" + return 0 + } - gdb_test "tvariable \$tvar1" \ - "Trace state variable \\\$tvar1 created, with initial value 0." \ - "Create a trace state variable" - - gdb_test "tvariable \$tvar2 = 45" \ - "Trace state variable \\\$tvar2 created, with initial value 45." \ - "Create a trace state variable with initial value" - # Define a tracepoint otherwise tracing cannot be started. - gdb_test "trace main" "Tracepoint $decimal at .*" - gdb_test_no_output "tstart" "start trace experiment" - - set test "disconnect" - gdb_test_multiple "disconnect" $test { - -re "Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" { - pass $test - - set test "disconnected" - gdb_test_multiple "y" $test { - -re "$gdb_prompt $" { - pass "$test" + gdb_test "tvariable \$tvar1" \ + "Trace state variable \\\$tvar1 created, with initial value 0." \ + "Create a trace state variable" + + gdb_test "tvariable \$tvar2 = 45" \ + "Trace state variable \\\$tvar2 created, with initial value 45." \ + "Create a trace state variable with initial value" + # Define a tracepoint otherwise tracing cannot be started. + gdb_test "trace main" "Tracepoint $decimal at .*" + gdb_test_no_output "tstart" "start trace experiment" + + set test "disconnect" + gdb_test_multiple "disconnect" $test { + -re "Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" { + pass $test + + set test "disconnected" + gdb_test_multiple "y" $test { + -re "$gdb_prompt $" { + pass "$test" + } } } } - } - gdb_exit + gdb_exit - if [mi_gdb_start] { - return - } + if [mi_gdb_start] { + return + } - global srcdir - global subdir - global binfile + global srcdir + global subdir + global binfile - mi_gdb_reinitialize_dir $srcdir/$subdir - mi_gdb_load ${binfile} + mi_gdb_reinitialize_dir $srcdir/$subdir + mi_gdb_load ${binfile} - global gdbserver_protocol - global gdbserver_gdbport + global gdbserver_protocol + global gdbserver_gdbport - send_gdb "47-target-select $gdbserver_protocol $gdbserver_gdbport\n" + send_gdb "47-target-select $gdbserver_protocol $gdbserver_gdbport\n" - global mi_gdb_prompt - set tsv1_created 0 - set tsv2_created 0 - gdb_expect { - -re "=tsv-created,name=\"tvar1\",initial=\"0\"" { - set tsv1_created 1 - exp_continue - } - -re "=tsv-created,name=\"tvar2\",initial=\"45\"" { - set tsv2_created 1 - exp_continue + global mi_gdb_prompt + set tsv1_created 0 + set tsv2_created 0 + gdb_expect { + -re "=tsv-created,name=\"tvar1\",initial=\"0\"" { + set tsv1_created 1 + exp_continue + } + -re "=tsv-created,name=\"tvar2\",initial=\"45\"" { + set tsv2_created 1 + exp_continue + } + -re ".*${mi_gdb_prompt}" { + + } } - -re ".*${mi_gdb_prompt}" { + if $tsv1_created { + pass "tsv1 created" + } else { + fail "tsv1 created" + } + if $tsv2_created { + pass "tsv2 created" + } else { + fail "tsv2 created" } - } - if $tsv1_created { - pass "tsv1 created" - } else { - fail "tsv1 created" - } - if $tsv2_created { - pass "tsv2 created" - } else { - fail "tsv2 created" + set gdbserver_reconnect_p 0 } - - set gdbserver_reconnect_p 0 -}} +} test_create_delete_modify_tsv diff --git a/gdb/testsuite/gdb.trace/pending.exp b/gdb/testsuite/gdb.trace/pending.exp index c70600a..0308e13 100644 --- a/gdb/testsuite/gdb.trace/pending.exp +++ b/gdb/testsuite/gdb.trace/pending.exp @@ -58,107 +58,117 @@ if ![gdb_target_supports_trace] { # Verify pending tracepoint is resolved to running to main. -proc pending_tracepoint_resolved { trace_type } { with_test_prefix "$trace_type resolved" { - global srcdir - global subdir - global binfile - global srcfile - global lib_sl1 - - # Start with a fresh gdb. - gdb_exit - gdb_start - gdb_reinitialize_dir $srcdir/$subdir - - gdb_test_multiple "$trace_type set_point1" "set pending tracepoint" { - -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" { - gdb_test "y" "\(Fast t|T\)racepoint.*set_point1.*pending." \ - "set pending tracepoint (without symbols)" +proc pending_tracepoint_resolved { trace_type } { + with_test_prefix "$trace_type resolved" { + global srcdir + global subdir + global binfile + global srcfile + global lib_sl1 + + # Start with a fresh gdb. + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + + gdb_test_multiple "$trace_type set_point1" "set pending tracepoint" { + -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" { + gdb_test "y" "\(Fast t|T\)racepoint.*set_point1.*pending." \ + "set pending tracepoint (without symbols)" + } } - } - gdb_test "info trace" \ - "Num Type\[ \]+Disp Enb Address\[ \]+What.* + gdb_test "info trace" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* \[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*PENDING.*set_point1.*" \ - "single pending tracepoint info (without symbols)" + "single pending tracepoint info (without symbols)" - gdb_load ${binfile} + gdb_load ${binfile} - gdb_test "break main" "Breakpoint.*at.* file .*$srcfile, line.*" \ - "breakpoint function" + gdb_test "break main" "Breakpoint.*at.* file .*$srcfile, line.*" \ + "breakpoint function" - gdb_run_cmd - gdb_test "" "Breakpoint 2, main.*" + gdb_run_cmd + gdb_test "" "Breakpoint 2, main.*" - # Run to main which should resolve a pending tracepoint - gdb_test "info trace" \ - "Num Type\[ \]+Disp Enb Address\[ \]+What.* + # Run to main which should resolve a pending tracepoint + gdb_test "info trace" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* \[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*pendfunc.*" \ - "single tracepoint info" -}} + "single tracepoint info" + } +} # Verify pending tracepoint is resolved and works as expected. -proc pending_tracepoint_works { trace_type } { with_test_prefix "$trace_type works" { - global executable - global srcfile - global lib_sl1 - global gdb_prompt +proc pending_tracepoint_works { trace_type } { + with_test_prefix "$trace_type works" { + global executable + global srcfile + global lib_sl1 + global gdb_prompt - # Restart with a fresh gdb. - clean_restart $executable + # Restart with a fresh gdb. + clean_restart $executable - # Test setting and querying pending tracepoints + # Test setting and querying pending tracepoints - gdb_test_multiple "$trace_type set_point1" "set pending tracepoint" { - -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" { - gdb_test "y" "\(Fast t|T\)racepoint.*set_point1.*pending." "set pending tracepoint" + gdb_test_multiple "$trace_type set_point1" "set pending tracepoint" { + -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" { + gdb_test "y" \ + "\(Fast t|T\)racepoint.*set_point1.*pending." \ + "set pending tracepoint" + } } - } - gdb_test "info trace" \ - "Num Type\[ \]+Disp Enb Address\[ \]+What.* + gdb_test "info trace" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* \[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*PENDING.*set_point1.*" \ - "single pending tracepoint info" + "single pending tracepoint info" - # Run to main which should resolve a pending tracepoint - gdb_test "break main" "Breakpoint.*at.* file .*$srcfile, line.*" \ - "breakpoint function" - gdb_run_cmd - gdb_test "" "Breakpoint 2, main.*" + # Run to main which should resolve a pending tracepoint + gdb_test "break main" "Breakpoint.*at.* file .*$srcfile, line.*" \ + "breakpoint function" + gdb_run_cmd + gdb_test "" "Breakpoint 2, main.*" - gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \ - "breakpoint on marker" + gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \ + "breakpoint on marker" - set test "start trace experiment" - gdb_test_multiple "tstart" $test { - -re "^tstart\r\n$gdb_prompt $" { - pass $test - } - -re "Target returns error code .* too far .*$gdb_prompt $" { - if [string equal $trace_type "ftrace"] { - # The target was unable to install the fast tracepoint - # (e.g., jump pad too far from tracepoint). - pass "$test (too far)" - # Skip the rest of the tests. - return - } else { - fail $test + set test "start trace experiment" + gdb_test_multiple "tstart" $test { + -re "^tstart\r\n$gdb_prompt $" { + pass $test + } + -re "Target returns error code .* too far .*$gdb_prompt $" { + if [string equal $trace_type "ftrace"] { + # The target was unable to install the fast tracepoint + # (e.g., jump pad too far from tracepoint). + pass "$test (too far)" + # Skip the rest of the tests. + return + } else { + fail $test + } } - } - } + } - gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*$srcfile.*" \ - "continue to marker" + gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*$srcfile.*" \ + "continue to marker" - gdb_test "tstop" "\[\r\n\]+" "stop trace experiment" + gdb_test "tstop" "\[\r\n\]+" "stop trace experiment" - gdb_test "tfind start" "#0 .*" "tfind test frame 0" - gdb_test "tfind" "Found trace frame 1, tracepoint 1.*" "tfind test frame 1" - gdb_test "tfind" "Found trace frame 2, tracepoint 1.*" "tfind test frame 2" - gdb_test "tfind" "Target failed to find requested trace frame..*" "tfind test frame" -}} + gdb_test "tfind start" "#0 .*" "tfind test frame 0" + gdb_test "tfind" "Found trace frame 1, tracepoint 1.*" \ + "tfind test frame 1" + gdb_test "tfind" "Found trace frame 2, tracepoint 1.*" \ + "tfind test frame 2" + gdb_test "tfind" \ + "Target failed to find requested trace frame..*" \ + "tfind test frame" + } +} # Verify pending tracepoint is resolved during trace. diff --git a/gdb/testsuite/gdb.trace/report.exp b/gdb/testsuite/gdb.trace/report.exp index 527b470..25680c7 100644 --- a/gdb/testsuite/gdb.trace/report.exp +++ b/gdb/testsuite/gdb.trace/report.exp @@ -192,212 +192,213 @@ gdb_test "help tdump" "Print everything collected at the current.*" \ # Check the collected trace data from different sources, such as live # inferior and tfile. -proc use_collected_data { data_source } { with_test_prefix "${data_source}" { - global tdp1 tdp2 tdp3 tdp4 tdp5 tdp6 - global testline1 testline2 testline3 testline4 testline5 testline6 - global pcreg fpreg spreg - global srcfile srcdir subdir - global arg1 arg3 - global decimal hex gdb_prompt - # - # 9.1 test the tdump command - # - - set timeout 60 - - gdb_tfind_test "9.1: find frame for TP $tdp1" "tracepoint $tdp1" \ - "\$tracepoint" "$tdp1" - - # Nothing was collected at tdp1, so this tdump should be empty. - gdb_test "tdump" \ - "Data collected at tracepoint $tdp1, trace frame $decimal:" \ - "9.1: tdump, nothing collected" - - gdb_tfind_test "9.1: find frame for TP $tdp2" "tracepoint $tdp2" \ - "\$tracepoint" "$tdp2" - - # regs were collected at tdp2. - # How to match for the output of "info registers" on an unknown architecture? - # For now, assume that most architectures have a register called "pc". - - gdb_test "tdump" \ - "\[\r\n\]$pcreg .*" \ - "9.1: tdump, regs collected" - - gdb_tfind_test "9.1: find frame for TP $tdp3" "tracepoint $tdp3" \ - "\$tracepoint" "$tdp3" - - # args were collected at tdp3 - gdb_test "tdump" \ - "depth = 3.*q1 = 2.*q2 = 2.*q3 = 3.*q4 = 4.*q5 = 5.*q6 = 6" \ - "9.1: tdump, args collected" - - gdb_tfind_test "9.1: find frame for TP $tdp4" "tracepoint $tdp4" \ - "\$tracepoint" "$tdp4" - - # locals were collected at tdp4 - gdb_test "tdump" \ - "q = 1" \ - "9.1: tdump, locals collected" - - gdb_tfind_test "9.1: find frame for TP $tdp5" "tracepoint $tdp5" \ - "\$tracepoint" "$tdp5" - - # stack was collected at tdp5, plus the frame pointer - gdb_test "tdump" \ - ".$fpreg = .*$spreg @ 64 = .*" \ - "9.1: tdump, memrange collected" - - gdb_tfind_test "9.1: find frame for TP $tdp6" "tracepoint $tdp6" \ - "\$tracepoint" "$tdp6" - - # globals were collected at tdp6 - gdb_test "tdump" \ - "gdb_char_test = 1.*gdb_short_test = 2.*gdb_long_test = 3" \ - "9.1: tdump, global variables collected" - - # 9.2 test tdump with arguments - # [no go, tdump doesn't have any arguments] - - set linecount1 0 - set linecount2 0 - set linecount3 0 - set linecount4 0 - set linecount5 0 - set linecount6 0 - - gdb_tfind_test "11.x, 12.1: find start frame" "start" "0" - - # - # 11.x test built-in trace variables $trace_frame, $trace_line etc. - # - - gdb_test "printf \"x %d x\\n\", \$trace_frame" "x 0 x" \ - "11.1: test \$trace_frame" - - gdb_test "printf \"x %d x\\n\", \$tracepoint" "x $tdp1 x" \ - "11.2: test \$tracepoint" - - gdb_test "printf \"x %d x\\n\", \$trace_line" "x $testline1 x" \ - "11.3: test \$trace_line" - - gdb_test_multiple "print \$trace_file" "11.4: test \$trace_file" { - -re "\\$\[0-9\]+ = \"$srcfile\"\[\r\n\]+$gdb_prompt $" { - pass "11.4: test \$trace_file" - } - -re "\\$\[0-9\]+ = \"$srcdir/$subdir/$srcfile\"\[\r\n\]+$gdb_prompt $" { - pass "11.4: test \$trace_file" +proc use_collected_data { data_source } { + with_test_prefix "${data_source}" { + global tdp1 tdp2 tdp3 tdp4 tdp5 tdp6 + global testline1 testline2 testline3 testline4 testline5 testline6 + global pcreg fpreg spreg + global srcfile srcdir subdir + global arg1 arg3 + global decimal hex gdb_prompt + # + # 9.1 test the tdump command + # + + set timeout 60 + + gdb_tfind_test "9.1: find frame for TP $tdp1" "tracepoint $tdp1" \ + "\$tracepoint" "$tdp1" + + # Nothing was collected at tdp1, so this tdump should be empty. + gdb_test "tdump" \ + "Data collected at tracepoint $tdp1, trace frame $decimal:" \ + "9.1: tdump, nothing collected" + + gdb_tfind_test "9.1: find frame for TP $tdp2" "tracepoint $tdp2" \ + "\$tracepoint" "$tdp2" + + # regs were collected at tdp2. + # How to match for the output of "info registers" on an unknown architecture? + # For now, assume that most architectures have a register called "pc". + + gdb_test "tdump" \ + "\[\r\n\]$pcreg .*" \ + "9.1: tdump, regs collected" + + gdb_tfind_test "9.1: find frame for TP $tdp3" "tracepoint $tdp3" \ + "\$tracepoint" "$tdp3" + + # args were collected at tdp3 + gdb_test "tdump" \ + "depth = 3.*q1 = 2.*q2 = 2.*q3 = 3.*q4 = 4.*q5 = 5.*q6 = 6" \ + "9.1: tdump, args collected" + + gdb_tfind_test "9.1: find frame for TP $tdp4" "tracepoint $tdp4" \ + "\$tracepoint" "$tdp4" + + # locals were collected at tdp4 + gdb_test "tdump" \ + "q = 1" \ + "9.1: tdump, locals collected" + + gdb_tfind_test "9.1: find frame for TP $tdp5" "tracepoint $tdp5" \ + "\$tracepoint" "$tdp5" + + # stack was collected at tdp5, plus the frame pointer + gdb_test "tdump" \ + ".$fpreg = .*$spreg @ 64 = .*" \ + "9.1: tdump, memrange collected" + + gdb_tfind_test "9.1: find frame for TP $tdp6" "tracepoint $tdp6" \ + "\$tracepoint" "$tdp6" + + # globals were collected at tdp6 + gdb_test "tdump" \ + "gdb_char_test = 1.*gdb_short_test = 2.*gdb_long_test = 3" \ + "9.1: tdump, global variables collected" + + # 9.2 test tdump with arguments + # [no go, tdump doesn't have any arguments] + + set linecount1 0 + set linecount2 0 + set linecount3 0 + set linecount4 0 + set linecount5 0 + set linecount6 0 + + gdb_tfind_test "11.x, 12.1: find start frame" "start" "0" + + # + # 11.x test built-in trace variables $trace_frame, $trace_line etc. + # + + gdb_test "printf \"x %d x\\n\", \$trace_frame" "x 0 x" \ + "11.1: test \$trace_frame" + + gdb_test "printf \"x %d x\\n\", \$tracepoint" "x $tdp1 x" \ + "11.2: test \$tracepoint" + + gdb_test "printf \"x %d x\\n\", \$trace_line" "x $testline1 x" \ + "11.3: test \$trace_line" + + gdb_test_multiple "print \$trace_file" "11.4: test \$trace_file" { + -re "\\$\[0-9\]+ = \"$srcfile\"\[\r\n\]+$gdb_prompt $" { + pass "11.4: test \$trace_file" + } + -re "\\$\[0-9\]+ = \"$srcdir/$subdir/$srcfile\"\[\r\n\]+$gdb_prompt $" { + pass "11.4: test \$trace_file" + } } - } - #gdb_test "print \$trace_file" "\"$srcdir/$subdir/$srcfile\"" \ - # "11.4: test \$trace_file" + #gdb_test "print \$trace_file" "\"$srcdir/$subdir/$srcfile\"" \ + # "11.4: test \$trace_file" - # - # 12.x test report generation using arbitrary GDB commands, loops etc. - # + # + # 12.x test report generation using arbitrary GDB commands, loops etc. + # - gdb_test_multiple "while \$trace_frame != -1\n output \$trace_file\n printf \", line \%d \(tracepoint #\%d\)\\n\", \$trace_line, \$tracepoint\n tfind\n end" "12.1: trace report #1" { - -re "> end\r\n" { - exp_continue - } - -re "^Found trace frame \[0-9\]+, tracepoint \[0-9\]+\r\n" { - exp_continue - } - -re "^\[^\r\n\]* line $testline1 .tracepoint .$tdp1\\)\r\n" { - set linecount1 [expr $linecount1 + 1] - exp_continue - } - -re "^\[^\r\n\]* line $testline2 .tracepoint .$tdp2\\)\r\n" { - set linecount2 [expr $linecount2 + 1] - exp_continue - } - -re "^\[^\r\n\]* line $testline3 .tracepoint .$tdp3\\)\r\n" { - set linecount3 [expr $linecount3 + 1] - exp_continue - } - -re "^\[^\r\n\]* line $testline4 .tracepoint .$tdp4\\)\r\n" { - set linecount4 [expr $linecount4 + 1] - exp_continue - } - -re "^\[^\r\n\]* line $testline5 .tracepoint .$tdp5\\)\r\n" { - set linecount5 [expr $linecount5 + 1] - exp_continue - } - -re "^\[^\r\n\]* line $testline6 .tracepoint .$tdp6\\)\r\n" { - set linecount6 [expr $linecount6 + 1] - exp_continue - } - -re "^No trace frame found\r\n$gdb_prompt $" { - if { ($linecount1 < 4) || ($linecount2 < 4) || ($linecount3 < 4) || ($linecount4 < 4) || ($linecount5 < 4) || ($linecount6 < 4) } { - fail "12.1: trace report #1" - } else { - pass "12.1: trace report #1" + gdb_test_multiple "while \$trace_frame != -1\n output \$trace_file\n printf \", line \%d \(tracepoint #\%d\)\\n\", \$trace_line, \$tracepoint\n tfind\n end" "12.1: trace report #1" { + -re "> end\r\n" { + exp_continue + } + -re "^Found trace frame \[0-9\]+, tracepoint \[0-9\]+\r\n" { + exp_continue + } + -re "^\[^\r\n\]* line $testline1 .tracepoint .$tdp1\\)\r\n" { + set linecount1 [expr $linecount1 + 1] + exp_continue + } + -re "^\[^\r\n\]* line $testline2 .tracepoint .$tdp2\\)\r\n" { + set linecount2 [expr $linecount2 + 1] + exp_continue + } + -re "^\[^\r\n\]* line $testline3 .tracepoint .$tdp3\\)\r\n" { + set linecount3 [expr $linecount3 + 1] + exp_continue + } + -re "^\[^\r\n\]* line $testline4 .tracepoint .$tdp4\\)\r\n" { + set linecount4 [expr $linecount4 + 1] + exp_continue + } + -re "^\[^\r\n\]* line $testline5 .tracepoint .$tdp5\\)\r\n" { + set linecount5 [expr $linecount5 + 1] + exp_continue + } + -re "^\[^\r\n\]* line $testline6 .tracepoint .$tdp6\\)\r\n" { + set linecount6 [expr $linecount6 + 1] + exp_continue + } + -re "^No trace frame found\r\n$gdb_prompt $" { + if { ($linecount1 < 4) || ($linecount2 < 4) || ($linecount3 < 4) || ($linecount4 < 4) || ($linecount5 < 4) || ($linecount6 < 4) } { + fail "12.1: trace report #1" + } else { + pass "12.1: trace report #1" + } } } - } - gdb_tfind_test "12.2: tfind end, selects no frame" "end" "-1" - gdb_tfind_test "12.2: find first TDP #2 frame" "tracepoint $tdp2" \ - "\$tracepoint" "$tdp2" + gdb_tfind_test "12.2: tfind end, selects no frame" "end" "-1" + gdb_tfind_test "12.2: find first TDP #2 frame" "tracepoint $tdp2" \ + "\$tracepoint" "$tdp2" - set linecount2 0 + set linecount2 0 - gdb_test_multiple "while \$trace_frame != -1\n printf \"tracepoint #\%d, FP 0x\%08x, SP 0x\%08x, PC 0x%08x\\n\", \$tracepoint, \$fp, \$sp, \$pc\n tfind tracepoint\n end" "12.2: trace report #2" { - -re "tracepoint #$tdp2, FP $hex, SP $hex, PC $hex" { - set linecount2 [expr $linecount2 + 1] - exp_continue - } - -re ".*$gdb_prompt $" { - if { ($linecount2 < 4) } { - fail "12.2: trace report #2" - } else { - pass "12.2: trace report #2" + gdb_test_multiple "while \$trace_frame != -1\n printf \"tracepoint #\%d, FP 0x\%08x, SP 0x\%08x, PC 0x%08x\\n\", \$tracepoint, \$fp, \$sp, \$pc\n tfind tracepoint\n end" "12.2: trace report #2" { + -re "tracepoint #$tdp2, FP $hex, SP $hex, PC $hex" { + set linecount2 [expr $linecount2 + 1] + exp_continue + } + -re ".*$gdb_prompt $" { + if { ($linecount2 < 4) } { + fail "12.2: trace report #2" + } else { + pass "12.2: trace report #2" + } } } - } - gdb_tfind_test "12.3: tfind end, selects no frame" "end" "-1" - gdb_tfind_test "12.3: find first TDP #3 frame" "tracepoint $tdp3" \ - "\$tracepoint" "$tdp3" + gdb_tfind_test "12.3: tfind end, selects no frame" "end" "-1" + gdb_tfind_test "12.3: find first TDP #3 frame" "tracepoint $tdp3" \ + "\$tracepoint" "$tdp3" - set linecount3 0 + set linecount3 0 - gdb_test_multiple "while \$trace_frame != -1\n printf \"TDP #\%d, frame \%d: depth = \%d, q1 = \%d\\n\", \$tracepoint, \$trace_frame, depth, q1\n tfind tracepoint\n end" "12.3: trace report #3" { - -re "TDP #$tdp3, frame $decimal: depth = $decimal, q1 = $decimal" { - set linecount3 [expr $linecount3 + 1] - exp_continue - } - -re ".*$gdb_prompt $" { - if { ($linecount3 < 4) } { - fail "12.3: trace report #3" - } else { - pass "12.3: trace report #3" + gdb_test_multiple "while \$trace_frame != -1\n printf \"TDP #\%d, frame \%d: depth = \%d, q1 = \%d\\n\", \$tracepoint, \$trace_frame, depth, q1\n tfind tracepoint\n end" "12.3: trace report #3" { + -re "TDP #$tdp3, frame $decimal: depth = $decimal, q1 = $decimal" { + set linecount3 [expr $linecount3 + 1] + exp_continue + } + -re ".*$gdb_prompt $" { + if { ($linecount3 < 4) } { + fail "12.3: trace report #3" + } else { + pass "12.3: trace report #3" + } } } - } - gdb_tfind_test "12.4: tfind end, selects no frame" "end" "-1" - gdb_tfind_test "12.4: find first TDP #6 frame" "tracepoint $tdp6" \ - "\$tracepoint" "$tdp6" + gdb_tfind_test "12.4: tfind end, selects no frame" "end" "-1" + gdb_tfind_test "12.4: find first TDP #6 frame" "tracepoint $tdp6" \ + "\$tracepoint" "$tdp6" - set linecount6 0 + set linecount6 0 - gdb_test_multiple "while \$trace_frame != -1\n printf \"TDP #\%d, frame %d: char_test = \%d, long_test = \%d\\n\", \$tracepoint, \$trace_frame, gdb_char_test, gdb_long_test\n tfind tracepoint\n end" "12.4: trace report #4" { - -re "TDP #$tdp6, frame $decimal: char_test = $arg1, long_test = $arg3" { - set linecount6 [expr $linecount6 + 1] - exp_continue - } - -re ".*$gdb_prompt $" { - if { ($linecount6 < 4) } { - fail "12.4: trace report #4" - } else { - pass "12.4: trace report #4" + gdb_test_multiple "while \$trace_frame != -1\n printf \"TDP #\%d, frame %d: char_test = \%d, long_test = \%d\\n\", \$tracepoint, \$trace_frame, gdb_char_test, gdb_long_test\n tfind tracepoint\n end" "12.4: trace report #4" { + -re "TDP #$tdp6, frame $decimal: char_test = $arg1, long_test = $arg3" { + set linecount6 [expr $linecount6 + 1] + exp_continue + } + -re ".*$gdb_prompt $" { + if { ($linecount6 < 4) } { + fail "12.4: trace report #4" + } else { + pass "12.4: trace report #4" + } } } } } -} use_collected_data "live" diff --git a/gdb/testsuite/gdb.trace/status-stop.exp b/gdb/testsuite/gdb.trace/status-stop.exp index 044e18f..bca03d2 100644 --- a/gdb/testsuite/gdb.trace/status-stop.exp +++ b/gdb/testsuite/gdb.trace/status-stop.exp @@ -37,72 +37,81 @@ if ![gdb_target_supports_trace] { # Verify that the sequence of commands "tstart tstop tstart" works well. -proc test_tstart_tstop_tstart { } { with_test_prefix "tstart_tstop_tstart" { - global executable - global hex - - # Start with a fresh gdb. - clean_restart ${executable} - if ![runto_main] { - fail "Can't run to main" - return -1 - } - - gdb_test "trace func1" "Tracepoint \[0-9\] at $hex: file.*" - gdb_test_no_output "tstart" - - gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*" - gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end" +proc test_tstart_tstop_tstart { } { + with_test_prefix "tstart_tstop_tstart" { + global executable + global hex - gdb_test_no_output "tstop" + # Start with a fresh gdb. + clean_restart ${executable} + if ![runto_main] { + fail "Can't run to main" + return -1 + } - gdb_test_no_output "tstart" -}} + gdb_test "trace func1" "Tracepoint \[0-9\] at $hex: file.*" + gdb_test_no_output "tstart" -# Verify the sequence of commands "tstart tstart" works well. + gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*" + gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \ + "continue to end" -proc test_tstart_tstart { } { with_test_prefix "tstart_tstart" { - global executable - global hex + gdb_test_no_output "tstop" - # Start with a fresh gdb. - clean_restart ${executable} - if ![runto_main] { - fail "Can't run to main" - return -1 + gdb_test_no_output "tstart" } +} - gdb_test "trace func1" "Tracepoint \[0-9\] at $hex: file.*" - gdb_test_no_output "tstart" +# Verify the sequence of commands "tstart tstart" works well. - gdb_test "tstart" "" "tstart again" "A trace is running already. Start a new run\\? \\(y or n\\) " "y" -}} +proc test_tstart_tstart { } { + with_test_prefix "tstart_tstart" { + global executable + global hex -# Verify that trace stops clearly when trace buffer is full. + # Start with a fresh gdb. + clean_restart ${executable} + if ![runto_main] { + fail "Can't run to main" + return -1 + } -proc test_buffer_full_tstart { } { with_test_prefix "buffer_full_tstart" { - global executable - global hex + gdb_test "trace func1" "Tracepoint \[0-9\] at $hex: file.*" + gdb_test_no_output "tstart" - # Start with a fresh gdb. - clean_restart ${executable} - if ![runto_main] { - fail "Can't run to main" - return -1 + gdb_test "tstart" "" "tstart again" \ + "A trace is running already. Start a new run\\? \\(y or n\\) " \ + "y" } +} - gdb_test "trace func2" "Tracepoint \[0-9\] at $hex: file.*" - gdb_trace_setactions "collect buf: define actions" \ - "" \ - "collect buf" "^$" - - gdb_test_no_output "tstart" - gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*" - gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end" +# Verify that trace stops clearly when trace buffer is full. - gdb_test "tstatus" ".*buffer was full.*" - gdb_test_no_output "tstart" -}} +proc test_buffer_full_tstart { } { + with_test_prefix "buffer_full_tstart" { + global executable + global hex + + # Start with a fresh gdb. + clean_restart ${executable} + if ![runto_main] { + fail "Can't run to main" + return -1 + } + + gdb_test "trace func2" "Tracepoint \[0-9\] at $hex: file.*" + gdb_trace_setactions "collect buf: define actions" \ + "" \ + "collect buf" "^$" + + gdb_test_no_output "tstart" + gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*" + gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end" + + gdb_test "tstatus" ".*buffer was full.*" + gdb_test_no_output "tstart" + } +} test_tstart_tstop_tstart diff --git a/gdb/testsuite/gdb.trace/strace.exp b/gdb/testsuite/gdb.trace/strace.exp index b330ee9..3f3eb4e 100644 --- a/gdb/testsuite/gdb.trace/strace.exp +++ b/gdb/testsuite/gdb.trace/strace.exp @@ -126,223 +126,245 @@ proc strace_remove_socket { action } { } }} -proc strace_info_marker { } { with_test_prefix "info_marker" { - global executable - global gdb_prompt - global libipa - - # Restart with a fresh gdb. - clean_restart $executable - gdb_load_shlibs $libipa - if ![runto_main] { - fail "Can't run to main" - return -1 - } +proc strace_info_marker { } { + with_test_prefix "info_marker" { + global executable + global gdb_prompt + global libipa + + # Restart with a fresh gdb. + clean_restart $executable + gdb_load_shlibs $libipa + if ![runto_main] { + fail "Can't run to main" + return -1 + } - # List the markers in program. They should be disabled. - gdb_test "info static-tracepoint-markers" \ - ".*ust/bar\[\t \]+n\[\t \]+.*ust/bar2\[\t \]+n\[\t \]+.*" + # List the markers in program. They should be disabled. + gdb_test "info static-tracepoint-markers" \ + ".*ust/bar\[\t \]+n\[\t \]+.*ust/bar2\[\t \]+n\[\t \]+.*" - # List all the thread. It is expected to get three threads without - # any errors. - gdb_test_multiple "info threads 3 2 1" "info threads" { - -re "3\[ \t\]+Thread .*2\[ \t\]+Thread .*1\[ \t\]+Thread .*${gdb_prompt} $" { - pass "info threads" + # List all the thread. It is expected to get three threads without + # any errors. + gdb_test_multiple "info threads 3 2 1" "info threads" { + -re "3\[ \t\]+Thread .*2\[ \t\]+Thread .*1\[ \t\]+Thread .*${gdb_prompt} $" { + pass "info threads" + } } - } - # GDB detaches inferior so that the socket file can be removed. - gdb_test_multiple "detach" "detach" { - -re "Detaching .*, process .*${gdb_prompt} $" { - pass "detach" + # GDB detaches inferior so that the socket file can be removed. + gdb_test_multiple "detach" "detach" { + -re "Detaching .*, process .*${gdb_prompt} $" { + pass "detach" + } } } -}} - -proc strace_probe_marker { } { with_test_prefix "probe_marker" { - global executable - global expect_out - global gdb_prompt - global hex - global libipa +} - # Restart with a fresh gdb. - clean_restart $executable - gdb_load_shlibs $libipa - if ![runto_main] { - fail "Can't run to main" - return -1 - } +proc strace_probe_marker { } { + with_test_prefix "probe_marker" { + global executable + global expect_out + global gdb_prompt + global hex + global libipa + + # Restart with a fresh gdb. + clean_restart $executable + gdb_load_shlibs $libipa + if ![runto_main] { + fail "Can't run to main" + return -1 + } - gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*" - gdb_test "strace -m ust/bar2" "Static tracepoint \[0-9\]+ at ${hex}: file.*" - # Two trace markers should be enabled. - gdb_test "info static-tracepoint-markers" \ - "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+y\[\t \]+$hex.*" + gdb_test "strace -m ust/bar" \ + "Static tracepoint \[0-9\]+ at ${hex}: file.*" + gdb_test "strace -m ust/bar2" \ + "Static tracepoint \[0-9\]+ at ${hex}: file.*" + # Two trace markers should be enabled. + gdb_test "info static-tracepoint-markers" \ + "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+y\[\t \]+$hex.*" - gdb_test "break end" "Breakpoint \[0-9\]+ at.*" + gdb_test "break end" "Breakpoint \[0-9\]+ at.*" - gdb_test_no_output "tstart" - gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end" - gdb_test_no_output "tstop" + gdb_test_no_output "tstart" + gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \ + "continue to end" + gdb_test_no_output "tstop" - gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0" - gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1" - gdb_test "tfind" "Target failed to find requested trace frame\\..*" -}} + gdb_test "tfind" "Found trace frame 0, tracepoint .*" \ + "tfind frame 0" + gdb_test "tfind" "Found trace frame 1, tracepoint .*" \ + "tfind frame 1" + gdb_test "tfind" \ + "Target failed to find requested trace frame\\..*" + } +} proc strace_trace_on_same_addr { type } { -with_test_prefix "trace_same_addr $type" { - global executable - global expect_out - global gdb_prompt - global hex - global libipa - - # Restart with a fresh gdb. - clean_restart $executable - gdb_load_shlibs $libipa - if ![runto_main] { - fail "Can't run to main" - return -1 - } + with_test_prefix "trace_same_addr $type" { + global executable + global expect_out + global gdb_prompt + global hex + global libipa + + # Restart with a fresh gdb. + clean_restart $executable + gdb_load_shlibs $libipa + if ![runto_main] { + fail "Can't run to main" + return -1 + } - set marker_bar_addr "" - set marker_bar2_addr "" + set marker_bar_addr "" + set marker_bar2_addr "" - # List the markers in program. They should be disabled. - gdb_test_multiple "info static-tracepoint-markers" "info static-tracepoint-markers 1" { - -re ".*ust/bar\[\t \]+n.*${gdb_prompt} $" { - set ignore "" + # List the markers in program. They should be disabled. + gdb_test_multiple "info static-tracepoint-markers" "info static-tracepoint-markers 1" { + -re ".*ust/bar\[\t \]+n.*${gdb_prompt} $" { + set ignore "" - regexp "ust/bar\[\t \]+n\[\t \]+($hex) .*ust/bar2\[\t \]+n\[\t \]+($hex) " \ - "$expect_out(0,string)" ignore marker_bar_addr marker_bar2_addr + regexp "ust/bar\[\t \]+n\[\t \]+($hex) .*ust/bar2\[\t \]+n\[\t \]+($hex) " \ + "$expect_out(0,string)" ignore marker_bar_addr marker_bar2_addr - pass "info static-tracepoint-markers 1" - } - -re ".*${gdb_prompt} $" { - fail "info static-tracepoint-markers 1" + pass "info static-tracepoint-markers 1" + } + -re ".*${gdb_prompt} $" { + fail "info static-tracepoint-markers 1" + } } - } - - gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*" - gdb_test "strace -m ust/bar2" "Static tracepoint \[0-9\]+ at ${hex}: file.*" - # Two trace markers should be enabled. - gdb_test "info static-tracepoint-markers" \ - "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+y\[\t \]+$hex.*" \ - "info static-tracepoint-markers 2" - # Set breapoints or tracepoints. - set test "${type} on marker bar" - gdb_test_multiple "${type} *${marker_bar_addr}" $test { - -re "\(Fast trace|Trace|Break\)point \[0-9\]+ at ${hex}: file.*\r\n$gdb_prompt $" { - pass $test - } - -re ".*\r\n$gdb_prompt $" { - if [string equal $type "ftrace"] { - # The instruction may be not long enough to set a fast - # tracepoint. Skip the rest of this test. - return -1 - } else { - fail $test + gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*" + gdb_test "strace -m ust/bar2" "Static tracepoint \[0-9\]+ at ${hex}: file.*" + # Two trace markers should be enabled. + gdb_test "info static-tracepoint-markers" \ + "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+y\[\t \]+$hex.*" \ + "info static-tracepoint-markers 2" + + # Set breapoints or tracepoints. + set test "${type} on marker bar" + gdb_test_multiple "${type} *${marker_bar_addr}" $test { + -re "\(Fast trace|Trace|Break\)point \[0-9\]+ at ${hex}: file.*\r\n$gdb_prompt $" { + pass $test + } + -re ".*\r\n$gdb_prompt $" { + if [string equal $type "ftrace"] { + # The instruction may be not long enough to set a fast + # tracepoint. Skip the rest of this test. + return -1 + } else { + fail $test + } } } - } - set test "${type} on marker bar2" - gdb_test_multiple "${type} *${marker_bar2_addr}" $test { - -re "\(Fast trace|Trace|Break\)point \[0-9\]+ at ${hex}: file.*" { - pass $test - } - -re ".*\r\n$gdb_prompt $" { - if [string equal $type "ftrace"] { - # The instruction may be not long enough to set a fast - # tracepoint. Skip the rest of this test. - return -1 - } else { - fail $test + set test "${type} on marker bar2" + gdb_test_multiple "${type} *${marker_bar2_addr}" $test { + -re "\(Fast trace|Trace|Break\)point \[0-9\]+ at ${hex}: file.*" { + pass $test + } + -re ".*\r\n$gdb_prompt $" { + if [string equal $type "ftrace"] { + # The instruction may be not long enough to set a fast + # tracepoint. Skip the rest of this test. + return -1 + } else { + fail $test + } } } - } - - gdb_test "break end" "Breakpoint \[0-9\]+ at.*" - if [string equal $type "break"] { - gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \ - "continue to bar" - gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \ - "continue to bar2" - gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \ - "continue to end" - } else { - - gdb_test_no_output "tstart" - gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \ - "continue to end" - gdb_test_no_output "tstop" - - gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0" - gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1" - gdb_test "tfind" "Found trace frame 2, tracepoint .*" "tfind frame 2" - gdb_test "tfind" "Found trace frame 3, tracepoint .*" "tfind frame 3" - gdb_test "tfind" "Target failed to find requested trace frame\\..*" + gdb_test "break end" "Breakpoint \[0-9\]+ at.*" + + if [string equal $type "break"] { + gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \ + "continue to bar" + gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \ + "continue to bar2" + gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \ + "continue to end" + } else { + + gdb_test_no_output "tstart" + gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \ + "continue to end" + gdb_test_no_output "tstop" + + gdb_test "tfind" "Found trace frame 0, tracepoint .*" \ + "tfind frame 0" + gdb_test "tfind" "Found trace frame 1, tracepoint .*" \ + "tfind frame 1" + gdb_test "tfind" "Found trace frame 2, tracepoint .*" \ + "tfind frame 2" + gdb_test "tfind" "Found trace frame 3, tracepoint .*" \ + "tfind frame 3" + gdb_test "tfind" \ + "Target failed to find requested trace frame\\..*" + } } -}} - -proc strace_trace_on_diff_addr { } { with_test_prefix "trace_diff_addr" { - - global executable - global expect_out - global gdb_prompt - global hex - global libipa +} - # Restart with a fresh gdb. - clean_restart $executable - gdb_load_shlibs $libipa - if ![runto_main] { - fail "Can't run to main" - return -1 - } +proc strace_trace_on_diff_addr { } { + with_test_prefix "trace_diff_addr" { + + global executable + global expect_out + global gdb_prompt + global hex + global libipa + + # Restart with a fresh gdb. + clean_restart $executable + gdb_load_shlibs $libipa + if ![runto_main] { + fail "Can't run to main" + return -1 + } - set marker_bar_addr "" - set marker_bar2_addr "" + set marker_bar_addr "" + set marker_bar2_addr "" - # List the markers in program. They should be disabled. - gdb_test_multiple "info static-tracepoint-markers" "info static-tracepoint-markers 1" { - -re ".*ust/bar\[\t \]+n.*${gdb_prompt} $" { - set ignore "" + # List the markers in program. They should be disabled. + gdb_test_multiple "info static-tracepoint-markers" "info static-tracepoint-markers 1" { + -re ".*ust/bar\[\t \]+n.*${gdb_prompt} $" { + set ignore "" - regexp "ust/bar\[\t \]+n\[\t \]+($hex) .*ust/bar2\[\t \]+n\[\t \]+($hex) " \ - "$expect_out(0,string)" ignore marker_bar_addr marker_bar2_addr + regexp "ust/bar\[\t \]+n\[\t \]+($hex) .*ust/bar2\[\t \]+n\[\t \]+($hex) " \ + "$expect_out(0,string)" ignore marker_bar_addr marker_bar2_addr - pass "info static-tracepoint-markers 1" - } - -re ".*${gdb_prompt} $" { - fail "info static-tracepoint-markers 1" + pass "info static-tracepoint-markers 1" + } + -re ".*${gdb_prompt} $" { + fail "info static-tracepoint-markers 1" + } } - } - gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*" + gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*" - gdb_test "info static-tracepoint-markers" \ - "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+n\[\t \]+$hex.*" \ - "info static-tracepoint-markers 2" + gdb_test "info static-tracepoint-markers" \ + "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+n\[\t \]+$hex.*" \ + "info static-tracepoint-markers 2" - # Set common tracepoint. - gdb_test "trace *${marker_bar2_addr}" \ - "Tracepoint \[0-9\]+ at ${hex}: file.*" + # Set common tracepoint. + gdb_test "trace *${marker_bar2_addr}" \ + "Tracepoint \[0-9\]+ at ${hex}: file.*" - gdb_test "break end" "Breakpoint \[0-9\]+ at.*" + gdb_test "break end" "Breakpoint \[0-9\]+ at.*" - gdb_test_no_output "tstart" - gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end" - gdb_test_no_output "tstop" + gdb_test_no_output "tstart" + gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \ + "continue to end" + gdb_test_no_output "tstop" - gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0" - gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1" - gdb_test "tfind" "Target failed to find requested trace frame\\..*" -}} + gdb_test "tfind" "Found trace frame 0, tracepoint .*" \ + "tfind frame 0" + gdb_test "tfind" "Found trace frame 1, tracepoint .*" \ + "tfind frame 1" + gdb_test "tfind" \ + "Target failed to find requested trace frame\\..*" + } +} # Run it on x86/x86_64 linux. if { [istarget "x86_64-*-linux*"] || [istarget "i\[34567\]86-*-linux*"] } { diff --git a/gdb/testsuite/gdb.trace/unavailable.exp b/gdb/testsuite/gdb.trace/unavailable.exp index 005aa62..8e2e105 100644 --- a/gdb/testsuite/gdb.trace/unavailable.exp +++ b/gdb/testsuite/gdb.trace/unavailable.exp @@ -133,174 +133,180 @@ proc test_maybe_regvar_display { var } { # Test procs # -proc gdb_collect_args_test {} { with_test_prefix "unavailable arguments" { - global cr - global gdb_prompt +proc gdb_collect_args_test {} { + with_test_prefix "unavailable arguments" { + global cr + global gdb_prompt - prepare_for_trace_test + prepare_for_trace_test - gdb_test "trace args_test_func" \ - "Tracepoint \[0-9\]+ at .*" \ - "set tracepoint" + gdb_test "trace args_test_func" \ + "Tracepoint \[0-9\]+ at .*" \ + "set tracepoint" - # Begin the test. - run_trace_experiment args_test_func + # Begin the test. + run_trace_experiment args_test_func - # Test printing the variables, and also their addresses. We - # haven't collected any stack, so there's no way GDB can figure - # out the latter. + # Test printing the variables, and also their addresses. We + # haven't collected any stack, so there's no way GDB can figure + # out the latter. - gdb_test "print argc" " = <unavailable>" - gdb_test "print &argc" \ - "Can't take address of \"argc\" which isn't an lvalue\." + gdb_test "print argc" " = <unavailable>" + gdb_test "print &argc" \ + "Can't take address of \"argc\" which isn't an lvalue\." - gdb_test "print argi" " = <unavailable>" - gdb_test "print &argi" \ - "Can't take address of \"argi\" which isn't an lvalue\." + gdb_test "print argi" " = <unavailable>" + gdb_test "print &argi" \ + "Can't take address of \"argi\" which isn't an lvalue\." - gdb_test "print argf" " = <unavailable>" - gdb_test "print &argf" \ - "Can't take address of \"argf\" which isn't an lvalue\." + gdb_test "print argf" " = <unavailable>" + gdb_test "print &argf" \ + "Can't take address of \"argf\" which isn't an lvalue\." - gdb_test "print argd" " = <unavailable>" - gdb_test "print &argd" \ - "Can't take address of \"argd\" which isn't an lvalue\." + gdb_test "print argd" " = <unavailable>" + gdb_test "print &argd" \ + "Can't take address of \"argd\" which isn't an lvalue\." - # struct arg as one of several args (near end of list) + # struct arg as one of several args (near end of list) - gdb_test "print argstruct" \ - " = \{memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>\}" + gdb_test "print argstruct" \ + " = \{memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>\}" - gdb_test "print argstruct.memberc" " = <unavailable>" - gdb_test "print argstruct.memberi" " = <unavailable>" - gdb_test "print argstruct.memberf" " = <unavailable>" - gdb_test "print argstruct.memberd" " = <unavailable>" + gdb_test "print argstruct.memberc" " = <unavailable>" + gdb_test "print argstruct.memberi" " = <unavailable>" + gdb_test "print argstruct.memberf" " = <unavailable>" + gdb_test "print argstruct.memberd" " = <unavailable>" - gdb_test "print argarray" " = \\(int \\*\\) <unavailable>" + gdb_test "print argarray" " = \\(int \\*\\) <unavailable>" - gdb_test "print &argarray" \ - "Can't take address of \"argarray\" which isn't an lvalue\." + gdb_test "print &argarray" \ + "Can't take address of \"argarray\" which isn't an lvalue\." - gdb_test "print argarray\[0\]" "value is not available" + gdb_test "print argarray\[0\]" "value is not available" - # Test "info args" - set r "" - set r "${r}argc = <unavailable>${cr}" - set r "${r}argi = <unavailable>${cr}" - set r "${r}argf = <unavailable>${cr}" - set r "${r}argd = <unavailable>${cr}" - set r "${r}argstruct = {memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>}${cr}" - set r "${r}argarray = <unavailable>${cr}" - gdb_test "info args" "$r" "info args" + # Test "info args" + set r "" + set r "${r}argc = <unavailable>${cr}" + set r "${r}argi = <unavailable>${cr}" + set r "${r}argf = <unavailable>${cr}" + set r "${r}argd = <unavailable>${cr}" + set r "${r}argstruct = {memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>}${cr}" + set r "${r}argarray = <unavailable>${cr}" + gdb_test "info args" "$r" "info args" - test_maybe_regvar_display "argc" + test_maybe_regvar_display "argc" - gdb_test "tfind none" \ - "#0 end .*" \ - "cease trace debugging" -}} + gdb_test "tfind none" \ + "#0 end .*" \ + "cease trace debugging" + } +} -proc gdb_collect_locals_test { func msg } { with_test_prefix "unavailable locals: $msg" { - global cr - global gdb_prompt +proc gdb_collect_locals_test { func msg } { + with_test_prefix "unavailable locals: $msg" { + global cr + global gdb_prompt - prepare_for_trace_test + prepare_for_trace_test - set testline [gdb_get_line_number "set $func tracepoint here"] + set testline [gdb_get_line_number "set $func tracepoint here"] - gdb_test "trace $testline" \ + gdb_test "trace $testline" \ "Tracepoint \[0-9\]+ at .*" \ "set tracepoint" - # Begin the test. - run_trace_experiment $func - - gdb_test "print locc" " = <unavailable>" - gdb_test "print loci" " = <unavailable>" - gdb_test "print locf" " = <unavailable>" - gdb_test "print locd" " = <unavailable>" - - gdb_test "print locst.memberc" " = <unavailable>" - gdb_test "print locst.memberi" " = <unavailable>" - gdb_test "print locst.memberf" " = <unavailable>" - gdb_test "print locst.memberd" " = <unavailable>" - - gdb_test "print locar\[0\]" " = <unavailable>" - gdb_test "print locar\[1\]" " = <unavailable>" - gdb_test "print locar\[2\]" " = <unavailable>" - gdb_test "print locar\[3\]" " = <unavailable>" - - # Test "info locals" - set r "" - set r "${r}locf = <unavailable>${cr}" - set r "${r}locd = <unavailable>${cr}" - set r "${r}locst = {memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>}${cr}" - set r "${r}locar = {<unavailable>, <unavailable>, <unavailable>, <unavailable>}${cr}" - set r "${r}i = <unavailable>${cr}" - if { $func == "local_test_func" } { - set r "${r}locdefst = {<No data fields>}${cr}" - } - set r "${r}locc = <unavailable>${cr}" - set r "${r}loci = <unavailable>${cr}" - gdb_test "info locals" "$r" "info locals" + # Begin the test. + run_trace_experiment $func + + gdb_test "print locc" " = <unavailable>" + gdb_test "print loci" " = <unavailable>" + gdb_test "print locf" " = <unavailable>" + gdb_test "print locd" " = <unavailable>" + + gdb_test "print locst.memberc" " = <unavailable>" + gdb_test "print locst.memberi" " = <unavailable>" + gdb_test "print locst.memberf" " = <unavailable>" + gdb_test "print locst.memberd" " = <unavailable>" + + gdb_test "print locar\[0\]" " = <unavailable>" + gdb_test "print locar\[1\]" " = <unavailable>" + gdb_test "print locar\[2\]" " = <unavailable>" + gdb_test "print locar\[3\]" " = <unavailable>" + + # Test "info locals" + set r "" + set r "${r}locf = <unavailable>${cr}" + set r "${r}locd = <unavailable>${cr}" + set r "${r}locst = {memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>}${cr}" + set r "${r}locar = {<unavailable>, <unavailable>, <unavailable>, <unavailable>}${cr}" + set r "${r}i = <unavailable>${cr}" + if { $func == "local_test_func" } { + set r "${r}locdefst = {<No data fields>}${cr}" + } + set r "${r}locc = <unavailable>${cr}" + set r "${r}loci = <unavailable>${cr}" + gdb_test "info locals" "$r" "info locals" - test_maybe_regvar_display "loci" + test_maybe_regvar_display "loci" - gdb_test "tfind none" \ - "#0 end .*" \ - "cease trace debugging" -}} + gdb_test "tfind none" \ + "#0 end .*" \ + "cease trace debugging" + } +} -proc gdb_unavailable_registers_test { } { with_test_prefix "unavailable registers" { - global gdb_prompt - global spreg - global pcreg +proc gdb_unavailable_registers_test { } { + with_test_prefix "unavailable registers" { + global gdb_prompt + global spreg + global pcreg - prepare_for_trace_test + prepare_for_trace_test - # We'll simply re-use the globals_test_function for this test - gdb_test "trace globals_test_func" \ + # We'll simply re-use the globals_test_function for this test + gdb_test "trace globals_test_func" \ "Tracepoint \[0-9\]+ at .*" \ "set tracepoint" - # Collect nothing. - - # Begin the test. - run_trace_experiment globals_test_func - - # On some archs, the $sp/$pc are a real raw registers. On others, - # like x86, they're user registers. Test both variants. - test_register_unavailable "\$$spreg" - test_register_unavailable "\$sp" - - # Test reading uncollected pseudo-registers. The set of which - # depends on target. - if [is_amd64_regs_target] { - # Check the raw register first. - test_register_unavailable "\$rax" - test_register_unavailable "\$eax" - test_register_unavailable "\$ax" - } elseif [is_x86_like_target] { - # Check the raw register first. - test_register_unavailable "\$eax" - test_register_unavailable "\$ax" - } + # Collect nothing. + + # Begin the test. + run_trace_experiment globals_test_func - # GDBserver always provides the PC value of regular tracepoint - # hits, since it's the same as the tracepoint's address. - test_register "\$$pcreg" - test_register "\$pc" + # On some archs, the $sp/$pc are a real raw registers. On others, + # like x86, they're user registers. Test both variants. + test_register_unavailable "\$$spreg" + test_register_unavailable "\$sp" + + # Test reading uncollected pseudo-registers. The set of which + # depends on target. + if [is_amd64_regs_target] { + # Check the raw register first. + test_register_unavailable "\$rax" + test_register_unavailable "\$eax" + test_register_unavailable "\$ax" + } elseif [is_x86_like_target] { + # Check the raw register first. + test_register_unavailable "\$eax" + test_register_unavailable "\$ax" + } - gdb_test "info registers" \ - "\\*value not available\\*.*\\*value not available\\*" \ - "info registers, multiple registers not available" + # GDBserver always provides the PC value of regular tracepoint + # hits, since it's the same as the tracepoint's address. + test_register "\$$pcreg" + test_register "\$pc" - gdb_test "info registers \$$spreg" \ - "\\*value not available\\*" \ - "info registers \$$spreg reports not available" + gdb_test "info registers" \ + "\\*value not available\\*.*\\*value not available\\*" \ + "info registers, multiple registers not available" - gdb_test "tfind none" "#0 end .*" "cease trace debugging" -}} + gdb_test "info registers \$$spreg" \ + "\\*value not available\\*" \ + "info registers \$$spreg reports not available" + + gdb_test "tfind none" "#0 end .*" "cease trace debugging" + } +} proc gdb_unavailable_floats { } { global gdb_prompt @@ -335,244 +341,246 @@ proc gdb_unavailable_floats { } { } } -proc gdb_collect_globals_test { } { with_test_prefix "collect globals" { - global ws - global cr - global gdb_prompt - global hex +proc gdb_collect_globals_test { } { + with_test_prefix "collect globals" { + global ws + global cr + global gdb_prompt + global hex - prepare_for_trace_test + prepare_for_trace_test - set testline [gdb_get_line_number "set globals_test_func tracepoint here"] + set testline [gdb_get_line_number "set globals_test_func tracepoint here"] - gdb_test "trace $testline" \ + gdb_test "trace $testline" \ "Tracepoint \[0-9\]+ at .*" \ "set tracepoint" - # We collect the initial sizeof(pointer) bytes of derived_partial - # in an attempt of collecting the vptr. Not portable, but should - # work everywhere we need to care. - gdb_trace_setactions "define actions" \ - "" \ - "collect struct_b.struct_a.array\[2\]" "^$" \ - "collect struct_b.struct_a.array\[100\]" "^$" \ - \ - "collect a" "^$" \ - "collect c" "^$" \ - \ - "collect tarray\[0\].a" "^$" \ - "collect tarray\[1\].a" "^$" \ - "collect tarray\[3\].a" "^$" \ - "collect tarray\[3\].b" "^$" \ - "collect tarray\[4\].b" "^$" \ - "collect tarray\[5\].b" "^$" \ - \ - "collect g_string_p" "^$" \ - "collect g_string_partial\[1\]" "^$" \ - "collect g_string_partial\[2\]" "^$" \ - \ - "collect g_structref_p" "^$" \ - \ - "collect *((char *)&derived_partial)@sizeof\(void *\)" "^$" \ - "collect derived_whole" "^$" \ - \ - "collect virtual_partial.z" "^$" - - # Begin the test. - run_trace_experiment globals_test_func - - gdb_test "print globalc" " = <unavailable>" - gdb_test "print globali" " = <unavailable>" - gdb_test "print globalf" " = <unavailable>" - gdb_test "print globald" " = <unavailable>" - - gdb_test "print globalstruct.memberc" " = <unavailable>" - gdb_test "print globalstruct.memberi" " = <unavailable>" - gdb_test "print globalstruct.memberf" " = <unavailable>" - gdb_test "print globalstruct.memberd" " = <unavailable>" - - gdb_test "print globalstruct" \ + # We collect the initial sizeof(pointer) bytes of derived_partial + # in an attempt of collecting the vptr. Not portable, but should + # work everywhere we need to care. + gdb_trace_setactions "define actions" \ + "" \ + "collect struct_b.struct_a.array\[2\]" "^$" \ + "collect struct_b.struct_a.array\[100\]" "^$" \ + \ + "collect a" "^$" \ + "collect c" "^$" \ + \ + "collect tarray\[0\].a" "^$" \ + "collect tarray\[1\].a" "^$" \ + "collect tarray\[3\].a" "^$" \ + "collect tarray\[3\].b" "^$" \ + "collect tarray\[4\].b" "^$" \ + "collect tarray\[5\].b" "^$" \ + \ + "collect g_string_p" "^$" \ + "collect g_string_partial\[1\]" "^$" \ + "collect g_string_partial\[2\]" "^$" \ + \ + "collect g_structref_p" "^$" \ + \ + "collect *((char *)&derived_partial)@sizeof\(void *\)" "^$" \ + "collect derived_whole" "^$" \ + \ + "collect virtual_partial.z" "^$" + + # Begin the test. + run_trace_experiment globals_test_func + + gdb_test "print globalc" " = <unavailable>" + gdb_test "print globali" " = <unavailable>" + gdb_test "print globalf" " = <unavailable>" + gdb_test "print globald" " = <unavailable>" + + gdb_test "print globalstruct.memberc" " = <unavailable>" + gdb_test "print globalstruct.memberi" " = <unavailable>" + gdb_test "print globalstruct.memberf" " = <unavailable>" + gdb_test "print globalstruct.memberd" " = <unavailable>" + + gdb_test "print globalstruct" \ " = {memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>}" - gdb_test "print globalp == &globalstruct" \ + gdb_test "print globalp == &globalstruct" \ "value is not available" \ "can't compare using non collected global pointer" - gdb_test "print globalarr\[1\]" " = <unavailable>" - gdb_test "print globalarr\[2\]" " = <unavailable>" - gdb_test "print globalarr\[3\]" " = <unavailable>" + gdb_test "print globalarr\[1\]" " = <unavailable>" + gdb_test "print globalarr\[2\]" " = <unavailable>" + gdb_test "print globalarr\[3\]" " = <unavailable>" - gdb_test "print struct_b" \ - " = {d = <unavailable>, ef = <unavailable>, struct_a = {a = <unavailable>, b = <unavailable>, array = {<unavailable>, <unavailable>, -1431655766, <unavailable> <repeats 97 times>, -1431655766, <unavailable> <repeats 9899 times>}, ptr = <unavailable>, bitfield = <unavailable>}, s = <unavailable>, static static_struct_a = {a = <unavailable>, b = <unavailable>, array = {<unavailable> <repeats 10000 times>}, ptr = <unavailable>, bitfield = <unavailable>}, string = <unavailable>}" + gdb_test "print struct_b" \ + " = {d = <unavailable>, ef = <unavailable>, struct_a = {a = <unavailable>, b = <unavailable>, array = {<unavailable>, <unavailable>, -1431655766, <unavailable> <repeats 97 times>, -1431655766, <unavailable> <repeats 9899 times>}, ptr = <unavailable>, bitfield = <unavailable>}, s = <unavailable>, static static_struct_a = {a = <unavailable>, b = <unavailable>, array = {<unavailable> <repeats 10000 times>}, ptr = <unavailable>, bitfield = <unavailable>}, string = <unavailable>}" - gdb_test "print /x struct_b" \ - " = {d = <unavailable>, ef = <unavailable>, struct_a = {a = <unavailable>, b = <unavailable>, array = {<unavailable>, <unavailable>, 0xaaaaaaaa, <unavailable> <repeats 97 times>, 0xaaaaaaaa, <unavailable> <repeats 9899 times>}, ptr = <unavailable>, bitfield = <unavailable>}, s = <unavailable>, static static_struct_a = {a = <unavailable>, b = <unavailable>, array = {<unavailable> <repeats 10000 times>}, ptr = <unavailable>, bitfield = <unavailable>}, string = <unavailable>}" + gdb_test "print /x struct_b" \ + " = {d = <unavailable>, ef = <unavailable>, struct_a = {a = <unavailable>, b = <unavailable>, array = {<unavailable>, <unavailable>, 0xaaaaaaaa, <unavailable> <repeats 97 times>, 0xaaaaaaaa, <unavailable> <repeats 9899 times>}, ptr = <unavailable>, bitfield = <unavailable>}, s = <unavailable>, static static_struct_a = {a = <unavailable>, b = <unavailable>, array = {<unavailable> <repeats 10000 times>}, ptr = <unavailable>, bitfield = <unavailable>}, string = <unavailable>}" - gdb_test "print /x struct_b.struct_a" \ - " = {a = <unavailable>, b = <unavailable>, array = {<unavailable>, <unavailable>, 0xaaaaaaaa, <unavailable> <repeats 97 times>, 0xaaaaaaaa, <unavailable> <repeats 9899 times>}, ptr = <unavailable>, bitfield = <unavailable>}" + gdb_test "print /x struct_b.struct_a" \ + " = {a = <unavailable>, b = <unavailable>, array = {<unavailable>, <unavailable>, 0xaaaaaaaa, <unavailable> <repeats 97 times>, 0xaaaaaaaa, <unavailable> <repeats 9899 times>}, ptr = <unavailable>, bitfield = <unavailable>}" - gdb_test "print /x struct_b.struct_a.array" \ - " = {<unavailable>, <unavailable>, 0xaaaaaaaa, <unavailable> <repeats 97 times>, 0xaaaaaaaa, <unavailable> <repeats 9899 times>}" + gdb_test "print /x struct_b.struct_a.array" \ + " = {<unavailable>, <unavailable>, 0xaaaaaaaa, <unavailable> <repeats 97 times>, 0xaaaaaaaa, <unavailable> <repeats 9899 times>}" - gdb_test "print /x struct_b.struct_a.array\[0\]" " = <unavailable>" + gdb_test "print /x struct_b.struct_a.array\[0\]" " = <unavailable>" - gdb_test "print /x struct_b.struct_a.array\[2\]" " = 0xaaaaaaaa" + gdb_test "print /x struct_b.struct_a.array\[2\]" " = 0xaaaaaaaa" - # Check the target doesn't overcollect. GDB used to merge memory - # ranges to collect if they were close enough (collecting the hole - # as well), but does not do that anymore. It's plausible that a - # target may do this on its end, but as of this writing, no known - # target does it. - gdb_test "print {a, b, c}" \ - " = \\{1, <unavailable>, 3\\}" \ - "No overcollect of almost but not quite adjacent memory ranges" + # Check the target doesn't overcollect. GDB used to merge memory + # ranges to collect if they were close enough (collecting the hole + # as well), but does not do that anymore. It's plausible that a + # target may do this on its end, but as of this writing, no known + # target does it. + gdb_test "print {a, b, c}" \ + " = \\{1, <unavailable>, 3\\}" \ + "No overcollect of almost but not quite adjacent memory ranges" - # Check <unavailable> isn't confused with 0 in array element repetitions + # Check <unavailable> isn't confused with 0 in array element repetitions - gdb_test_no_output "set print repeat 1" + gdb_test_no_output "set print repeat 1" - gdb_test "print /x tarray" \ - " = \{\{a = 0x0, b = <unavailable>\} <repeats 2 times>, \{a = <unavailable>, b = <unavailable>\}, \{a = 0x0, b = 0x0\}, \{a = <unavailable>, b = 0x0\} <repeats 2 times>, \{a = <unavailable>, b = <unavailable>\} <repeats 2 times>\}" \ - "<unavailable> is not the same as 0 in array element repetitions" + gdb_test "print /x tarray" \ + " = \{\{a = 0x0, b = <unavailable>\} <repeats 2 times>, \{a = <unavailable>, b = <unavailable>\}, \{a = 0x0, b = 0x0\}, \{a = <unavailable>, b = 0x0\} <repeats 2 times>, \{a = <unavailable>, b = <unavailable>\} <repeats 2 times>\}" \ + "<unavailable> is not the same as 0 in array element repetitions" - gdb_test_no_output "set print repeat 10" + gdb_test_no_output "set print repeat 10" - # Check that value repeat handles unavailable-ness. - gdb_test "print *tarray@3" " = \\{\\{a = 0, b = <unavailable>\\}, \\{a = 0, b = <unavailable>\\}, \\{a = <unavailable>, b = <unavailable>\\}\\}" + # Check that value repeat handles unavailable-ness. + gdb_test "print *tarray@3" " = \\{\\{a = 0, b = <unavailable>\\}, \\{a = 0, b = <unavailable>\\}, \\{a = <unavailable>, b = <unavailable>\\}\\}" - # Static fields + # Static fields - gdb_test "print struct_b.static_struct_a" \ - " = {a = <unavailable>, b = <unavailable>, array = {<unavailable> <repeats 10000 times>}, ptr = <unavailable>, bitfield = <unavailable>}" + gdb_test "print struct_b.static_struct_a" \ + " = {a = <unavailable>, b = <unavailable>, array = {<unavailable> <repeats 10000 times>}, ptr = <unavailable>, bitfield = <unavailable>}" - # Bitfields + # Bitfields - gdb_test "print struct_b.struct_a.bitfield" " = <unavailable>" + gdb_test "print struct_b.struct_a.bitfield" " = <unavailable>" - # References + # References - gdb_test "print g_int" " = <unavailable>" + gdb_test "print g_int" " = <unavailable>" - gdb_test "print g_ref" \ - "\\(int &\\) @$hex: <unavailable>" \ - "global reference shows address but not value" + gdb_test "print g_ref" \ + "\\(int &\\) @$hex: <unavailable>" \ + "global reference shows address but not value" - gdb_test "print *&g_ref" \ - "\\$\[0-9\]+ = <unavailable>$cr" \ - "referenced integer was not collected (taking address of reference)" + gdb_test "print *&g_ref" \ + "\\$\[0-9\]+ = <unavailable>$cr" \ + "referenced integer was not collected (taking address of reference)" - gdb_test "print *g_structref_p" \ - " = {d = <unavailable>, ref = <unavailable>}" + gdb_test "print *g_structref_p" \ + " = {d = <unavailable>, ref = <unavailable>}" - # Strings + # Strings - # Const string is always available, even when not collected. - gdb_test "print g_const_string" \ - " = \"hello world\"$cr" \ - "non collected const string is still printable" + # Const string is always available, even when not collected. + gdb_test "print g_const_string" \ + " = \"hello world\"$cr" \ + "non collected const string is still printable" - gdb_test "print g_string_p" \ - " = $hex <g_const_string> \"hello world\"" \ - "printing constant string through collected pointer" + gdb_test "print g_string_p" \ + " = $hex <g_const_string> \"hello world\"" \ + "printing constant string through collected pointer" - gdb_test "print g_string_unavail" \ - " = \{<unavailable> <repeats 12 times>\}" \ - "printing non collected string" + gdb_test "print g_string_unavail" \ + " = \{<unavailable> <repeats 12 times>\}" \ + "printing non collected string" - # Incomplete strings print as an array. - gdb_test "print g_string_partial" \ - "\\$\[0-9\]+ = \{<unavailable>, 101 'e', 108 'l', <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>\}" \ - "printing partially collected string" + # Incomplete strings print as an array. + gdb_test "print g_string_partial" \ + "\\$\[0-9\]+ = \{<unavailable>, 101 'e', 108 'l', <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>\}" \ + "printing partially collected string" - # It is important for this test that the last examined value is - # <unavailable>, to exercise the case of the $__ convenience - # variable being set to <unavailable> without error. - set msg "examining partially collected object" - gdb_test_multiple "x /10x &struct_b" "$msg" { - -re "$hex <struct_b>:${ws}<unavailable>${ws}<unavailable>${ws}<unavailable>${ws}<unavailable>$cr$hex <struct_b\\+16>:${ws}<unavailable>${ws}<unavailable>${ws}0xaaaaaaaa${ws}<unavailable>$cr$hex <struct_b\\+32>:${ws}<unavailable>${ws}<unavailable>$cr$gdb_prompt $" { - pass "$msg" - } - -re "value is not available" { - fail "$msg" + # It is important for this test that the last examined value is + # <unavailable>, to exercise the case of the $__ convenience + # variable being set to <unavailable> without error. + set msg "examining partially collected object" + gdb_test_multiple "x /10x &struct_b" "$msg" { + -re "$hex <struct_b>:${ws}<unavailable>${ws}<unavailable>${ws}<unavailable>${ws}<unavailable>$cr$hex <struct_b\\+16>:${ws}<unavailable>${ws}<unavailable>${ws}0xaaaaaaaa${ws}<unavailable>$cr$hex <struct_b\\+32>:${ws}<unavailable>${ws}<unavailable>$cr$gdb_prompt $" { + pass "$msg" + } + -re "value is not available" { + fail "$msg" + } } - } - gdb_test "p \$__" " = <unavailable>" "last examined value was <unavailable>" - - # This tests that building the array does not require accessing - # g_int's contents. - gdb_test "print { 1, g_int, 3 }" \ - " = \\{1, <unavailable>, 3\\}" \ - "build array from unavailable value" - - # Note, depends on previous test. - gdb_test "print \$\[1\]" \ - " = <unavailable>" \ - "subscript a non-memory rvalue array, accessing an unvailable element" - - # Access a field of a non-lazy value, making sure the - # unavailable-ness is propagated. History values are easy - # non-lazy values, so use those. The first test just sets up for - # the second. - gdb_test "print g_smallstruct" " = \\{member = <unavailable>\\}" - gdb_test "print \$.member" " = <unavailable>" - - # Cast to baseclass, checking the unavailable-ness is propagated. - gdb_test "print (small_struct) g_smallstruct_b" " = \\{member = <unavailable>\\}" - - # Same cast, but starting from a non-lazy, value. - gdb_test "print g_smallstruct_b" " = \\{<small_struct> = \\{member = <unavailable>\\}, <No data fields>\\}" - gdb_test "print (small_struct) \$" " = \\{member = <unavailable>\\}" - - gdb_test_no_output "set print object on" - - with_test_prefix "print object on" { - # With print object on, printing a pointer may need to fetch - # the pointed-to object, to check its run-time type. Make - # sure that fails gracefully and transparently when the - # pointer itself is unavailable. - gdb_test "print virtualp" " = \\(Virtual \\*\\) <unavailable>" - - # no vtable pointer available - gdb_test "print derived_unavail" \ - " = {<Middle> = <unavailable>, _vptr.Derived = <unavailable>, z = <unavailable>}" - - # vtable pointer available, but nothing else - gdb_test "print derived_partial" \ - " = \\(Derived\\) {<Middle> = {<Base> = <unavailable>, _vptr.Middle = <unavailable>, y = <unavailable>}, _vptr.Derived = $hex <vtable for Derived.*>, z = <unavailable>}" - - # whole object available - gdb_test "print derived_whole" \ - " = \\(Derived\\) {<Middle> = {<Base> = {x = 2}, _vptr.Middle = $hex, y = 3}, _vptr.Derived = $hex <vtable for Derived.*>, z = 4}" - } + gdb_test "p \$__" " = <unavailable>" "last examined value was <unavailable>" + + # This tests that building the array does not require accessing + # g_int's contents. + gdb_test "print { 1, g_int, 3 }" \ + " = \\{1, <unavailable>, 3\\}" \ + "build array from unavailable value" + + # Note, depends on previous test. + gdb_test "print \$\[1\]" \ + " = <unavailable>" \ + "subscript a non-memory rvalue array, accessing an unvailable element" + + # Access a field of a non-lazy value, making sure the + # unavailable-ness is propagated. History values are easy + # non-lazy values, so use those. The first test just sets up for + # the second. + gdb_test "print g_smallstruct" " = \\{member = <unavailable>\\}" + gdb_test "print \$.member" " = <unavailable>" + + # Cast to baseclass, checking the unavailable-ness is propagated. + gdb_test "print (small_struct) g_smallstruct_b" " = \\{member = <unavailable>\\}" + + # Same cast, but starting from a non-lazy, value. + gdb_test "print g_smallstruct_b" " = \\{<small_struct> = \\{member = <unavailable>\\}, <No data fields>\\}" + gdb_test "print (small_struct) \$" " = \\{member = <unavailable>\\}" + + gdb_test_no_output "set print object on" + + with_test_prefix "print object on" { + # With print object on, printing a pointer may need to fetch + # the pointed-to object, to check its run-time type. Make + # sure that fails gracefully and transparently when the + # pointer itself is unavailable. + gdb_test "print virtualp" " = \\(Virtual \\*\\) <unavailable>" + + # no vtable pointer available + gdb_test "print derived_unavail" \ + " = {<Middle> = <unavailable>, _vptr.Derived = <unavailable>, z = <unavailable>}" + + # vtable pointer available, but nothing else + gdb_test "print derived_partial" \ + " = \\(Derived\\) {<Middle> = {<Base> = <unavailable>, _vptr.Middle = <unavailable>, y = <unavailable>}, _vptr.Derived = $hex <vtable for Derived.*>, z = <unavailable>}" + + # whole object available + gdb_test "print derived_whole" \ + " = \\(Derived\\) {<Middle> = {<Base> = {x = 2}, _vptr.Middle = $hex, y = 3}, _vptr.Derived = $hex <vtable for Derived.*>, z = 4}" + } - gdb_test_no_output "set print object off" + gdb_test_no_output "set print object off" - with_test_prefix "print object off" { - gdb_test "print virtualp" " = \\(Virtual \\*\\) <unavailable>" + with_test_prefix "print object off" { + gdb_test "print virtualp" " = \\(Virtual \\*\\) <unavailable>" - # no vtable pointer available - gdb_test "print derived_unavail" \ - " = {<Middle> = <unavailable>, _vptr.Derived = <unavailable>, z = <unavailable>}" + # no vtable pointer available + gdb_test "print derived_unavail" \ + " = {<Middle> = <unavailable>, _vptr.Derived = <unavailable>, z = <unavailable>}" - # vtable pointer available, but nothing else - gdb_test "print derived_partial" \ - " = {<Middle> = {<Base> = <unavailable>, _vptr.Middle = <unavailable>, y = <unavailable>}, _vptr.Derived = $hex <vtable for Derived.*>, z = <unavailable>}" + # vtable pointer available, but nothing else + gdb_test "print derived_partial" \ + " = {<Middle> = {<Base> = <unavailable>, _vptr.Middle = <unavailable>, y = <unavailable>}, _vptr.Derived = $hex <vtable for Derived.*>, z = <unavailable>}" - # whole object available - gdb_test "print derived_whole" \ - " = {<Middle> = {<Base> = {x = 2}, _vptr.Middle = $hex, y = 3}, _vptr.Derived = $hex <vtable for Derived.*>, z = 4}" - } + # whole object available + gdb_test "print derived_whole" \ + " = {<Middle> = {<Base> = {x = 2}, _vptr.Middle = $hex, y = 3}, _vptr.Derived = $hex <vtable for Derived.*>, z = 4}" + } - # An instance of a virtual class where we collected everything but - # the vptr. - gdb_test "print virtual_partial" \ - " = {_vptr.Virtual = <unavailable>, z = 0}" + # An instance of a virtual class where we collected everything but + # the vptr. + gdb_test "print virtual_partial" \ + " = {_vptr.Virtual = <unavailable>, z = 0}" - gdb_test "tfind none" \ - "#0 end .*" \ - "cease trace debugging" -}} + gdb_test "tfind none" \ + "#0 end .*" \ + "cease trace debugging" + } +} proc gdb_trace_collection_test {} { gdb_collect_globals_test |