1# Copyright (C) 2011-2020 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 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 24set dmsym_o [standard_output_file dmsym.o] 25 26if {[gdb_compile "${srcdir}/${subdir}/dmsym.c" \ 27 $dmsym_o \ 28 object {}] != ""} { 29 untested "failed to compile object file" 30 return -1 31} 32 33if {[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 39} 40 41clean_restart ${testfile} 42 43# Some convenient regular expressions... 44set num "\[0-9\]+" 45set addr "0x\[0-9a-zA-Z\]+" 46 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" \ 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 59gdb_test "info line test_minsym" \ 60 "Line $num of \".*dmsym_main\\.c\" .*\r\nNo line number information available for address $addr <test_minsym>" 61 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. 66 67gdb_breakpoint dmsym_main.c:[gdb_get_line_number "BREAK" dmsym_main.c] 68 69gdb_run_cmd 70gdb_test "" \ 71 "Breakpoint $num, test_minsym \\(\\) at.*" \ 72 "run until breakpoint at BREAK" 73 74gdb_test "continue" \ 75 "Breakpoint $num, main \\(\\) at.*" 76 77gdb_test "print val" \ 78 " = 124" 79