new file mode 100644
@@ -0,0 +1,40 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2020 Free Software Foundation, Inc.
+
+ 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/>. */
+
+#include <pthread.h>
+#include <unistd.h>
+
+static void *
+fun (void *dummy)
+{
+ while (1)
+ sleep (1);
+
+ return NULL;
+}
+
+int
+main (void)
+{
+ pthread_t thread;
+ pthread_create (&thread, NULL, fun, NULL);
+
+ while (1)
+ sleep (1);
+
+ return 0;
+}
new file mode 100644
@@ -0,0 +1,73 @@
+# Copyright (C) 2020 Free Software Foundation, Inc.
+
+# 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/>.
+
+standard_testfile
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
+ {pthreads}] == -1} {
+ return -1
+}
+
+set res [runto main no-message temporary]
+if { $res != 1 } {
+ return -1
+}
+
+set pid -1
+gdb_test_multiple "info inferior 1" "get inferior pid" {
+ -re -wrap "process (\[0-9\]*).*" {
+ set pid $expect_out(1,string)
+ pass $gdb_test_name
+ }
+}
+if { $pid == -1 } {
+ return -1
+}
+
+gdb_test_multiple "continue" "" {
+ -re "Continuing" {
+ pass $gdb_test_name
+ }
+}
+
+send_gdb "\003"
+
+gdb_test_multiple "" "get sigint" {
+ -re -wrap "Thread \[0-9\]+ .* received signal SIGINT, Interrupt\..*" {
+ pass $gdb_test_name
+ }
+}
+
+gdb_test_no_output "shell kill -s SIGKILL $pid" "shell kill -s SIGKILL pid"
+
+# Expect the signal to arrive, and the program to terminate.
+# Ideally at the first continue, currently though at the second.
+set killed_msg "Program terminated with signal SIGKILL, Killed\."
+set no_longer_exists_msg "The program no longer exists\."
+set not_being_run_msg "The program is not being run\."
+set msg [join [list $killed_msg $no_longer_exists_msg $not_being_run_msg] \
+ ".*"]
+
+# Don't expect '$gdb_prompt $', there still may be output after the prompt,
+# f.i.:
+# ...
+# (gdb) [Thread 0x7ffff74c6700 (LWP 19277) exited]^M
+# ...
+gdb_test_multiple "continue" "" {
+ -re ".*\r\n$gdb_prompt " {
+ gdb_test "continue" $msg $gdb_test_name
+ }
+}
+
@@ -571,7 +571,7 @@ proc runto { function args } {
}
return 1
}
- -re "Breakpoint \[0-9\]*, \[0-9xa-f\]* in .*$gdb_prompt $" {
+ -re "\[Bb\]reakpoint \[0-9\]*, \[0-9xa-f\]* in .*$gdb_prompt $" {
if { $print_pass } {
pass $test_name
}
@@ -1444,6 +1444,8 @@ scoped_restore_current_thread::restore ()
scoped_restore_current_thread::~scoped_restore_current_thread ()
{
+ if (m_inf == NULL)
+ return;
if (!m_dont_restore)
{
try
@@ -1488,7 +1490,17 @@ scoped_restore_current_thread::scoped_restore_current_thread ()
else
frame = NULL;
- m_selected_frame_id = get_frame_id (frame);
+ try
+ {
+ m_selected_frame_id = get_frame_id (frame);
+ }
+ catch (const gdb_exception &ex)
+ {
+ m_inf = NULL;
+ m_selected_frame_id = null_frame_id;
+ m_selected_frame_level = -1;
+ return;
+ }
m_selected_frame_level = frame_relative_level (frame);
tp->incref ();