public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/3] gdb/testsuite: fix gdb.base/info-macros.exp with clang
Date: Tue,  3 Aug 2021 11:31:14 -0400	[thread overview]
Message-ID: <20210803153114.2516992-3-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20210803153114.2516992-1-simon.marchi@polymtl.ca>

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 538279fd309a..f1d912a75cfa 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.32.0


  parent reply	other threads:[~2021-08-03 15:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-29 18:42 [PATCH] gdbsupport: add debug assertions in gdb::optional::get Simon Marchi
2021-08-02 17:19 ` Tom Tromey
2021-08-03 12:56   ` Simon Marchi
2021-08-03 13:14     ` Simon Marchi
2021-08-03 15:31       ` [PATCH 1/3] gdb: fix typo in complaint in dwarf2/macro.c Simon Marchi
2021-08-03 15:31         ` [PATCH 2/3] gdb: avoid dereferencing empty str_offsets_base optional in dwarf_decode_macros Simon Marchi
2021-08-04 16:03           ` Tom Tromey
2021-08-03 15:31         ` Simon Marchi [this message]
2021-08-04 16:15           ` [PATCH 3/3] gdb/testsuite: fix gdb.base/info-macros.exp with clang Tom Tromey
2021-08-04 19:39             ` Simon Marchi
2021-08-04 15:52         ` [PATCH 1/3] gdb: fix typo in complaint in dwarf2/macro.c Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210803153114.2516992-3-simon.marchi@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).