Files
binutils-gdb/gdb/testsuite/gdb.compile/compile-cplus-inherit.exp
Guinevere Larsen c4375bc51c gdb: add configure option to disable compile
GDB's compile subsystem is deeply tied to GDB's ability to understand
DWARF. A future patch will add the option to disable DWARF at configure
time, but for that to work, the compile subsystem will need to be
entirely disabled as well, so this patch adds that possibility.

I also think there is motive for a security conscious user to disable
compile for it's own sake. Considering that the code is quite
unmaintained, and depends on an equally unmaintained gcc plugin, there
is a case to be made that this is an unnecessary increase in the attack
surface if a user knows they won't use the subsystem. Additionally, this
can make compilation slightly faster and the final binary is around 3Mb
smaller. But these are all secondary to the main goal of being able to
disable dwarf at configure time.

To be able to achieve optional compilation, some of the code that
interfaces with compile had to be changed. All parts that directly
called compile things have been wrapped by ifdefs checking for compile
support.  The file compile/compile.c has been setup in a similar way to
how python's and guile's main file has been setup, still being compiled
but only for with placeholder command.

Finally, to avoid several new errors, a new TCL proc was introduced to
gdb.exp, allow_compile_tests, which checks if the "compile" command is
recognized before the inferior is started and otherwise skips the compile
tests. All tests in the gdb.compile subfolder have been updated to use
that, and the test gdb.base/filename-completion also uses this. The proc
skip_compile_feature_tests to recognize when the subsystem has been
disabled at compile time.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
2025-03-26 11:15:59 -03:00

52 lines
1.4 KiB
Plaintext

# Copyright 2015-2024 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/>.
# Inheritance tests for GDB's C++ compile feature.
load_lib compile-support.exp
standard_testfile .cc
require allow_cplus_tests
require is_c_compiler_gcc
require allow_compile_tests
if {[prepare_for_testing $testfile $testfile $srcfile \
{debug nowarnings c++}]} {
return -1
}
if {![runto_main]} {
return -1
}
gdb_breakpoint [gdb_get_line_number "break here" $srcfile]
gdb_continue_to_breakpoint "testing location"
if {[skip_compile_feature_untested "var = 0"]} {
return -1
}
CompileExpression::new "var"
CompileExpression::test "d.a_" 1
CompileExpression::test "d.b_" 2
CompileExpression::test "d.c_" 3
CompileExpression::test "d.d_" 4
CompileExpression::test "d.A::do_it (1)" 2
CompileExpression::test "d.B::do_it (1)" 1
CompileExpression::test "d.C::do_it (1)" 3