Imported Upstream version 7.9
[platform/upstream/gdb.git] / gdb / testsuite / gdb.base / dmsym.exp
1 # Copyright (C) 2011-2015 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 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
24 set dmsym_o [standard_output_file dmsym.o]
25
26 if {[gdb_compile "${srcdir}/${subdir}/dmsym.c" \
27                  $dmsym_o \
28                  object {}] != ""} {
29   untested dmsym.exp
30   return -1
31 }
32
33 if {[gdb_compile \
34       [list ${srcdir}/${subdir}/dmsym_main.c $dmsym_o] \
35       [standard_output_file ${testfile}] \
36       executable {debug}] != ""} {
37     untested dmsym.exp
38     return -1
39 }
40
41 clean_restart ${testfile}
42
43 # Some convenient regular expressions...
44 set num "\[0-9\]+"
45 set addr "0x\[0-9a-zA-Z\]+"
46
47 # Although the test program is written in C, the original problem
48 # occurs only when the language is Ada. The use of a C program is
49 # only a convenience to be able to exercise the original problem
50 # without requiring an Ada compiler. In the meantime, temporarily
51 # force the language to Ada.
52
53 gdb_test_no_output "set lang ada"
54
55 # Verify that setting a breakpoint on `pck__foo__bar__minsym' only
56 # results in one location found (function pck__foo__bar__minsym__2).
57 # A mistake would be to also insert a breakpoint where
58 # pck__foo__bar__minsym is defined.  Despite the fact that there is
59 # no debugging info available, this is a data symbol and thus should
60 # not be used for breakpoint purposes.
61
62 gdb_test "break pck__foo__bar__minsym" \
63          "Breakpoint $num at $addr.: file .*dmsym_main\\.c, line $num\\."
64
65 # However, verify that the `info line' command, on the other hand,
66 # finds both locations.
67
68 gdb_test "info line pck__foo__bar__minsym" \
69          "Line $num of \".*dmsym_main\\.c\" .*\r\nNo line number information available for address $addr <pck__foo__bar__minsym>"
70
71 gdb_test_no_output "set lang auto"
72
73 # Now, run the program until we get past the call to
74 # pck__foo__bar__minsym__2. Except when using hardware breakpoints,
75 # inferior behavior is going to be affected if a breakpoint was
76 # incorrectly inserted at pck__foo__bar__minsym.
77
78 gdb_breakpoint dmsym_main.c:[gdb_get_line_number "BREAK" dmsym_main.c]
79
80 gdb_run_cmd
81 gdb_test "" \
82          "Breakpoint $num, pck__foo__bar__minsym__2 \\(\\) at.*" \
83          "Run until breakpoint at BREAK"
84
85 gdb_test "continue" \
86          "Breakpoint $num, main \\(\\) at.*"
87
88 gdb_test "print val" \
89          " = 124"