This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[rfc] -gdwarf-3 and DW_OP_call_frame_cfa


I don't necessarily take it as given that we want a switch to
select DWARF 3 vs DWARF 2, given that we're already generating
some DWARF 3 extensions unconditionally.  We might simply want
to do all of DWARF3 unconditionally and hope consumers can cope.

That said, I've written this patch remembering the DWARF4 branch
and the possibility that we do in fact want to cope with different
versions of the standard.

There is one quirk.  Previously we'd accept options like -gdwarf-23
and take that to mean dwarf2 debugging, verbosity level 3.  Now
you *must* write this as -gdwarf-2 -g3.  Which, frankly, is what I
thought we had to do beforehand and was surprised at the error
message I got while testing the handling of -gdwarf-4.

Comments?


r~
ada/ChangeLog:
	* gcc-interface/misc.c (gnat_handle_option): Rename
	OPT_gdwarf_ to OPT_gdwarfplus.

ChangeLog:
	* common.opt (gdwarf-): Accept a version number.
	* doc/invoke.texi (gdwarf-): Update docs.
	* opth-gen.awk: Special case -gdwarf+ to OPT_gdwarfplus.
	* opts.c (common_handle_option) [OPT_gdwarf_]: Verify dwarf
	version level, and record it.

	* dwarf2out.c (dwarf_stack_op_name): Add all dwarf3 values.
	(gen_subprogram_die): Emit DW_OP_call_frame_cfa if emitting dwarf3.



--- ada/gcc-interface/misc.c	(revision 148317)
+++ ada/gcc-interface/misc.c	(local)
@@ -272,8 +272,8 @@ gnat_handle_option (size_t scode, const 
       gnat_argc++;
       break;
 
-    case OPT_gdwarf_:
-      gnat_dwarf_extensions ++;
+    case OPT_gdwarfplus:
+      gnat_dwarf_extensions = 1;
       break;
 
     default:
--- common.opt	(revision 148317)
+++ common.opt	(local)
@@ -1410,11 +1410,11 @@ Common JoinedOrMissing
 Generate debug information in default format
 
 gcoff
-Common JoinedOrMissing Negative(gdwarf-2)
+Common JoinedOrMissing Negative(gdwarf-)
 Generate debug information in COFF format
 
-gdwarf-2
-Common JoinedOrMissing Negative(gstabs)
+gdwarf-
+Common Joined UInteger Var(dwarf2_level) Init(2) Negative(gstabs)
 Generate debug information in DWARF v2 format
 
 ggdb
--- doc/invoke.texi	(revision 148317)
+++ doc/invoke.texi	(local)
@@ -310,7 +310,7 @@ Objective-C and Objective-C++ Dialects}.
 -frandom-seed=@var{string} -fsched-verbose=@var{n} @gol
 -fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose @gol
 -ftest-coverage  -ftime-report -fvar-tracking @gol
--g  -g@var{level}  -gtoggle  -gcoff  -gdwarf-2 @gol
+-g  -g@var{level}  -gtoggle  -gcoff  -gdwarf-@var{n} @gol
 -ggdb  -gstabs  -gstabs+  -gvms  -gxcoff  -gxcoff+ @gol
 -fno-merge-debug-strings -fno-dwarf2-cfi-asm @gol
 -fdebug-prefix-map=@var{old}=@var{new} @gol
@@ -4344,13 +4344,12 @@ use of these extensions is likely to mak
 refuse to read the program, and may cause assemblers other than the GNU
 assembler (GAS) to fail with an error.
 
-@item -gdwarf-2
-@opindex gdwarf-2
-Produce debugging information in DWARF version 2 format (if that is
-supported).  This is the format used by DBX on IRIX 6.  With this
-option, GCC uses features of DWARF version 3 when they are useful;
-version 3 is upward compatible with version 2, but may still cause
-problems for older debuggers.
+@item -gdwarf-@var{version}
+@opindex gdwarf-@var{version}
+Produce debugging information in DWARF format (if that is
+supported).  This is the format used by DBX on IRIX 6.  The value
+of @var{version} may be either 2 or 3.  The default DWARF version
+level is 2, with some DWARF 3 extensions.
 
 @item -gvms
 @opindex gvms
