]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.opt/break-on-_exit.exp
Automatic Copyright Year update after running gdb/copyright.py
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.opt / break-on-_exit.exp
1 # Copyright 2021-2022 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 excercise 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 { [lsearch -exact $GDBFLAGS -readnow] != -1 \
40 || [lsearch -exact $GDBFLAGS --readnow] != -1 } {
41 untested "--readnever not allowed in combination with --readnow"
42 return -1
43 }
44
45 save_vars { GDBFLAGS } {
46 append GDBFLAGS " -readnever"
47
48 if {[prepare_for_testing "failed to prepare" $testfile $srcfile nodebug]} {
49 return -1
50 }
51 }
52
53 if ![runto_main] then {
54 return 0
55 }
56
57 gdb_breakpoint "_exit"
58
59 # Give some background information about the breakpoint(s) and corresponding
60 # the shared lib(s).
61 gdb_test "info breakpoints"
62 gdb_test "info shared"
63
64 # If the skip_prologue analysis of _exit is too eager, we may not hit the
65 # breakpoint.
66 gdb_continue_to_breakpoint "_exit" "_exit \\(\\) .*"