[RFC,V2,2/3] Add CTF command line options : -gtLEVEL

Message ID 1560362410-27014-3-git-send-email-indu.bhagat@oracle.com
State Superseded
Headers show
Series
  • Support for CTF in GCC
Related show

Commit Message

Indu Bhagat June 12, 2019, 6 p.m.
-gtLEVEL is used to request CTF debug information and also to specify how much
CTF debug information.

[Changes from V1]
  None

gcc/ChangeLog:
 
	* common.opt: Add CTF debug info options.
	* doc/invoke.texi: Document the CTF debug info options.
	* flag-types.h (enum ctf_debug_info_levels): New enum.
	* opts.c (common_handle_option): New Function.
	(set_ctf_debug_level): Handle the new CTF debug info options.

---
 gcc/ChangeLog       |  8 ++++++++
 gcc/common.opt      |  9 +++++++++
 gcc/doc/invoke.texi | 16 ++++++++++++++++
 gcc/flag-types.h    | 13 +++++++++++++
 gcc/opts.c          | 26 ++++++++++++++++++++++++++
 5 files changed, 72 insertions(+)

-- 
1.8.3.1

Comments

Bernhard Reutner-Fischer June 18, 2019, 7:24 p.m. | #1
On 12 June 2019 20:00:09 CEST, Indu Bhagat <indu.bhagat@oracle.com> wrote:
>-gtLEVEL is used to request CTF debug information and also to specify

>how much

>CTF debug information.


The option name is way too generic IMO.
-gctfLEVEL or some such would at least  indicate its intended purpose, fwiw.

thanks

>

>[Changes from V1]

>  None

>

>gcc/ChangeLog:

> 

>	* common.opt: Add CTF debug info options.

>	* doc/invoke.texi: Document the CTF debug info options.

>	* flag-types.h (enum ctf_debug_info_levels): New enum.

>	* opts.c (common_handle_option): New Function.

>	(set_ctf_debug_level): Handle the new CTF debug info options.
Indu Bhagat June 19, 2019, 11:13 p.m. | #2
On 06/18/2019 12:24 PM, Bernhard Reutner-Fischer wrote:
> On 12 June 2019 20:00:09 CEST, Indu Bhagat<indu.bhagat@oracle.com>  wrote:

>> -gtLEVEL is used to request CTF debug information and also to specify

>> how much

>> CTF debug information.

> The option name is way too generic IMO.

> -gctfLEVEL or some such would at least  indicate its intended purpose, fwiw.

>

> thanks

>

I thought about this too. The prime reason for -gtLEVEL is consistency with the
DWARF debug info command line options.

For DWARF, we have -gdwarf-VERSION and -gLEVEL. Although GCC, at this time, will
generate only the most recent CTF version (CTF_VERSION_3 in <ctf.h>); I don't
know for sure if the compiler will need to support the CTF_VERSION_3 and higher
simultaneously in the future. If we do, then -gctf-VERSION and -gtLEVEL will be
the most palatable choice for generating Type debug information (Type, hence
the "t" in gt) of various versions.

Thanks
Indu

Patch

diff --git a/gcc/common.opt b/gcc/common.opt
index e140416..499f27c 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -125,6 +125,11 @@  enum debug_info_levels debug_info_level = DINFO_LEVEL_NONE
 Variable
 bool use_gnu_debug_info_extensions
 
+; Level of CTF debugging information we are producing.  See flag-types.h
+; for the definitions of the different possible levels.
+Variable
+enum ctf_debug_info_levels ctf_debug_info_level = CTFINFO_LEVEL_NONE
+
 ; Original value of maximum field alignment in bytes, specified via
 ; -fpack-struct=<value>.
 Variable
@@ -2995,6 +3000,10 @@  gcolumn-info
 Common Driver Var(debug_column_info,1) Init(1)
 Record DW_AT_decl_column and DW_AT_call_column in DWARF.
 
