diff options
-rw-r--r-- | gdb/testsuite/gdb.base/bt-on-fatal-signal.exp | 36 | ||||
-rw-r--r-- | gdb/utils.c | 5 |
2 files changed, 41 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.base/bt-on-fatal-signal.exp b/gdb/testsuite/gdb.base/bt-on-fatal-signal.exp index 8875d00..1f0d61f 100644 --- a/gdb/testsuite/gdb.base/bt-on-fatal-signal.exp +++ b/gdb/testsuite/gdb.base/bt-on-fatal-signal.exp @@ -135,3 +135,39 @@ foreach test_data {{SEGV "Segmentation fault"} \ gdb_exit } } + +# Check that when we get an internal error and choose to dump core, we +# don't print a backtrace to the console. +with_test_prefix "internal-error" { + # Restart GDB. + clean_restart $binfile + + set saw_bt_start false + + gdb_test_multiple "maint internal-error foo" "" { + -early -re "internal-error: foo\r\n" { + exp_continue + } + -early -re "^A problem internal to GDB has been detected,\r\n" { + exp_continue + } + -early -re "^further debugging may prove unreliable\\.\r\n" { + exp_continue + } + -early -re "^Quit this debugging session\\? \\(y or n\\)" { + send_gdb "y\n" + exp_continue + } + -early -re "^Create a core file of GDB\\? \\(y or n\\)" { + send_gdb "y\n" + exp_continue + } + -early -re "----- Backtrace -----\r\n" { + set saw_bt_start true + exp_continue + } + eof { + gdb_assert { [expr ! $saw_bt_start] } + } + } +} diff --git a/gdb/utils.c b/gdb/utils.c index c59c635..1c226d5 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -201,6 +201,11 @@ dump_core (void) setrlimit (RLIMIT_CORE, &rlim); #endif /* HAVE_SETRLIMIT */ + /* Ensure that the SIGABRT we're about to raise will immediately cause + GDB to exit and dump core, we don't want to trigger GDB's printing of + a backtrace to the console here. */ + signal (SIGABRT, SIG_DFL); + abort (); /* ARI: abort */ } |