Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / dmsym.exp
CommitLineData
88b9d363 1# Copyright (C) 2011-2022 Free Software Foundation, Inc.
095bcf5e
JB
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
16set testfile dmsym_main
17
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.
23
f76495c8
TT
24set dmsym_o [standard_output_file dmsym.o]
25
095bcf5e 26if {[gdb_compile "${srcdir}/${subdir}/dmsym.c" \
f76495c8 27 $dmsym_o \
095bcf5e 28 object {}] != ""} {
84c93cd5 29 untested "failed to compile object file"
095bcf5e
JB
30 return -1
31}
32
33if {[gdb_compile \
f76495c8
TT
34 [list ${srcdir}/${subdir}/dmsym_main.c $dmsym_o] \
35 [standard_output_file ${testfile}] \
095bcf5e 36 executable {debug}] != ""} {
84c93cd5 37 untested "failed to compile"
095bcf5e
JB
38 return -1
39}
40
41clean_restart ${testfile}
42
43# Some convenient regular expressions...
44set num "\[0-9\]+"
45set addr "0x\[0-9a-zA-Z\]+"
46
62d2a18a
PA
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.
52
53gdb_test "break test_minsym" \
095bcf5e
JB
54 "Breakpoint $num at $addr.: file .*dmsym_main\\.c, line $num\\."
55
56# However, verify that the `info line' command, on the other hand,
57# finds both locations.
58
62d2a18a
PA
59gdb_test "info line test_minsym" \
60 "Line $num of \".*dmsym_main\\.c\" .*\r\nNo line number information available for address $addr <test_minsym>"
095bcf5e 61
62d2a18a
PA
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.
095bcf5e
JB
66
67gdb_breakpoint dmsym_main.c:[gdb_get_line_number "BREAK" dmsym_main.c]
68
69gdb_run_cmd
70gdb_test "" \
62d2a18a 71 "Breakpoint $num, test_minsym \\(\\) at.*" \
bb95117e 72 "run until breakpoint at BREAK"
095bcf5e
JB
73
74gdb_test "continue" \
75 "Breakpoint $num, main \\(\\) at.*"
76
77gdb_test "print val" \
78 " = 124"
This page took 1.193549 seconds and 4 git commands to generate.