📄 exception.exp
字号:
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: why XFAIL? need comment xfail "backtrace after catch (3) (static 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: 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 gdbgdb_exitgdb_startgdb_reinitialize_dir $srcdir/$subdirset prms_id 0set bug_id 0set testfile "exception"set srcfile ${testfile}.ccset 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 automatically fail."}gdb_exitgdb_startgdb_reinitialize_dir $srcdir/$subdirgdb_load ${binfile}if ![runto_main] then { perror "couldn't run to breakpoint" continue}# Set a catch catchpointsend_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 catchpointsend_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*-*-* CLLbs14858send_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:36setup_xfail hppa*-*-* CLLbs14858send_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)" }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -