binutils-gdb/gdb/testsuite/gdb.cp/nextoverthrow.exp

175 lines
5.8 KiB
Plaintext
Raw Normal View History

# Copyright 2008-2012 Free Software Foundation, Inc.
gdb PR c++/9593: * thread.c (clear_thread_inferior_resources): Call delete_longjmp_breakpoint. * infrun.c (handle_inferior_event): Handle exception breakpoints. (handle_inferior_event): Likewise. (insert_exception_resume_breakpoint): New function. (check_exception_resume): Likewise. * inferior.h (delete_longjmp_breakpoint_cleanup): Declare. * infcmd.c (delete_longjmp_breakpoint_cleanup): No longer static. (step_1): Set thread's initiating frame. (until_next_continuation): New function. (until_next_command): Support exception breakpoints. (finish_command_continuation): Delete longjmp breakpoint. (finish_forward): Support exception breakpoints. * gdbthread.h (struct thread_info) <initiating_frame>: New field. * breakpoint.h (enum bptype) <bp_exception, bp_exception_resume, bp_exception_master>: New constants. (struct bpstat_what) <is_longjmp>: New field. (set_longjmp_breakpoint): Update. * breakpoint.c (create_exception_master_breakpoint): New function. (update_breakpoints_after_exec): Handle bp_exception_master. Call create_exception_master_breakpoint. (print_it_typical): Handle bp_exception_master, bp_exception. (bpstat_stop_status): Handle bp_exception_master. (bpstat_what): Handle bp_exception_master, bp_exception, bp_exception_resume. (bptype_string): Likewise. (print_one_breakpoint_location): Likewise. (allocate_bp_location): Likewise. (set_longjmp_breakpoint): Handle exception breakpoints. Change interface. (delete_longjmp_breakpoint): Handle exception breakpoints. (mention): Likewise. (struct until_break_command_continuation_args) <thread_num>: New field. (until_break_command_continuation): Call delete_longjmp_breakpoint. (until_break_command): Support exception breakpoints. (delete_command): Likewise. (breakpoint_re_set_one): Likewise. (breakpoint_re_set): Likewise. gdb/testuite * gdb.java/jnpe.java: New file. * gdb.java/jnpe.exp: New file. * gdb.cp/nextoverthrow.exp: New file. * gdb.cp/nextoverthrow.cc: New file.
2010-12-09 17:09:54 +01:00
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if { [skip_cplus_tests] } { continue }
set testfile "nextoverthrow"
set srcfile ${testfile}.cc
set binfile $objdir/$subdir/$testfile
# Create and source the file that provides information about the compiler
# used to compile the test case.
if [get_compiler_info ${binfile} "c++"] {
untested nextoverthrow.exp
return -1
}
if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
return -1
}
if ![runto_main] then {
perror "couldn't run to main"
continue
}
# See whether we have the needed unwinder hooks.
set ok 1
gdb_test_multiple "print _Unwind_DebugHook" "check for unwinder hook" {
-re "= .*no debug info.*_Unwind_DebugHook.*\r\n$gdb_prompt $" {
# Pass the test so we don't get bogus fails in the results.
pass "check for unwinder hook"
set ok 0
}
gdb PR c++/9593: * thread.c (clear_thread_inferior_resources): Call delete_longjmp_breakpoint. * infrun.c (handle_inferior_event): Handle exception breakpoints. (handle_inferior_event): Likewise. (insert_exception_resume_breakpoint): New function. (check_exception_resume): Likewise. * inferior.h (delete_longjmp_breakpoint_cleanup): Declare. * infcmd.c (delete_longjmp_breakpoint_cleanup): No longer static. (step_1): Set thread's initiating frame. (until_next_continuation): New function. (until_next_command): Support exception breakpoints. (finish_command_continuation): Delete longjmp breakpoint. (finish_forward): Support exception breakpoints. * gdbthread.h (struct thread_info) <initiating_frame>: New field. * breakpoint.h (enum bptype) <bp_exception, bp_exception_resume, bp_exception_master>: New constants. (struct bpstat_what) <is_longjmp>: New field. (set_longjmp_breakpoint): Update. * breakpoint.c (create_exception_master_breakpoint): New function. (update_breakpoints_after_exec): Handle bp_exception_master. Call create_exception_master_breakpoint. (print_it_typical): Handle bp_exception_master, bp_exception. (bpstat_stop_status): Handle bp_exception_master. (bpstat_what): Handle bp_exception_master, bp_exception, bp_exception_resume. (bptype_string): Likewise. (print_one_breakpoint_location): Likewise. (allocate_bp_location): Likewise. (set_longjmp_breakpoint): Handle exception breakpoints. Change interface. (delete_longjmp_breakpoint): Handle exception breakpoints. (mention): Likewise. (struct until_break_command_continuation_args) <thread_num>: New field. (until_break_command_continuation): Call delete_longjmp_breakpoint. (until_break_command): Support exception breakpoints. (delete_command): Likewise. (breakpoint_re_set_one): Likewise. (breakpoint_re_set): Likewise. gdb/testuite * gdb.java/jnpe.java: New file. * gdb.java/jnpe.exp: New file. * gdb.cp/nextoverthrow.exp: New file. * gdb.cp/nextoverthrow.cc: New file.
2010-12-09 17:09:54 +01:00
-re "= .*_Unwind_DebugHook.*\r\n$gdb_prompt $" {
pass "check for unwinder hook"
}
-re "No symbol .* in current context.\r\n$gdb_prompt $" {
# Pass the test so we don't get bogus fails in the results.
pass "check for unwinder hook"
set ok 0
}
}
if {!$ok} {
gdb_test_multiple "info probe" "check for stap probe in unwinder" {
-re ".*libgcc.*unwind.*\r\n$gdb_prompt $" {
pass "check for stap probe in unwinder"
set ok 1
}
-re "\r\n$gdb_prompt $" {
}
}
}
gdb PR c++/9593: * thread.c (clear_thread_inferior_resources): Call delete_longjmp_breakpoint. * infrun.c (handle_inferior_event): Handle exception breakpoints. (handle_inferior_event): Likewise. (insert_exception_resume_breakpoint): New function. (check_exception_resume): Likewise. * inferior.h (delete_longjmp_breakpoint_cleanup): Declare. * infcmd.c (delete_longjmp_breakpoint_cleanup): No longer static. (step_1): Set thread's initiating frame. (until_next_continuation): New function. (until_next_command): Support exception breakpoints. (finish_command_continuation): Delete longjmp breakpoint. (finish_forward): Support exception breakpoints. * gdbthread.h (struct thread_info) <initiating_frame>: New field. * breakpoint.h (enum bptype) <bp_exception, bp_exception_resume, bp_exception_master>: New constants. (struct bpstat_what) <is_longjmp>: New field. (set_longjmp_breakpoint): Update. * breakpoint.c (create_exception_master_breakpoint): New function. (update_breakpoints_after_exec): Handle bp_exception_master. Call create_exception_master_breakpoint. (print_it_typical): Handle bp_exception_master, bp_exception. (bpstat_stop_status): Handle bp_exception_master. (bpstat_what): Handle bp_exception_master, bp_exception, bp_exception_resume. (bptype_string): Likewise. (print_one_breakpoint_location): Likewise. (allocate_bp_location): Likewise. (set_longjmp_breakpoint): Handle exception breakpoints. Change interface. (delete_longjmp_breakpoint): Handle exception breakpoints. (mention): Likewise. (struct until_break_command_continuation_args) <thread_num>: New field. (until_break_command_continuation): Call delete_longjmp_breakpoint. (until_break_command): Support exception breakpoints. (delete_command): Likewise. (breakpoint_re_set_one): Likewise. (breakpoint_re_set): Likewise. gdb/testuite * gdb.java/jnpe.java: New file. * gdb.java/jnpe.exp: New file. * gdb.cp/nextoverthrow.exp: New file. * gdb.cp/nextoverthrow.cc: New file.
2010-12-09 17:09:54 +01:00
if {!$ok} {
unsupported "nextoverthrow.exp could not find _Unwind_DebugHook"
return -1
}
# Set a temporary breakpoint and then continue to it.
# The breakpoint is set according to a marker in the file.
proc tbreak_and_cont {text} {
global testfile
set line [gdb_get_line_number $text $testfile.cc]
gdb_breakpoint "$testfile.cc:$line" temporary
gdb_test "continue" "Temporary breakpoint.*" "continuing to $text"
}
# Verify the value of testval.
proc verify_testval {name value} {
gdb_test "print testval == $value" " = true" $name
}
# See http://sourceware.org/bugzilla/show_bug.cgi?id=9593
# Our general approach here is to do some operation, verify
# that testval has not changed, continue to the location at
# which the next test starts, and verify testval again.
# This works around platform differences in debuginfo that
# make looking at the source line unreliable.
# A simple test of next over a throw.
tbreak_and_cont "Start: first test"
gdb_test "next" ".*" "next over a throw 1"
tbreak_and_cont "End: first test"
verify_testval "pre-check - next over a throw 1" -1
tbreak_and_cont "Start: nested throw"
verify_testval "post-check - next over a throw 1" 0
gdb_test "next" ".*" "next over a throw 2"
tbreak_and_cont "End: nested throw"
verify_testval "pre-check - next over a throw 2" 0
tbreak_and_cont "Start: step in test"
verify_testval "post-check - next over a throw 2" 1
gdb_test "step" "function1().*" "step into function2 1"
gdb_test "next" ".*" "next over a throw 3"
tbreak_and_cont "End: step in test"
verify_testval "pre-check - next over a throw 3" 1
tbreak_and_cont "Start: next past catch"
verify_testval "post-check - next over a throw 3" 2
gdb_test "next" ".*" "next past catch"
tbreak_and_cont "End: next past catch"
verify_testval "pre-check - next past catch" 2
tbreak_and_cont "Start: rethrow"
verify_testval "post-check - next past catch" 3
gdb_test "next" ".*" "next over a throw 4"
tbreak_and_cont "End: rethrow"
verify_testval "pre-check - next over a throw 4" 3
tbreak_and_cont "Start: first finish"
verify_testval "post-check - next over a throw 4" 4
gdb_test "step" "function1().*" "step into function2 2"
gdb_test "finish" ".*" "finish 1"
tbreak_and_cont "End: first finish"
verify_testval "pre-check - finish 1" 4
tbreak_and_cont "Start: second finish"
verify_testval "post-check - finish 1" 5
gdb_test "step" "function1 ().*" "step into finish method"
gdb_test "finish" ".*" "finish 2"
tbreak_and_cont "End: second finish"
verify_testval "pre-check - finish 2" 5
tbreak_and_cont "Start: first until"
verify_testval "post-check - finish 2" 6
gdb_test "step" ".*" "step into finish, for until"
gdb_test "until" ".*" "until with no argument 1"
set line [gdb_get_line_number "marker for until" $testfile.cc]
gdb_test "until $line" "function1 ().*" "next past catch 6"
gdb_test "until" ".*" "until with no argument 2"
tbreak_and_cont "End: first until"
verify_testval "pre-check - until 1" 6
tbreak_and_cont "Start: second until"
verify_testval "post-check - until 1" 7
set line [gdb_get_line_number "until here" $testfile.cc]
gdb_test "step" "function1 ().*" "step into until"
gdb_test "until $line" ".*" "until-over-throw"
tbreak_and_cont "End: second until"
verify_testval "pre-check - until 2" 7
tbreak_and_cont "Start: advance"
verify_testval "post-check - until 2" 8
gdb_test "step" "function1 ().*" "step into until, for advance"
gdb_test "advance $line" ".*" "advance-over-throw"
tbreak_and_cont "End: advance"
verify_testval "pre-check - advance" 8
tbreak_and_cont "Start: resumebpt"
gdb_test "tbreak _Unwind_RaiseException"
gdb_test "continue" "Temporary breakpoint.*" "continuing to _Unwind_RaiseException"
gdb_test "finish" "Run till exit .*"
gdb_test {set $retpc=$pc}
gdb_test {break *$retpc if dummy ()}
tbreak_and_cont "Second: resumebpt"
gdb_test "next"
gdb PR c++/9593: * thread.c (clear_thread_inferior_resources): Call delete_longjmp_breakpoint. * infrun.c (handle_inferior_event): Handle exception breakpoints. (handle_inferior_event): Likewise. (insert_exception_resume_breakpoint): New function. (check_exception_resume): Likewise. * inferior.h (delete_longjmp_breakpoint_cleanup): Declare. * infcmd.c (delete_longjmp_breakpoint_cleanup): No longer static. (step_1): Set thread's initiating frame. (until_next_continuation): New function. (until_next_command): Support exception breakpoints. (finish_command_continuation): Delete longjmp breakpoint. (finish_forward): Support exception breakpoints. * gdbthread.h (struct thread_info) <initiating_frame>: New field. * breakpoint.h (enum bptype) <bp_exception, bp_exception_resume, bp_exception_master>: New constants. (struct bpstat_what) <is_longjmp>: New field. (set_longjmp_breakpoint): Update. * breakpoint.c (create_exception_master_breakpoint): New function. (update_breakpoints_after_exec): Handle bp_exception_master. Call create_exception_master_breakpoint. (print_it_typical): Handle bp_exception_master, bp_exception. (bpstat_stop_status): Handle bp_exception_master. (bpstat_what): Handle bp_exception_master, bp_exception, bp_exception_resume. (bptype_string): Likewise. (print_one_breakpoint_location): Likewise. (allocate_bp_location): Likewise. (set_longjmp_breakpoint): Handle exception breakpoints. Change interface. (delete_longjmp_breakpoint): Handle exception breakpoints. (mention): Likewise. (struct until_break_command_continuation_args) <thread_num>: New field. (until_break_command_continuation): Call delete_longjmp_breakpoint. (until_break_command): Support exception breakpoints. (delete_command): Likewise. (breakpoint_re_set_one): Likewise. (breakpoint_re_set): Likewise. gdb/testuite * gdb.java/jnpe.java: New file. * gdb.java/jnpe.exp: New file. * gdb.cp/nextoverthrow.exp: New file. * gdb.cp/nextoverthrow.cc: New file.
2010-12-09 17:09:54 +01:00
tbreak_and_cont "done"
verify_testval "post-check - advance" 10