This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Dwarf2 missing location lists for VMS
- From: Douglas B Rupp <rupp at gnat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Tristan Gingold <gingold at adacore dot com>
- Date: Thu, 23 Jul 2009 13:29:18 -0700
- Subject: [PATCH] Dwarf2 missing location lists for VMS
The VMS debugger needs this.
Tested on x86_64-linux-gnu
OK to commit?
--Douglas Rupp
AdaCore
2009-07-23 Tristan Gingold <gingold@adacore.com>
Douglas B Rupp <rupp@gnat.com>
* doc/tm.texi (DWARF2_LOCATION_LISTS_SUPPORT_MISSING_ON_TARGET):
Document new macro.
* defaults.h: Default it supported.
* dwarf2out.c: (add_location_or_const_value_attribute): Mention it.
(gen_subprogram_die): Rework location lists to allow for missing
support.
* toplev.c (process_options): Warn that variable tracking not
supported without location lists.
--- gcc/doc/tm.texi.old 2009-07-14 22:47:03.286156626 -0700
+++ gcc/doc/tm.texi 2009-07-14 22:49:49.090653534 -0700
@@ -9124,6 +9124,14 @@ Dwarf 2 frame information. If @code{DWA
information not matter how you define @code{DWARF2_FRAME_INFO}.
@end defmac
+@defmac DWARF2_LOCATION_LISTS_SUPPORT_MISSING_ON_TARGET
+Define this macro to evaluate to a nonzero value if GCC should refrain
+from generating location lists in DWARF2 debug information, for instance
+if your target is stuck with an old version of GDB that is unable to
+process them properly. This automatically disables variable tracking, with
+a warning if it has been requested explicitly.
+@end defmac
+
@defmac DWARF2_ASM_LINE_DEBUG_INFO
Define this macro to be a nonzero value if the assembler can generate Dwarf 2
line debug info sections. This will result in much more compact line number
--- gcc/defaults.h.old 2009-07-14 22:47:25.108826078 -0700
+++ gcc/defaults.h 2009-07-14 22:50:37.178174209 -0700
@@ -853,6 +853,13 @@ see the files COPYING3 and COPYING.RUNTI
#define PREFERRED_DEBUGGING_TYPE NO_DEBUG
#endif
+/* For DWARF2, assume there is proper support for location lists on the
+ target by default. */
+#if defined (DWARF2_DEBUGGING_INFO) \
+ && !defined (DWARF2_LOCATION_LISTS_SUPPORT_MISSING_ON_TARGET)
+#define DWARF2_LOCATION_LISTS_SUPPORT_MISSING_ON_TARGET 0
+#endif
+
#ifndef LARGEST_EXPONENT_IS_NORMAL
#define LARGEST_EXPONENT_IS_NORMAL(SIZE) 0
#endif
--- gcc/dwarf2out.c.old 2009-07-14 22:47:51.628767787 -0700
+++ gcc/dwarf2out.c 2009-07-14 23:01:32.692117898 -0700
@@ -12401,7 +12401,9 @@ add_location_or_const_value_attribute (d
gcc_assert (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == PARM_DECL
|| TREE_CODE (decl) == RESULT_DECL);
- /* See if we possibly have multiple locations for this variable. */
+ /* See if we possibly have multiple locations for this variable. We expect
+ the call to always return 0 when var-tracking is disabled and the latter
+ to be enforced if DWARF2_LOCATION_LISTS_SUPPORT_MISSING_ON_TARGET. */
loc_list = lookup_decl_loc (decl);
/* If it truly has multiple locations, the first and last node will
@@ -14352,8 +14354,6 @@ gen_subprogram_die (tree decl, dw_die_re
}
else if (!DECL_EXTERNAL (decl))
{
- HOST_WIDE_INT cfa_fb_offset;
-
if (!old_die || !get_AT (old_die, DW_AT_inline))
equate_decl_number_to_die (decl, subr_die);
@@ -14404,37 +14404,60 @@ gen_subprogram_die (tree decl, dw_die_re
add_AT_fde_ref (subr_die, DW_AT_MIPS_fde, current_funcdef_fde);
#endif
- cfa_fb_offset = CFA_FRAME_BASE_OFFSET (decl);
-
- /* We define the "frame base" as the function's CFA. This is more
- convenient for several reasons: (1) It's stable across the prologue
- and epilogue, which makes it better than just a frame pointer,
- (2) With dwarf3, there exists a one-byte encoding that allows us
- to reference the .debug_frame data by proxy, but failing that,
- (3) We can at least reuse the code inspection and interpretation
- code that determines the CFA position at various points in the
- function. */
- if (dwarf_version >= 3)
+ /* On targets where there is proper support for DWARF2 locations list,
+ convert the CFA data into this form and define this as the function's
+ "frame base".
+
+ Having the function's CFA as the "frame base" is more convenient for
+ several reasons: (1) It's stable across the prologue and epilogue,
+ which makes it better than just a frame pointer, (2) With dwarf3,
+ there exists a one-byte encoding that allows us to reference the
+ .debug_frame data by proxy, but failing that, (3) We can at least
+ reuse the code inspection and interpretation code that determines the
+ CFA position at various points in the function. */
+ if (!DWARF2_LOCATION_LISTS_SUPPORT_MISSING_ON_TARGET)
{
- 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);
- }
+ HOST_WIDE_INT cfa_fb_offset = CFA_FRAME_BASE_OFFSET (decl);
+
+ if (dwarf_version >= 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
+ will reference in the rtl; the later is what we've told the
+ debugger about. We'll need to adjust all frame_base references
+ by this displacement. */
+ compute_frame_pointer_to_fb_displacement (cfa_fb_offset);
+ }
+ /* On other targets, use the frame pointer or stack pointer registers,
+ since the RTL for local variables is relative to one of them. This
+ yields inaccurate debug info for prologue instructions but there is
+ not much we can do about this on such targets. */
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);
+ rtx fp_reg
+ = (frame_pointer_needed
+ ? hard_frame_pointer_rtx : stack_pointer_rtx);
+
+ add_AT_loc
+ (subr_die, DW_AT_frame_base,
+ reg_loc_descriptor (fp_reg, VAR_INIT_STATUS_INITIALIZED));
+
+ /* We just made "frame base" the frame pointer register, so ... */
+ frame_pointer_fb_offset = 0;
}
- /* Compute a displacement from the "steady-state frame pointer" to
- the CFA. The former is what all stack slots and argument slots
- will reference in the rtl; the later is what we've told the
- debugger about. We'll need to adjust all frame_base references
- by this displacement. */
- compute_frame_pointer_to_fb_displacement (cfa_fb_offset);
-
if (cfun->static_chain_decl)
add_AT_location_description (subr_die, DW_AT_static_link,
loc_descriptor_from_tree (cfun->static_chain_decl));
--- gcc/toplev.c.old 2009-07-14 22:48:13.437421637 -0700
+++ gcc/toplev.c 2009-07-14 23:03:03.138392371 -0700
@@ -1948,6 +1948,21 @@ process_options (void)
/* Now we know which debug output will be used so we can set
flag_var_tracking, flag_rename_registers if the user has
not specified them. */
+
+ /* var_tracking relies on location lists support for DWARF2, for which a
+ target might not have full support. Honor this. */
+#ifdef DWARF2_DEBUGGING_INFO
+ if (write_symbols == DWARF2_DEBUG
+ && DWARF2_LOCATION_LISTS_SUPPORT_MISSING_ON_TARGET)
+ {
+ if (flag_var_tracking == 1)
+ warning (0, "variable tracking requested, but not supported "
+ "in this configuration");
+
+ flag_var_tracking = 0;
+ }
+#endif
+
if (debug_info_level < DINFO_LEVEL_NORMAL
|| debug_hooks->var_location == do_nothing_debug_hooks.var_location)
{