return -1
}
-set options {debug}
-
-get_compiler_info
-if { [test_compiler_info gcc*] } {
- lappend options "additional_flags=-g3"
-} elseif { [test_compiler_info clang*] } {
- lappend options "additional_flags=-fdebug-macro"
-} else {
- untested "no compiler info"
- return -1
-}
-
-if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $options] } {
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug macros}] } {
return -1
}
standard_testfile macscp1.c
set objfile [standard_output_file ${testfile}.o]
-set options { debug additional_flags=-DFROM_COMMANDLINE=ARG}
-
-get_compiler_info
-if { [test_compiler_info "gcc-*"] } {
- lappend options additional_flags=-g3
-} elseif { [test_compiler_info "clang-*"] } {
- lappend options additional_flags=-fdebug-macro
-}
+set options {debug macros additional_flags=-DFROM_COMMANDLINE=ARG}
# Generate the intermediate object file. This is required by Darwin to
# have access to the .debug_macinfo section.
if {[gdb_compile "${srcdir}/${subdir}/macscp1.c" "${objfile}" \
- object $options] != ""
+ object $options] != ""
|| [gdb_compile "${objfile}" "${binfile}" executable $options] != "" } {
untested "failed to compile"
return -1
standard_testfile
# Compile the test executable.
-set test_macros 0
-set options debug
-get_compiler_info
-if { [test_compiler_info "gcc-*"] } {
- lappend options additional_flags=-g3
- set test_macros 1
-} elseif { [test_compiler_info "clang-*"] } {
- lappend options additional_flags=-fdebug-macro
- set test_macros 1
-}
-
-if {[build_executable "failed to build" $testfile $srcfile $options]} {
+if {[build_executable "failed to build" $testfile $srcfile {debug macros}]} {
return -1
}
# CLEAN_RESTART_AND_DISABLE instead of CLEAN_RESTART, this ensures
# that the test operates as expected as styles are disabled.
proc run_style_tests { } {
- global testfile srcfile hex binfile test_macros
+ global testfile srcfile hex binfile
global currently_disabled_style decimal hex
save_vars { env(TERM) } {
gdb_test_no_output "set width 0" ""
}
- if {$test_macros} {
- set macro_line [gdb_get_line_number "\#define SOME_MACRO"]
- gdb_test "info macro SOME_MACRO" \
- "Defined at $base_file_expr:$macro_line\r\n#define SOME_MACRO 23"
- }
+ set macro_line [gdb_get_line_number "\#define SOME_MACRO"]
+ gdb_test "info macro SOME_MACRO" \
+ "Defined at $base_file_expr:$macro_line\r\n#define SOME_MACRO 23"
gdb_test_no_output "set width 0"
return 0
}
-set opts {debug additional_flags=-I.}
-
-get_compiler_info
-if [test_compiler_info gcc*] {
- lappend opts additional_flags=-g3
-} elseif [test_compiler_info clang*] {
- lappend opts additional_flags=-fdebug-macro
-}
+set opts {debug additional_flags=-I. macros}
if { [file pathtype $objdir] == "relative" } {
untested "objdir $objdir should be absolute"
# - nowarnings: Inhibit all compiler warnings.
# - pie: Force creation of PIE executables.
# - nopie: Prevent creation of PIE executables.
+# - macros: Add the required compiler flag to include macro information in
+# debug information
#
# And here are some of the not too obscure options understood by DejaGnu that
# influence the compilation:
lappend options "$flag"
}
+ set macros [lsearch -exact $options macros]
+ if {$macros != -1} {
+ if { [test_compiler_info "clang-*"] } {
+ set flag "additional_flags=-fdebug-macro"
+ } else {
+ set flag "additional_flags=-g3"
+ }
+
+ set options [lreplace $options $macros $macros $flag]
+ }
+
if { $type == "executable" } {
if { ([istarget "*-*-mingw*"]
|| [istarget "*-*-*djgpp"]