2016-01-01 04:33:14 +00:00
|
|
|
# Copyright 2010-2016 Free Software Foundation, Inc.
|
2010-05-17 17:23:33 +00:00
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
|
|
|
|
load_lib "ada.exp"
|
|
|
|
|
2012-07-26 18:43:02 +00:00
|
|
|
standard_ada_testfile a
|
|
|
|
|
2010-05-17 17:23:33 +00:00
|
|
|
set cfile "${testdir}/foo"
|
|
|
|
set csrcfile ${srcdir}/${subdir}/${cfile}.c
|
2012-07-26 18:43:02 +00:00
|
|
|
set cobject [standard_output_file ${cfile}.o]
|
2010-05-17 17:23:33 +00:00
|
|
|
|
|
|
|
gdb_compile "${csrcfile}" "${cobject}" object [list debug]
|
2012-07-26 18:43:02 +00:00
|
|
|
if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } {
|
2010-05-17 17:23:33 +00:00
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
clean_restart ${testfile}
|
|
|
|
|
|
|
|
# Run to c_function an verify that the language automatically gets set to C.
|
|
|
|
runto c_function
|
|
|
|
gdb_test "show lang" \
|
|
|
|
"The current source language is \"auto; currently c\"\\."
|
|
|
|
|
|
|
|
# Now, insert a breakpoint inside an Ada unit, using a condition written
|
|
|
|
# in Ada. Even though the current language is "auto; currently c", we
|
|
|
|
# expect the debugger to parse the expression using Ada, because the
|
|
|
|
# current language mode is auto, and the breakpoint is inside Ada code.
|
|
|
|
set bp_location [gdb_get_line_number "STOP" ${testdir}/mixed.adb]
|
|
|
|
gdb_test "break mixed.adb:${bp_location} if light = green" \
|
[testsuite/Ada] stop using project files when building test programs
The current approach when building Ada programs for testing is
based on the use of a project file (testsuite/gdb.ada/gnat_ada.gpr).
To do that, we pass a number of additional arguments to target_compile,
one of them being the project file (via "-P/path/to/gnat_ada.gpr").
This used to work well-enough, but AdaCore is currently working towards
removing project-file support from gnatmake (the prefered tool for
using project files is gprbuild). So, we need to either switch
the compilation to gprbuild, or stop using project files.
First, using gprbuild is not always what users will be using to
build their applications. So having the option of using gnatmake
provides more flexibility towards exactly reproducing past bugs.
If we ever need a testcase that requires the use of gprbuild, then
I believe support for a new target needs to be added to dejagnu's
target_compile.
Also, the only real reason behind using a project file in the first
place is that we wanted to make it easy to specify the directory
where all compilation artifacts get stored. This is a consequence
of the organization choice we made for gdb.ada to keep each testcase
well organized. It is very easy to achieve that goal without using
project files.
This is therefore what this patch does: It change gdb_compile_ada
to build any program using gnatmake without using a project file
(by temporarily changing the current working directory).
There is a small (beneficial) side-effect; in the situation where
GDB is built in-tree, gnatmake is called as...
% gnatmake [...] unit.adb
... which means that the debugging info in unit.o will say contain
a filename whose name is 'unit.adb', rather than '/path/to/unit.adb'.
This also better matches what users might typically do. But the side-
effect is that the unit name in the GDB output is not always a full
path. This patch tweaks a couple of testcases to make the path part
optional.
gdb/testsuite:
* lib/ada.exp (target_compile_ada_from_dir): New function.
(gdb_compile_ada): Reimplement avoiding the use of project files.
* gdb.ada/gnat_ada.gpr: Delete.
* gdb.ada/cond_lang.exp: Adjust test to make path before
filename optional.
* gdb.ada/small_reg_param.exp: Likewise.
Tested on x86_64-linux, with both in-tree and out-of-tree builds.
2015-12-22 09:28:41 +00:00
|
|
|
"Breakpoint \[0-9\]* at .*: file (.*/)?mixed.adb, line \[0-9\]*\\."
|
2010-05-17 17:23:33 +00:00
|
|
|
|
|
|
|
# Now, continue until we hit the breakpoint. If the condition is
|
|
|
|
# evaluated correctly, the first hit will be ignored, and the debugger
|
|
|
|
# will stop at the second hit only, when the "light" argument is equal
|
|
|
|
# to green.
|
|
|
|
gdb_test "continue" \
|
|
|
|
"Breakpoint \[0-9\]*, mixed\\.break_me \\(light=green\\) at .*"
|
|
|
|
|
|
|
|
|