[PATCH 2/2] debug: Allow means for targets to opt out of CTF/BTF support

Indu Bhagat indu.bhagat@oracle.com
Sat Jul 17 14:44:18 GMT 2021


CTF/BTF debug formats can be safely enabled for all ELF-based targets by
default in GCC.

CTF/BTF debug formats now adopt a similar approach as taken for DWARF debug
format via the DWARF2_DEBUGGING_INFO.
  - By default, CTF/BTF formats can be enabled for all ELF-based targets.
  - By default, CTF/BTF formats can be disabled for all non ELF-based targets.
  - If the user passed a -gctf but CTF is not enabled for the target, GCC
  issues an error to the user (as is done currently with other debug formats) -
  "target system does not support the 'ctf' debug format". Analogous behavior
  for -gbtf command line option.

A previous commit disabled the CTF and BTF testcases on the AIX platform. This
is not necessary now that CTF and BTF debug formats are disabled by default on
all non-ELF targets. GCC emits an error message when -gctf/-gbtf is used on
such platforms and these tests will be skipped.

gcc/Changelog:

	* config/elfos.h (CTF_DEBUGGING_INFO): New definition.
	(BTF_DEBUGGING_INFO): Likewise.
	* doc/tm.texi.in: Document the new macros.
	* doc/tm.texi: Regenerated.
	* toplev.c: Guard initialization of debug hooks.

gcc/testsuite/Changelog:

	* gcc.dg/debug/btf/btf.exp: Do not run BTF testsuite if target does not
	support BTF format. Remove redundant check for AIX.
	* gcc.dg/debug/ctf/ctf.exp: Do not run CTF testsuite if target does not
	support CTF format. Remove redundant check for AIX.
	* lib/gcc-dg.exp: Remove redundant check for AIX.
---
 gcc/config/elfos.h                     |  8 ++++++++
 gcc/doc/tm.texi                        | 26 ++++++++++++++++++++++++++
 gcc/doc/tm.texi.in                     | 26 ++++++++++++++++++++++++++
 gcc/testsuite/gcc.dg/debug/btf/btf.exp | 16 +++++++++-------
 gcc/testsuite/gcc.dg/debug/ctf/ctf.exp | 16 +++++++++-------
 gcc/testsuite/lib/gcc-dg.exp           |  1 -
 gcc/toplev.c                           | 11 +++++++++--
 7 files changed, 87 insertions(+), 17 deletions(-)

diff --git a/gcc/config/elfos.h b/gcc/config/elfos.h
index 7a736cc..e5cb487 100644
--- a/gcc/config/elfos.h
+++ b/gcc/config/elfos.h
@@ -68,6 +68,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #define DWARF2_DEBUGGING_INFO 1
 
+/* All ELF targets can support CTF.  */
+
+#define CTF_DEBUGGING_INFO 1
+
+/* All ELF targets can support BTF.  */
+
+#define BTF_DEBUGGING_INFO 1
+
 /* The GNU tools operate better with dwarf2, and it is required by some
    psABI's.  Since we don't have any native tools to be compatible with,
    default to dwarf2.  */
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 3ad3944..c8f4abe 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -9947,6 +9947,8 @@ This describes how to specify debugging information.
 * File Names and DBX:: Macros controlling output of file names in DBX format.
 * DWARF::              Macros for DWARF format.
 * VMS Debug::          Macros for VMS debug format.
+* CTF Debug::          Macros for CTF debug format.
+* BTF Debug::          Macros for BTF debug format.
 @end menu
 
 @node All Debuggers
@@ -10374,6 +10376,30 @@ behavior is controlled by @code{TARGET_OPTION_OPTIMIZATION} and
 @code{TARGET_OPTION_OVERRIDE}.
 @end defmac
 
+@need 2000
+@node CTF Debug
+@subsection Macros for CTF Debug Format
+
+@c prevent bad page break with this line
+Here are macros for CTF debug format.
+
+@defmac CTF_DEBUGGING_INFO
+Define this macro if GCC should produce debugging output in CTF debug
+format in response to the @option{-gctf} option.
+@end defmac
+
+@need 2000
+@node BTF Debug
+@subsection Macros for BTF Debug Format
+
+@c prevent bad page break with this line
+Here are macros for BTF debug format.
+
+@defmac BTF_DEBUGGING_INFO
+Define this macro if GCC should produce debugging output in BTF debug
+format in response to the @option{-gbtf} option.
+@end defmac
+
 @node Floating Point
 @section Cross Compilation and Floating Point
 @cindex cross compilation and floating point
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index f881cda..9c4b501 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -6613,6 +6613,8 @@ This describes how to specify debugging information.
 * File Names and DBX:: Macros controlling output of file names in DBX format.
 * DWARF::              Macros for DWARF format.
 * VMS Debug::          Macros for VMS debug format.
+* CTF Debug::          Macros for CTF debug format.
+* BTF Debug::          Macros for BTF debug format.
 @end menu
 
 @node All Debuggers
