1 # Copyright 2021-2024 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 16 # Set a breakpoint on libc's _exit, and verify that it triggers. The function 17 # tends to do a syscall immediately after the prologue, and if the breakpoint is 18 # set past the syscall due to faulty prologue skipping, the breakpoint will not 19 # trigger. 20 # 21 # In particular, we're trying to exercise the instruction analysis 22 # functionality of prologue skipping. If the non-minimal symbols are 23 # read for libc, then that functionality might not be used because f.i. 24 # line-info is used instead. Also, if the minimal symbols are not read 25 # for libc, then the breakpoint is set on the exec-local _exit@plt instead, 26 # and that functionality will also not be used. 27 # 28 # We may get the required setup in case of a libc with misssing separate 29 # debuginfo, but we want the same effect if that debuginfo is installed. 30 # 31 # So, we use -readnever to read minimal symbols, but not non-miminal symbols. 32 # 33 # Because the code at _exit may be and usually is optimized, the test is in 34 # the gdb.opt directory. 35 36 standard_testfile 37 38 # See if we have target board readnow.exp or similar. 39 if {[readnow]} { 40 untested "--readnever not allowed in combination with --readnow" 41 return -1 42 } 43 44 save_vars { GDBFLAGS } { 45 append GDBFLAGS " -readnever" 46 47 if {[prepare_for_testing "failed to prepare" $testfile $srcfile nodebug]} { 48 return -1 49 } 50 } 51 52 if {![runto_main]} { 53 return 0 54 } 55 56 gdb_breakpoint "_exit" 57 58 # Give some background information about the breakpoint(s) and corresponding 59 # the shared lib(s). 60 gdb_test "info breakpoints" 61 gdb_test "info shared" 62 63 # If the skip_prologue analysis of _exit is too eager, we may not hit the 64 # breakpoint. 65 gdb_continue_to_breakpoint "_exit" "_exit \\(\\) .*" 66