[PATCH, PING*4] PR debug/53927: fix value for DW_AT_static_link

Eric Botcazou ebotcazou@adacore.com
Wed Nov 25 21:08:00 GMT 2015


> The DWARF change is OK if the tree-nested.c changes make sense to Eric.

As discussed in the audit trail of the PR, I'd rather have avoided the 
additional indirection, but the DWARF requirement seems to force it if we base 
the computation on the static chain and I don't see another approach.

A few comments:

+      int save_warn_padded;
+      tree *adjust, *field_decl_p;
+      char *name;
+      tree fb_decl, fb_ref, fb_tmp;
+      gcall *fb_gimple;
+      gimple_stmt_iterator gsi;

We try to declare variables only at the first use point now I think.

+      /* Debugging information needs to compute the frame base address of the
+	 nestee frame out of the static chain from the nested frame.

"parent frame"

+	 The static chain is the address of the FRAME record, so one could
+	 imagine it would be possible to compute the frame base address just
+	 adding a constant offset to this address.  Unfortunately, this is not
+	 possible: if the FRAME object has alignment constraints that are
+	 stronger than the stack, then the offset between the frame base and
+	 the FRAME object will be dynamic.
+
+	 What we do instead is to append a field to the FRAME object that 
holds
+	 the frame base address: then debug. info. just has to fetch this
+	 field.  */

No useless period: "debug info"

+      /* Debugging information will refer to the CFA as the frame base
+	 address: we will do the same here.  */
+      const tree frame_addr_fndecl
+        = builtin_decl_explicit (BUILT_IN_DWARF_CFA);
+
+      /* Create a field in the FRAME record to hold the frame base address 
for
+	 this stack frame.  Since it will be used only by the debugger 
(through
+	 the debugging information), put it at the end of the record not to
+	 shift all other offsets.  */

"(through the debugging information)" sounds superfluous. "in order not to..."

+      fb_decl = make_node (FIELD_DECL);
+      name = concat ("FRAME_BASE.",
+		     IDENTIFIER_POINTER (DECL_NAME (root->context)),
+		     NULL);
+      DECL_NAME (fb_decl) = get_identifier (name);
+      free (name);

Let's avoid this concat/free business and use a simpler name.

+      TREE_TYPE (fb_decl) = ptr_type_node;
+      TREE_ADDRESSABLE (fb_decl) = 1;
+      DECL_CONTEXT (fb_decl) = root->frame_type;
+      field_decl_p = &TYPE_FIELDS (root->frame_type);
+      while (*field_decl_p != NULL_TREE)
+	field_decl_p = &DECL_CHAIN (*field_decl_p);
+      *field_decl_p = fb_decl;

TYPE_FIELDS (root->frame_type)
  = chainon (TYPE_FIELDS (root->frame_type), fb_decl);

-- 
Eric Botcazou



More information about the Gcc-patches mailing list