1 # Copyright 2010-2025 Free Software Foundation, Inc.
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.
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.
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/>.
18 # If we're using a stub, breakpoints at the entry point will not trigger.
19 # See also the comment in break-entry.exp.
23 # default_target_compile would otherwise add "-lm" making the testcase
24 # dependent on whether the system libraries are already prelinked.
25 # prelink: Could not set /lib64/libm-2.11.1.so owner or mode: Operation not permitted
27 gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $opts
30 foreach_with_prefix pie { "nopie" "pie" } {
31 # OPTS and BINFILE are used by the COMPILE string (defined above)
32 # when it is evaluated below.
33 set opts [list debug additional_flags=-nostdlib $pie]
34 set binfile [standard_output_file $testfile-$pie]
36 set board [target_info name]
37 if [board_info $board exists mathlib] {
38 set mathlib [board_info $dest mathlib]
39 set_board_info mathlib ""
40 set err [eval $compile]
41 set_board_info mathlib $mathlib
43 set_board_info mathlib ""
44 set err [eval $compile]
45 unset_board_info mathlib
48 untested "failed to compile"
52 clean_restart $binfile
54 gdb_breakpoint "*marker"
56 # Say we set a permanent breakpoint on *_start. When setting the
57 # breakpoint, it will resolve to _start in the exec.
58 # After starting to run, that may stay the same, and consequently
59 # execution will stop there.
60 # OTOH, after starting to run, that may change to *_start in the dynamic
61 # linker, and consequently execution will stop there.
62 # There's currently no way to enforce one or the other (PR32748).
64 # Say we run into a stop in *_start in the dynamic linker. Continuing
65 # from this situation, the dynamic linker is reported as unloaded, which
66 # makes the breakpoint resolve again to *_start in the exec, and
67 # consequently execution will stop there as well.
69 # However, we cannot rely on this behavior either. Reporting the dynamic
70 # linker as unloaded is a GLIBC bug, which may get fixed eventually.
72 # Instead of trying to cater for all these possibilities in a controlled
73 # fashion, make the breakpoint temporary, ensuring that there will just be
75 gdb_breakpoint "*_start" temporary
79 # Breakpoint 2, Stopped due to shared library event
80 # _start () at ./gdb.base/nostdlib.c:20
81 gdb_test "" {Temporary breakpoint [0-9]+, .*_start .*} "stop at run"
83 gdb_test "continue" {Breakpoint [0-9]+, marker .*} "continue to marker"
85 # When compiling as PIE the executable will be a dynamic
86 # executable, the dynamic linker performs the PIE relocation.
87 # Some versions of glibc would (possibly due to a bug) report the
88 # dynamic linker as unmapped during startup, which places the
89 # 'shlib event' breakpoint(s) into the PENDING state.
91 # At one point trying to print these internal breakpoints in a
92 # PENDING state would crash GDB, so lets make sure that doesn't
93 # happen now. We don't really care about the exact output,
94 # gdb_test will spot if running this command crashes GDB, which is
95 # all we're really checking for.
96 gdb_test "maint info breakpoints" ".*"