From 06b80590fbe63875e8e7a6c97622675b8ac099bc Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 3 Aug 2021 11:31:14 -0400 Subject: [PATCH] gdb/testsuite: fix gdb.base/info-macros.exp with clang 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 --- gdb/testsuite/gdb.base/info-macros.exp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gdb/testsuite/gdb.base/info-macros.exp b/gdb/testsuite/gdb.base/info-macros.exp index 538279fd309..f1d912a75cf 100644 --- a/gdb/testsuite/gdb.base/info-macros.exp +++ b/gdb/testsuite/gdb.base/info-macros.exp @@ -21,13 +21,13 @@ if [using_fission] { 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 -- 2.30.2