1# Copyright 2017-2020 Free Software Foundation, Inc. 2 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation; either version 3 of the License, or 6# (at your option) any later version. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License 14# along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16load_lib "ada.exp" 17 18if { [skip_ada_tests] } { return -1 } 19 20standard_ada_testfile crash 21 22if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } { 23 return -1 24} 25 26clean_restart ${testfile} 27 28# Run the program to a certain point, and then use the gcore command 29# to generate a core file. The only objective of this part of this 30# testcase is to generate this core file, so we can then exercise 31# task-switching when debugging from core files. 32 33if { ![runto request_for_crash ]} then { 34 untested "couldn't run to Request_For_Crash" 35 return -1 36} 37 38set corefile [standard_output_file crash.gcore] 39set core_supported [gdb_gcore_cmd "$corefile" "save a corefile"] 40if {!$core_supported} { 41 return -1 42} 43 44# Now taht the core file has been created, we can start the real 45# part of this testcase, which is to debug using that core file. 46# Restart GDB and load that core file. 47 48clean_restart ${testfile} 49 50set core_loaded [gdb_core_cmd "$corefile" "re-load generated corefile"] 51if { $core_loaded == -1 } { 52 # No use proceeding from here. 53 return 54} 55 56# First, switch to task 1. 57 58gdb_test "task 1" \ 59 "crash\\.request_for_crash \\(\\) at .*crash\\.adb:$decimal.*" 60 61 62gdb_test "info tasks" \ 63 [multi_line "\\s+ID\\s+TID\\s+P-ID\\s+Pri\\s+State\\s+Name" \ 64 "\\*\\s+1\\s+.*main_task" \ 65 "\\s+2.*my_t"] \ 66 "info tasks after switching to task 1" 67 68# Switch to task 2. Unlike in the case where we tested the switch to 69# task 1, don't check the location where the debugger says the program 70# is, as this might depend on the runtime, and in particular it might 71# depend on whether the runtime is built with debugging information 72# or not. Just check that we get the "switching to task" message, and 73# we will verify right after with an additional test that the current 74# task is now task 2. 75gdb_test "task 2" \ 76 "\\\[Switching to task 2 \"my_t\"\\\].*" 77 78gdb_test "info tasks" \ 79 [multi_line "\\s+ID\\s+TID\\s+P-ID\\s+Pri\\s+State\\s+Name" \ 80 "\\s+1\\s+.*main_task" \ 81 "\\*\\s+2.*my_t"] \ 82 "info tasks after switching to task 2" 83