--- dwarf2out.c	(revision 148317)
+++ dwarf2out.c	(local)
@@ -4187,6 +4187,7 @@ dwarf_stack_op_name (unsigned int op)
       return "DW_OP_xderef_size";
     case DW_OP_nop:
       return "DW_OP_nop";
+
     case DW_OP_push_object_address:
       return "DW_OP_push_object_address";
     case DW_OP_call2:
@@ -4195,10 +4196,20 @@ dwarf_stack_op_name (unsigned int op)
       return "DW_OP_call4";
     case DW_OP_call_ref:
       return "DW_OP_call_ref";
+    case DW_OP_form_tls_address:
+      return "DW_OP_form_tls_address";
+    case DW_OP_call_frame_cfa:
+      return "DW_OP_call_frame_cfa";
+    case DW_OP_bit_piece:
+      return "DW_OP_bit_piece";
+
     case DW_OP_GNU_push_tls_address:
       return "DW_OP_GNU_push_tls_address";
     case DW_OP_GNU_uninit:
       return "DW_OP_GNU_uninit";
+    case DW_OP_GNU_encoded_addr:
+      return "DW_OP_GNU_encoded_addr";
+
     default:
       return "OP_<unknown>";
     }
@@ -14079,17 +14090,19 @@ gen_subprogram_die (tree decl, dw_die_re
 	 (3) We can at least reuse the code inspection and interpretation
 	 code that determines the CFA position at various points in the
 	 function.  */
-      /* ??? Use some command-line or configury switch to enable the use
-	 of dwarf3 DW_OP_call_frame_cfa.  At present there are no dwarf
-	 consumers that understand it; fall back to "pure" dwarf2 and
-	 convert the CFA data into a location list.  */
-      {
-	dw_loc_list_ref list = convert_cfa_to_fb_loc_list (cfa_fb_offset);
-	if (list->dw_loc_next)
-	  add_AT_loc_list (subr_die, DW_AT_frame_base, list);
-	else
-	  add_AT_loc (subr_die, DW_AT_frame_base, list->expr);
-      }
+      if (dwarf2_level >= 3)
+	{
+	  dw_loc_descr_ref op = new_loc_descr (DW_OP_call_frame_cfa, 0, 0);
+	  add_AT_loc (subr_die, DW_AT_frame_base, op);
+	}
+      else
+	{
+	  dw_loc_list_ref list = convert_cfa_to_fb_loc_list (cfa_fb_offset);
+	  if (list->dw_loc_next)
+	    add_AT_loc_list (subr_die, DW_AT_frame_base, list);
+	  else
+	    add_AT_loc (subr_die, DW_AT_frame_base, list->expr);
+	}
 
       /* Compute a displacement from the "steady-state frame pointer" to
 	 the CFA.  The former is what all stack slots and argument slots
--- opth-gen.awk	(revision 148317)
+++ opth-gen.awk	(local)
@@ -333,6 +333,8 @@ for (i = 0; i < n_opts; i++) {
 	enum = "OPT_" opts[i]
 	if (opts[i] == "finline-limit=" || opts[i] == "Wlarger-than=")
 		enum = enum "eq"
+	if (opts[i] == "gdwarf+")
+		enum = "OPT_gdwarfplus"
 	gsub ("[^A-Za-z0-9]", "_", enum)
 
 	# If this switch takes joined arguments, back-chain all
@@ -348,7 +350,7 @@ for (i = 0; i < n_opts; i++) {
 		}
 	}
 
-	s = substr("                                     ", length (opts[i]))
+	s = substr("                                         ", length (enum))
 	if (i + 1 == n_opts)
 		comma = ""
 
--- opts.c	(revision 148317)
+++ opts.c	(local)
@@ -2033,7 +2033,11 @@ common_handle_option (size_t scode, cons
       set_debug_level (SDB_DEBUG, false, arg);
       break;
 
-    case OPT_gdwarf_2:
+    case OPT_gdwarf_:
+      if (value < 2 || value > 3)
+	error ("dwarf version %d is not supported", value);
+      else
+	dwarf2_level = value;
       set_debug_level (DWARF2_DEBUG, false, arg);
       break;
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]