+gt
+Common Driver RejectNegative JoinedOrMissing
+Generate CTF debug information at default level.
+
 gdwarf
 Common Driver JoinedOrMissing Negative(gdwarf-)
 Generate debug information in default version of DWARF format.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 1520b2c..babf037 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -374,6 +374,7 @@  Objective-C and Objective-C++ Dialects}.
 @item Debugging Options
 @xref{Debugging Options,,Options for Debugging Your Program}.
 @gccoptlist{-g  -g@var{level}  -gdwarf  -gdwarf-@var{version} @gol
+-gt  -gt@var{level} @gol
 -ggdb  -grecord-gcc-switches  -gno-record-gcc-switches @gol
 -gstabs  -gstabs+  -gstrict-dwarf  -gno-strict-dwarf @gol
 -gas-loc-support  -gno-as-loc-support @gol
@@ -7784,6 +7785,21 @@  other DWARF-related options such as
 @option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2
 in their names, but apply to all currently-supported versions of DWARF.
 
+@item -gt
+@itemx -gt@var{level}
+@opindex gt
+Request CTF debug information and use level to specify how much CTF debug
+information should be produced.  If -gt is specified without a value for level,
+the default level of CTF debug information is 2.
+
+Level 0 produces no CTF debug information at all.  Thus, -gt0 negates -gt.
+
+Level 1 produces CTF information for tracebacks only.  This includes callsite
+information, but does not include type information.
+
+Level 2 produces type information for entities (functions, data objects etc.)
+at file-scope or global-scope only.
+
 @item -gstabs
 @opindex gstabs
 Produce debugging information in stabs format (if that is supported),
diff --git a/gcc/flag-types.h b/gcc/flag-types.h
index a210328..61a1432 100644
--- a/gcc/flag-types.h
+++ b/gcc/flag-types.h
@@ -105,6 +105,19 @@  enum dwarf_gnat_encodings
 				       Emit GNAT encodings for the rest.  */
 };
 
+/* CTF debug info levels.
+   CTF debug info levels are untied with DWARF debug info levels because CTF
+   may co-exist with DWARF.  */
+enum ctf_debug_info_levels
+{
+  CTFINFO_LEVEL_NONE = 0,     /* Write no CTF debug info.  */
+  CTFINFO_LEVEL_TERSE = 1,    /* Write CTF information to support tracebacks
+				 only.  Not Implemented.  */
+  CTFINFO_LEVEL_NORMAL = 2    /* Write CTF type information for all entities
+				 (functions, data objects, variables etc.)
+				 at file-scope or global-scope only.  */
+};
+
 /* Enumerate Objective-c instance variable visibility settings. */
 
 enum ivar_visibility
diff --git a/gcc/opts.c b/gcc/opts.c
index 64f94ac..a471a76 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -195,6 +195,8 @@  static void set_debug_level (enum debug_info_type type, int extended,
 			     const char *arg, struct gcc_options *opts,
 			     struct gcc_options *opts_set,
 			     location_t loc);
+static void set_ctf_debug_level (const char *arg,
+				 struct gcc_options *opts, location_t loc);
 static void set_fast_math_flags (struct gcc_options *opts, int set);
 static void decode_d_option (const char *arg, struct gcc_options *opts,
 			     location_t loc, diagnostic_context *dc);
@@ -2683,6 +2685,10 @@  common_handle_option (struct gcc_options *opts,
       opts->x_flag_stack_usage_info = value != 0;
       break;
 
+    case OPT_gt:
+      set_ctf_debug_level (arg, opts, loc);
+      break;
+
     case OPT_g:
       set_debug_level (NO_DEBUG, DEFAULT_GDB_EXTENSIONS, arg, opts, opts_set,
                        loc);
@@ -3005,6 +3011,26 @@  set_debug_level (enum debug_info_type type, int extended, const char *arg,
     }
 }
 
+/* Handle a debug output -gt switch for options OPTS.  */
+static void
+set_ctf_debug_level (const char *arg,
+		     struct gcc_options *opts, location_t loc)
+{
+  /* CTF debug flag without a level defaults to level 2.  */
+  if (*arg == '\0')
+    opts->x_ctf_debug_info_level = CTFINFO_LEVEL_NORMAL;
+  else
+    {
+      int argval = integral_argument (arg);
+      if (argval == -1)
+	error_at (loc, "unrecognized ctf debug output level %qs", arg);
+      else if (argval > CTFINFO_LEVEL_NORMAL)
+	error_at (loc, "ctf debug output level %qs is too high", arg);
+      else
+	opts->x_ctf_debug_info_level = (enum ctf_debug_info_levels) argval;
+    }
+}
+
 /* Arrange to dump core on error for diagnostic context DC.  (The
    regular error message is still printed first, except in the case of
    abort ().)  */