+2010-09-09 Jakub Jelinek <jakub@redhat.com>
+
+ * rtl.def (DEBUG_IMPLICIT_PTR): New rtl code.
+ * rtl.h (DEBUG_IMPLICIT_PTR_DECL): Define.
+ * rtl.c (rtx_equal_p_cb, rtx_equal_p): Handle DEBUG_IMPLICIT_PTR.
+ * print-rtl.c (print_rtx): Likewise.
+ * cselib.c (rtx_equal_for_cselib_p, cselib_hash_rtx): Likewise.
+ * cfgexpand.c (expand_debug_expr): Generate DEBUG_IMPLICIT_PTR
+ for ADDR_EXPR with non-addressable object.
+ * dwarf2out.c (enum dw_val_class): Add dw_val_class_decl_ref.
+ (struct dw_val_struct): Add v.val_decl_ref.
+ (dwarf_stack_op_name, output_loc_operands, output_loc_operands_raw):
+ Handle DW_OP_GNU_implicit_pointer.
+ (size_of_loc_descr): Likewise. Fix up DW_OP_call_ref size.
+ (get_ref_die_offset_label): New function.
+ (implicit_ptr_descriptor): New function.
+ (mem_loc_descriptor): Handle DEBUG_IMPLICIT_PTR.
+ (loc_descriptor): Likewise.
+ (gen_variable_die): Put even definitions into decl_die_table.
+ (resolve_addr_in_expr): Resolve still unresolved
+ DW_OP_GNU_implicit_pointer operands, if it can't be resolved
+ return false.
+ (dwarf2out_finish): Call output_location_lists after outputting
+ .debug_info and .debug_abbrev instead of before.
+
+2010-09-09 Roland McGrath <roland@redhat.com>
+
+ * dwarf2out.c (DWARF_REF_SIZE): Define.
+ (size_of_loc_descr): Use it for DW_OP_call_ref.
+
2010-09-09 Alan Modra <amodra@gmail.com>
* doc/invoke.text: Reinstate mcmodel=medium.
case ADDR_EXPR:
op0 = expand_debug_expr (TREE_OPERAND (exp, 0));
if (!op0 || !MEM_P (op0))
- return NULL;
+ {
+ if ((TREE_CODE (TREE_OPERAND (exp, 0)) == VAR_DECL
+ || TREE_CODE (TREE_OPERAND (exp, 0)) == PARM_DECL
+ || TREE_CODE (TREE_OPERAND (exp, 0)) == RESULT_DECL)
+ && !TREE_ADDRESSABLE (TREE_OPERAND (exp, 0)))
+ return gen_rtx_DEBUG_IMPLICIT_PTR (mode, TREE_OPERAND (exp, 0));
+
+ if (handled_component_p (TREE_OPERAND (exp, 0)))
+ {
+ HOST_WIDE_INT bitoffset, bitsize, maxsize;
+ tree decl
+ = get_ref_base_and_extent (TREE_OPERAND (exp, 0),
+ &bitoffset, &bitsize, &maxsize);
+ if ((TREE_CODE (decl) == VAR_DECL
+ || TREE_CODE (decl) == PARM_DECL
+ || TREE_CODE (decl) == RESULT_DECL)
+ && !TREE_ADDRESSABLE (decl)
+ && (bitoffset % BITS_PER_UNIT) == 0
+ && bitsize > 0
+ && bitsize == maxsize)
+ return plus_constant (gen_rtx_DEBUG_IMPLICIT_PTR (mode, decl),
+ bitoffset / BITS_PER_UNIT);
+ }
+
+ return NULL;
+ }
op0 = convert_debug_memory_address (mode, XEXP (op0, 0));
dw_val_class_macptr,
dw_val_class_file,
dw_val_class_data8,
+ dw_val_class_decl_ref,
dw_val_class_vms_delta
};
unsigned char GTY ((tag ("dw_val_class_flag"))) val_flag;
struct dwarf_file_data * GTY ((tag ("dw_val_class_file"))) val_file;
unsigned char GTY ((tag ("dw_val_class_data8"))) val_data8[8];
+ tree GTY ((tag ("dw_val_class_decl_ref"))) val_decl_ref;
struct dw_val_vms_delta_union
{
char * lbl1;
return "DW_OP_GNU_uninit";
case DW_OP_GNU_encoded_addr:
return "DW_OP_GNU_encoded_addr";
+ case DW_OP_GNU_implicit_pointer:
+ return "DW_OP_GNU_implicit_pointer";
default:
return "OP_<unknown>";
loc_descr_plus_const (&d->expr, offset);
}
+#define DWARF_REF_SIZE \
+ (dwarf_version == 2 ? DWARF2_ADDR_SIZE : DWARF_OFFSET_SIZE)
+
/* Return the size of a location descriptor. */
static unsigned long
size += 4;
break;
case DW_OP_call_ref:
- size += DWARF2_ADDR_SIZE;
+ size += DWARF_REF_SIZE;
break;
case DW_OP_implicit_value:
size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned)
+ loc->dw_loc_oprnd1.v.val_unsigned;
break;
+ case DW_OP_GNU_implicit_pointer:
+ size += DWARF_REF_SIZE + size_of_sleb128 (loc->dw_loc_oprnd2.v.val_int);
+ break;
default:
break;
}
}
static HOST_WIDE_INT extract_int (const unsigned char *, unsigned);
+static void get_ref_die_offset_label (char *, dw_die_ref);
/* Output location description stack opcode's operands (if any). */
}
break;
+ case DW_OP_GNU_implicit_pointer:
+ {
+ char label[MAX_ARTIFICIAL_LABEL_BYTES
+ + HOST_BITS_PER_WIDE_INT / 2 + 2];
+ gcc_assert (val1->val_class == dw_val_class_die_ref);
+ get_ref_die_offset_label (label, val1->v.val_die_ref.die);
+ dw2_asm_output_offset (DWARF_REF_SIZE, label, debug_info_section, NULL);
+ dw2_asm_output_data_sleb128 (val2->v.val_int, NULL);
+ }
+ break;
+
default:
/* Other codes have no operands. */
break;
dw2_asm_output_data_sleb128_raw (val2->v.val_int);
break;
+ case DW_OP_GNU_implicit_pointer:
+ gcc_unreachable ();
+ break;
+
default:
/* Other codes have no operands. */
break;
|| code == QUAL_UNION_TYPE || code == ENUMERAL_TYPE);
}
+/* Set label to debug_info_section_label + die_offset of a DIE reference. */
+
+static void
+get_ref_die_offset_label (char *label, dw_die_ref ref)
+{
+ sprintf (label, "%s+" HOST_WIDE_INT_PRINT_DEC,
+ debug_info_section_label, ref->die_offset);
+}
+
/* Convert a DIE tag into its string name. */
static const char *
case CONCAT:
case CONCATN:
case VAR_LOCATION:
+ case DEBUG_IMPLICIT_PTR:
expansion_failed (NULL_TREE, rtl,
"CONCAT/CONCATN/VAR_LOCATION is handled only by loc_descriptor");
return 0;
return cc_loc_result;
}
+/* Helper function for loc_descriptor. Return DW_OP_GNU_implicit_pointer
+ for DEBUG_IMPLICIT_PTR RTL. */
+
+static dw_loc_descr_ref
+implicit_ptr_descriptor (rtx rtl, HOST_WIDE_INT offset)
+{
+ dw_loc_descr_ref ret;
+ dw_die_ref ref;
+
+ gcc_assert (TREE_CODE (DEBUG_IMPLICIT_PTR_DECL (rtl)) == VAR_DECL
+ || TREE_CODE (DEBUG_IMPLICIT_PTR_DECL (rtl)) == PARM_DECL
+ || TREE_CODE (DEBUG_IMPLICIT_PTR_DECL (rtl)) == RESULT_DECL);
+ ref = lookup_decl_die (DEBUG_IMPLICIT_PTR_DECL (rtl));
+ ret = new_loc_descr (DW_OP_GNU_implicit_pointer, 0, offset);
+ ret->dw_loc_oprnd2.val_class = dw_val_class_const;
+ if (ref)
+ {
+ ret->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
+ ret->dw_loc_oprnd1.v.val_die_ref.die = ref;
+ ret->dw_loc_oprnd1.v.val_die_ref.external = 0;
+ }
+ else
+ {
+ ret->dw_loc_oprnd1.val_class = dw_val_class_decl_ref;
+ ret->dw_loc_oprnd1.v.val_decl_ref = DEBUG_IMPLICIT_PTR_DECL (rtl);
+ }
+ return ret;
+}
+
/* Output a proper Dwarf location descriptor for a variable or parameter
which is either allocated in a register or in a memory location. For a
register, we just generate an OP_REG and the register number. For a
}
break;
+ case DEBUG_IMPLICIT_PTR:
+ loc_result = implicit_ptr_descriptor (rtl, 0);
+ break;
+
+ case PLUS:
+ if (GET_CODE (XEXP (rtl, 0)) == DEBUG_IMPLICIT_PTR
+ && CONST_INT_P (XEXP (rtl, 1)))
+ {
+ loc_result
+ = implicit_ptr_descriptor (XEXP (rtl, 0), INTVAL (XEXP (rtl, 1)));
+ break;
+ }
+ /* FALLTHRU */
default:
if (GET_MODE_CLASS (mode) == MODE_INT && GET_MODE (rtl) == mode
&& GET_MODE_SIZE (GET_MODE (rtl)) <= DWARF2_ADDR_SIZE
if (declaration)
add_AT_flag (var_die, DW_AT_declaration, 1);
- if (decl && (DECL_ABSTRACT (decl) || declaration))
+ if (decl && (DECL_ABSTRACT (decl) || declaration || old_die == NULL))
equate_decl_number_to_die (decl, var_die);
if (! declaration
&& loc->dw_loc_oprnd2.val_class == dw_val_class_addr
&& resolve_one_addr (&loc->dw_loc_oprnd2.v.val_addr, NULL)))
return false;
+ else if (loc->dw_loc_opc == DW_OP_GNU_implicit_pointer
+ && loc->dw_loc_oprnd1.val_class == dw_val_class_decl_ref)
+ {
+ dw_die_ref ref
+ = lookup_decl_die (loc->dw_loc_oprnd1.v.val_decl_ref);
+ if (ref == NULL)
+ return false;
+ loc->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
+ loc->dw_loc_oprnd1.v.val_die_ref.die = ref;
+ loc->dw_loc_oprnd1.v.val_die_ref.external = 0;
+ }
return true;
}
add_ranges (NULL);
}
- /* Output location list section if necessary. */
- if (have_location_lists)
- {
- /* Output the location lists info. */
- switch_to_section (debug_loc_section);
- ASM_GENERATE_INTERNAL_LABEL (loc_section_label,
- DEBUG_LOC_SECTION_LABEL, 0);
- ASM_OUTPUT_LABEL (asm_out_file, loc_section_label);
- output_location_lists (die);
- }
-
if (debug_info_level >= DINFO_LEVEL_NORMAL)
add_AT_lineptr (comp_unit_die, DW_AT_stmt_list,
debug_line_section_label);
switch_to_section (debug_abbrev_section);
output_abbrev_section ();
+ /* Output location list section if necessary. */
+ if (have_location_lists)
+ {
+ /* Output the location lists info. */
+ switch_to_section (debug_loc_section);
+ ASM_GENERATE_INTERNAL_LABEL (loc_section_label,
+ DEBUG_LOC_SECTION_LABEL, 0);
+ ASM_OUTPUT_LABEL (asm_out_file, loc_section_label);
+ output_location_lists (die);
+ }
+
/* Output public names table if necessary. */
if (!VEC_empty (pubname_entry, pubname_table))
{