2004-01-09 Michael Chastain <mec.gnu@mindspring.com>
* gdb.cp/exception.cc: Change <iostream.h> to <iostream>. * gdb.cp/exception.exp: Use gdb test, gdb_test_multiple. Use gdb_compile. Remove restriction on gcc. Add some patterns for recent version of gdb. Delete second half, which was a copy of the first half with different build flags. This test is still disabled because it is still not ready for production.
This commit is contained in:
parent
e36d075ac4
commit
041ab88cf0
|
@ -1,3 +1,12 @@
|
||||||
|
2004-01-09 Michael Chastain <mec.gnu@mindspring.com>
|
||||||
|
|
||||||
|
* gdb.cp/exception.cc: Change <iostream.h> to <iostream>.
|
||||||
|
* gdb.cp/exception.exp: Use gdb test, gdb_test_multiple.
|
||||||
|
Use gdb_compile. Remove restriction on gcc. Add some patterns
|
||||||
|
for recent version of gdb. Delete second half, which was a copy
|
||||||
|
of the first half with different build flags. This test is
|
||||||
|
still disabled because it is still not ready for production.
|
||||||
|
|
||||||
2004-01-08 Michael Chastain <mec.gnu@mindspring.com>
|
2004-01-08 Michael Chastain <mec.gnu@mindspring.com>
|
||||||
|
|
||||||
* gdb.cp/exception.cc: Add copyright notice.
|
* gdb.cp/exception.cc: Add copyright notice.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* This testcase is part of GDB, the GNU debugger.
|
/* This testcase is part of GDB, the GNU debugger.
|
||||||
|
|
||||||
Copyright 1997, 1998 Free Software Foundation, Inc.
|
Copyright 1997, 1998, 2004 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -21,7 +21,8 @@
|
||||||
|
|
||||||
// Test file for exception handling support.
|
// Test file for exception handling support.
|
||||||
|
|
||||||
#include <iostream.h>
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
int foo (int i)
|
int foo (int i)
|
||||||
{
|
{
|
||||||
|
@ -65,5 +66,4 @@ int main()
|
||||||
|
|
||||||
// Not caught
|
// Not caught
|
||||||
foo (20);
|
foo (20);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,66 +17,41 @@
|
||||||
# Please email any bugs, comments, and/or additions to this file to:
|
# Please email any bugs, comments, and/or additions to this file to:
|
||||||
# bug-gdb@prep.ai.mit.edu
|
# bug-gdb@prep.ai.mit.edu
|
||||||
|
|
||||||
# Note: every line number in this file is too low by 21,
|
# This file is part of the gdb testsuite.
|
||||||
# because I added a copyright notice to exception.cc.
|
|
||||||
# -- chastain 2004-01-08
|
|
||||||
|
|
||||||
#
|
|
||||||
# tests for exception-handling support
|
# tests for exception-handling support
|
||||||
# Written by Satish Pai <pai@apollo.hp.com> 1997-07-23
|
# Written by Satish Pai <pai@apollo.hp.com> 1997-07-23
|
||||||
|
# Rewritten by Michael Chastain <mec.gnu@mindspring.com> 2004-01-08
|
||||||
|
|
||||||
# This file is part of the gdb testsuite
|
# This file used to have two copies of the tests with different
|
||||||
|
# compiler flags for hp-ux. Instead, the user should set CXXOPTS
|
||||||
|
# or run runtest with --target_board unix/gdb:debug_flags="..."
|
||||||
|
# to choose the compiler flags.
|
||||||
|
#
|
||||||
|
# The interesting compiler flags are: "aCC +A -Wl,-a-archive" .
|
||||||
|
# Static-linked executables use a different mechanism to get the
|
||||||
|
# address of the notification hook in the C++ support library.
|
||||||
|
|
||||||
# Note: These tests are geared to the HP aCC compiler,
|
# TODO: this file is not ready for production yet. If you are working
|
||||||
# which has an idiosyncratic way of emitting debug info
|
# on C++ exception support for gdb, you can take out the "continue"
|
||||||
# for exceptions -- it uses a callback mechanism, which
|
# statement and try your luck. -- chastain 2004-01-09
|
||||||
# is different from the way g++ records exception info
|
|
||||||
# for debugging
|
|
||||||
|
|
||||||
# The tests are in two parts; the first part deals with
|
|
||||||
# statically linked (archive-bound) executables, and the
|
|
||||||
# second part repeats those tests with dynamically linked
|
|
||||||
# (shared bound) executables. (In the latter case we use
|
|
||||||
# a different mechanism to get the address of the notification
|
|
||||||
# hook in the C++ support library.) The tests themselves are
|
|
||||||
# the same in both parts.
|
|
||||||
#
|
|
||||||
# IMPORTANT:
|
|
||||||
# ---------
|
|
||||||
# IF YOU CHANGE A TEST IN ONE PART MAKE SURE YOU CHANGE IT
|
|
||||||
# --------------------------------------------------------
|
|
||||||
# IN THE OTHER PART TOO!
|
|
||||||
# ----------------------
|
|
||||||
|
|
||||||
|
# TODO: this file has many absolute line numbers.
|
||||||
|
# Replace them with gdb_get_line_number.
|
||||||
|
|
||||||
|
set ws "\[\r\n\t \]+"
|
||||||
|
set nl "\[\r\n\]+"
|
||||||
|
|
||||||
if $tracelevel then {
|
if $tracelevel then {
|
||||||
strace $tracelevel
|
strace $tracelevel
|
||||||
}
|
}
|
||||||
|
|
||||||
if { [skip_hp_tests] } then { continue }
|
|
||||||
|
|
||||||
#
|
|
||||||
# test running programs
|
|
||||||
#
|
|
||||||
|
|
||||||
# Part I : Archive-bound executables
|
|
||||||
# ----------------------------------
|
|
||||||
|
|
||||||
set testfile "exception"
|
set testfile "exception"
|
||||||
set srcfile ${testfile}.cc
|
set srcfile ${testfile}.cc
|
||||||
set binfile ${objdir}/${subdir}/${testfile}
|
set binfile ${objdir}/${subdir}/${testfile}
|
||||||
|
|
||||||
if [get_compiler_info ${binfile} "c++"] {
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
|
||||||
return -1;
|
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if { $gcc_compiled } then { continue }
|
|
||||||
|
|
||||||
set cmdline "$CXX_FOR_TARGET ${srcdir}/${subdir}/${srcfile} +A -Wl,-a,archive -g -o ${binfile}"
|
|
||||||
|
|
||||||
remote_exec build $cmdline
|
|
||||||
|
|
||||||
# Start with a fresh gdb
|
# Start with a fresh gdb
|
||||||
|
|
||||||
|
@ -93,351 +68,155 @@ if ![runto_main] then {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# As I said before, this test script is not ready yet!
|
||||||
|
|
||||||
|
continue
|
||||||
|
|
||||||
# Set a catch catchpoint
|
# Set a catch catchpoint
|
||||||
|
|
||||||
send_gdb "catch catch\n"
|
gdb_test "catch catch" "Catchpoint \[0-9\]+ \\(catch\\)"
|
||||||
gdb_expect {
|
|
||||||
-re "Catchpoint \[0-9\]* \\(catch\\)\r\n$gdb_prompt $" {
|
|
||||||
pass "catch catch (static executable)"
|
|
||||||
}
|
|
||||||
-re ".*$gdb_prompt $" { fail "catch catch (static executable)" }
|
|
||||||
timeout { fail "(timeout) catch catch (static executable)" }
|
|
||||||
}
|
|
||||||
|
|
||||||
# Set a throw catchpoint
|
# Set a throw catchpoint
|
||||||
|
|
||||||
send_gdb "catch throw\n"
|
gdb_test "catch throw" "Catchpoint \[0-9\]+ \\(throw\\)" \
|
||||||
gdb_expect {
|
"catch throw (static executable)"
|
||||||
-re "Catchpoint \[0-9\]* \\(throw\\)\r\n$gdb_prompt $" {
|
|
||||||
pass "catch throw (static executable)"
|
|
||||||
}
|
|
||||||
-re ".*$gdb_prompt $" { fail "catch throw (static executable)" }
|
|
||||||
timeout { fail "(timeout) catch throw (static executable)" }
|
|
||||||
}
|
|
||||||
|
|
||||||
# The catchpoints should be listed in the list of breakpoints.
|
# The catchpoints should be listed in the list of breakpoints.
|
||||||
|
|
||||||
send_gdb "info break\n"
|
set re_head "Num${ws}Type${ws}Disp${ws}Enb${ws}Address${ws}What"
|
||||||
gdb_expect {
|
set re_1_main "1${ws}breakpoint${ws}keep${ws}y${ws}$hex${ws}in main.*breakpoint already hit.*"
|
||||||
-re ".*\[0-9\]*\[ \]*catch catch\[ \]*keep y\[ \]*exception catch\[ \]*\r\n\[0-9\]*\[ \]*catch throw\[ \]*keep y\[ \]*exception throw\[ \]*\r\n$gdb_prompt $" {
|
set re_2_catch "2${ws}catch catch${ws}keep${ws}y${ws}$hex${ws}exception catch"
|
||||||
pass "info break with catchpoints (static executable)"
|
set re_3_catch "3${ws}catch throw${ws}keep${ws}y${ws}$hex${ws}exception throw"
|
||||||
}
|
set re_2_bp "2${ws}breakpoint${ws}keep${ws}y${ws}$hex${ws}exception catch"
|
||||||
-re ".*$gdb_prompt $" { fail "info break (static executable)" }
|
set re_3_bp "3${ws}breakpoint${ws}keep${ws}y${ws}$hex${ws}exception throw"
|
||||||
timeout { fail "(timeout) info break (static executable)" }
|
|
||||||
|
set name "info breakpoints"
|
||||||
|
gdb_test_multiple "info breakpoints" $name {
|
||||||
|
-re "$re_head${ws}$re_1_main${ws}$re_2_catch${ws}$re_3_catch\r\n$gdb_prompt $" {
|
||||||
|
pass $name
|
||||||
|
}
|
||||||
|
-re "$re_head${ws}$re_1_main${ws}$re_2_bp${ws}$re_3_bp\r\n$gdb_prompt $" {
|
||||||
|
# TODO: gdb HEAD 2004-01-08 does this. Is this okay?
|
||||||
|
unresolved $name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Info catch currently does not work with HP aCC. No easy way to
|
# Some targets support "info catch".
|
||||||
# list the active handlers on the stack.
|
# Some do not.
|
||||||
|
|
||||||
send_gdb "info catch\n"
|
set name "info catch"
|
||||||
gdb_expect {
|
gdb_test_multiple "info catch" $name {
|
||||||
-re "Info catch not supported with this target/compiler combination.\r\n$gdb_prompt $" {
|
-re "Info catch not supported with this target/compiler combination.\r\n$gdb_prompt $" {
|
||||||
pass "info catch (static executable)"
|
unsupported $name
|
||||||
}
|
}
|
||||||
-re ".*$gdb_prompt $" { fail "info catch (static executable)" }
|
-re "No catches.\r\n$gdb_prompt $" {
|
||||||
timeout { fail "(timeout) info catch (static executable)" }
|
# TODO: gdb HEAD 2004-01-08 does this. Is this okay?
|
||||||
|
unresolved $name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get the first exception thrown
|
# Get the first exception thrown
|
||||||
|
|
||||||
send_gdb "continue\n"
|
set name "continue to first throw"
|
||||||
gdb_expect {
|
gdb_test_multiple "continue" $name {
|
||||||
-re "Continuing.*Catchpoint \[0-9\]* \\(exception thrown\\), throw location.*exception\\.cc:8, catch location .*exception\\.cc:28\r\n.*$gdb_prompt $" {
|
-re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception thrown\\), throw location.*${srcfile}:30, catch location .*${srcfile}:50\r\n$gdb_prompt $" {
|
||||||
pass "caught a throw (static executable)"
|
pass $name
|
||||||
}
|
}
|
||||||
-re ".*$gdb_prompt $" { fail "didn't catch a throw (static executable)" }
|
-re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception thrown\\)\r\n.*\r\n$gdb_prompt $" {
|
||||||
timeout { fail "(timeout) after continue -- didn't catch a throw? (static executable)" }
|
# TODO: gdb HEAD 2004-01-08 does this. Is this okay?
|
||||||
|
unresolved $name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
send_gdb "backtrace\n"
|
# Backtrace from the throw point.
|
||||||
gdb_expect {
|
# This should get to user code.
|
||||||
-re "#0\[ \]*__d_eh_break.*\r\n#1\[ \]*$hex in __d_eh_notify_callback \\(eh_type=__EH_NOTIFY_THROW.*\r\n#2\[ \]*$hex in __eh_notify_throw.*\r\n#3\[ \]*$hex in foo \\(i=20\\) at .*exception\\.cc:8\r\n#4\[ \]*$hex in main.* at .*exception\\.cc:26\r\n$gdb_prompt $" {
|
|
||||||
pass "backtrace after throw (static executable)"
|
set name "backtrace after first throw"
|
||||||
}
|
gdb_test_multiple "backtrace" $name {
|
||||||
-re "#0\[ \]*__d_eh_break.*\r\n#1\[ \]*$hex in __d_eh_notify_callback \\(eh_type=\[0-9\].*\r\n#2\[ \]*$hex in __eh_notify_throw.*\r\n#3\[ \]*$hex in foo \\(i=20\\) at .*exception\\.cc:8\r\n#4\[ \]*$hex in main.* at .*exception\\.cc:26\r\n$gdb_prompt $" {
|
-re ".*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:30\r\n#\[0-9\]+${ws}$hex in main \\((void|)\\) at .*${srcfile}:48\r\n$gdb_prompt $" {
|
||||||
pass "backtrace after throw (static executable)"
|
pass $name
|
||||||
}
|
}
|
||||||
-re ".*$gdb_prompt $" { fail "backtrace after throw (static executable)" }
|
|
||||||
timeout { fail "(timeout) backtrace after throw (static executable)" }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Now intercept it when it is caught.
|
# Continue to the catch.
|
||||||
|
|
||||||
send_gdb "continue\n"
|
set name "continue to first catch"
|
||||||
gdb_expect {
|
gdb_test_multiple "continue" $name {
|
||||||
-re "Continuing.*Catchpoint \[0-9\]* \\(exception caught\\), throw location.*exception\\.cc:8, catch location .*exception\\.cc:28\r\n.*$gdb_prompt $" {
|
-re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\), throw location.*${srcfile}:30, catch location .*${srcfile}:50\r\n$gdb_prompt $" {
|
||||||
pass "caught a catch (static executable)"
|
pass $name
|
||||||
}
|
}
|
||||||
-re ".*$gdb_prompt $" { fail "didn't catch a catch (static executable)" }
|
-re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\)\r\n.*\r\n$gdb_prompt $" {
|
||||||
timeout { fail "(timeout) after continue -- didn't catch a catch? (static executable)" }
|
# TODO: gdb HEAD 2004-01-08 does this. Is this okay?
|
||||||
|
unresolved $name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
send_gdb "backtrace\n"
|
# Backtrace from the catch point.
|
||||||
gdb_expect {
|
# This should get to user code.
|
||||||
-re "#0\[ \]*__d_eh_break.*\r\n#1\[ \]*$hex in __d_eh_notify_callback \\(eh_type=__EH_NOTIFY_CATCH.*\r\n.*\r\n#3\[ \]*$hex in __throw__.*\r\n#4\[ \]*$hex in foo \\(i=20\\) at .*exception.cc:8\r\n#5\[ \]*$hex in main.* at .*exception.cc:26\r\n$gdb_prompt $" {
|
|
||||||
pass "backtrace after catch (static executable)"
|
set name "backtrace after first catch"
|
||||||
}
|
gdb_test_multiple "backtrace" $name {
|
||||||
-re "#0\[ \]*__d_eh_break.*\r\n#1\[ \]*$hex in __d_eh_notify_callback \\(eh_type=\[0-9\].*\r\n.*\r\n#3\[ \]*$hex in __throw__.*\r\n#4\[ \]*$hex in foo \\(i=20\\) at .*exception.cc:8\r\n#5\[ \]*$hex in main.* at .*exception.cc:26\r\n$gdb_prompt $" {
|
-re ".*#\[0-9\]+${ws}$hex in main \\((void|)\\) at .*$srcfile:50\r\n$gdb_prompt $" {
|
||||||
pass "backtrace after catch (static executable)"
|
pass $name
|
||||||
}
|
}
|
||||||
-re ".*$gdb_prompt $" { fail "backtrace after catch (static executable)" }
|
|
||||||
timeout { fail "(timeout) backtrace after catch (static executable)" }
|
|
||||||
}
|
|
||||||
|
|
||||||
send_gdb "continue\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "Continuing\\.\r\nGot.*\r\nCatchpoint \[0-9\]* \\(exception thrown\\), throw location.*exception\\.cc:8, catch location .*exception\\.cc:36\r\n.*$gdb_prompt $" {
|
|
||||||
pass "caught a throw (2) (static executable)"
|
|
||||||
}
|
|
||||||
-re ".*$gdb_prompt $" { fail "didn't catch a throw (2) (static executable)" }
|
|
||||||
timeout { fail "(timeout) after continue -- didn't catch a throw (2)? (static executable)" }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
send_gdb "continue\n"
|
# Continue to second throw.
|
||||||
gdb_expect {
|
|
||||||
-re "Continuing.*Catchpoint \[0-9\]* \\(exception caught\\), throw location.*exception\\.cc:8, catch location .*exception\\.cc:36\r\n.*$gdb_prompt $" {
|
set name "continue to second throw"
|
||||||
pass "caught a catch (2) (static executable)"
|
gdb_test_multiple "continue" $name {
|
||||||
}
|
-re "Continuing.${ws}Got an except 13${ws}Catchpoint \[0-9\]+ \\(exception thrown\\), throw location.*${srcfile}:30, catch location .*${srcfile}:58\r\n$gdb_prompt $" {
|
||||||
-re ".*$gdb_prompt $" { fail "didn't catch a catch (2) (static executable)" }
|
pass $name
|
||||||
timeout { fail "(timeout) after continue -- didn't catch a catch (2)? (static executable)" }
|
}
|
||||||
|
-re "Continuing.${ws}Got an except 13${ws}Catchpoint \[0-9\]+ \\(exception thrown\\)\r\n.*\r\n$gdb_prompt $" {
|
||||||
|
# TODO: gdb HEAD 2004-01-08 does this. Is this okay?
|
||||||
|
unresolved $name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Now the exception will be rethrown.
|
# Backtrace from the throw point.
|
||||||
|
# This should get to user code.
|
||||||
|
|
||||||
send_gdb "continue\n"
|
set name "backtrace after second throw"
|
||||||
gdb_expect {
|
gdb_test_multiple "backtrace" $name {
|
||||||
-re "Continuing\\.\r\nGot.*\r\nCatchpoint \[0-9\]* \\(exception thrown\\), throw location.*exception\\.cc:38, catch location .*exception\\.cc:41\r\n.*$gdb_prompt $" {
|
-re ".*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:30\r\n#\[0-9\]+${ws}$hex in main \\((void|)\\) at .*${srcfile}:56\r\n$gdb_prompt $" {
|
||||||
pass "caught a rethrow (static executable)"
|
pass $name
|
||||||
}
|
}
|
||||||
-re ".*$gdb_prompt $" { fail "didn't catch a rethrow (static executable)" }
|
|
||||||
timeout { fail "(timeout) after continue -- didn't catch a rethrow? (static executable)" }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
send_gdb "continue\n"
|
# Continue to second catch.
|
||||||
gdb_expect {
|
|
||||||
-re "Continuing.*Catchpoint \[0-9\]* \\(exception caught\\), throw location.*exception\\.cc:3\[68\], catch location .*exception\\.cc:41\r\n.*$gdb_prompt $" {
|
set name "continue to second catch"
|
||||||
# FIXME: guo: why XFAIL? need comment
|
gdb_test_multiple "continue" $name {
|
||||||
xfail "caught a catch (3) (static executable)"
|
-re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\), throw location.*${srcfile}:30, catch location .*${srcfile}:58\r\n$gdb_prompt $" {
|
||||||
}
|
pass $name
|
||||||
-re ".*$gdb_prompt $" { fail "didn't catch a catch (3) (static executable)" }
|
}
|
||||||
timeout { fail "(timeout) after continue -- didn't catch a catch (3)? (static executable)" }
|
-re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\)\r\n.*\r\n$gdb_prompt $" {
|
||||||
|
# TODO: gdb HEAD 2004-01-08 does this. Is this okay?
|
||||||
|
unresolved $name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
send_gdb "backtrace\n"
|
# Backtrace from the catch point.
|
||||||
gdb_expect {
|
# This should get to user code.
|
||||||
-re "#0\[ \]*__d_eh_break.*\r\n#1\[ \]*$hex in __d_eh_notify_callback \\(eh_type=__EH_NOTIFY_CATCH.*\r\n.*\r\n#3\[ \]*$hex in __rethrow.*\r\n#4\[ \]*$hex in main.* at .*exception\\.cc:3\[68\]\r\n#5\[ \]*$hex in foo \\(i=20\\) at .*exception.cc:8\r\n#6\[ \]*$hex in main.* at .*exception.cc:34\r\n$gdb_prompt $" {
|
|
||||||
# FIXME: guo: why XFAIL? need comment
|
set name "backtrace after second catch"
|
||||||
xfail "backtrace after catch (3) (static executable)"
|
gdb_test_multiple "backtrace" $name {
|
||||||
}
|
-re ".*#\[0-9\]+${ws}$hex in main \\((void|)\\) at .*$srcfile:58\r\n$gdb_prompt $" {
|
||||||
-re "#0\[ \]*__d_eh_break.*\r\n#1\[ \]*$hex in __d_eh_notify_callback \\(eh_type=\[0-9\].*\r\n.*\r\n#3\[ \]*$hex in __rethrow.*\r\n#4\[ \]*$hex in main.* at .*exception\\.cc:3\[68\]\r\n#5\[ \]*$hex in foo \\(i=20\\) at .*exception.cc:8\r\n#6\[ \]*$hex in main.* at .*exception.cc:34\r\n$gdb_prompt $" {
|
pass $name
|
||||||
# FIXME: guo: why XFAIL? need comment
|
}
|
||||||
xfail "backtrace after catch (3) (static executable)"
|
|
||||||
}
|
|
||||||
-re ".*$gdb_prompt $" { fail "backtrace after catch (3) (static executable)" }
|
|
||||||
timeout { fail "(timeout) backtrace after catch (3) (static executable)" }
|
|
||||||
}
|
|
||||||
|
|
||||||
# Now the exception will be thrown, but not catch-able anywhere.
|
|
||||||
|
|
||||||
send_gdb "continue\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "Continuing\\.\r\nGot.*\r\nCatchpoint \[0-9\]* \\(exception thrown\\), throw location.*exception\\.cc:8, catch location unknown\r\n.*$gdb_prompt $" {
|
|
||||||
pass "caught an uncatchable throw (static executable)"
|
|
||||||
}
|
|
||||||
-re ".*$gdb_prompt $" { fail "didn't catch an uncatchable throw (static executable)" }
|
|
||||||
timeout { fail "(timeout) after continue -- didn't catch an uncatchable throw? (static executable)" }
|
|
||||||
}
|
|
||||||
|
|
||||||
# Part II : Shared-bound executables
|
|
||||||
# ----------------------------------
|
|
||||||
|
|
||||||
# Start with a fresh gdb
|
|
||||||
gdb_exit
|
|
||||||
gdb_start
|
|
||||||
gdb_reinitialize_dir $srcdir/$subdir
|
|
||||||
|
|
||||||
set prms_id 0
|
|
||||||
set bug_id 0
|
|
||||||
|
|
||||||
set testfile "exception"
|
|
||||||
set srcfile ${testfile}.cc
|
|
||||||
set binfile ${objdir}/${subdir}/${testfile}
|
|
||||||
|
|
||||||
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
|
|
||||||
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will a
|
|
||||||
utomatically fail."
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
gdb_exit
|
|
||||||
gdb_start
|
|
||||||
gdb_reinitialize_dir $srcdir/$subdir
|
|
||||||
gdb_load ${binfile}
|
|
||||||
|
|
||||||
|
|
||||||
if ![runto_main] then {
|
|
||||||
perror "couldn't run to breakpoint"
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
# Set a catch catchpoint
|
|
||||||
|
|
||||||
send_gdb "catch catch\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "Catchpoint \[0-9\]* \\(catch\\)\r\n$gdb_prompt $" {
|
|
||||||
pass "catch catch (dynamic executable)"
|
|
||||||
}
|
|
||||||
-re ".*$gdb_prompt $" { fail "catch catch (dynamic executable)" }
|
|
||||||
timeout { fail "(timeout) catch catch (dynamic executable)" }
|
|
||||||
}
|
|
||||||
|
|
||||||
# Set a throw catchpoint
|
|
||||||
|
|
||||||
send_gdb "catch throw\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "Catchpoint \[0-9\]* \\(throw\\)\r\n$gdb_prompt $" {
|
|
||||||
pass "catch throw (dynamic executable)"
|
|
||||||
}
|
|
||||||
-re ".*$gdb_prompt $" { fail "catch throw (dynamic executable)" }
|
|
||||||
timeout { fail "(timeout) catch throw (dynamic executable)" }
|
|
||||||
}
|
|
||||||
|
|
||||||
# The catchpoints should be listed in the list of breakpoints.
|
|
||||||
|
|
||||||
send_gdb "info break\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re ".*\[0-9\]*\[ \]*catch catch\[ \]*keep y\[ \]*exception catch\[ \]*\r\n\[0-9\]*\[ \]*catch throw\[ \]*keep y\[ \]*exception throw\[ \]*\r\n$gdb_prompt $" {
|
|
||||||
pass "info break with catchpoints (dynamic executable)"
|
|
||||||
}
|
|
||||||
-re ".*$gdb_prompt $" { fail "info break (dynamic executable)" }
|
|
||||||
timeout { fail "(timeout) info break (dynamic executable)" }
|
|
||||||
}
|
|
||||||
|
|
||||||
# Info catch currently does not work with HP aCC. No easy way to
|
|
||||||
# list the active handlers on the stack.
|
|
||||||
|
|
||||||
send_gdb "info catch\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "Info catch not supported with this target/compiler combination.\r\n$gdb_prompt $" {
|
|
||||||
pass "info catch (dynamic executable)"
|
|
||||||
}
|
|
||||||
-re ".*$gdb_prompt $" { fail "info catch (dynamic executable)" }
|
|
||||||
timeout { fail "(timeout) info catch (dynamic executable)" }
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get the first exception thrown
|
|
||||||
|
|
||||||
send_gdb "continue\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "Continuing.*Catchpoint \[0-9\]* \\(exception thrown\\), throw location.*exception\\.cc:8, catch location .*exception\\.cc:28\r\n.*$gdb_prompt $" {
|
|
||||||
pass "caught a throw (dynamic executable)"
|
|
||||||
}
|
|
||||||
-re ".*$gdb_prompt $" { fail "didn't catch a throw (dynamic executable)" }
|
|
||||||
timeout { fail "(timeout) after continue -- didn't catch a throw? (dynamic executable)" }
|
|
||||||
}
|
|
||||||
|
|
||||||
send_gdb "backtrace\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "#0\[ \]*__d_eh_break.*\r\n#1\[ \]*$hex in __d_eh_notify_callback \\(eh_type=__EH_NOTIFY_THROW.*\r\n#2\[ \]*$hex in __eh_notify_throw.*\r\n#3\[ \]*$hex in foo \\(i=20\\) at .*exception\\.cc:8\r\n#4\[ \]*$hex in main.* at .*exception\\.cc:26\r\n$gdb_prompt $" {
|
|
||||||
pass "backtrace after throw (dynamic executable)"
|
|
||||||
}
|
|
||||||
-re "#0\[ \]*__d_eh_break.*\r\n#1\[ \]*$hex in __d_eh_notify_callback \\(eh_type=\[0-9\].*\r\n#2\[ \]*$hex in __eh_notify_throw.*\r\n#3\[ \]*$hex in foo \\(i=20\\) at .*exception\\.cc:8\r\n#4\[ \]*$hex in main.* at .*exception\\.cc:26\r\n$gdb_prompt $" {
|
|
||||||
pass "backtrace after throw (dynamic executable)"
|
|
||||||
}
|
|
||||||
-re ".*$gdb_prompt $" { fail "backtrace after throw (dynamic executable)" }
|
|
||||||
timeout { fail "(timeout) backtrace after throw (dynamic executable)" }
|
|
||||||
}
|
|
||||||
|
|
||||||
# Now intercept it when it is caught.
|
|
||||||
|
|
||||||
send_gdb "continue\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "Continuing.*Catchpoint \[0-9\]* \\(exception caught\\), throw location.*exception\\.cc:8, catch location .*exception\\.cc:28\r\n.*$gdb_prompt $" {
|
|
||||||
pass "caught a catch (dynamic executable)"
|
|
||||||
}
|
|
||||||
-re ".*$gdb_prompt $" { fail "didn't catch a catch (dynamic executable)" }
|
|
||||||
timeout { fail "(timeout) after continue -- didn't catch a catch? (dynamic executable)" }
|
|
||||||
}
|
|
||||||
|
|
||||||
send_gdb "backtrace\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "#0\[ \]*__d_eh_break.*\r\n#1\[ \]*$hex in __d_eh_notify_callback \\(eh_type=__EH_NOTIFY_CATCH.*\r\n.*\r\n#3\[ \]*$hex in __throw__.*\r\n#4\[ \]*$hex in foo \\(i=20\\) at .*exception.cc:8\r\n#5\[ \]*$hex in main.* at .*exception.cc:26\r\n$gdb_prompt $" {
|
|
||||||
pass "backtrace after catch (dynamic executable)"
|
|
||||||
}
|
|
||||||
-re "#0\[ \]*__d_eh_break.*\r\n#1\[ \]*$hex in __d_eh_notify_callback \\(eh_type=\[0-9\].*\r\n.*\r\n#3\[ \]*$hex in __throw__.*\r\n#4\[ \]*$hex in foo \\(i=20\\) at .*exception.cc:8\r\n#5\[ \]*$hex in main.* at .*exception.cc:26\r\n$gdb_prompt $" {
|
|
||||||
pass "backtrace after catch (dynamic executable)"
|
|
||||||
}
|
|
||||||
-re ".*$gdb_prompt $" { fail "backtrace after catch (dynamic executable)" }
|
|
||||||
timeout { fail "(timeout) backtrace after catch (dynamic executable)" }
|
|
||||||
}
|
|
||||||
|
|
||||||
send_gdb "continue\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "Continuing\\.\r\nGot.*\r\nCatchpoint \[0-9\]* \\(exception thrown\\), throw location.*exception\\.cc:8, catch location .*exception\\.cc:36\r\n.*$gdb_prompt $" {
|
|
||||||
pass "caught a throw (2) (dynamic executable)"
|
|
||||||
}
|
|
||||||
-re ".*$gdb_prompt $" { fail "didn't catch a throw (2) (dynamic executable)" }
|
|
||||||
timeout { fail "(timeout) after continue -- didn't catch a throw (2)? (dynamic executable)" }
|
|
||||||
}
|
|
||||||
|
|
||||||
send_gdb "continue\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "Continuing.*Catchpoint \[0-9\]* \\(exception caught\\), throw location.*exception\\.cc:8, catch location .*exception\\.cc:36\r\n.*$gdb_prompt $" {
|
|
||||||
pass "caught a catch (2) (dynamic executable)"
|
|
||||||
}
|
|
||||||
-re ".*$gdb_prompt $" { fail "didn't catch a catch (2) (dynamic executable)" }
|
|
||||||
timeout { fail "(timeout) after continue -- didn't catch a catch (2)? (dynamic executable)" }
|
|
||||||
}
|
|
||||||
|
|
||||||
# Now the exception will be rethrown.
|
|
||||||
|
|
||||||
send_gdb "continue\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "Continuing\\.\r\nGot.*\r\nCatchpoint \[0-9\]* \\(exception thrown\\), throw location.*exception\\.cc:38, catch location .*exception\\.cc:41\r\n.*$gdb_prompt $" {
|
|
||||||
pass "caught a rethrow (dynamic executable)"
|
|
||||||
}
|
|
||||||
-re ".*$gdb_prompt $" { fail "didn't catch a rethrow (dynamic executable)" }
|
|
||||||
timeout { fail "(timeout) after continue -- didn't catch a rethrow? (dynamic executable)" }
|
|
||||||
}
|
|
||||||
|
|
||||||
#DTS CLLbs14858
|
|
||||||
#The throw location should be at line 38 instead of 36.
|
|
||||||
setup_xfail hppa*-*-* CLLbs14858
|
|
||||||
send_gdb "continue\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "Continuing.*Catchpoint \[0-9\]* \\(exception caught\\), throw location.*exception\\.cc:3\[68\], catch location .*exception\\.cc:41\r\n.*$gdb_prompt $" {
|
|
||||||
# FIXME: guo: according to comment above the RE is wrong!
|
|
||||||
pass "caught a catch (3) (dynamic executable)"
|
|
||||||
}
|
|
||||||
-re ".*$gdb_prompt $" { fail "didn't catch a catch (3) (dynamic executable)" }
|
|
||||||
timeout { fail "(timeout) after continue -- didn't catch a catch (3)? (dynamic executable)" }
|
|
||||||
}
|
|
||||||
|
|
||||||
#DTS CLLbs14858
|
|
||||||
#The line number for main() should be at exception.cc:38 instead of exception.cc:36
|
|
||||||
setup_xfail hppa*-*-* CLLbs14858
|
|
||||||
send_gdb "backtrace\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "#0\[ \]*__d_eh_break.*\r\n#1\[ \]*$hex in __d_eh_notify_callback \\(eh_type=__EH_NOTIFY_CATCH.*\r\n.*\r\n#3\[ \]*$hex in __rethrow.*\r\n#4\[ \]*$hex in main.* at .*exception\\.cc:3\[68\]\r\n#5\[ \]*$hex in foo \\(i=20\\) at .*exception.cc:8\r\n#6\[ \]*$hex in main.* at .*exception.cc:34\r\n$gdb_prompt $" {
|
|
||||||
# FIXME: guo: according to comment above the RE is wrong!
|
|
||||||
pass "backtrace after catch (3) (dynamic executable)"
|
|
||||||
}
|
|
||||||
-re "#0\[ \]*__d_eh_break.*\r\n#1\[ \]*$hex in __d_eh_notify_callback \\(eh_type=\[0-9\].*\r\n.*\r\n#3\[ \]*$hex in __rethrow.*\r\n#4\[ \]*$hex in main.* at .*exception\\.cc:3\[68\]\r\n#5\[ \]*$hex in foo \\(i=20\\) at .*exception.cc:8\r\n#6\[ \]*$hex in main.* at .*exception.cc:34\r\n$gdb_prompt $" {
|
|
||||||
# FIXME: guo: according to comment above the RE is wrong!
|
|
||||||
pass "backtrace after catch (3) (dynamic executable)"
|
|
||||||
}
|
|
||||||
-re ".*$gdb_prompt $" { fail "backtrace after catch (3) (dynamic executable)" }
|
|
||||||
timeout { fail "(timeout) backtrace after catch (3) (dynamic executable)" }
|
|
||||||
}
|
|
||||||
|
|
||||||
# Now the exception will be thrown, but not catch-able anywhere.
|
|
||||||
|
|
||||||
send_gdb "continue\n"
|
|
||||||
gdb_expect {
|
|
||||||
-re "Continuing\\.\r\nGot.*\r\nCatchpoint \[0-9\]* \\(exception thrown\\), throw location.*exception\\.cc:8, catch location unknown\r\n.*$gdb_prompt $" {
|
|
||||||
pass "caught an uncatchable throw (dynamic executable)"
|
|
||||||
}
|
|
||||||
-re ".*$gdb_prompt $" { fail "didn't catch an uncatchable throw (dynamic executable)" }
|
|
||||||
timeout { fail "(timeout) after continue -- didn't catch an uncatchable throw? (dynamic executable)" }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# That is all for now.
|
||||||
|
#
|
||||||
|
# The original code had:
|
||||||
|
#
|
||||||
|
# continue to re-throw ; backtrace
|
||||||
|
# continue to catch ; backtrace
|
||||||
|
# continue to throw out of main
|
||||||
|
#
|
||||||
|
# The problem is that "re-throw" does not show a throw; only a catch.
|
||||||
|
# I do not know if this is because of a bug, or because the generated
|
||||||
|
# code is optimized for a throw into the same function.
|
||||||
|
#
|
||||||
|
# -- chastain 2004-01-09
|
||||||
|
|
Loading…
Reference in New Issue