/* Output Dwarf2 format symbol table information from GCC.
Copyright (C) 1992, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
- 2003 Free Software Foundation, Inc.
+ 2003, 2004 Free Software Foundation, Inc.
Contributed by Gary Funck (gary@intrepid.com).
Derived from DWARF 1 implementation of Ron Guilmette (rfg@monkeys.com).
Extensively modified by Jason Merrill (jason@cygnus.com).
#include "coretypes.h"
#include "tm.h"
#include "tree.h"
+#include "version.h"
#include "flags.h"
#include "real.h"
#include "rtl.h"
#include "langhooks.h"
#include "hashtab.h"
#include "cgraph.h"
+#include "input.h"
#ifdef DWARF2_DEBUGGING_INFO
static void dwarf2out_source_line (unsigned int, const char *);
data_section ();
ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE));
- (*targetm.asm_out.globalize_label) (asm_out_file, IDENTIFIER_POINTER (label));
+ targetm.asm_out.globalize_label (asm_out_file, IDENTIFIER_POINTER (label));
ASM_OUTPUT_LABEL (asm_out_file, IDENTIFIER_POINTER (label));
}
typedef struct dw_fde_struct GTY(())
{
+ tree decl;
const char *dw_fde_begin;
const char *dw_fde_current_label;
const char *dw_fde_end;
static void output_cfi (dw_cfi_ref, dw_fde_ref, int);
static void output_call_frame_info (int);
static void dwarf2out_stack_adjust (rtx);
-static void queue_reg_save (const char *, rtx, HOST_WIDE_INT);
static void flush_queued_reg_saves (void);
static bool clobbers_queued_reg_save (rtx);
static void dwarf2out_frame_debug_expr (rtx, const char *);
#define FUNC_END_LABEL "LFE"
#endif
+#ifndef FRAME_BEGIN_LABEL
#define FRAME_BEGIN_LABEL "Lframe"
+#endif
#define CIE_AFTER_SIZE_LABEL "LSCIE"
#define CIE_END_LABEL "LECIE"
#define FDE_LABEL "LSFDE"
cfi->dw_cfi_oprnd1.dw_cfi_reg_num = reg;
- /* The following comparison is correct. -1 is used to indicate that
- the value isn't a register number. */
- if (sreg == (unsigned int) -1)
+ if (sreg == INVALID_REGNUM)
{
if (reg & ~0x3f)
/* The register number won't fit in 6 bits, so we have to use
cfi->dw_cfi_oprnd2.dw_cfi_offset = offset;
}
else if (sreg == reg)
- /* We could emit a DW_CFA_same_value in this case, but don't bother. */
- return;
+ cfi->dw_cfi_opc = DW_CFA_same_value;
else
{
cfi->dw_cfi_opc = DW_CFA_register;
void
dwarf2out_reg_save (const char *label, unsigned int reg, HOST_WIDE_INT offset)
{
- reg_save (label, DWARF_FRAME_REGNUM (reg), -1, offset);
+ reg_save (label, DWARF_FRAME_REGNUM (reg), INVALID_REGNUM, offset);
}
/* Entry point for saving the return address in the stack.
void
dwarf2out_return_save (const char *label, HOST_WIDE_INT offset)
{
- reg_save (label, DWARF_FRAME_RETURN_COLUMN, -1, offset);
+ reg_save (label, DWARF_FRAME_RETURN_COLUMN, INVALID_REGNUM, offset);
}
/* Entry point for saving the return address in a register.
void
dwarf2out_return_reg (const char *label, unsigned int sreg)
{
- reg_save (label, DWARF_FRAME_RETURN_COLUMN, sreg, 0);
+ reg_save (label, DWARF_FRAME_RETURN_COLUMN, DWARF_FRAME_REGNUM (sreg), 0);
}
/* Record the initial position of the return address. RTL is
static void
initial_return_save (rtx rtl)
{
- unsigned int reg = (unsigned int) -1;
+ unsigned int reg = INVALID_REGNUM;
HOST_WIDE_INT offset = 0;
switch (GET_CODE (rtl))
abort ();
}
- reg_save (NULL, DWARF_FRAME_RETURN_COLUMN, reg, offset - cfa.offset);
+ if (reg != DWARF_FRAME_RETURN_COLUMN)
+ reg_save (NULL, DWARF_FRAME_RETURN_COLUMN, reg, offset - cfa.offset);
}
/* Given a SET, calculate the amount of stack adjustment it
if (code == PLUS)
offset = -offset;
}
- else if (GET_CODE (dest) == MEM)
+ else if (MEM_P (dest))
{
/* (set (mem (pre_dec (reg sp))) (foo)) */
src = XEXP (dest, 0);
const char *label;
int i;
- if (!flag_asynchronous_unwind_tables && GET_CODE (insn) == CALL_INSN)
+ /* Don't handle epilogues at all. Certainly it would be wrong to do so
+ with this function. Proper support would require all frame-related
+ insns to be marked, and to be able to handle saving state around
+ epilogues textually in the middle of the function. */
+ if (prologue_epilogue_contains (insn) || sibcall_epilogue_contains (insn))
+ return;
+
+ if (!flag_asynchronous_unwind_tables && CALL_P (insn))
{
/* Extract the size of the args from the CALL rtx itself. */
insn = PATTERN (insn);
else if (!flag_asynchronous_unwind_tables && cfa.reg != STACK_POINTER_REGNUM)
return;
- if (GET_CODE (insn) == BARRIER)
+ if (BARRIER_P (insn))
{
/* When we see a BARRIER, we know to reset args_size to 0. Usually
the compiler will have already emitted a stack adjustment, but
struct queued_reg_save *next;
rtx reg;
HOST_WIDE_INT cfa_offset;
+ rtx saved_reg;
};
static GTY(()) struct queued_reg_save *queued_reg_saves;
+/* The caller's ORIG_REG is saved in SAVED_IN_REG. */
+struct reg_saved_in_data GTY(()) {
+ rtx orig_reg;
+ rtx saved_in_reg;
+};
+
+/* A list of registers saved in other registers.
+ The list intentionally has a small maximum capacity of 4; if your
+ port needs more than that, you might consider implementing a
+ more efficient data structure. */
+static GTY(()) struct reg_saved_in_data regs_saved_in_regs[4];
+static GTY(()) size_t num_regs_saved_in_regs;
+
#if defined (DWARF2_DEBUGGING_INFO) || defined (DWARF2_UNWIND_INFO)
static const char *last_reg_save_label;
+/* Add an entry to QUEUED_REG_SAVES saying that REG is now saved at
+ SREG, or if SREG is NULL then it is saved at OFFSET to the CFA. */
+
static void
-queue_reg_save (const char *label, rtx reg, HOST_WIDE_INT offset)
+queue_reg_save (const char *label, rtx reg, rtx sreg, HOST_WIDE_INT offset)
{
- struct queued_reg_save *q = ggc_alloc (sizeof (*q));
+ struct queued_reg_save *q;
+
+ /* Duplicates waste space, but it's also necessary to remove them
+ for correctness, since the queue gets output in reverse
+ order. */
+ for (q = queued_reg_saves; q != NULL; q = q->next)
+ if (REGNO (q->reg) == REGNO (reg))
+ break;
+
+ if (q == NULL)
+ {
+ q = ggc_alloc (sizeof (*q));
+ q->next = queued_reg_saves;
+ queued_reg_saves = q;
+ }
- q->next = queued_reg_saves;
q->reg = reg;
q->cfa_offset = offset;
- queued_reg_saves = q;
+ q->saved_reg = sreg;
last_reg_save_label = label;
}
+/* Output all the entries in QUEUED_REG_SAVES. */
+
static void
flush_queued_reg_saves (void)
{
- struct queued_reg_save *q, *next;
+ struct queued_reg_save *q;
- for (q = queued_reg_saves; q; q = next)
+ for (q = queued_reg_saves; q; q = q->next)
{
- dwarf2out_reg_save (last_reg_save_label, REGNO (q->reg), q->cfa_offset);
- next = q->next;
+ size_t i;
+ unsigned int reg, sreg;
+
+ for (i = 0; i < num_regs_saved_in_regs; i++)
+ if (REGNO (regs_saved_in_regs[i].orig_reg) == REGNO (q->reg))
+ break;
+ if (q->saved_reg && i == num_regs_saved_in_regs)
+ {
+ if (i == ARRAY_SIZE (regs_saved_in_regs))
+ abort ();
+ num_regs_saved_in_regs++;
+ }
+ if (i != num_regs_saved_in_regs)
+ {
+ regs_saved_in_regs[i].orig_reg = q->reg;
+ regs_saved_in_regs[i].saved_in_reg = q->saved_reg;
+ }
+
+ reg = DWARF_FRAME_REGNUM (REGNO (q->reg));
+ if (q->saved_reg)
+ sreg = DWARF_FRAME_REGNUM (REGNO (q->saved_reg));
+ else
+ sreg = INVALID_REGNUM;
+ reg_save (last_reg_save_label, reg, sreg, q->cfa_offset);
}
queued_reg_saves = NULL;
last_reg_save_label = NULL;
}
+/* Does INSN clobber any register which QUEUED_REG_SAVES lists a saved
+ location for? Or, does it clobber a register which we've previously
+ said that some other register is saved in, and for which we now
+ have a new location for? */
+
static bool
clobbers_queued_reg_save (rtx insn)
{
struct queued_reg_save *q;
for (q = queued_reg_saves; q; q = q->next)
- if (modified_in_p (q->reg, insn))
- return true;
+ {
+ size_t i;
+ if (modified_in_p (q->reg, insn))
+ return true;
+ for (i = 0; i < num_regs_saved_in_regs; i++)
+ if (REGNO (q->reg) == REGNO (regs_saved_in_regs[i].orig_reg)
+ && modified_in_p (regs_saved_in_regs[i].saved_in_reg, insn))
+ return true;
+ }
return false;
}
+/* What register, if any, is currently saved in REG? */
+
+static rtx
+reg_saved_in (rtx reg)
+{
+ unsigned int regn = REGNO (reg);
+ size_t i;
+ struct queued_reg_save *q;
+
+ for (q = queued_reg_saves; q; q = q->next)
+ if (q->saved_reg && regn == REGNO (q->saved_reg))
+ return q->reg;
+
+ for (i = 0; i < num_regs_saved_in_regs; i++)
+ if (regs_saved_in_regs[i].saved_in_reg
+ && regn == REGNO (regs_saved_in_regs[i].saved_in_reg))
+ return regs_saved_in_regs[i].orig_reg;
+
+ return NULL_RTX;
+}
+
/* A temporary register holding an integral value used in adjusting SP
or setting up the store_reg. The "offset" field holds the integer
/* Record call frame debugging information for an expression EXPR,
which either sets SP or FP (adjusting how we calculate the frame
- address) or saves a register to the stack. LABEL indicates the
- address of EXPR.
+ address) or saves a register to the stack or another register.
+ LABEL indicates the address of EXPR.
This function encodes a state machine mapping rtxes to actions on
cfa, cfa_store, and cfa_temp.reg. We describe these rules so
RTX_FRAME_RELATED_P is set on an insn which modifies memory, it's a
register save, and the register used to calculate the destination
had better be the one we think we're using for this purpose.
+ It's also assumed that a copy from a call-saved register to another
+ register is saving that register if RTX_FRAME_RELATED_P is set on
+ that instruction. If the copy is from a call-saved register to
+ the *same* register, that means that the register is now the same
+ value as in the caller.
Except: If the register being saved is the CFA register, and the
offset is nonzero, we are saving the CFA, so we assume we have to
use DW_CFA_def_cfa_expression. If the offset is 0, we assume that
the intent is to save the value of SP from the previous frame.
+ In addition, if a register has previously been saved to a different
+ register,
+
Invariants / Summaries of Rules
cfa current rule for calculating the CFA. It usually
src = SET_SRC (expr);
dest = SET_DEST (expr);
+ if (GET_CODE (src) == REG)
+ {
+ rtx rsi = reg_saved_in (src);
+ if (rsi)
+ src = rsi;
+ }
+
switch (GET_CODE (dest))
{
case REG:
- /* Rule 1 */
- /* Update the CFA rule wrt SP or FP. Make sure src is
- relative to the current CFA register. */
switch (GET_CODE (src))
{
/* Setting FP from SP. */
case REG:
if (cfa.reg == (unsigned) REGNO (src))
- /* OK. */
- ;
+ {
+ /* Rule 1 */
+ /* Update the CFA rule wrt SP or FP. Make sure src is
+ relative to the current CFA register.
+
+ We used to require that dest be either SP or FP, but the
+ ARM copies SP to a temporary register, and from there to
+ FP. So we just rely on the backends to only set
+ RTX_FRAME_RELATED_P on appropriate insns. */
+ cfa.reg = REGNO (dest);
+ cfa_temp.reg = cfa.reg;
+ cfa_temp.offset = cfa.offset;
+ }
+ else if (call_used_regs [REGNO (dest)]
+ && ! fixed_regs [REGNO (dest)])
+ {
+ /* Saving a register in a register. */
+ queue_reg_save (label, src, dest, 0);
+ }
else
abort ();
-
- /* We used to require that dest be either SP or FP, but the
- ARM copies SP to a temporary register, and from there to
- FP. So we just rely on the backends to only set
- RTX_FRAME_RELATED_P on appropriate insns. */
- cfa.reg = REGNO (dest);
- cfa_temp.reg = cfa.reg;
- cfa_temp.offset = cfa.offset;
break;
case PLUS:
if (! frame_pointer_needed)
abort ();
- if (GET_CODE (XEXP (src, 0)) == REG
+ if (REG_P (XEXP (src, 0))
&& (unsigned) REGNO (XEXP (src, 0)) == cfa.reg
&& GET_CODE (XEXP (src, 1)) == CONST_INT)
{
abort ();
/* Rule 4 */
- if (GET_CODE (XEXP (src, 0)) == REG
+ if (REG_P (XEXP (src, 0))
&& REGNO (XEXP (src, 0)) == cfa.reg
&& GET_CODE (XEXP (src, 1)) == CONST_INT)
{
}
/* Rule 5 */
- else if (GET_CODE (XEXP (src, 0)) == REG
+ else if (REG_P (XEXP (src, 0))
&& REGNO (XEXP (src, 0)) == cfa_temp.reg
&& XEXP (src, 1) == stack_pointer_rtx)
{
/* Rule 7 */
case IOR:
- if (GET_CODE (XEXP (src, 0)) != REG
+ if (!REG_P (XEXP (src, 0))
|| (unsigned) REGNO (XEXP (src, 0)) != cfa_temp.reg
|| GET_CODE (XEXP (src, 1)) != CONST_INT)
abort ();
break;
case MEM:
- if (GET_CODE (src) != REG)
+ if (!REG_P (src))
abort ();
/* Saving a register to the stack. Make sure dest is relative to the
we're saving SP like any other register; this happens
on the ARM. */
def_cfa_1 (label, &cfa);
- queue_reg_save (label, stack_pointer_rtx, offset);
+ queue_reg_save (label, stack_pointer_rtx, NULL_RTX, offset);
break;
}
else
calculate the CFA. */
rtx x = XEXP (dest, 0);
- if (GET_CODE (x) != REG)
+ if (!REG_P (x))
x = XEXP (x, 0);
- if (GET_CODE (x) != REG)
+ if (!REG_P (x))
abort ();
cfa.reg = REGNO (x);
}
def_cfa_1 (label, &cfa);
- queue_reg_save (label, src, offset);
+ queue_reg_save (label, src, NULL_RTX, offset);
break;
default:
if (insn == NULL_RTX)
{
+ size_t i;
+
/* Flush any queued register saves. */
flush_queued_reg_saves ();
cfa_store = cfa;
cfa_temp.reg = -1;
cfa_temp.offset = 0;
+
+ for (i = 0; i < num_regs_saved_in_regs; i++)
+ {
+ regs_saved_in_regs[i].orig_reg = NULL_RTX;
+ regs_saved_in_regs[i].saved_in_reg = NULL_RTX;
+ }
+ num_regs_saved_in_regs = 0;
return;
}
- if (GET_CODE (insn) != INSN || clobbers_queued_reg_save (insn))
+ if (!NONJUMP_INSN_P (insn) || clobbers_queued_reg_save (insn))
flush_queued_reg_saves ();
if (! RTX_FRAME_RELATED_P (insn))
#if defined (DWARF2_DEBUGGING_INFO) || defined (DWARF2_UNWIND_INFO)
+/* Map register numbers held in the call frame info that gcc has
+ collected using DWARF_FRAME_REGNUM to those that should be output in
+ .debug_frame and .eh_frame. */
+#ifndef DWARF2_FRAME_REG_OUT
+#define DWARF2_FRAME_REG_OUT(REGNO, FOR_EH) (REGNO)
+#endif
+
/* Output a Call Frame Information opcode and its operand(s). */
static void
output_cfi (dw_cfi_ref cfi, dw_fde_ref fde, int for_eh)
{
+ unsigned long r;
if (cfi->dw_cfi_opc == DW_CFA_advance_loc)
dw2_asm_output_data (1, (cfi->dw_cfi_opc
| (cfi->dw_cfi_oprnd1.dw_cfi_offset & 0x3f)),
cfi->dw_cfi_oprnd1.dw_cfi_offset);
else if (cfi->dw_cfi_opc == DW_CFA_offset)
{
- dw2_asm_output_data (1, (cfi->dw_cfi_opc
- | (cfi->dw_cfi_oprnd1.dw_cfi_reg_num & 0x3f)),
- "DW_CFA_offset, column 0x%lx",
- cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
+ r = DWARF2_FRAME_REG_OUT (cfi->dw_cfi_oprnd1.dw_cfi_reg_num, for_eh);
+ dw2_asm_output_data (1, (cfi->dw_cfi_opc | (r & 0x3f)),
+ "DW_CFA_offset, column 0x%lx", r);
dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_offset, NULL);
}
else if (cfi->dw_cfi_opc == DW_CFA_restore)
- dw2_asm_output_data (1, (cfi->dw_cfi_opc
- | (cfi->dw_cfi_oprnd1.dw_cfi_reg_num & 0x3f)),
- "DW_CFA_restore, column 0x%lx",
- cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
+ {
+ r = DWARF2_FRAME_REG_OUT (cfi->dw_cfi_oprnd1.dw_cfi_reg_num, for_eh);
+ dw2_asm_output_data (1, (cfi->dw_cfi_opc | (r & 0x3f)),
+ "DW_CFA_restore, column 0x%lx", r);
+ }
else
{
dw2_asm_output_data (1, cfi->dw_cfi_opc,
case DW_CFA_offset_extended:
case DW_CFA_def_cfa:
- dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num,
- NULL);
+ r = DWARF2_FRAME_REG_OUT (cfi->dw_cfi_oprnd1.dw_cfi_reg_num, for_eh);
+ dw2_asm_output_data_uleb128 (r, NULL);
dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_offset, NULL);
break;
case DW_CFA_offset_extended_sf:
case DW_CFA_def_cfa_sf:
- dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num,
- NULL);
+ r = DWARF2_FRAME_REG_OUT (cfi->dw_cfi_oprnd1.dw_cfi_reg_num, for_eh);
+ dw2_asm_output_data_uleb128 (r, NULL);
dw2_asm_output_data_sleb128 (cfi->dw_cfi_oprnd2.dw_cfi_offset, NULL);
break;
case DW_CFA_undefined:
case DW_CFA_same_value:
case DW_CFA_def_cfa_register:
- dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num,
- NULL);
+ r = DWARF2_FRAME_REG_OUT (cfi->dw_cfi_oprnd1.dw_cfi_reg_num, for_eh);
+ dw2_asm_output_data_uleb128 (r, NULL);
break;
case DW_CFA_register:
- dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num,
- NULL);
- dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_reg_num,
- NULL);
+ r = DWARF2_FRAME_REG_OUT (cfi->dw_cfi_oprnd1.dw_cfi_reg_num, for_eh);
+ dw2_asm_output_data_uleb128 (r, NULL);
+ r = DWARF2_FRAME_REG_OUT (cfi->dw_cfi_oprnd2.dw_cfi_reg_num, for_eh);
+ dw2_asm_output_data_uleb128 (r, NULL);
break;
case DW_CFA_def_cfa_offset:
}
}
-/* Output the call frame information used to used to record information
+/* Output the call frame information used to record information
that relates to calculating the frame pointer, and records the
location of saved registers. */
if (fde_table_in_use == 0)
return;
+ /* If we make FDEs linkonce, we may have to emit an empty label for
+ an FDE that wouldn't otherwise be emitted. We want to avoid
+ having an FDE kept around when the function it refers to is
+ discarded. (Example where this matters: a primary function
+ template in C++ requires EH information, but an explicit
+ specialization doesn't. */
+ if (TARGET_USES_WEAK_UNWIND_INFO
+ && ! flag_asynchronous_unwind_tables
+ && for_eh)
+ for (i = 0; i < fde_table_in_use; i++)
+ if ((fde_table[i].nothrow || fde_table[i].all_throwers_are_sibcalls)
+ && !fde_table[i].uses_eh_lsda
+ && ! DECL_ONE_ONLY (fde_table[i].decl))
+ targetm.asm_out.unwind_label (asm_out_file, fde_table[i].decl,
+ for_eh, /* empty */ 1);
+
/* If we don't have any functions we'll want to unwind out of, don't
emit any EH unwind information. Note that if exceptions aren't
enabled, we won't have collected nothrow information, and if we
for (i = 0; i < fde_table_in_use; i++)
if (fde_table[i].uses_eh_lsda)
any_eh_needed = any_lsda_needed = true;
+ else if (TARGET_USES_WEAK_UNWIND_INFO
+ && DECL_ONE_ONLY (fde_table[i].decl))
+ any_eh_needed = 1;
else if (! fde_table[i].nothrow
&& ! fde_table[i].all_throwers_are_sibcalls)
any_eh_needed = true;
app_enable ();
if (for_eh)
- (*targetm.asm_out.eh_frame_section) ();
+ targetm.asm_out.eh_frame_section ();
else
named_section_flags (DEBUG_FRAME_SECTION, SECTION_DEBUG);
P Indicates the presence of an encoding + language
personality routine in the CIE augmentation. */
- fde_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/1, /*global=*/0);
+ fde_encoding = TARGET_USES_WEAK_UNWIND_INFO
+ ? ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2, /*global=*/1)
+ : ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/1, /*global=*/0);
per_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2, /*global=*/1);
lsda_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/0);
dw2_asm_output_data_uleb128 (1, "CIE Code Alignment Factor");
dw2_asm_output_data_sleb128 (DWARF_CIE_DATA_ALIGNMENT,
"CIE Data Alignment Factor");
- dw2_asm_output_data (1, DWARF_FRAME_RETURN_COLUMN, "CIE RA Column");
+
+ if (DW_CIE_VERSION == 1)
+ dw2_asm_output_data (1, DWARF_FRAME_RETURN_COLUMN, "CIE RA Column");
+ else
+ dw2_asm_output_data_uleb128 (DWARF_FRAME_RETURN_COLUMN, "CIE RA Column");
if (augmentation[0])
{
/* Don't emit EH unwind info for leaf functions that don't need it. */
if (for_eh && !flag_asynchronous_unwind_tables && flag_exceptions
&& (fde->nothrow || fde->all_throwers_are_sibcalls)
+ && (! TARGET_USES_WEAK_UNWIND_INFO || ! DECL_ONE_ONLY (fde->decl))
&& !fde->uses_eh_lsda)
continue;
- (*targetm.asm_out.internal_label) (asm_out_file, FDE_LABEL, for_eh + i * 2);
+ targetm.asm_out.unwind_label (asm_out_file, fde->decl, for_eh, /* empty */ 0);
+ targetm.asm_out.internal_label (asm_out_file, FDE_LABEL, for_eh + i * 2);
ASM_GENERATE_INTERNAL_LABEL (l1, FDE_AFTER_SIZE_LABEL, for_eh + i * 2);
ASM_GENERATE_INTERNAL_LABEL (l2, FDE_END_LABEL, for_eh + i * 2);
dw2_asm_output_delta (for_eh ? 4 : DWARF_OFFSET_SIZE, l2, l1,
if (for_eh)
{
- dw2_asm_output_encoded_addr_rtx (fde_encoding,
- gen_rtx_SYMBOL_REF (Pmode, fde->dw_fde_begin),
- "FDE initial location");
+ if (TARGET_USES_WEAK_UNWIND_INFO
+ && DECL_ONE_ONLY (fde->decl))
+ dw2_asm_output_encoded_addr_rtx (fde_encoding,
+ gen_rtx_SYMBOL_REF (Pmode, IDENTIFIER_POINTER
+ (DECL_ASSEMBLER_NAME (fde->decl))),
+ "FDE initial location");
+ else
+ dw2_asm_output_encoded_addr_rtx (fde_encoding,
+ gen_rtx_SYMBOL_REF (Pmode, fde->dw_fde_begin),
+ "FDE initial location");
dw2_asm_output_delta (size_of_encoded_value (fde_encoding),
fde->dw_fde_end, fde->dw_fde_begin,
"FDE address range");
/* Add the new FDE at the end of the fde_table. */
fde = &fde_table[fde_table_in_use++];
+ fde->decl = current_function_decl;
fde->dw_fde_begin = xstrdup (label);
fde->dw_fde_current_label = NULL;
fde->dw_fde_end = NULL;
fde->dw_fde_cfi = NULL;
fde->funcdef_number = current_function_funcdef_no;
- fde->nothrow = current_function_nothrow;
+ fde->nothrow = TREE_NOTHROW (current_function_decl);
fde->uses_eh_lsda = cfun->uses_eh_lsda;
fde->all_throwers_are_sibcalls = cfun->all_throwers_are_sibcalls;
dw_val_class_const,
dw_val_class_unsigned_const,
dw_val_class_long_long,
- dw_val_class_float,
+ dw_val_class_vec,
dw_val_class_flag,
dw_val_class_die_ref,
dw_val_class_fde_ref,
}
dw_long_long_const;
-/* Describe a floating point constant value. */
+/* Describe a floating point constant value, or a vector constant value. */
-typedef struct dw_fp_struct GTY(())
+typedef struct dw_vec_struct GTY(())
{
- long * GTY((length ("%h.length"))) array;
+ unsigned char * GTY((length ("%h.length"))) array;
unsigned length;
+ unsigned elt_size;
}
-dw_float_const;
+dw_vec_const;
/* The dw_val_node describes an attribute's value, as it is
represented internally. */
unsigned HOST_WIDE_INT GTY ((tag ("dw_val_class_offset"))) val_offset;
dw_loc_list_ref GTY ((tag ("dw_val_class_loc_list"))) val_loc_list;
dw_loc_descr_ref GTY ((tag ("dw_val_class_loc"))) val_loc;
- HOST_WIDE_INT GTY ((default (""))) val_int;
+ HOST_WIDE_INT GTY ((default)) val_int;
unsigned HOST_WIDE_INT GTY ((tag ("dw_val_class_unsigned_const"))) val_unsigned;
dw_long_long_const GTY ((tag ("dw_val_class_long_long"))) val_long_long;
- dw_float_const GTY ((tag ("dw_val_class_float"))) val_float;
+ dw_vec_const GTY ((tag ("dw_val_class_vec"))) val_vec;
struct dw_val_die_union
{
dw_die_ref die;
static void dwarf2out_end_block (unsigned, unsigned);
static bool dwarf2out_ignore_block (tree);
static void dwarf2out_global_decl (tree);
+static void dwarf2out_type_decl (tree, int);
+static void dwarf2out_imported_module_or_decl (tree, tree);
static void dwarf2out_abstract_function (tree);
+static void dwarf2out_var_location (rtx);
+static void dwarf2out_begin_function (tree);
/* The debug hooks structure. */
dwarf2out_begin_prologue,
debug_nothing_int_charstar, /* end_prologue */
dwarf2out_end_epilogue,
- debug_nothing_tree, /* begin_function */
+ dwarf2out_begin_function,
debug_nothing_int, /* end_function */
dwarf2out_decl, /* function_decl */
dwarf2out_global_decl,
+ dwarf2out_type_decl, /* type_decl */
+ dwarf2out_imported_module_or_decl,
debug_nothing_tree, /* deferred_inline_function */
/* The DWARF 2 backend tries to reduce debugging bloat by not
emitting the abstract description of inline functions until
something tries to reference them. */
dwarf2out_abstract_function, /* outlining_inline_function */
debug_nothing_rtx, /* label */
- debug_nothing_int /* handle_pch */
+ debug_nothing_int, /* handle_pch */
+ dwarf2out_var_location
};
#endif
\f
dw_offset die_offset;
unsigned long die_abbrev;
int die_mark;
+ unsigned int decl_id;
}
die_node;
static GTY(()) varray_type file_table_emitted;
static GTY(()) size_t file_table_last_lookup_index;
-/* A pointer to the base of a table of references to DIE's that describe
- declarations. The table is indexed by DECL_UID() which is a unique
- number identifying each decl. */
-static GTY((length ("decl_die_table_allocated"))) dw_die_ref *decl_die_table;
+/* A hash table of references to DIE's that describe declarations.
+ The key is a DECL_UID() which is a unique number identifying each decl. */
+static GTY ((param_is (struct die_struct))) htab_t decl_die_table;
-/* Number of elements currently allocated for the decl_die_table. */
-static GTY(()) unsigned decl_die_table_allocated;
+/* Node of the variable location list. */
+struct var_loc_node GTY ((chain_next ("%h.next")))
+{
+ rtx GTY (()) var_loc_note;
+ const char * GTY (()) label;
+ struct var_loc_node * GTY (()) next;
+};
-/* Number of elements in decl_die_table currently in use. */
-static GTY(()) unsigned decl_die_table_in_use;
+/* Variable location list. */
+struct var_loc_list_def GTY (())
+{
+ struct var_loc_node * GTY (()) first;
-/* Size (in elements) of increments by which we may expand the
- decl_die_table. */
-#define DECL_DIE_TABLE_INCREMENT 256
+ /* Do not mark the last element of the chained list because
+ it is marked through the chain. */
+ struct var_loc_node * GTY ((skip ("%h"))) last;
+
+ /* DECL_UID of the variable decl. */
+ unsigned int decl_id;
+};
+typedef struct var_loc_list_def var_loc_list;
+
+
+/* Table of decl location linked lists. */
+static GTY ((param_is (var_loc_list))) htab_t decl_loc_table;
/* A pointer to the base of a list of references to DIE's that
are uniquely identified by their tag, presence/absence of
/* Whether we have location lists that need outputting */
static GTY(()) unsigned have_location_lists;
+/* Unique label counter. */
+static GTY(()) unsigned int loclabel_num;
+
#ifdef DWARF2_DEBUGGING_INFO
/* Record whether the function being analyzed contains inlined functions. */
static int current_function_has_inlines;
static inline unsigned HOST_WIDE_INT AT_unsigned (dw_attr_ref);
static void add_AT_long_long (dw_die_ref, enum dwarf_attribute, unsigned long,
unsigned long);
-static void add_AT_float (dw_die_ref, enum dwarf_attribute, unsigned, long *);
+static inline void add_AT_vec (dw_die_ref, enum dwarf_attribute, unsigned int,
+ unsigned int, unsigned char *);
static hashval_t debug_str_do_hash (const void *);
static int debug_str_eq (const void *, const void *);
static void add_AT_string (dw_die_ref, enum dwarf_attribute, const char *);
static bool is_fortran (void);
static bool is_ada (void);
static void remove_AT (dw_die_ref, enum dwarf_attribute);
+static void remove_child_TAG (dw_die_ref, enum dwarf_tag);
static inline void free_die (dw_die_ref);
static void remove_children (dw_die_ref);
static void add_child_die (dw_die_ref, dw_die_ref);
static dw_die_ref new_die (enum dwarf_tag, dw_die_ref, tree);
static dw_die_ref lookup_type_die (tree);
static void equate_type_number_to_die (tree, dw_die_ref);
+static hashval_t decl_die_table_hash (const void *);
+static int decl_die_table_eq (const void *, const void *);
static dw_die_ref lookup_decl_die (tree);
+static hashval_t decl_loc_table_hash (const void *);
+static int decl_loc_table_eq (const void *, const void *);
+static var_loc_list *lookup_decl_loc (tree);
static void equate_decl_number_to_die (tree, dw_die_ref);
+static void add_var_loc_to_decl (tree, struct var_loc_node *);
static void print_spaces (FILE *);
static void print_die (dw_die_ref, FILE *);
static void print_dwarf_line_table (FILE *);
static dw_die_ref base_type_die (tree);
static tree root_type (tree);
static int is_base_type (tree);
-static bool is_ada_subrange_type (tree);
+static bool is_subrange_type (tree);
static dw_die_ref subrange_type_die (tree, dw_die_ref);
static dw_die_ref modified_type_die (tree, int, int, dw_die_ref);
static int type_is_enum (tree);
-static unsigned int reg_number (rtx);
+static unsigned int dbx_reg_number (rtx);
static dw_loc_descr_ref reg_loc_descriptor (rtx);
static dw_loc_descr_ref one_reg_loc_descriptor (unsigned int);
static dw_loc_descr_ref multiple_reg_loc_descriptor (rtx, rtx);
static dw_loc_descr_ref int_loc_descriptor (HOST_WIDE_INT);
-static dw_loc_descr_ref based_loc_descr (unsigned, HOST_WIDE_INT);
+static dw_loc_descr_ref based_loc_descr (unsigned, HOST_WIDE_INT, bool);
static int is_based_loc (rtx);
-static dw_loc_descr_ref mem_loc_descriptor (rtx, enum machine_mode mode);
+static dw_loc_descr_ref mem_loc_descriptor (rtx, enum machine_mode mode, bool);
static dw_loc_descr_ref concat_loc_descriptor (rtx, rtx);
-static dw_loc_descr_ref loc_descriptor (rtx);
+static dw_loc_descr_ref loc_descriptor (rtx, bool);
static dw_loc_descr_ref loc_descriptor_from_tree (tree, int);
static HOST_WIDE_INT ceiling (HOST_WIDE_INT, unsigned int);
static tree field_type (tree);
dw_loc_descr_ref);
static void add_data_member_location_attribute (dw_die_ref, tree);
static void add_const_value_attribute (dw_die_ref, rtx);
+static void insert_int (HOST_WIDE_INT, unsigned, unsigned char *);
+static HOST_WIDE_INT extract_int (const unsigned char *, unsigned);
+static void insert_float (rtx, unsigned char *);
static rtx rtl_for_decl_location (tree);
-static void add_location_or_const_value_attribute (dw_die_ref, tree);
+static void add_location_or_const_value_attribute (dw_die_ref, tree,
+ enum dwarf_attribute);
static void tree_add_const_value_attribute (dw_die_ref, tree);
static void add_name_attribute (dw_die_ref, const char *);
static void add_comp_dir_attribute (dw_die_ref);
static int is_redundant_typedef (tree);
static void gen_namespace_die (tree);
static void gen_decl_die (tree, dw_die_ref);
-static dw_die_ref force_namespace_die (tree);
+static dw_die_ref force_decl_die (tree);
+static dw_die_ref force_type_die (tree);
static dw_die_ref setup_namespace_context (tree, dw_die_ref);
static void declare_in_namespace (tree, dw_die_ref);
static unsigned lookup_filename (const char *);
static inline int
is_pseudo_reg (rtx rtl)
{
- return ((GET_CODE (rtl) == REG && REGNO (rtl) >= FIRST_PSEUDO_REGISTER)
+ return ((REG_P (rtl) && REGNO (rtl) >= FIRST_PSEUDO_REGISTER)
|| (GET_CODE (rtl) == SUBREG
&& REGNO (SUBREG_REG (rtl)) >= FIRST_PSEUDO_REGISTER));
}
return "DW_TAG_variable";
case DW_TAG_volatile_type:
return "DW_TAG_volatile_type";
+ case DW_TAG_imported_module:
+ return "DW_TAG_imported_module";
case DW_TAG_MIPS_loop:
return "DW_TAG_MIPS_loop";
case DW_TAG_format_label:
/* Add a floating point attribute value to a DIE and return it. */
static inline void
-add_AT_float (dw_die_ref die, enum dwarf_attribute attr_kind,
- unsigned int length, long int *array)
+add_AT_vec (dw_die_ref die, enum dwarf_attribute attr_kind,
+ unsigned int length, unsigned int elt_size, unsigned char *array)
{
dw_attr_ref attr = ggc_alloc (sizeof (dw_attr_node));
attr->dw_attr_next = NULL;
attr->dw_attr = attr_kind;
- attr->dw_attr_val.val_class = dw_val_class_float;
- attr->dw_attr_val.v.val_float.length = length;
- attr->dw_attr_val.v.val_float.array = array;
+ attr->dw_attr_val.val_class = dw_val_class_vec;
+ attr->dw_attr_val.v.val_vec.length = length;
+ attr->dw_attr_val.v.val_vec.elt_size = elt_size;
+ attr->dw_attr_val.v.val_vec.array = array;
add_dwarf_attr (die, attr);
}
/* Get the attribute of type attr_kind. */
-static inline dw_attr_ref
+static dw_attr_ref
get_AT (dw_die_ref die, enum dwarf_attribute attr_kind)
{
dw_attr_ref a;
{
unsigned int lang = get_AT_unsigned (comp_unit_die, DW_AT_language);
- return lang == DW_LANG_Fortran77 || lang == DW_LANG_Fortran90;
+ return (lang == DW_LANG_Fortran77
+ || lang == DW_LANG_Fortran90
+ || lang == DW_LANG_Fortran95);
}
/* Return TRUE if the language is Java. */
}
}
+/* Remove child die whose die_tag is specified tag. */
+
+static void
+remove_child_TAG (dw_die_ref die, enum dwarf_tag tag)
+{
+ dw_die_ref current, prev, next;
+ current = die->die_child;
+ prev = NULL;
+ while (current != NULL)
+ {
+ if (current->die_tag == tag)
+ {
+ next = current->die_sib;
+ if (prev == NULL)
+ die->die_child = next;
+ else
+ prev->die_sib = next;
+ free_die (current);
+ current = next;
+ }
+ else
+ {
+ prev = current;
+ current = current->die_sib;
+ }
+ }
+}
+
/* Free up the memory used by DIE. */
static inline void
TYPE_SYMTAB_DIE (type) = type_die;
}
+/* Returns a hash value for X (which really is a die_struct). */
+
+static hashval_t
+decl_die_table_hash (const void *x)
+{
+ return (hashval_t) ((const dw_die_ref) x)->decl_id;
+}
+
+/* Return nonzero if decl_id of die_struct X is the same as UID of decl *Y. */
+
+static int
+decl_die_table_eq (const void *x, const void *y)
+{
+ return (((const dw_die_ref) x)->decl_id == DECL_UID ((const tree) y));
+}
+
/* Return the DIE associated with a given declaration. */
static inline dw_die_ref
lookup_decl_die (tree decl)
{
- unsigned decl_id = DECL_UID (decl);
+ return htab_find_with_hash (decl_die_table, decl, DECL_UID (decl));
+}
- return (decl_id < decl_die_table_in_use ? decl_die_table[decl_id] : NULL);
+/* Returns a hash value for X (which really is a var_loc_list). */
+
+static hashval_t
+decl_loc_table_hash (const void *x)
+{
+ return (hashval_t) ((const var_loc_list *) x)->decl_id;
+}
+
+/* Return nonzero if decl_id of var_loc_list X is the same as
+ UID of decl *Y. */
+
+static int
+decl_loc_table_eq (const void *x, const void *y)
+{
+ return (((const var_loc_list *) x)->decl_id == DECL_UID ((const tree) y));
+}
+
+/* Return the var_loc list associated with a given declaration. */
+
+static inline var_loc_list *
+lookup_decl_loc (tree decl)
+{
+ return htab_find_with_hash (decl_loc_table, decl, DECL_UID (decl));
}
/* Equate a DIE to a particular declaration. */
equate_decl_number_to_die (tree decl, dw_die_ref decl_die)
{
unsigned int decl_id = DECL_UID (decl);
- unsigned int num_allocated;
+ void **slot;
- if (decl_id >= decl_die_table_allocated)
- {
- num_allocated
- = ((decl_id + 1 + DECL_DIE_TABLE_INCREMENT - 1)
- / DECL_DIE_TABLE_INCREMENT)
- * DECL_DIE_TABLE_INCREMENT;
+ slot = htab_find_slot_with_hash (decl_die_table, decl, decl_id, INSERT);
+ *slot = decl_die;
+ decl_die->decl_id = decl_id;
+}
- decl_die_table = ggc_realloc (decl_die_table,
- sizeof (dw_die_ref) * num_allocated);
+/* Add a variable location node to the linked list for DECL. */
- memset (&decl_die_table[decl_die_table_allocated], 0,
- (num_allocated - decl_die_table_allocated) * sizeof (dw_die_ref));
- decl_die_table_allocated = num_allocated;
- }
+static void
+add_var_loc_to_decl (tree decl, struct var_loc_node *loc)
+{
+ unsigned int decl_id = DECL_UID (decl);
+ var_loc_list *temp;
+ void **slot;
- if (decl_id >= decl_die_table_in_use)
- decl_die_table_in_use = (decl_id + 1);
+ slot = htab_find_slot_with_hash (decl_loc_table, decl, decl_id, INSERT);
+ if (*slot == NULL)
+ {
+ temp = ggc_alloc_cleared (sizeof (var_loc_list));
+ temp->decl_id = decl_id;
+ *slot = temp;
+ }
+ else
+ temp = *slot;
- decl_die_table[decl_id] = decl_die;
+ if (temp->last)
+ {
+ /* If the current location is the same as the end of the list,
+ we have nothing to do. */
+ if (!rtx_equal_p (NOTE_VAR_LOCATION_LOC (temp->last->var_loc_note),
+ NOTE_VAR_LOCATION_LOC (loc->var_loc_note)))
+ {
+ /* Add LOC to the end of list and update LAST. */
+ temp->last->next = loc;
+ temp->last = loc;
+ }
+ }
+ /* Do not add empty location to the beginning of the list. */
+ else if (NOTE_VAR_LOCATION_LOC (loc->var_loc_note) != NULL_RTX)
+ {
+ temp->first = loc;
+ temp->last = loc;
+ }
}
\f
/* Keep track of the number of spaces used to indent the
a->dw_attr_val.v.val_long_long.hi,
a->dw_attr_val.v.val_long_long.low);
break;
- case dw_val_class_float:
- fprintf (outfile, "floating-point constant");
+ case dw_val_class_vec:
+ fprintf (outfile, "floating-point or vector constant");
break;
case dw_val_class_flag:
fprintf (outfile, "%u", AT_flag (a));
case dw_val_class_long_long:
CHECKSUM (at->dw_attr_val.v.val_long_long);
break;
- case dw_val_class_float:
- CHECKSUM (at->dw_attr_val.v.val_float);
+ case dw_val_class_vec:
+ CHECKSUM (at->dw_attr_val.v.val_vec);
break;
case dw_val_class_flag:
CHECKSUM (at->dw_attr_val.v.val_flag);
{
dw_loc_descr_ref loc1, loc2;
rtx r1, r2;
- unsigned i;
if (v1->val_class != v2->val_class)
return 0;
case dw_val_class_long_long:
return v1->v.val_long_long.hi == v2->v.val_long_long.hi
&& v1->v.val_long_long.low == v2->v.val_long_long.low;
- case dw_val_class_float:
- if (v1->v.val_float.length != v2->v.val_float.length)
+ case dw_val_class_vec:
+ if (v1->v.val_vec.length != v2->v.val_vec.length
+ || v1->v.val_vec.elt_size != v2->v.val_vec.elt_size)
+ return 0;
+ if (memcmp (v1->v.val_vec.array, v2->v.val_vec.array,
+ v1->v.val_vec.length * v1->v.val_vec.elt_size))
return 0;
- for (i = 0; i < v1->v.val_float.length; i++)
- if (v1->v.val_float.array[i] != v2->v.val_float.array[i])
- return 0;
return 1;
case dw_val_class_flag:
return v1->v.val_flag == v2->v.val_flag;
case dw_val_class_long_long:
size += 1 + 2*HOST_BITS_PER_LONG/HOST_BITS_PER_CHAR; /* block */
break;
- case dw_val_class_float:
- size += 1 + a->dw_attr_val.v.val_float.length * 4; /* block */
+ case dw_val_class_vec:
+ size += 1 + (a->dw_attr_val.v.val_vec.length
+ * a->dw_attr_val.v.val_vec.elt_size); /* block */
break;
case dw_val_class_flag:
size += 1;
}
case dw_val_class_long_long:
return DW_FORM_block1;
- case dw_val_class_float:
+ case dw_val_class_vec:
return DW_FORM_block1;
case dw_val_class_flag:
return DW_FORM_flag;
/* We make these global, not weak; if the target doesn't support
.linkonce, it doesn't support combining the sections, so debugging
will break. */
- (*targetm.asm_out.globalize_label) (asm_out_file, sym);
+ targetm.asm_out.globalize_label (asm_out_file, sym);
ASM_OUTPUT_LABEL (asm_out_file, sym);
}
ASM_OUTPUT_LABEL (asm_out_file, list_head->ll_symbol);
- /* ??? This shouldn't be needed now that we've forced the
- compilation unit base address to zero when there is code
- in more than one section. */
- if (strcmp (curr->section, ".text") == 0)
- {
- /* dw2_asm_output_data will mask off any extra bits in the ~0. */
- dw2_asm_output_data (DWARF2_ADDR_SIZE, ~(unsigned HOST_WIDE_INT) 0,
- "Location list base address specifier fake entry");
- dw2_asm_output_offset (DWARF2_ADDR_SIZE, curr->section,
- "Location list base address specifier base");
- }
-
+ /* Walk the location list, and output each range + expression. */
for (curr = list_head; curr != NULL; curr = curr->dw_loc_next)
{
unsigned long size;
-
- dw2_asm_output_delta (DWARF2_ADDR_SIZE, curr->begin, curr->section,
- "Location list begin address (%s)",
- list_head->ll_symbol);
- dw2_asm_output_delta (DWARF2_ADDR_SIZE, curr->end, curr->section,
- "Location list end address (%s)",
- list_head->ll_symbol);
+ if (separate_line_info_table_in_use == 0)
+ {
+ dw2_asm_output_delta (DWARF2_ADDR_SIZE, curr->begin, curr->section,
+ "Location list begin address (%s)",
+ list_head->ll_symbol);
+ dw2_asm_output_delta (DWARF2_ADDR_SIZE, curr->end, curr->section,
+ "Location list end address (%s)",
+ list_head->ll_symbol);
+ }
+ else
+ {
+ dw2_asm_output_addr (DWARF2_ADDR_SIZE, curr->begin,
+ "Location list begin address (%s)",
+ list_head->ll_symbol);
+ dw2_asm_output_addr (DWARF2_ADDR_SIZE, curr->end,
+ "Location list end address (%s)",
+ list_head->ll_symbol);
+ }
size = size_of_locs (curr->expr);
/* Output the block length for this list of location operations. */
output_loc_sequence (curr->expr);
}
- dw2_asm_output_data (DWARF_OFFSET_SIZE, 0,
+ dw2_asm_output_data (DWARF2_ADDR_SIZE, 0,
"Location list terminator begin (%s)",
list_head->ll_symbol);
- dw2_asm_output_data (DWARF_OFFSET_SIZE, 0,
+ dw2_asm_output_data (DWARF2_ADDR_SIZE, 0,
"Location list terminator end (%s)",
list_head->ll_symbol);
}
}
break;
- case dw_val_class_float:
+ case dw_val_class_vec:
{
+ unsigned int elt_size = a->dw_attr_val.v.val_vec.elt_size;
+ unsigned int len = a->dw_attr_val.v.val_vec.length;
unsigned int i;
+ unsigned char *p;
- dw2_asm_output_data (1, a->dw_attr_val.v.val_float.length * 4,
- "%s", name);
-
- for (i = 0; i < a->dw_attr_val.v.val_float.length; i++)
- dw2_asm_output_data (4, a->dw_attr_val.v.val_float.array[i],
- "fp constant word %u", i);
+ dw2_asm_output_data (1, len * elt_size, "%s", name);
+ if (elt_size > sizeof (HOST_WIDE_INT))
+ {
+ elt_size /= 2;
+ len *= 2;
+ }
+ for (i = 0, p = a->dw_attr_val.v.val_vec.array;
+ i < len;
+ i++, p += elt_size)
+ dw2_asm_output_data (elt_size, extract_int (p, elt_size),
+ "fp or vector constant word %u", i);
break;
}
if (sym == 0)
abort ();
- dw2_asm_output_delta (DWARF_OFFSET_SIZE, sym,
- loc_section_label, "%s", name);
+ dw2_asm_output_offset (DWARF_OFFSET_SIZE, sym, "%s", name);
}
break;
static const char *
dwarf2_name (tree decl, int scope)
{
- return (*lang_hooks.decl_printable_name) (decl, scope ? 1 : 0);
+ return lang_hooks.decl_printable_name (decl, scope ? 1 : 0);
}
/* Add a new entry to .debug_pubnames if appropriate. */
|| ! strcmp (type_name, "signed char")
|| ! strcmp (type_name, "unsigned char"))))
{
- if (TREE_UNSIGNED (type))
+ if (TYPE_UNSIGNED (type))
encoding = DW_ATE_unsigned;
else
encoding = DW_ATE_signed;
case CHAR_TYPE:
/* GNU Pascal/Ada CHAR type. Not used in C. */
- if (TREE_UNSIGNED (type))
+ if (TYPE_UNSIGNED (type))
encoding = DW_ATE_unsigned_char;
else
encoding = DW_ATE_signed_char;
emitted as a subrange type. */
static inline bool
-is_ada_subrange_type (tree type)
-{
- /* We should use a subrange type in the following situations:
- - For Ada modular types: These types are stored as integer subtypes
- of an unsigned integer type;
- - For subtypes of an Ada enumeration type: These types are stored
- as integer subtypes of enumeral types.
-
- This subrange type is mostly for the benefit of debugger users.
- A nameless type would therefore not be very useful, so no need
- to generate a subrange type in these cases. */
+is_subrange_type (tree type)
+{
tree subtype = TREE_TYPE (type);
- if (is_ada ()
- && TREE_CODE (type) == INTEGER_TYPE
- && TYPE_NAME (type) != NULL_TREE
- && subtype != NULL_TREE)
+ /* Subrange types are identified by the fact that they are integer
+ types, and that they have a subtype which is either an integer type
+ or an enumeral type. */
+
+ if (TREE_CODE (type) != INTEGER_TYPE
+ || subtype == NULL_TREE)
+ return false;
+
+ if (TREE_CODE (subtype) != INTEGER_TYPE
+ && TREE_CODE (subtype) != ENUMERAL_TYPE)
+ return false;
+
+ if (TREE_CODE (type) == TREE_CODE (subtype)
+ && int_size_in_bytes (type) == int_size_in_bytes (subtype)
+ && TYPE_MIN_VALUE (type) != NULL
+ && TYPE_MIN_VALUE (subtype) != NULL
+ && tree_int_cst_equal (TYPE_MIN_VALUE (type), TYPE_MIN_VALUE (subtype))
+ && TYPE_MAX_VALUE (type) != NULL
+ && TYPE_MAX_VALUE (subtype) != NULL
+ && tree_int_cst_equal (TYPE_MAX_VALUE (type), TYPE_MAX_VALUE (subtype)))
{
- if (TREE_CODE (subtype) == INTEGER_TYPE && TREE_UNSIGNED (subtype))
- return true;
- if (TREE_CODE (subtype) == ENUMERAL_TYPE)
- return true;
+ /* The type and its subtype have the same representation. If in
+ addition the two types also have the same name, then the given
+ type is not a subrange type, but rather a plain base type. */
+ /* FIXME: brobecker/2004-03-22:
+ Sizetype INTEGER_CSTs nodes are canonicalized. It should
+ therefore be sufficient to check the TYPE_SIZE node pointers
+ rather than checking the actual size. Unfortunately, we have
+ found some cases, such as in the Ada "integer" type, where
+ this is not the case. Until this problem is solved, we need to
+ keep checking the actual size. */
+ tree type_name = TYPE_NAME (type);
+ tree subtype_name = TYPE_NAME (subtype);
+
+ if (type_name != NULL && TREE_CODE (type_name) == TYPE_DECL)
+ type_name = DECL_NAME (type_name);
+
+ if (subtype_name != NULL && TREE_CODE (subtype_name) == TYPE_DECL)
+ subtype_name = DECL_NAME (subtype_name);
+
+ if (type_name == subtype_name)
+ return false;
}
- return false;
+
+ return true;
}
/* Given a pointer to a tree node for a subrange type, return a pointer
dw_die_ref subtype_die;
dw_die_ref subrange_die;
tree name = TYPE_NAME (type);
+ const HOST_WIDE_INT size_in_bytes = int_size_in_bytes (type);
+ tree subtype = TREE_TYPE (type);
if (context_die == NULL)
context_die = comp_unit_die;
- if (TREE_CODE (TREE_TYPE (type)) == ENUMERAL_TYPE)
- subtype_die = gen_enumeration_type_die (TREE_TYPE (type), context_die);
+ if (TREE_CODE (subtype) == ENUMERAL_TYPE)
+ subtype_die = gen_enumeration_type_die (subtype, context_die);
else
- subtype_die = base_type_die (TREE_TYPE (type));
-
- if (TREE_CODE (name) == TYPE_DECL)
- name = DECL_NAME (name);
+ subtype_die = base_type_die (subtype);
subrange_die = new_die (DW_TAG_subrange_type, context_die, type);
- add_name_attribute (subrange_die, IDENTIFIER_POINTER (name));
+
+ if (name != NULL)
+ {
+ if (TREE_CODE (name) == TYPE_DECL)
+ name = DECL_NAME (name);
+ add_name_attribute (subrange_die, IDENTIFIER_POINTER (name));
+ }
+
+ if (int_size_in_bytes (subtype) != size_in_bytes)
+ {
+ /* The size of the subrange type and its base type do not match,
+ so we need to generate a size attribute for the subrange type. */
+ add_AT_unsigned (subrange_die, DW_AT_byte_size, size_in_bytes);
+ }
+
if (TYPE_MIN_VALUE (type) != NULL)
add_bound_info (subrange_die, DW_AT_lower_bound,
TYPE_MIN_VALUE (type));
#endif
item_type = TREE_TYPE (type);
}
- else if (is_ada_subrange_type (type))
+ else if (is_subrange_type (type))
mod_type_die = subrange_type_die (type, context_die);
else if (is_base_type (type))
mod_type_die = base_type_die (type);
return TREE_CODE (type) == ENUMERAL_TYPE;
}
-/* Return the register number described by a given RTL node. */
+/* Return the DBX register number described by a given RTL node. */
static unsigned int
-reg_number (rtx rtl)
+dbx_reg_number (rtx rtl)
{
unsigned regno = REGNO (rtl);
if (REGNO (rtl) >= FIRST_PSEUDO_REGISTER)
return 0;
- reg = reg_number (rtl);
- regs = (*targetm.dwarf_register_span) (rtl);
+ reg = dbx_reg_number (rtl);
+ regs = targetm.dwarf_register_span (rtl);
- if (HARD_REGNO_NREGS (reg, GET_MODE (rtl)) > 1
+ if (hard_regno_nregs[REGNO (rtl)][GET_MODE (rtl)] > 1
|| regs)
return multiple_reg_loc_descriptor (rtl, regs);
else
unsigned reg;
dw_loc_descr_ref loc_result = NULL;
- reg = reg_number (rtl);
- nregs = HARD_REGNO_NREGS (reg, GET_MODE (rtl));
+ reg = dbx_reg_number (rtl);
+ nregs = hard_regno_nregs[REGNO (rtl)][GET_MODE (rtl)];
/* Simple, contiguous registers. */
if (regs == NULL_RTX)
/* Return a location descriptor that designates a base+offset location. */
static dw_loc_descr_ref
-based_loc_descr (unsigned int reg, HOST_WIDE_INT offset)
+based_loc_descr (unsigned int reg, HOST_WIDE_INT offset, bool can_use_fbreg)
{
dw_loc_descr_ref loc_result;
/* For the "frame base", we use the frame pointer or stack pointer
? HARD_FRAME_POINTER_REGNUM
: STACK_POINTER_REGNUM);
- if (reg == fp_reg)
+ if (reg == fp_reg && can_use_fbreg)
loc_result = new_loc_descr (DW_OP_fbreg, offset, 0);
else if (reg <= 31)
loc_result = new_loc_descr (DW_OP_breg0 + reg, offset, 0);
is_based_loc (rtx rtl)
{
return (GET_CODE (rtl) == PLUS
- && ((GET_CODE (XEXP (rtl, 0)) == REG
+ && ((REG_P (XEXP (rtl, 0))
&& REGNO (XEXP (rtl, 0)) < FIRST_PSEUDO_REGISTER
&& GET_CODE (XEXP (rtl, 1)) == CONST_INT)));
}
MODE is the mode of the memory reference, needed to handle some
autoincrement addressing modes.
+ CAN_USE_FBREG is a flag whether we can use DW_AT_frame_base in the location
+ list for RTL. We can't use it when we are emitting location list for
+ virtual variable frame_base_decl (i.e. a location list for DW_AT_frame_base)
+ which describes how frame base changes when !frame_pointer_needed.
+
Return 0 if we can't represent the location. */
static dw_loc_descr_ref
-mem_loc_descriptor (rtx rtl, enum machine_mode mode)
+mem_loc_descriptor (rtx rtl, enum machine_mode mode, bool can_use_fbreg)
{
dw_loc_descr_ref mem_loc_result = NULL;
+ enum dwarf_location_atom op;
/* Note that for a dynamically sized array, the location we will generate a
description of here will be the lowest numbered location which is
actually within the array. That's *not* necessarily the same as the
zeroth element of the array. */
- rtl = (*targetm.delegitimize_address) (rtl);
+ rtl = targetm.delegitimize_address (rtl);
switch (GET_CODE (rtl))
{
memory) so DWARF consumers need to be aware of the subtle
distinction between OP_REG and OP_BASEREG. */
if (REGNO (rtl) < FIRST_PSEUDO_REGISTER)
- mem_loc_result = based_loc_descr (reg_number (rtl), 0);
+ mem_loc_result = based_loc_descr (dbx_reg_number (rtl), 0,
+ can_use_fbreg);
break;
case MEM:
- mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl));
+ mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl),
+ can_use_fbreg);
if (mem_loc_result != 0)
add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_deref, 0, 0));
break;
case PLUS:
plus:
if (is_based_loc (rtl))
- mem_loc_result = based_loc_descr (reg_number (XEXP (rtl, 0)),
- INTVAL (XEXP (rtl, 1)));
+ mem_loc_result = based_loc_descr (dbx_reg_number (XEXP (rtl, 0)),
+ INTVAL (XEXP (rtl, 1)),
+ can_use_fbreg);
else
{
- mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), mode);
+ mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), mode,
+ can_use_fbreg);
if (mem_loc_result == 0)
break;
else
{
add_loc_descr (&mem_loc_result,
- mem_loc_descriptor (XEXP (rtl, 1), mode));
+ mem_loc_descriptor (XEXP (rtl, 1), mode,
+ can_use_fbreg));
add_loc_descr (&mem_loc_result,
new_loc_descr (DW_OP_plus, 0, 0));
}
}
break;
+ /* If a pseudo-reg is optimized away, it is possible for it to
+ be replaced with a MEM containing a multiply or shift. */
case MULT:
+ op = DW_OP_mul;
+ goto do_binop;
+
+ case ASHIFT:
+ op = DW_OP_shl;
+ goto do_binop;
+
+ case ASHIFTRT:
+ op = DW_OP_shra;
+ goto do_binop;
+
+ case LSHIFTRT:
+ op = DW_OP_shr;
+ goto do_binop;
+
+ do_binop:
{
- /* If a pseudo-reg is optimized away, it is possible for it to
- be replaced with a MEM containing a multiply. */
- dw_loc_descr_ref op0 = mem_loc_descriptor (XEXP (rtl, 0), mode);
- dw_loc_descr_ref op1 = mem_loc_descriptor (XEXP (rtl, 1), mode);
+ dw_loc_descr_ref op0 = mem_loc_descriptor (XEXP (rtl, 0), mode,
+ can_use_fbreg);
+ dw_loc_descr_ref op1 = mem_loc_descriptor (XEXP (rtl, 1), mode,
+ can_use_fbreg);
if (op0 == 0 || op1 == 0)
break;
mem_loc_result = op0;
add_loc_descr (&mem_loc_result, op1);
- add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_mul, 0, 0));
+ add_loc_descr (&mem_loc_result, new_loc_descr (op, 0, 0));
break;
}
mem_loc_result = int_loc_descriptor (INTVAL (rtl));
break;
- case ADDRESSOF:
- /* If this is a MEM, return its address. Otherwise, we can't
- represent this. */
- if (GET_CODE (XEXP (rtl, 0)) == MEM)
- return mem_loc_descriptor (XEXP (XEXP (rtl, 0), 0), mode);
- else
- return 0;
-
default:
abort ();
}
concat_loc_descriptor (rtx x0, rtx x1)
{
dw_loc_descr_ref cc_loc_result = NULL;
- dw_loc_descr_ref x0_ref = loc_descriptor (x0);
- dw_loc_descr_ref x1_ref = loc_descriptor (x1);
+ dw_loc_descr_ref x0_ref = loc_descriptor (x0, true);
+ dw_loc_descr_ref x1_ref = loc_descriptor (x1, true);
if (x0_ref == 0 || x1_ref == 0)
return 0;
If we don't know how to describe it, return 0. */
static dw_loc_descr_ref
-loc_descriptor (rtx rtl)
+loc_descriptor (rtx rtl, bool can_use_fbreg)
{
dw_loc_descr_ref loc_result = NULL;
break;
case MEM:
- loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl));
+ loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl),
+ can_use_fbreg);
break;
case CONCAT:
loc_result = concat_loc_descriptor (XEXP (rtl, 0), XEXP (rtl, 1));
break;
+ case VAR_LOCATION:
+ /* Single part. */
+ if (GET_CODE (XEXP (rtl, 1)) != PARALLEL)
+ {
+ loc_result = loc_descriptor (XEXP (XEXP (rtl, 1), 0), can_use_fbreg);
+ }
+ /* Multiple parts. */
+ else
+ {
+ rtvec par_elems = XVEC (XEXP (rtl, 1), 0);
+ int num_elem = GET_NUM_ELEM (par_elems);
+ enum machine_mode mode;
+ int i;
+
+ /* Create the first one, so we have something to add to. */
+ loc_result = loc_descriptor (XEXP (RTVEC_ELT (par_elems, 0), 0),
+ can_use_fbreg);
+ mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, 0), 0));
+ add_loc_descr (&loc_result,
+ new_loc_descr (DW_OP_piece, GET_MODE_SIZE (mode), 0));
+ for (i = 1; i < num_elem; i++)
+ {
+ dw_loc_descr_ref temp;
+
+ temp = loc_descriptor (XEXP (RTVEC_ELT (par_elems, i), 0),
+ can_use_fbreg);
+ add_loc_descr (&loc_result, temp);
+ mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, i), 0));
+ add_loc_descr (&loc_result,
+ new_loc_descr (DW_OP_piece,
+ GET_MODE_SIZE (mode), 0));
+ }
+ }
+ break;
+
default:
abort ();
}
{
dw_loc_descr_ref ret, ret1;
int indirect_p = 0;
- int unsignedp = TREE_UNSIGNED (TREE_TYPE (loc));
+ int unsignedp = TYPE_UNSIGNED (TREE_TYPE (loc));
enum dwarf_location_atom op;
/* ??? Most of the time we do not take proper care for sign/zero
case ERROR_MARK:
return 0;
- case WITH_RECORD_EXPR:
case PLACEHOLDER_EXPR:
/* This case involves extracting fields from an object to determine the
position of other fields. We don't try to encode this here. The
case CALL_EXPR:
return 0;
+ case PREINCREMENT_EXPR:
+ case PREDECREMENT_EXPR:
+ case POSTINCREMENT_EXPR:
+ case POSTDECREMENT_EXPR:
+ /* There are no opcodes for these operations. */
+ return 0;
+
case ADDR_EXPR:
/* We can support this only if we can look through conversions and
find an INDIRECT_EXPR. */
if (rtl == NULL_RTX)
return 0;
- if (GET_CODE (rtl) != MEM)
+ if (!MEM_P (rtl))
return 0;
rtl = XEXP (rtl, 0);
if (! CONSTANT_P (rtl))
/* Fall through. */
case PARM_DECL:
+ case RESULT_DECL:
{
rtx rtl = rtl_for_decl_location (loc);
{
enum machine_mode mode = GET_MODE (rtl);
- if (GET_CODE (rtl) == MEM)
+ if (MEM_P (rtl))
{
indirect_p = 1;
rtl = XEXP (rtl, 0);
}
- ret = mem_loc_descriptor (rtl, mode);
+ ret = mem_loc_descriptor (rtl, mode, true);
}
}
break;
rtx rtl = lookup_constant_def (loc);
enum machine_mode mode;
- if (GET_CODE (rtl) != MEM)
+ if (!MEM_P (rtl))
return 0;
mode = GET_MODE (rtl);
rtl = XEXP (rtl, 0);
- rtl = (*targetm.delegitimize_address) (rtl);
+ rtl = targetm.delegitimize_address (rtl);
indirect_p = 1;
- ret = mem_loc_descriptor (rtl, mode);
+ ret = mem_loc_descriptor (rtl, mode, true);
break;
}
goto do_binop;
case LE_EXPR:
- if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
+ if (TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
return 0;
op = DW_OP_le;
goto do_binop;
case GE_EXPR:
- if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
+ if (TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
return 0;
op = DW_OP_ge;
goto do_binop;
case LT_EXPR:
- if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
+ if (TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
return 0;
op = DW_OP_lt;
goto do_binop;
case GT_EXPR:
- if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
+ if (TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
return 0;
op = DW_OP_gt;
add_loc_descr (&ret, new_loc_descr (op, 0, 0));
break;
+ case MIN_EXPR:
case MAX_EXPR:
- loc = build (COND_EXPR, TREE_TYPE (loc),
- build (LT_EXPR, integer_type_node,
- TREE_OPERAND (loc, 0), TREE_OPERAND (loc, 1)),
- TREE_OPERAND (loc, 1), TREE_OPERAND (loc, 0));
+ {
+ const enum tree_code code =
+ TREE_CODE (loc) == MIN_EXPR ? GT_EXPR : LT_EXPR;
+
+ loc = build (COND_EXPR, TREE_TYPE (loc),
+ build (code, integer_type_node,
+ TREE_OPERAND (loc, 0), TREE_OPERAND (loc, 1)),
+ TREE_OPERAND (loc, 1), TREE_OPERAND (loc, 0));
+ }
/* ... fall through ... */
HOST_WIDE_INT offset;
dw_loc_descr_ref loc_descr = 0;
- if (TREE_CODE (decl) == TREE_VEC)
+ if (TREE_CODE (decl) == TREE_BINFO)
{
/* We're working on the TAG_inheritance for a base class. */
- if (TREE_VIA_VIRTUAL (decl) && is_cxx ())
+ if (BINFO_VIRTUAL_P (decl) && is_cxx ())
{
/* For C++ virtual bases we can't just use BINFO_OFFSET, as they
aren't at a fixed offset from all (sub)objects of the same
add_AT_loc (die, DW_AT_data_member_location, loc_descr);
}
+/* Writes integer values to dw_vec_const array. */
+
+static void
+insert_int (HOST_WIDE_INT val, unsigned int size, unsigned char *dest)
+{
+ while (size != 0)
+ {
+ *dest++ = val & 0xff;
+ val >>= 8;
+ --size;
+ }
+}
+
+/* Reads integers from dw_vec_const array. Inverse of insert_int. */
+
+static HOST_WIDE_INT
+extract_int (const unsigned char *src, unsigned int size)
+{
+ HOST_WIDE_INT val = 0;
+
+ src += size;
+ while (size != 0)
+ {
+ val <<= 8;
+ val |= *--src & 0xff;
+ --size;
+ }
+ return val;
+}
+
+/* Writes floating point values to dw_vec_const array. */
+
+static void
+insert_float (rtx rtl, unsigned char *array)
+{
+ REAL_VALUE_TYPE rv;
+ long val[4];
+ int i;
+
+ REAL_VALUE_FROM_CONST_DOUBLE (rv, rtl);
+ real_to_target (val, &rv, GET_MODE (rtl));
+
+ /* real_to_target puts 32-bit pieces in each long. Pack them. */
+ for (i = 0; i < GET_MODE_SIZE (GET_MODE (rtl)) / 4; i++)
+ {
+ insert_int (val[i], 4, array);
+ array += 4;
+ }
+}
+
/* Attach a DW_AT_const_value attribute for a variable or a parameter which
does not have a "location" either in memory or in a register. These
things can arise in GNU C when a constant is passed as an actual parameter
if (GET_MODE_CLASS (mode) == MODE_FLOAT)
{
- unsigned length = GET_MODE_SIZE (mode) / 4;
- long *array = ggc_alloc (sizeof (long) * length);
- REAL_VALUE_TYPE rv;
-
- REAL_VALUE_FROM_CONST_DOUBLE (rv, rtl);
- real_to_target (array, &rv, mode);
+ unsigned int length = GET_MODE_SIZE (mode);
+ unsigned char *array = ggc_alloc (length);
- add_AT_float (die, DW_AT_const_value, length, array);
+ insert_float (rtl, array);
+ add_AT_vec (die, DW_AT_const_value, length / 4, 4, array);
}
else
{
}
break;
+ case CONST_VECTOR:
+ {
+ enum machine_mode mode = GET_MODE (rtl);
+ unsigned int elt_size = GET_MODE_UNIT_SIZE (mode);
+ unsigned int length = CONST_VECTOR_NUNITS (rtl);
+ unsigned char *array = ggc_alloc (length * elt_size);
+ unsigned int i;
+ unsigned char *p;
+
+ if (GET_MODE_CLASS (mode) == MODE_VECTOR_INT)
+ {
+ for (i = 0, p = array; i < length; i++, p += elt_size)
+ {
+ rtx elt = CONST_VECTOR_ELT (rtl, i);
+ HOST_WIDE_INT lo, hi;
+ if (GET_CODE (elt) == CONST_INT)
+ {
+ lo = INTVAL (elt);
+ hi = -(lo < 0);
+ }
+ else if (GET_CODE (elt) == CONST_DOUBLE)
+ {
+ lo = CONST_DOUBLE_LOW (elt);
+ hi = CONST_DOUBLE_HIGH (elt);
+ }
+ else
+ abort ();
+
+ if (elt_size <= sizeof (HOST_WIDE_INT))
+ insert_int (lo, elt_size, p);
+ else if (elt_size == 2 * sizeof (HOST_WIDE_INT))
+ {
+ unsigned char *p0 = p;
+ unsigned char *p1 = p + sizeof (HOST_WIDE_INT);
+
+ if (WORDS_BIG_ENDIAN)
+ {
+ p0 = p1;
+ p1 = p;
+ }
+ insert_int (lo, sizeof (HOST_WIDE_INT), p0);
+ insert_int (hi, sizeof (HOST_WIDE_INT), p1);
+ }
+ else
+ abort ();
+ }
+ }
+ else if (GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT)
+ {
+ for (i = 0, p = array; i < length; i++, p += elt_size)
+ {
+ rtx elt = CONST_VECTOR_ELT (rtl, i);
+ insert_float (elt, p);
+ }
+ }
+ else
+ abort ();
+
+ add_AT_vec (die, DW_AT_const_value, length, elt_size, array);
+ }
+ break;
+
case CONST_STRING:
add_AT_string (die, DW_AT_const_value, XSTR (rtl, 0));
break;
This happens (for example) for inlined-instances of inline function formal
parameters which are never referenced. This really shouldn't be
happening. All PARM_DECL nodes should get valid non-NULL
- DECL_INCOMING_RTL values, but integrate.c doesn't currently generate these
- values for inlined instances of inline function parameters, so when we see
- such cases, we are just out-of-luck for the time being (until integrate.c
- gets fixed). */
+ DECL_INCOMING_RTL values. FIXME. */
/* Use DECL_RTL as the "location" unless we find something better. */
rtl = DECL_RTL_IF_SET (decl);
{
if (rtl
&& (CONSTANT_P (rtl)
- || (GET_CODE (rtl) == MEM
+ || (MEM_P (rtl)
&& CONSTANT_P (XEXP (rtl, 0)))
- || (GET_CODE (rtl) == REG
+ || (REG_P (rtl)
&& TREE_CODE (decl) == VAR_DECL
&& TREE_STATIC (decl))))
{
- rtl = (*targetm.delegitimize_address) (rtl);
+ rtl = targetm.delegitimize_address (rtl);
return rtl;
}
rtl = NULL_RTX;
we reach the big endian correction code there. It isn't clear if all
of these checks are necessary here, but keeping them all is the safe
thing to do. */
- else if (GET_CODE (rtl) == MEM
+ else if (MEM_P (rtl)
&& XEXP (rtl, 0) != const0_rtx
&& ! CONSTANT_P (XEXP (rtl, 0))
/* Not passed in memory. */
- && GET_CODE (DECL_INCOMING_RTL (decl)) != MEM
+ && !MEM_P (DECL_INCOMING_RTL (decl))
/* Not passed by invisible reference. */
- && (GET_CODE (XEXP (rtl, 0)) != REG
+ && (!REG_P (XEXP (rtl, 0))
|| REGNO (XEXP (rtl, 0)) == HARD_FRAME_POINTER_REGNUM
|| REGNO (XEXP (rtl, 0)) == STACK_POINTER_REGNUM
#if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
plus_constant (XEXP (rtl, 0), offset));
}
}
+ else if (TREE_CODE (decl) == VAR_DECL
+ && rtl
+ && MEM_P (rtl)
+ && GET_MODE (rtl) != TYPE_MODE (TREE_TYPE (decl))
+ && BYTES_BIG_ENDIAN)
+ {
+ int rsize = GET_MODE_SIZE (GET_MODE (rtl));
+ int dsize = GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (decl)));
+
+ /* If a variable is declared "register" yet is smaller than
+ a register, then if we store the variable to memory, it
+ looks like we're storing a register-sized value, when in
+ fact we are not. We need to adjust the offset of the
+ storage location to reflect the actual value's bytes,
+ else gdb will not be able to display it. */
+ if (rsize > dsize)
+ rtl = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (decl)),
+ plus_constant (XEXP (rtl, 0), rsize-dsize));
+ }
if (rtl != NULL_RTX)
{
rtl = expand_expr (DECL_INITIAL (decl), NULL_RTX, VOIDmode,
EXPAND_INITIALIZER);
/* If expand_expr returns a MEM, it wasn't immediate. */
- if (rtl && GET_CODE (rtl) == MEM)
+ if (rtl && MEM_P (rtl))
abort ();
}
}
if (rtl)
- rtl = (*targetm.delegitimize_address) (rtl);
+ rtl = targetm.delegitimize_address (rtl);
/* If we don't look past the constant pool, we risk emitting a
reference to a constant pool entry that isn't referenced from
function call evaluates to a compile-time constant address. */
static void
-add_location_or_const_value_attribute (dw_die_ref die, tree decl)
+add_location_or_const_value_attribute (dw_die_ref die, tree decl,
+ enum dwarf_attribute attr)
{
rtx rtl;
dw_loc_descr_ref descr;
+ var_loc_list *loc_list;
if (TREE_CODE (decl) == ERROR_MARK)
return;
- else if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != PARM_DECL)
+ else if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != PARM_DECL
+ && TREE_CODE (decl) != RESULT_DECL)
abort ();
+ /* See if we possibly have multiple locations for this variable. */
+ loc_list = lookup_decl_loc (decl);
+
+ /* If it truly has multiple locations, the first and last node will
+ differ. */
+ if (loc_list && loc_list->first != loc_list->last)
+ {
+ const char *secname;
+ const char *endname;
+ dw_loc_list_ref list;
+ rtx varloc;
+ struct var_loc_node *node;
+
+ /* We need to figure out what section we should use as the base
+ for the address ranges where a given location is valid.
+ 1. If this particular DECL has a section associated with it,
+ use that.
+ 2. If this function has a section associated with it, use
+ that.
+ 3. Otherwise, use the text section.
+ XXX: If you split a variable across multiple sections, this
+ won't notice. */
+
+ if (DECL_SECTION_NAME (decl))
+ {
+ tree sectree = DECL_SECTION_NAME (decl);
+ secname = TREE_STRING_POINTER (sectree);
+ }
+ else if (current_function_decl
+ && DECL_SECTION_NAME (current_function_decl))
+ {
+ tree sectree = DECL_SECTION_NAME (current_function_decl);
+ secname = TREE_STRING_POINTER (sectree);
+ }
+ else
+ secname = text_section_label;
+
+ /* Now that we know what section we are using for a base,
+ actually construct the list of locations.
+ The first location information is what is passed to the
+ function that creates the location list, and the remaining
+ locations just get added on to that list.
+ Note that we only know the start address for a location
+ (IE location changes), so to build the range, we use
+ the range [current location start, next location start].
+ This means we have to special case the last node, and generate
+ a range of [last location start, end of function label]. */
+
+ node = loc_list->first;
+ varloc = NOTE_VAR_LOCATION (node->var_loc_note);
+ list = new_loc_list (loc_descriptor (varloc, attr != DW_AT_frame_base),
+ node->label, node->next->label, secname, 1);
+ node = node->next;
+
+ for (; node->next; node = node->next)
+ if (NOTE_VAR_LOCATION_LOC (node->var_loc_note) != NULL_RTX)
+ {
+ /* The variable has a location between NODE->LABEL and
+ NODE->NEXT->LABEL. */
+ varloc = NOTE_VAR_LOCATION (node->var_loc_note);
+ add_loc_descr_to_loc_list (&list,
+ loc_descriptor (varloc,
+ attr != DW_AT_frame_base),
+ node->label, node->next->label, secname);
+ }
+
+ /* If the variable has a location at the last label
+ it keeps its location until the end of function. */
+ if (NOTE_VAR_LOCATION_LOC (node->var_loc_note) != NULL_RTX)
+ {
+ char label_id[MAX_ARTIFICIAL_LABEL_BYTES];
+
+ varloc = NOTE_VAR_LOCATION (node->var_loc_note);
+ if (!current_function_decl)
+ endname = text_end_label;
+ else
+ {
+ ASM_GENERATE_INTERNAL_LABEL (label_id, FUNC_END_LABEL,
+ current_function_funcdef_no);
+ endname = ggc_strdup (label_id);
+ }
+ add_loc_descr_to_loc_list (&list,
+ loc_descriptor (varloc,
+ attr != DW_AT_frame_base),
+ node->label, endname, secname);
+ }
+
+ /* Finally, add the location list to the DIE, and we are done. */
+ add_AT_loc_list (die, attr, list);
+ return;
+ }
+
rtl = rtl_for_decl_location (decl);
if (rtl == NULL_RTX)
return;
switch (GET_CODE (rtl))
{
- case ADDRESSOF:
- /* The address of a variable that was optimized away;
- don't emit anything. */
- break;
-
case CONST_INT:
case CONST_DOUBLE:
+ case CONST_VECTOR:
case CONST_STRING:
case SYMBOL_REF:
case LABEL_REF:
case REG:
case SUBREG:
case CONCAT:
- descr = loc_descriptor (rtl);
+ descr = loc_descriptor (rtl, true);
}
- add_AT_location_description (die, DW_AT_location, descr);
+ add_AT_location_description (die, attr, descr);
break;
case PARALLEL:
int i;
/* Create the first one, so we have something to add to. */
- descr = loc_descriptor (XEXP (RTVEC_ELT (par_elems, 0), 0));
+ descr = loc_descriptor (XEXP (RTVEC_ELT (par_elems, 0), 0), true);
mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, 0), 0));
add_loc_descr (&descr,
new_loc_descr (DW_OP_piece, GET_MODE_SIZE (mode), 0));
{
dw_loc_descr_ref temp;
- temp = loc_descriptor (XEXP (RTVEC_ELT (par_elems, i), 0));
+ temp = loc_descriptor (XEXP (RTVEC_ELT (par_elems, i), 0), true);
add_loc_descr (&descr, temp);
mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, i), 0));
add_loc_descr (&descr,
|| (bound_attr == DW_AT_lower_bound
&& (((is_c_family () || is_java ()) && integer_zerop (bound))
|| (is_fortran () && integer_onep (bound)))))
- /* use the default */
+ /* Use the default. */
;
else
add_AT_unsigned (subrange_die, bound_attr, tree_low_cst (bound, 0));
break;
case SAVE_EXPR:
- /* If optimization is turned on, the SAVE_EXPRs that describe how to
- access the upper bound values may be bogus. If they refer to a
- register, they may only describe how to get at these values at the
- points in the generated code right after they have just been
- computed. Worse yet, in the typical case, the upper bound values
- will not even *be* computed in the optimized code (though the
- number of elements will), so these SAVE_EXPRs are entirely
- bogus. In order to compensate for this fact, we check here to see
- if optimization is enabled, and if so, we don't add an attribute
- for the (unknown and unknowable) upper bound. This should not
- cause too much trouble for existing (stupid?) debuggers because
- they have to deal with empty upper bounds location descriptions
- anyway in order to be able to deal with incomplete array types.
- Of course an intelligent debugger (GDB?) should be able to
- comprehend that a missing upper bound specification in an array
- type used for a storage class `auto' local array variable
- indicates that the upper bound is both unknown (at compile- time)
- and unknowable (at run-time) due to optimization.
-
- We assume that a MEM rtx is safe because gcc wouldn't put the
- value there unless it was going to be used repeatedly in the
- function, i.e. for cleanups. */
- if (SAVE_EXPR_RTL (bound)
- && (! optimize || GET_CODE (SAVE_EXPR_RTL (bound)) == MEM))
- {
- dw_die_ref ctx = lookup_decl_die (current_function_decl);
- dw_die_ref decl_die = new_die (DW_TAG_variable, ctx, bound);
- rtx loc = SAVE_EXPR_RTL (bound);
-
- /* If the RTL for the SAVE_EXPR is memory, handle the case where
- it references an outer function's frame. */
- if (GET_CODE (loc) == MEM)
- {
- rtx new_addr = fix_lexical_addr (XEXP (loc, 0), bound);
-
- if (XEXP (loc, 0) != new_addr)
- loc = gen_rtx_MEM (GET_MODE (loc), new_addr);
- }
-
- add_AT_flag (decl_die, DW_AT_artificial, 1);
- add_type_attribute (decl_die, TREE_TYPE (bound), 1, 0, ctx);
- add_AT_location_description (decl_die, DW_AT_location,
- loc_descriptor (loc));
- add_AT_die_ref (subrange_die, bound_attr, decl_die);
- }
-
- /* Else leave out the attribute. */
break;
case VAR_DECL:
case PARM_DECL:
+ case RESULT_DECL:
{
dw_die_ref decl_die = lookup_decl_die (bound);
else
ctx = lookup_decl_die (current_function_decl);
- /* If we weren't able to find a context, it's most likely the case
- that we are processing the return type of the function. So
- make a SAVE_EXPR to point to it and have the limbo DIE code
- find the proper die. The save_expr function doesn't always
- make a SAVE_EXPR, so do it ourselves. */
- if (ctx == 0)
- bound = build (SAVE_EXPR, TREE_TYPE (bound), bound,
- current_function_decl, NULL_TREE);
-
decl_die = new_die (DW_TAG_variable, ctx, bound);
add_AT_flag (decl_die, DW_AT_artificial, 1);
add_type_attribute (decl_die, TREE_TYPE (bound), 1, 0, ctx);
static void
add_src_coords_attributes (dw_die_ref die, tree decl)
{
- unsigned file_index = lookup_filename (DECL_SOURCE_FILE (decl));
+ expanded_location s = expand_location (DECL_SOURCE_LOCATION (decl));
+ unsigned file_index = lookup_filename (s.file);
add_AT_unsigned (die, DW_AT_decl_file, file_index);
- add_AT_unsigned (die, DW_AT_decl_line, DECL_SOURCE_LINE (decl));
+ add_AT_unsigned (die, DW_AT_decl_line, s.line);
}
/* Add a DW_AT_name attribute and source coordinate attribute for the
const char *fnname;
x = DECL_RTL (decl);
- if (GET_CODE (x) != MEM)
+ if (!MEM_P (x))
abort ();
x = XEXP (x, 0);
if (type_die->die_parent == NULL)
add_child_die (scope_die_for (type, context_die), type_die);
- for (link = TYPE_FIELDS (type);
+ for (link = TYPE_VALUES (type);
link != NULL; link = TREE_CHAIN (link))
{
dw_die_ref enum_die = new_die (DW_TAG_enumerator, type_die, link);
+ tree value = TREE_VALUE (link);
add_name_attribute (enum_die,
IDENTIFIER_POINTER (TREE_PURPOSE (link)));
- if (host_integerp (TREE_VALUE (link),
- TREE_UNSIGNED (TREE_TYPE (TREE_VALUE (link)))))
- {
- if (tree_int_cst_sgn (TREE_VALUE (link)) < 0)
- add_AT_int (enum_die, DW_AT_const_value,
- tree_low_cst (TREE_VALUE (link), 0));
- else
- add_AT_unsigned (enum_die, DW_AT_const_value,
- tree_low_cst (TREE_VALUE (link), 1));
- }
+ if (host_integerp (value, TYPE_UNSIGNED (TREE_TYPE (value))))
+ /* DWARF2 does not provide a way of indicating whether or
+ not enumeration constants are signed or unsigned. GDB
+ always assumes the values are signed, so we output all
+ values as if they were signed. That means that
+ enumeration constants with very large unsigned values
+ will appear to have negative values in the debugger. */
+ add_AT_int (enum_die, DW_AT_const_value,
+ tree_low_cst (value, tree_int_cst_sgn (value) > 0));
}
}
else
equate_decl_number_to_die (node, parm_die);
if (! DECL_ABSTRACT (node))
- add_location_or_const_value_attribute (parm_die, node);
+ add_location_or_const_value_attribute (parm_die, node, DW_AT_location);
break;
}
else if (old_die)
{
- unsigned file_index = lookup_filename (DECL_SOURCE_FILE (decl));
+ expanded_location s = expand_location (DECL_SOURCE_LOCATION (decl));
+ unsigned file_index = lookup_filename (s.file);
if (!get_AT_flag (old_die, DW_AT_declaration)
/* We can have a normal definition following an inline one in the
&& (DECL_ARTIFICIAL (decl)
|| (get_AT_unsigned (old_die, DW_AT_decl_file) == file_index
&& (get_AT_unsigned (old_die, DW_AT_decl_line)
- == (unsigned) DECL_SOURCE_LINE (decl)))))
+ == (unsigned) s.line))))
{
subr_die = old_die;
- /* Clear out the declaration attribute and the parm types. */
+ /* Clear out the declaration attribute and the formal parameters.
+ Do not remove all children, because it is possible that this
+ declaration die was forced using force_decl_die(). In such
+ cases die that forced declaration die (e.g. TAG_imported_module)
+ is one of the children that we do not want to remove. */
remove_AT (subr_die, DW_AT_declaration);
- remove_children (subr_die);
+ remove_child_TAG (subr_die, DW_TAG_formal_parameter);
}
else
{
if (get_AT_unsigned (old_die, DW_AT_decl_file) != file_index)
add_AT_unsigned (subr_die, DW_AT_decl_file, file_index);
if (get_AT_unsigned (old_die, DW_AT_decl_line)
- != (unsigned) DECL_SOURCE_LINE (decl))
+ != (unsigned) s.line)
add_AT_unsigned
- (subr_die, DW_AT_decl_line, DECL_SOURCE_LINE (decl));
+ (subr_die, DW_AT_decl_line, s.line);
}
}
else
/* The first time we see a member function, it is in the context of
the class to which it belongs. We make sure of this by emitting
the class first. The next time is the definition, which is
- handled above. The two may come from the same source text. */
- if (DECL_CONTEXT (decl) || DECL_ABSTRACT (decl))
+ handled above. The two may come from the same source text.
+
+ Note that force_decl_die() forces function declaration die. It is
+ later reused to represent definition. */
equate_decl_number_to_die (decl, subr_die);
}
}
/* Define the "frame base" location for this routine. We use the
frame pointer or stack pointer registers, since the RTL for local
variables is relative to one of them. */
- 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));
+ if (frame_base_decl && lookup_decl_loc (frame_base_decl) != NULL)
+ {
+ add_location_or_const_value_attribute (subr_die, frame_base_decl,
+ DW_AT_frame_base);
+ }
+ else
+ {
+ 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));
+ }
-#if 0
- /* ??? This fails for nested inline functions, because context_display
- is not part of the state saved/restored for inline functions. */
- if (current_function_needs_context)
+ if (cfun->static_chain_decl)
add_AT_location_description (subr_die, DW_AT_static_link,
- loc_descriptor (lookup_static_chain (decl)));
-#endif
+ loc_descriptor_from_tree (cfun->static_chain_decl, 0));
}
/* Now output descriptions of the arguments for this function. This gets
constructor function. */
if (! declaration && TREE_CODE (outer_scope) != ERROR_MARK)
{
+ /* Emit a DW_TAG_variable DIE for a named return value. */
+ if (DECL_NAME (DECL_RESULT (decl)))
+ gen_decl_die (DECL_RESULT (decl), subr_die);
+
current_function_has_inlines = 0;
decls_for_scope (outer_scope, subr_die, 0);
add_AT_specification (var_die, old_die);
if (DECL_NAME (decl))
{
- unsigned file_index = lookup_filename (DECL_SOURCE_FILE (decl));
+ expanded_location s = expand_location (DECL_SOURCE_LOCATION (decl));
+ unsigned file_index = lookup_filename (s.file);
if (get_AT_unsigned (old_die, DW_AT_decl_file) != file_index)
add_AT_unsigned (var_die, DW_AT_decl_file, file_index);
if (get_AT_unsigned (old_die, DW_AT_decl_line)
- != (unsigned) DECL_SOURCE_LINE (decl))
+ != (unsigned) s.line)
- add_AT_unsigned (var_die, DW_AT_decl_line,
- DECL_SOURCE_LINE (decl));
+ add_AT_unsigned (var_die, DW_AT_decl_line, s.line);
}
}
else
if (declaration)
add_AT_flag (var_die, DW_AT_declaration, 1);
- if (class_or_namespace_scope_p (context_die) || DECL_ABSTRACT (decl))
+ if (DECL_ABSTRACT (decl) || declaration)
equate_decl_number_to_die (decl, var_die);
if (! declaration && ! DECL_ABSTRACT (decl))
{
- add_location_or_const_value_attribute (var_die, decl);
+ add_location_or_const_value_attribute (var_die, decl, DW_AT_location);
add_pubname (decl, var_die);
}
else
eliminated because of various optimizations. We still emit them
here so that it is possible to put breakpoints on them. */
if (insn
- && (GET_CODE (insn) == CODE_LABEL
- || ((GET_CODE (insn) == NOTE
+ && (LABEL_P (insn)
+ || ((NOTE_P (insn)
&& NOTE_LINE_NUMBER (insn) == NOTE_INSN_DELETED_LABEL))))
{
/* When optimization is enabled (via -O) some parts of the compiler
language = DW_LANG_Ada95;
else if (strcmp (language_string, "GNU F77") == 0)
language = DW_LANG_Fortran77;
+ else if (strcmp (language_string, "GNU F95") == 0)
+ language = DW_LANG_Fortran95;
else if (strcmp (language_string, "GNU Pascal") == 0)
language = DW_LANG_Pascal83;
else if (strcmp (language_string, "GNU Java") == 0)
add_type_attribute (die, BINFO_TYPE (binfo), 0, 0, context_die);
add_data_member_location_attribute (die, binfo);
- if (TREE_VIA_VIRTUAL (binfo))
+ if (BINFO_VIRTUAL_P (binfo))
add_AT_unsigned (die, DW_AT_virtuality, DW_VIRTUALITY_virtual);
if (access == access_public_node)
the TREE node representing the appropriate (containing) type. */
/* First output info about the base classes. */
- if (binfo && BINFO_BASETYPES (binfo))
+ if (binfo && BINFO_BASE_BINFOS (binfo))
{
- tree bases = BINFO_BASETYPES (binfo);
- tree accesses = BINFO_BASEACCESSES (binfo);
+ tree bases = BINFO_BASE_BINFOS (binfo);
+ tree accesses = BINFO_BASE_ACCESSES (binfo);
int n_bases = TREE_VEC_LENGTH (bases);
int i;
return 0;
}
-/* Returns the DIE for namespace NS or aborts.
+/* Returns the DIE for decl or aborts. */
- Note that namespaces don't really have a lexical context, so there's no
- need to pass in a context_die. They always go inside their containing
- namespace, or comp_unit_die if none. */
+static dw_die_ref
+force_decl_die (tree decl)
+{
+ dw_die_ref decl_die;
+ unsigned saved_external_flag;
+ tree save_fn = NULL_TREE;
+ decl_die = lookup_decl_die (decl);
+ if (!decl_die)
+ {
+ dw_die_ref context_die;
+ tree decl_context = DECL_CONTEXT (decl);
+ if (decl_context)
+ {
+ /* Find die that represents this context. */
+ if (TYPE_P (decl_context))
+ context_die = force_type_die (decl_context);
+ else
+ context_die = force_decl_die (decl_context);
+ }
+ else
+ context_die = comp_unit_die;
+
+ switch (TREE_CODE (decl))
+ {
+ case FUNCTION_DECL:
+ /* Clear current_function_decl, so that gen_subprogram_die thinks
+ that this is a declaration. At this point, we just want to force
+ declaration die. */
+ save_fn = current_function_decl;
+ current_function_decl = NULL_TREE;
+ gen_subprogram_die (decl, context_die);
+ current_function_decl = save_fn;
+ break;
+
+ case VAR_DECL:
+ /* Set external flag to force declaration die. Restore it after
+ gen_decl_die() call. */
+ saved_external_flag = DECL_EXTERNAL (decl);
+ DECL_EXTERNAL (decl) = 1;
+ gen_decl_die (decl, context_die);
+ DECL_EXTERNAL (decl) = saved_external_flag;
+ break;
+
+ case NAMESPACE_DECL:
+ dwarf2out_decl (decl);
+ break;
+
+ default:
+ abort ();
+ }
+
+ /* See if we can find the die for this deci now.
+ If not then abort. */
+ if (!decl_die)
+ decl_die = lookup_decl_die (decl);
+ if (!decl_die)
+ abort ();
+ }
+
+ return decl_die;
+}
+
+/* Returns the DIE for decl or aborts. */
static dw_die_ref
-force_namespace_die (tree ns)
+force_type_die (tree type)
{
- dw_die_ref ns_die;
+ dw_die_ref type_die;
- dwarf2out_decl (ns);
- ns_die = lookup_decl_die (ns);
- if (!ns_die)
- abort();
+ type_die = lookup_type_die (type);
+ if (!type_die)
+ {
+ dw_die_ref context_die;
+ if (TYPE_CONTEXT (type))
+ if (TYPE_P (TYPE_CONTEXT (type)))
+ context_die = force_type_die (TYPE_CONTEXT (type));
+ else
+ context_die = force_decl_die (TYPE_CONTEXT (type));
+ else
+ context_die = comp_unit_die;
- return ns_die;
+ gen_type_die (type, context_die);
+ type_die = lookup_type_die (type);
+ if (!type_die)
+ abort();
+ }
+ return type_die;
}
/* Force out any required namespaces to be able to output DECL,
tree context = DECL_P (thing) ? DECL_CONTEXT (thing) : TYPE_CONTEXT (thing);
if (context && TREE_CODE (context) == NAMESPACE_DECL)
/* Force out the namespace. */
- context_die = force_namespace_die (context);
+ context_die = force_decl_die (context);
return context_die;
}
dw_die_ref context_die = setup_namespace_context (decl, comp_unit_die);
/* Namespace aliases have a DECL_ABSTRACT_ORIGIN of the namespace
- they are an alias of. */
+ they are an alias of. */
if (DECL_ABSTRACT_ORIGIN (decl) == NULL)
{
/* Output a real namespace. */
/* Force out the namespace we are an alias of, if necessary. */
dw_die_ref origin_die
- = force_namespace_die (DECL_ABSTRACT_ORIGIN (decl));
+ = force_decl_die (DECL_ABSTRACT_ORIGIN (decl));
/* Now create the namespace alias DIE. */
dw_die_ref namespace_die
&& (current_function_decl == NULL_TREE || DECL_ARTIFICIAL (decl)))
break;
+#if 0
+ /* FIXME */
+ /* This doesn't work because the C frontend sets DECL_ABSTRACT_ORIGIN
+ on local redeclarations of global functions. That seems broken. */
+ if (current_function_decl != decl)
+ /* This is only a declaration. */;
+#endif
+
/* If we're emitting a clone, emit info for the abstract instance. */
if (DECL_ORIGIN (decl) != decl)
dwarf2out_abstract_function (DECL_ABSTRACT_ORIGIN (decl));
break;
case VAR_DECL:
+ case RESULT_DECL:
/* If we are in terse mode, don't generate any DIEs to represent any
variable declarations or definitions. */
if (debug_info_level <= DINFO_LEVEL_TERSE)
case FIELD_DECL:
/* Ignore the nameless fields that are used to skip bits but handle C++
- anonymous unions. */
+ anonymous unions and structs. */
if (DECL_NAME (decl) != NULL_TREE
- || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE)
+ || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE
+ || TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE)
{
gen_type_die (member_declared_type (decl), context_die);
gen_field_die (decl, context_die);
dwarf2out_decl (decl);
}
+/* Output debug information for type decl DECL. Called from toplev.c
+ and from language front ends (to record built-in types). */
+static void
+dwarf2out_type_decl (tree decl, int local)
+{
+ if (!local)
+ dwarf2out_decl (decl);
+}
+
+/* Output debug information for imported module or decl. */
+
+static void
+dwarf2out_imported_module_or_decl (tree decl, tree context)
+{
+ dw_die_ref imported_die, at_import_die;
+ dw_die_ref scope_die;
+ unsigned file_index;
+ expanded_location xloc;
+
+ if (debug_info_level <= DINFO_LEVEL_TERSE)
+ return;
+
+ if (!decl)
+ abort ();
+
+ /* To emit DW_TAG_imported_module or DW_TAG_imported_decl, we need two DIEs.
+ We need decl DIE for reference and scope die. First, get DIE for the decl
+ itself. */
+
+ /* Get the scope die for decl context. Use comp_unit_die for global module
+ or decl. If die is not found for non globals, force new die. */
+ if (!context)
+ scope_die = comp_unit_die;
+ else if (TYPE_P (context))
+ scope_die = force_type_die (context);
+ else
+ scope_die = force_decl_die (context);
+
+ /* For TYPE_DECL or CONST_DECL, lookup TREE_TYPE. */
+ if (TREE_CODE (decl) == TYPE_DECL || TREE_CODE (decl) == CONST_DECL)
+ at_import_die = force_type_die (TREE_TYPE (decl));
+ else
+ at_import_die = force_decl_die (decl);
+
+ /* OK, now we have DIEs for decl as well as scope. Emit imported die. */
+ if (TREE_CODE (decl) == NAMESPACE_DECL)
+ imported_die = new_die (DW_TAG_imported_module, scope_die, context);
+ else
+ imported_die = new_die (DW_TAG_imported_declaration, scope_die, context);
+
+ xloc = expand_location (input_location);
+ file_index = lookup_filename (xloc.file);
+ add_AT_unsigned (imported_die, DW_AT_decl_file, file_index);
+ add_AT_unsigned (imported_die, DW_AT_decl_line, xloc.line);
+ add_AT_die_ref (imported_die, DW_AT_import, at_import_die);
+}
+
/* Write the debugging output for DECL. */
void
return;
case FUNCTION_DECL:
- /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of a
- builtin function. Explicit programmer-supplied declarations of
- these same functions should NOT be ignored however. */
- if (DECL_EXTERNAL (decl) && DECL_BUILT_IN (decl))
- return;
-
/* What we would really like to do here is to filter out all mere
file-scope declarations of file-scope functions which are never
referenced later within this translation unit (and keep all of ones
/* Don't bother trying to generate any DIEs to represent any of the
normal built-in types for the language we are compiling. */
- if (DECL_SOURCE_LINE (decl) == 0)
+ if (DECL_IS_BUILTIN (decl))
{
/* OK, we need to generate one for `bool' so GDB knows what type
comparisons have. */
file_table_last_lookup_index = 0;
}
+/* Called by the final INSN scan whenever we see a var location. We
+ use it to drop labels in the right places, and throw the location in
+ our lookup table. */
+
+static void
+dwarf2out_var_location (rtx loc_note)
+{
+ char loclabel[MAX_ARTIFICIAL_LABEL_BYTES];
+ struct var_loc_node *newloc;
+ rtx prev_insn;
+ static rtx last_insn;
+ static const char *last_label;
+
+ if (!DECL_P (NOTE_VAR_LOCATION_DECL (loc_note)))
+ return;
+ prev_insn = PREV_INSN (loc_note);
+
+ newloc = ggc_alloc_cleared (sizeof (struct var_loc_node));
+ /* If the insn we processed last time is the previous insn
+ and it is also a var location note, use the label we emitted
+ last time. */
+ if (last_insn != NULL_RTX
+ && last_insn == prev_insn
+ && NOTE_P (prev_insn)
+ && NOTE_LINE_NUMBER (prev_insn) == NOTE_INSN_VAR_LOCATION)
+ {
+ newloc->label = last_label;
+ }
+ else
+ {
+ ASM_GENERATE_INTERNAL_LABEL (loclabel, "LVL", loclabel_num);
+ ASM_OUTPUT_DEBUG_LABEL (asm_out_file, "LVL", loclabel_num);
+ loclabel_num++;
+ newloc->label = ggc_strdup (loclabel);
+ }
+ newloc->var_loc_note = loc_note;
+ newloc->next = NULL;
+
+ last_insn = loc_note;
+ last_label = newloc->label;
+
+ add_var_loc_to_decl (NOTE_VAR_LOCATION_DECL (loc_note), newloc);
+}
+
+/* We need to reset the locations at the beginning of each
+ function. We can't do this in the end_function hook, because the
+ declarations that use the locations won't have been outputted when
+ that hook is called. */
+
+static void
+dwarf2out_begin_function (tree unused ATTRIBUTE_UNUSED)
+{
+ htab_empty (decl_loc_table);
+}
+
/* Output a label to mark the beginning of a source code line entry
and record information relating to this source line, in
'line_info_table' for later output of the .debug_line section. */
else if (DECL_SECTION_NAME (current_function_decl))
{
dw_separate_line_info_ref line_info;
- (*targetm.asm_out.internal_label) (asm_out_file, SEPARATE_LINE_CODE_LABEL,
+ targetm.asm_out.internal_label (asm_out_file, SEPARATE_LINE_CODE_LABEL,
separate_line_info_table_in_use);
- /* expand the line info table if necessary */
+ /* Expand the line info table if necessary. */
if (separate_line_info_table_in_use
== separate_line_info_table_allocated)
{
{
dw_line_info_ref line_info;
- (*targetm.asm_out.internal_label) (asm_out_file, LINE_CODE_LABEL,
+ targetm.asm_out.internal_label (asm_out_file, LINE_CODE_LABEL,
line_info_table_in_use);
/* Expand the line info table if necessary. */
{
init_file_table ();
- /* Allocate the initial hunk of the decl_die_table. */
- decl_die_table = ggc_alloc_cleared (DECL_DIE_TABLE_INCREMENT
- * sizeof (dw_die_ref));
- decl_die_table_allocated = DECL_DIE_TABLE_INCREMENT;
- decl_die_table_in_use = 0;
+ /* Allocate the decl_die_table. */
+ decl_die_table = htab_create_ggc (10, decl_die_table_hash,
+ decl_die_table_eq, NULL);
+
+ /* Allocate the decl_loc_table. */
+ decl_loc_table = htab_create_ggc (10, decl_loc_table_hash,
+ decl_loc_table_eq, NULL);
/* Allocate the initial hunk of the decl_scope_table. */
VARRAY_TREE_INIT (decl_scope_table, 256, "decl_scope_table");
add_child_die (origin->die_parent, die);
else if (die == comp_unit_die)
;
- /* If this was an expression for a bound involved in a function
- return type, it may be a SAVE_EXPR for which we weren't able
- to find a DIE previously. So try now. */
- else if (node->created_for
- && TREE_CODE (node->created_for) == SAVE_EXPR
- && 0 != (origin = (lookup_decl_die
- (SAVE_EXPR_CONTEXT
- (node->created_for)))))
- add_child_die (origin, die);
else if (errorcount > 0 || sorrycount > 0)
/* It's OK to be confused by errors in the input. */
add_child_die (comp_unit_die, die);
/* Output a terminator label for the .text section. */
text_section ();
- (*targetm.asm_out.internal_label) (asm_out_file, TEXT_END_LABEL, 0);
+ targetm.asm_out.internal_label (asm_out_file, TEXT_END_LABEL, 0);
/* Output the source line correspondence table. We must do this
even if there is no line information. Otherwise, on an empty