The test gdb.base/info-macros.exp says that it doesn't pass the "debug"
option to prepare_for_testing because that would cause -g to appear
after -g3 on the command line, and that would cause some gcc versions to
not include macro info. I don't know what gcc versions this refers to.
I tested with gcc 4.8, and that works fine with -g after -g3.
The current state is problematic when testing with CC_FOR_TARGET=clang,
because then only -fdebug-macro is included. No -g switch if included,
meaning we get a binary without any debug info, and the test fails.
One way to fix it would be to add "debug" to the options when the
compiler is clang.
However, the solution I chose was to specify "debug" in any case, even
for gcc. Other macro tests such as gdb.base/macscp.exp do perfectly
fine with it. Also, this lets the test use the debug flag specified by
the board file. For example, we can test with GCC and DWARF 5, with:
$ make check RUNTESTFLAGS="--target_board unix/gdb:debug_flags=-gdwarf-5" TESTS="gdb.base/info-macros.exp"
With the hard-coded -g3, this wouldn't actually test with DWARF 5.
Change-Id: I33fa92ee545007d3ae9c52c4bb2d5be6b5b698f1
return -1
}
+set options {debug}
+
get_compiler_info
if { [test_compiler_info gcc*] } {
- # Don't use "debug" here. Otherwise "-g" would be appended to the gcc
- # command line, possibly overriding "-g3" (depending on gcc version).
- set options "additional_flags=-g3"
+ lappend options "additional_flags=-g3"
} elseif { [test_compiler_info clang*] } {
- set options "additional_flags=-fdebug-macro"
+ lappend options "additional_flags=-fdebug-macro"
} else {
untested "no compiler info"
return -1