[2/6] opts: allow any combination of DWARF, CTF, BTF

Message ID 20240501191506.4579-3-david.faust@oracle.com
State New
Headers
Series btf: refactor and add pruning option |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm success Testing passed

Commit Message

David Faust May 1, 2024, 7:15 p.m. UTC
  Previously it was not supported to generate both CTF and BTF debug info
in the same compiler run, as both formats made incompatible changes to
the same internal data structures.

With the structural change in the prior patch, in particular the
guarantee that CTF will always be fully emitted before any BTF
translation occurs, there is no longer anything preventing generation
of both CTF and BTF at the same time.  This patch changes option parsing
to allow any combination of -gdwarf, -gctf, and -gbtf at the same time.

gcc/
	* opts.cc (set_debug_level): Allow any combination of -gdwarf,
	-gctf and -gbtf at the same time.
---
 gcc/opts.cc | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)
  

Patch

diff --git a/gcc/opts.cc b/gcc/opts.cc
index 3333600e0ea..0a00eb6e2da 100644
--- a/gcc/opts.cc
+++ b/gcc/opts.cc
@@ -3488,21 +3488,14 @@  set_debug_level (uint32_t dinfo, int extended, const char *arg,
     }
   else
     {
-      /* Make and retain the choice if both CTF and DWARF debug info are to
-	 be generated.  */
-      if (((dinfo == DWARF2_DEBUG) || (dinfo == CTF_DEBUG))
+      /* Any combination of DWARF, CTF and BTF is allowed together.  */
+      if (((dinfo == DWARF2_DEBUG) || (dinfo == CTF_DEBUG) || (dinfo == BTF_DEBUG))
 	  && ((opts->x_write_symbols == (DWARF2_DEBUG|CTF_DEBUG))
+	      || (opts->x_write_symbols == (DWARF2_DEBUG|BTF_DEBUG))
+	      || (opts->x_write_symbols == (CTF_DEBUG|BTF_DEBUG))
 	      || (opts->x_write_symbols == DWARF2_DEBUG)
-	      || (opts->x_write_symbols == CTF_DEBUG)))
-	{
-	  opts->x_write_symbols |= dinfo;
-	  opts_set->x_write_symbols |= dinfo;
-	}
-      /* However, CTF and BTF are not allowed together at this time.  */
-      else if (((dinfo == DWARF2_DEBUG) || (dinfo == BTF_DEBUG))
-	       && ((opts->x_write_symbols == (DWARF2_DEBUG|BTF_DEBUG))
-		   || (opts->x_write_symbols == DWARF2_DEBUG)
-		   || (opts->x_write_symbols == BTF_DEBUG)))
+	      || (opts->x_write_symbols == CTF_DEBUG)
+	      || (opts->x_write_symbols == BTF_DEBUG)))
 	{
 	  opts->x_write_symbols |= dinfo;
 	  opts_set->x_write_symbols |= dinfo;