summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/dmsym.exp
blob: 7472d1b615b64d53e110f72cb5c19fe4f53b15f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Copyright (C) 2011-2012 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

set testfile dmsym_main

# Build dmsym_main using two C files:
#   - dmsym.c, which needs to be built without debug info;
#   - dmsym_main.c, which needs to be build with debug info.
# This is why we use gdb_compile instead of relying on the usual
# call to prepare_for_testing.

if {[gdb_compile "${srcdir}/${subdir}/dmsym.c" \
                 ${objdir}/${subdir}/dmsym.o \
                 object {}] != ""} {
  untested dmsym.exp
  return -1
}

if {[gdb_compile \
      [list ${srcdir}/${subdir}/dmsym_main.c ${objdir}/${subdir}/dmsym.o] \
      ${objdir}/${subdir}/${testfile} \
      executable {debug}] != ""} {
    untested dmsym.exp
    return -1
}

clean_restart ${testfile}

# Some convenient regular expressions...
set num "\[0-9\]+"
set addr "0x\[0-9a-zA-Z\]+"

# Although the test program is written in C, the original problem
# occurs only when the language is Ada. The use of a C program is
# only a convenience to be able to exercise the original problem
# without requiring an Ada compiler. In the meantime, temporarily
# force the language to Ada.

gdb_test_no_output "set lang ada"

# Verify that setting a breakpoint on `pck__foo__bar__minsym' only
# results in one location found (function pck__foo__bar__minsym__2).
# A mistake would be to also insert a breakpoint where
# pck__foo__bar__minsym is defined.  Despite the fact that there is
# no debugging info available, this is a data symbol and thus should
# not be used for breakpoint purposes.

gdb_test "break pck__foo__bar__minsym" \
         "Breakpoint $num at $addr.: file .*dmsym_main\\.c, line $num\\."

# However, verify that the `info line' command, on the other hand,
# finds both locations.

gdb_test "info line pck__foo__bar__minsym" \
         "Line $num of \".*dmsym_main\\.c\" .*\r\nNo line number information available for address $addr <pck__foo__bar__minsym>"

gdb_test_no_output "set lang auto"

# Now, run the program until we get past the call to
# pck__foo__bar__minsym__2. Except when using hardware breakpoints,
# inferior behavior is going to be affected if a breakpoint was
# incorrectly inserted at pck__foo__bar__minsym.

gdb_breakpoint dmsym_main.c:[gdb_get_line_number "BREAK" dmsym_main.c]

gdb_run_cmd
gdb_test "" \
         "Breakpoint $num, pck__foo__bar__minsym__2 \\(\\) at.*" \
         "Run until breakpoint at BREAK"

gdb_test "continue" \
         "Breakpoint $num, main \\(\\) at.*"

gdb_test "print val" \
         " = 124"