1 1.1.1.2 christos # Copyright 2021-2024 Free Software Foundation, Inc. 2 1.1 christos 3 1.1 christos # This program is free software; you can redistribute it and/or modify 4 1.1 christos # it under the terms of the GNU General Public License as published by 5 1.1 christos # the Free Software Foundation; either version 3 of the License, or 6 1.1 christos # (at your option) any later version. 7 1.1 christos # 8 1.1 christos # This program is distributed in the hope that it will be useful, 9 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 1.1 christos # GNU General Public License for more details. 12 1.1 christos # 13 1.1 christos # You should have received a copy of the GNU General Public License 14 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 1.1 christos 16 1.1 christos # Set a breakpoint on libc's _exit, and verify that it triggers. The function 17 1.1 christos # tends to do a syscall immediately after the prologue, and if the breakpoint is 18 1.1 christos # set past the syscall due to faulty prologue skipping, the breakpoint will not 19 1.1 christos # trigger. 20 1.1 christos # 21 1.1.1.3 christos # In particular, we're trying to exercise the instruction analysis 22 1.1 christos # functionality of prologue skipping. If the non-minimal symbols are 23 1.1 christos # read for libc, then that functionality might not be used because f.i. 24 1.1 christos # line-info is used instead. Also, if the minimal symbols are not read 25 1.1 christos # for libc, then the breakpoint is set on the exec-local _exit@plt instead, 26 1.1 christos # and that functionality will also not be used. 27 1.1 christos # 28 1.1 christos # We may get the required setup in case of a libc with misssing separate 29 1.1 christos # debuginfo, but we want the same effect if that debuginfo is installed. 30 1.1 christos # 31 1.1 christos # So, we use -readnever to read minimal symbols, but not non-miminal symbols. 32 1.1 christos # 33 1.1 christos # Because the code at _exit may be and usually is optimized, the test is in 34 1.1 christos # the gdb.opt directory. 35 1.1 christos 36 1.1 christos standard_testfile 37 1.1 christos 38 1.1 christos # See if we have target board readnow.exp or similar. 39 1.1 christos if {[readnow]} { 40 1.1 christos untested "--readnever not allowed in combination with --readnow" 41 1.1 christos return -1 42 1.1 christos } 43 1.1 christos 44 1.1 christos save_vars { GDBFLAGS } { 45 1.1 christos append GDBFLAGS " -readnever" 46 1.1 christos 47 1.1 christos if {[prepare_for_testing "failed to prepare" $testfile $srcfile nodebug]} { 48 1.1 christos return -1 49 1.1 christos } 50 1.1 christos } 51 1.1 christos 52 1.1 christos if {![runto_main]} { 53 1.1 christos return 0 54 1.1 christos } 55 1.1 christos 56 1.1 christos gdb_breakpoint "_exit" 57 1.1 christos 58 1.1 christos # Give some background information about the breakpoint(s) and corresponding 59 1.1 christos # the shared lib(s). 60 1.1 christos gdb_test "info breakpoints" 61 1.1 christos gdb_test "info shared" 62 1.1 christos 63 1.1 christos # If the skip_prologue analysis of _exit is too eager, we may not hit the 64 1.1 christos # breakpoint. 65 1.1 christos gdb_continue_to_breakpoint "_exit" "_exit \\(\\) .*" 66