@@ -6994,6 +6996,30 @@ behavior is controlled by @code{TARGET_OPTION_OPTIMIZATION} and
 @code{TARGET_OPTION_OVERRIDE}.
 @end defmac
 
+@need 2000
+@node CTF Debug
+@subsection Macros for CTF Debug Format
+
+@c prevent bad page break with this line
+Here are macros for CTF debug format.
+
+@defmac CTF_DEBUGGING_INFO
+Define this macro if GCC should produce debugging output in CTF debug
+format in response to the @option{-gctf} option.
+@end defmac
+
+@need 2000
+@node BTF Debug
+@subsection Macros for BTF Debug Format
+
+@c prevent bad page break with this line
+Here are macros for BTF debug format.
+
+@defmac BTF_DEBUGGING_INFO
+Define this macro if GCC should produce debugging output in BTF debug
+format in response to the @option{-gbtf} option.
+@end defmac
+
 @node Floating Point
 @section Cross Compilation and Floating Point
 @cindex cross compilation and floating point
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf.exp b/gcc/testsuite/gcc.dg/debug/btf/btf.exp
index e173515..15593fd 100644
--- a/gcc/testsuite/gcc.dg/debug/btf/btf.exp
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf.exp
@@ -24,11 +24,6 @@ if { [istarget nvptx-*-*] } {
     return
 }
 
-if { [istarget "powerpc-ibm-aix*"] } {
-    set torture_execute_xfail "powerpc-ibm-aix*"
-    return
-}
-
 # If a testcase doesn't have special options, use these.
 global DEFAULT_CFLAGS
 if ![info exists DEFAULT_CFLAGS] then {
@@ -39,8 +34,15 @@ if ![info exists DEFAULT_CFLAGS] then {
 dg-init
 
 # Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\] ]] \
-	"" $DEFAULT_CFLAGS
+set comp_output [gcc_target_compile \
+    "$srcdir/$subdir/../trivial.c" "trivial.S" assembly \
+    "additional_flags=-gbtf"]
+if { ! [string match "*: target system does not support the * debug format*" \
+    $comp_output] } {
+    remove-build-file "trivial.S"
+    dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\] ]] \
+	    "" $DEFAULT_CFLAGS
+}
 
 # All done.
 dg-finish
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf.exp b/gcc/testsuite/gcc.dg/debug/ctf/ctf.exp
index 0b650ed..7ad6723 100644
--- a/gcc/testsuite/gcc.dg/debug/ctf/ctf.exp
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf.exp
@@ -24,11 +24,6 @@ if { [istarget nvptx-*-*] } {
     return
 }
 
-if { [istarget "powerpc-ibm-aix*"] } {
-    set torture_execute_xfail "powerpc-ibm-aix*"
-    return
-}
-
 # If a testcase doesn't have special options, use these.
 global DEFAULT_CFLAGS
 if ![info exists DEFAULT_CFLAGS] then {
@@ -39,8 +34,15 @@ if ![info exists DEFAULT_CFLAGS] then {
 dg-init
 
 # Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\] ]] \
-	"" $DEFAULT_CFLAGS
+set comp_output [gcc_target_compile \
+    "$srcdir/$subdir/../trivial.c" "trivial.S" assembly \
+    "additional_flags=-gctf"]
+if { ! [string match "*: target system does not support the * debug format*" \
+    $comp_output] } {
+    remove-build-file "trivial.S"
+    dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\] ]] \
+	    "" $DEFAULT_CFLAGS
+}
 
 # All done.
 dg-finish
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 81f4bb2..7edd070 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -641,7 +641,6 @@ proc gcc-dg-frontend-supports-ctf { target_compile trivial } {
 proc gcc-dg-target-supports-debug-format { target_compile trivial type } {
     global srcdir subdir
 
-    if {$type == "-gctf" && [istarget *-*-aix*]} { return 0 }
     set comp_output [$target_compile \
 	    "$srcdir/$subdir/$trivial" "trivial.S" assembly \
 	    "additional_flags=$type"]
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 43f1f7d..14d1335 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1463,8 +1463,15 @@ process_options (void)
     debug_hooks = &xcoff_debug_hooks;
 #endif
 #ifdef DWARF2_DEBUGGING_INFO
-  else if (dwarf_debuginfo_p ()
-	   || dwarf_based_debuginfo_p ())
+  else if (dwarf_debuginfo_p ())
+    debug_hooks = &dwarf2_debug_hooks;
+#endif
+#ifdef CTF_DEBUGGING_INFO
+  else if (ctf_debuginfo_p ())
+    debug_hooks = &dwarf2_debug_hooks;
+#endif
+#ifdef BTF_DEBUGGING_INFO
+  else if (btf_debuginfo_p ())
     debug_hooks = &dwarf2_debug_hooks;
 #endif
 #ifdef VMS_DEBUGGING_INFO
-- 
1.8.3.1



More information about the Gcc-patches mailing list