[gdb/syscalls] Sync with strace v6.13
[binutils-gdb.git] / gdb / testsuite / gdb.base / dmsym.exp
bloba80684500dfa3c6d30e760fac1f31969f27a08b5
1 # Copyright (C) 2011-2024 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/>.
16 set testfile dmsym_main
18 # Build dmsym_main using two C files:
19 #   - dmsym.c, which needs to be built without debug info;
20 #   - dmsym_main.c, which needs to be build with debug info.
21 # This is why we use gdb_compile instead of relying on the usual
22 # call to prepare_for_testing.
24 set dmsym_o [standard_output_file dmsym.o]
26 if {[gdb_compile "${srcdir}/${subdir}/dmsym.c" \
27                  $dmsym_o \
28                  object {}] != ""} {
29   untested "failed to compile object file"
30   return -1
33 if {[gdb_compile \
34       [list ${srcdir}/${subdir}/dmsym_main.c $dmsym_o] \
35       [standard_output_file ${testfile}] \
36       executable {debug}] != ""} {
37     untested "failed to compile"
38     return -1
41 clean_restart ${testfile}
43 # Some convenient regular expressions...
44 set num "\[0-9\]+"
45 set addr "0x\[0-9a-zA-Z\]+"
47 # Verify that setting a breakpoint on `test_minsym' only results in
48 # one location found.  A mistake would be to also insert a breakpoint
49 # in the test_minsym data symbol in dmsym.c.  Despite the fact that
50 # there is no debugging info available, this is a data symbol and thus
51 # should not be used for breakpoint purposes.
53 gdb_test "break test_minsym" \
54          "Breakpoint $num at $addr.: file .*dmsym_main\\.c, line $num\\."
56 # However, verify that the `info line' command, on the other hand,
57 # finds both locations.
59 gdb_test "info line test_minsym" \
60          "Line $num of \".*dmsym_main\\.c\" .*\r\nNo line number information available for address $addr <test_minsym>"
62 # Now, run the program until we get past the call to test_minsym.
63 # Except when using hardware breakpoints, inferior behavior is going
64 # to be affected if a breakpoint was incorrectly inserted at
65 # test_minsym.
67 gdb_breakpoint dmsym_main.c:[gdb_get_line_number "BREAK" dmsym_main.c]
69 gdb_run_cmd
70 gdb_test "" \
71          "Breakpoint $num, test_minsym \\(\\) at.*" \
72          "run until breakpoint at BREAK"
74 gdb_test "continue" \
75          "Breakpoint $num, main \\(\\) at.*"
77 gdb_test "print val" \
78          " = 124"