summaryrefslogtreecommitdiffstats
path: root/contrib/gcc/dwarf2out.c
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2002-02-01 18:16:02 +0000
committerobrien <obrien@FreeBSD.org>2002-02-01 18:16:02 +0000
commitc9ab9ae440a8066b2c2b85b157b1fdadcf09916a (patch)
tree086d9d6c8fbd4fc8fe4495059332f66bc0f8d12b /contrib/gcc/dwarf2out.c
parent2ecfd8bd04b63f335c1ec6295740a4bfd97a4fa6 (diff)
downloadFreeBSD-src-c9ab9ae440a8066b2c2b85b157b1fdadcf09916a.zip
FreeBSD-src-c9ab9ae440a8066b2c2b85b157b1fdadcf09916a.tar.gz
Enlist the FreeBSD-CURRENT users as testers of what is to become Gcc 3.1.0.
These bits are taken from the FSF anoncvs repo on 1-Feb-2002 08:20 PST.
Diffstat (limited to 'contrib/gcc/dwarf2out.c')
-rw-r--r--contrib/gcc/dwarf2out.c11377
1 files changed, 6725 insertions, 4652 deletions
diff --git a/contrib/gcc/dwarf2out.c b/contrib/gcc/dwarf2out.c
index 7ce8050..526766b 100644
--- a/contrib/gcc/dwarf2out.c
+++ b/contrib/gcc/dwarf2out.c
@@ -1,26 +1,32 @@
/* Output Dwarf2 format symbol table information from the GNU C compiler.
- Copyright (C) 1992, 1993, 1995, 1996, 1997, 1998, 1999, 2000 Free Software
- Foundation, Inc.
+ Copyright (C) 1992, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+ 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).
-This file is part of GNU CC.
+This file is part of GCC.
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
+along with GCC; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
+
+/* TODO: Emit .debug_line header even when there are no functions, since
+ the file numbers are used by .debug_info. Alternately, leave
+ out locations for types and decls.
+ Avoid talking about ctors and op= for PODs.
+ Factor out common prologue sequences into multiple CIEs. */
/* The first part of this file deals with the DWARF 2 frame unwind
information, which is also used by the GCC efficient exception handling
@@ -30,7 +36,6 @@ Boston, MA 02111-1307, USA. */
#include "config.h"
#include "system.h"
-#include "defaults.h"
#include "tree.h"
#include "flags.h"
#include "rtl.h"
@@ -38,23 +43,47 @@ Boston, MA 02111-1307, USA. */
#include "regs.h"
#include "insn-config.h"
#include "reload.h"
+#include "function.h"
#include "output.h"
#include "expr.h"
+#include "libfuncs.h"
#include "except.h"
#include "dwarf2.h"
#include "dwarf2out.h"
+#include "dwarf2asm.h"
#include "toplev.h"
-#include "dyn-string.h"
+#include "varray.h"
+#include "ggc.h"
+#include "md5.h"
+#include "tm_p.h"
+#include "diagnostic.h"
+#include "debug.h"
+#include "target.h"
+#include "langhooks.h"
+#include "hashtable.h"
-/* We cannot use <assert.h> in GCC source, since that would include
- GCC's assert.h, which may not be compatible with the host compiler. */
-#undef assert
-#ifdef NDEBUG
-# define assert(e)
-#else
-# define assert(e) do { if (! (e)) abort (); } while (0)
+#ifdef DWARF2_DEBUGGING_INFO
+static void dwarf2out_source_line PARAMS ((unsigned int, const char *));
#endif
+/* DWARF2 Abbreviation Glossary:
+ CFA = Canonical Frame Address
+ a fixed address on the stack which identifies a call frame.
+ We define it to be the value of SP just before the call insn.
+ The CFA register and offset, which may change during the course
+ of the function, are used to calculate its value at runtime.
+ CFI = Call Frame Instruction
+ an instruction for the DWARF2 abstract machine
+ CIE = Common Information Entry
+ information describing information common to one or more FDEs
+ DIE = Debugging Information Entry
+ FDE = Frame Description Entry
+ information describing the stack call frame, in particular,
+ how to restore registers
+
+ DW_CFA_... = DWARF2 CFA call frame instruction
+ DW_TAG_... = DWARF2 DIE tag */
+
/* Decide whether we want to emit frame unwind information for the current
translation unit. */
@@ -62,15 +91,48 @@ int
dwarf2out_do_frame ()
{
return (write_symbols == DWARF2_DEBUG
+ || write_symbols == VMS_AND_DWARF2_DEBUG
#ifdef DWARF2_FRAME_INFO
- || DWARF2_FRAME_INFO
+ || DWARF2_FRAME_INFO
#endif
#ifdef DWARF2_UNWIND_INFO
- || (flag_exceptions && ! exceptions_via_longjmp)
+ || flag_unwind_tables
+ || (flag_exceptions && ! USING_SJLJ_EXCEPTIONS)
#endif
);
}
+/* The number of the current function definition for which debugging
+ information is being generated. These numbers range from 1 up to the
+ maximum number of function definitions contained within the current
+ compilation unit. These numbers are used to create unique label id's
+ unique to each function definition. */
+unsigned current_funcdef_number = 0;
+
+/* The size of the target's pointer type. */
+#ifndef PTR_SIZE
+#define PTR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
+#endif
+
+/* Default version of targetm.eh_frame_section. Note this must appear
+ outside the DWARF2_DEBUGGING_INFO || DWARF2_UNWIND_INFO macro
+ guards. */
+
+void
+default_eh_frame_section ()
+{
+#ifdef EH_FRAME_SECTION_NAME
+ named_section_flags (EH_FRAME_SECTION_NAME, SECTION_WRITE);
+#else
+ tree label = get_file_function_name ('F');
+
+ data_section ();
+ ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE));
+ ASM_GLOBALIZE_LABEL (asm_out_file, IDENTIFIER_POINTER (label));
+ ASM_OUTPUT_LABEL (asm_out_file, IDENTIFIER_POINTER (label));
+#endif
+}
+
#if defined (DWARF2_DEBUGGING_INFO) || defined (DWARF2_UNWIND_INFO)
/* How to start an assembler comment. */
@@ -91,7 +153,8 @@ typedef union dw_cfi_oprnd_struct
{
unsigned long dw_cfi_reg_num;
long int dw_cfi_offset;
- char *dw_cfi_addr;
+ const char *dw_cfi_addr;
+ struct dw_loc_descr_struct *dw_cfi_loc;
}
dw_cfi_oprnd;
@@ -104,39 +167,53 @@ typedef struct dw_cfi_struct
}
dw_cfi_node;
+/* This is how we define the location of the CFA. We use to handle it
+ as REG + OFFSET all the time, but now it can be more complex.
+ It can now be either REG + CFA_OFFSET or *(REG + BASE_OFFSET) + CFA_OFFSET.
+ Instead of passing around REG and OFFSET, we pass a copy
+ of this structure. */
+typedef struct cfa_loc
+{
+ unsigned long reg;
+ long offset;
+ long base_offset;
+ int indirect; /* 1 if CFA is accessed via a dereference. */
+} dw_cfa_location;
+
/* All call frame descriptions (FDE's) in the GCC generated DWARF
refer to a single Common Information Entry (CIE), defined at
- the beginning of the .debug_frame section. This used of a single
+ the beginning of the .debug_frame section. This use of a single
CIE obviates the need to keep track of multiple CIE's
in the DWARF generation routines below. */
typedef struct dw_fde_struct
{
- char *dw_fde_begin;
- char *dw_fde_current_label;
- char *dw_fde_end;
+ const char *dw_fde_begin;
+ const char *dw_fde_current_label;
+ const char *dw_fde_end;
dw_cfi_ref dw_fde_cfi;
+ unsigned funcdef_number;
+ unsigned nothrow : 1;
+ unsigned uses_eh_lsda : 1;
}
dw_fde_node;
-/* Maximum size (in bytes) of an artificially generated label. */
+/* Maximum size (in bytes) of an artificially generated label. */
#define MAX_ARTIFICIAL_LABEL_BYTES 30
-/* Make sure we know the sizes of the various types dwarf can describe. These
- are only defaults. If the sizes are different for your target, you should
- override these values by defining the appropriate symbols in your tm.h
- file. */
-
-#ifndef CHAR_TYPE_SIZE
-#define CHAR_TYPE_SIZE BITS_PER_UNIT
-#endif
-#ifndef PTR_SIZE
-#define PTR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
+/* The size of addresses as they appear in the Dwarf 2 data.
+ Some architectures use word addresses to refer to code locations,
+ but Dwarf 2 info always uses byte addresses. On such machines,
+ Dwarf 2 addresses need to be larger than the architecture's
+ pointers. */
+#ifndef DWARF2_ADDR_SIZE
+#define DWARF2_ADDR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
#endif
/* The size in bytes of a DWARF field indicating an offset or length
- relative to a debug info section, specified to be 4 bytes in the DWARF-2
- specification. The SGI/MIPS ABI defines it to be the same as PTR_SIZE. */
+ relative to a debug info section, specified to be 4 bytes in the
+ DWARF-2 specification. The SGI/MIPS ABI defines it to be the same
+ as PTR_SIZE. */
#ifndef DWARF_OFFSET_SIZE
#define DWARF_OFFSET_SIZE 4
@@ -146,13 +223,15 @@ dw_fde_node;
/* Round SIZE up to the nearest BOUNDARY. */
#define DWARF_ROUND(SIZE,BOUNDARY) \
- (((SIZE) + (BOUNDARY) - 1) & ~((BOUNDARY) - 1))
+ ((((SIZE) + (BOUNDARY) - 1) / (BOUNDARY)) * (BOUNDARY))
/* Offsets recorded in opcodes are a multiple of this alignment factor. */
+#ifndef DWARF_CIE_DATA_ALIGNMENT
#ifdef STACK_GROWS_DOWNWARD
-#define DWARF_CIE_DATA_ALIGNMENT (-UNITS_PER_WORD)
+#define DWARF_CIE_DATA_ALIGNMENT (-((int) UNITS_PER_WORD))
#else
-#define DWARF_CIE_DATA_ALIGNMENT UNITS_PER_WORD
+#define DWARF_CIE_DATA_ALIGNMENT ((int) UNITS_PER_WORD)
+#endif
#endif
/* A pointer to the base of a table that contains frame description
@@ -172,60 +251,56 @@ static unsigned fde_table_in_use;
/* A list of call frame insns for the CIE. */
static dw_cfi_ref cie_cfi_head;
-/* The number of the current function definition for which debugging
- information is being generated. These numbers range from 1 up to the
- maximum number of function definitions contained within the current
- compilation unit. These numbers are used to create unique label id's
- unique to each function definition. */
-static unsigned current_funcdef_number = 0;
-
/* Some DWARF extensions (e.g., MIPS/SGI) implement a subprogram
attribute that accelerates the lookup of the FDE associated
- with the subprogram. This variable holds the table index of the FDE
+ with the subprogram. This variable holds the table index of the FDE
associated with the current function (body) definition. */
static unsigned current_funcdef_fde;
+struct ht *debug_str_hash;
+
+struct indirect_string_node
+{
+ struct ht_identifier id;
+ unsigned int refcount;
+ unsigned int form;
+ char *label;
+};
+
/* Forward declarations for functions defined in this file. */
-static char *stripattributes PROTO((char *));
-static char *dwarf_cfi_name PROTO((unsigned));
-static dw_cfi_ref new_cfi PROTO((void));
-static void add_cfi PROTO((dw_cfi_ref *, dw_cfi_ref));
-static unsigned long size_of_uleb128 PROTO((unsigned long));
-static unsigned long size_of_sleb128 PROTO((long));
-static void output_uleb128 PROTO((unsigned long));
-static void output_sleb128 PROTO((long));
-static void add_fde_cfi PROTO((char *, dw_cfi_ref));
-static void lookup_cfa_1 PROTO((dw_cfi_ref, unsigned long *,
- long *));
-static void lookup_cfa PROTO((unsigned long *, long *));
-static void reg_save PROTO((char *, unsigned, unsigned,
- long));
-static void initial_return_save PROTO((rtx));
-static void output_cfi PROTO((dw_cfi_ref, dw_fde_ref));
-static void output_call_frame_info PROTO((int));
-static unsigned reg_number PROTO((rtx));
-static void dwarf2out_stack_adjust PROTO((rtx));
-
-/* Definitions of defaults for assembler-dependent names of various
- pseudo-ops and section names.
- Theses may be overridden in the tm.h file (if necessary) for a particular
- assembler. */
-
-#ifdef OBJECT_FORMAT_ELF
-#ifndef UNALIGNED_SHORT_ASM_OP
-#define UNALIGNED_SHORT_ASM_OP ".2byte"
-#endif
-#ifndef UNALIGNED_INT_ASM_OP
-#define UNALIGNED_INT_ASM_OP ".4byte"
-#endif
-#ifndef UNALIGNED_DOUBLE_INT_ASM_OP
-#define UNALIGNED_DOUBLE_INT_ASM_OP ".8byte"
-#endif
-#endif /* OBJECT_FORMAT_ELF */
+static char *stripattributes PARAMS ((const char *));
+static const char *dwarf_cfi_name PARAMS ((unsigned));
+static dw_cfi_ref new_cfi PARAMS ((void));
+static void add_cfi PARAMS ((dw_cfi_ref *, dw_cfi_ref));
+static void add_fde_cfi PARAMS ((const char *, dw_cfi_ref));
+static void lookup_cfa_1 PARAMS ((dw_cfi_ref,
+ dw_cfa_location *));
+static void lookup_cfa PARAMS ((dw_cfa_location *));
+static void reg_save PARAMS ((const char *, unsigned,
+ unsigned, long));
+static void initial_return_save PARAMS ((rtx));
+static long stack_adjust_offset PARAMS ((rtx));
+static void output_cfi PARAMS ((dw_cfi_ref, dw_fde_ref, int));
+static void output_call_frame_info PARAMS ((int));
+static void dwarf2out_stack_adjust PARAMS ((rtx));
+static void queue_reg_save PARAMS ((const char *, rtx, long));
+static void flush_queued_reg_saves PARAMS ((void));
+static bool clobbers_queued_reg_save PARAMS ((rtx));
+static void dwarf2out_frame_debug_expr PARAMS ((rtx, const char *));
+
+/* Support for complex CFA locations. */
+static void output_cfa_loc PARAMS ((dw_cfi_ref));
+static void get_cfa_from_loc_descr PARAMS ((dw_cfa_location *,
+ struct dw_loc_descr_struct *));
+static struct dw_loc_descr_struct *build_cfa_loc
+ PARAMS ((dw_cfa_location *));
+static void def_cfa_1 PARAMS ((const char *,
+ dw_cfa_location *));
-#ifndef ASM_BYTE_OP
-#define ASM_BYTE_OP ".byte"
+/* How to start an assembler comment. */
+#ifndef ASM_COMMENT_START
+#define ASM_COMMENT_START ";#"
#endif
/* Data and reference forms for relocatable data. */
@@ -234,228 +309,44 @@ static void dwarf2out_stack_adjust PROTO((rtx));
/* Pseudo-op for defining a new section. */
#ifndef SECTION_ASM_OP
-#define SECTION_ASM_OP ".section"
-#endif
-
-/* The default format used by the ASM_OUTPUT_SECTION macro (see below) to
- print the SECTION_ASM_OP and the section name. The default here works for
- almost all svr4 assemblers, except for the sparc, where the section name
- must be enclosed in double quotes. (See sparcv4.h). */
-#ifndef SECTION_FORMAT
-#ifdef PUSHSECTION_FORMAT
-#define SECTION_FORMAT PUSHSECTION_FORMAT
-#else
-#define SECTION_FORMAT "\t%s\t%s\n"
-#endif
+#define SECTION_ASM_OP "\t.section\t"
#endif
-#ifndef FRAME_SECTION
-#define FRAME_SECTION ".debug_frame"
+#ifndef DEBUG_FRAME_SECTION
+#define DEBUG_FRAME_SECTION ".debug_frame"
#endif
#ifndef FUNC_BEGIN_LABEL
#define FUNC_BEGIN_LABEL "LFB"
#endif
+
#ifndef FUNC_END_LABEL
#define FUNC_END_LABEL "LFE"
#endif
+
+#define FRAME_BEGIN_LABEL "Lframe"
#define CIE_AFTER_SIZE_LABEL "LSCIE"
#define CIE_END_LABEL "LECIE"
#define CIE_LENGTH_LABEL "LLCIE"
-#define FDE_AFTER_SIZE_LABEL "LSFDE"
+#define FDE_LABEL "LSFDE"
+#define FDE_AFTER_SIZE_LABEL "LASFDE"
#define FDE_END_LABEL "LEFDE"
#define FDE_LENGTH_LABEL "LLFDE"
+#define LINE_NUMBER_BEGIN_LABEL "LSLT"
+#define LINE_NUMBER_END_LABEL "LELT"
+#define LN_PROLOG_AS_LABEL "LASLTP"
+#define LN_PROLOG_END_LABEL "LELTP"
+#define DIE_LABEL_PREFIX "DW"
/* Definitions of defaults for various types of primitive assembly language
output operations. These may be overridden from within the tm.h file,
but typically, that is unnecessary. */
-#ifndef ASM_OUTPUT_SECTION
-#define ASM_OUTPUT_SECTION(FILE, SECTION) \
- fprintf ((FILE), SECTION_FORMAT, SECTION_ASM_OP, SECTION)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_DATA1
-#define ASM_OUTPUT_DWARF_DATA1(FILE,VALUE) \
- fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) (VALUE))
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_DELTA1
-#define ASM_OUTPUT_DWARF_DELTA1(FILE,LABEL1,LABEL2) \
- do { fprintf ((FILE), "\t%s\t", ASM_BYTE_OP); \
- assemble_name (FILE, LABEL1); \
- fprintf (FILE, "-"); \
- assemble_name (FILE, LABEL2); \
- } while (0)
-#endif
-
-#ifdef UNALIGNED_INT_ASM_OP
-
-#ifndef UNALIGNED_OFFSET_ASM_OP
-#define UNALIGNED_OFFSET_ASM_OP \
- (DWARF_OFFSET_SIZE == 8 ? UNALIGNED_DOUBLE_INT_ASM_OP : UNALIGNED_INT_ASM_OP)
-#endif
-
-#ifndef UNALIGNED_WORD_ASM_OP
-#define UNALIGNED_WORD_ASM_OP \
- (PTR_SIZE == 8 ? UNALIGNED_DOUBLE_INT_ASM_OP : UNALIGNED_INT_ASM_OP)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_DELTA2
-#define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2) \
- do { fprintf ((FILE), "\t%s\t", UNALIGNED_SHORT_ASM_OP); \
- assemble_name (FILE, LABEL1); \
- fprintf (FILE, "-"); \
- assemble_name (FILE, LABEL2); \
- } while (0)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_DELTA4
-#define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2) \
- do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
- assemble_name (FILE, LABEL1); \
- fprintf (FILE, "-"); \
- assemble_name (FILE, LABEL2); \
- } while (0)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_DELTA
-#define ASM_OUTPUT_DWARF_DELTA(FILE,LABEL1,LABEL2) \
- do { fprintf ((FILE), "\t%s\t", UNALIGNED_OFFSET_ASM_OP); \
- assemble_name (FILE, LABEL1); \
- fprintf (FILE, "-"); \
- assemble_name (FILE, LABEL2); \
- } while (0)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_ADDR_DELTA
-#define ASM_OUTPUT_DWARF_ADDR_DELTA(FILE,LABEL1,LABEL2) \
- do { fprintf ((FILE), "\t%s\t", UNALIGNED_WORD_ASM_OP); \
- assemble_name (FILE, LABEL1); \
- fprintf (FILE, "-"); \
- assemble_name (FILE, LABEL2); \
- } while (0)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_ADDR
-#define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \
- do { fprintf ((FILE), "\t%s\t", UNALIGNED_WORD_ASM_OP); \
- assemble_name (FILE, LABEL); \
- } while (0)
-#endif
-
-/* ??? This macro takes an RTX in dwarfout.c and a string in dwarf2out.c.
- We resolve the conflict by creating a new macro ASM_OUTPUT_DWARF2_ADDR_CONST
- for ports that want to support both DWARF1 and DWARF2. This needs a better
- solution. See also the comments in sparc/sp64-elf.h. */
-#ifdef ASM_OUTPUT_DWARF2_ADDR_CONST
-#undef ASM_OUTPUT_DWARF_ADDR_CONST
-#define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,ADDR) \
- ASM_OUTPUT_DWARF2_ADDR_CONST (FILE, ADDR)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_ADDR_CONST
-#define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,ADDR) \
- fprintf ((FILE), "\t%s\t%s", UNALIGNED_WORD_ASM_OP, (ADDR))
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_OFFSET4
-#define ASM_OUTPUT_DWARF_OFFSET4(FILE,LABEL) \
- do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
- assemble_name (FILE, LABEL); \
- } while (0)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_OFFSET
-#define ASM_OUTPUT_DWARF_OFFSET(FILE,LABEL) \
- do { fprintf ((FILE), "\t%s\t", UNALIGNED_OFFSET_ASM_OP); \
- assemble_name (FILE, LABEL); \
- } while (0)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_DATA2
-#define ASM_OUTPUT_DWARF_DATA2(FILE,VALUE) \
- fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_SHORT_ASM_OP, (unsigned) (VALUE))
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_DATA4
-#define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
- fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_INT_ASM_OP, (unsigned) (VALUE))
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_DATA
-#define ASM_OUTPUT_DWARF_DATA(FILE,VALUE) \
- fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_OFFSET_ASM_OP, \
- (unsigned long) (VALUE))
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_ADDR_DATA
-#define ASM_OUTPUT_DWARF_ADDR_DATA(FILE,VALUE) \
- fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_WORD_ASM_OP, \
- (unsigned long) (VALUE))
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_DATA8
-#define ASM_OUTPUT_DWARF_DATA8(FILE,HIGH_VALUE,LOW_VALUE) \
- do { \
- if (WORDS_BIG_ENDIAN) \
- { \
- fprintf ((FILE), "\t%s\t0x%lx\n", UNALIGNED_INT_ASM_OP, (HIGH_VALUE));\
- fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_INT_ASM_OP, (LOW_VALUE));\
- } \
- else \
- { \
- fprintf ((FILE), "\t%s\t0x%lx\n", UNALIGNED_INT_ASM_OP, (LOW_VALUE)); \
- fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_INT_ASM_OP, (HIGH_VALUE)); \
- } \
- } while (0)
-#endif
-
-#else /* UNALIGNED_INT_ASM_OP */
-
-/* We don't have unaligned support, let's hope the normal output works for
- .debug_frame. */
-
-#define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \
- assemble_integer (gen_rtx_SYMBOL_REF (Pmode, LABEL), PTR_SIZE, 1)
-
-#define ASM_OUTPUT_DWARF_OFFSET4(FILE,LABEL) \
- assemble_integer (gen_rtx_SYMBOL_REF (SImode, LABEL), 4, 1)
-
-#define ASM_OUTPUT_DWARF_OFFSET(FILE,LABEL) \
- assemble_integer (gen_rtx_SYMBOL_REF (SImode, LABEL), 4, 1)
-
-#define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2) \
- assemble_integer (gen_rtx_MINUS (HImode, \
- gen_rtx_SYMBOL_REF (Pmode, LABEL1), \
- gen_rtx_SYMBOL_REF (Pmode, LABEL2)), \
- 2, 1)
-
-#define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2) \
- assemble_integer (gen_rtx_MINUS (SImode, \
- gen_rtx_SYMBOL_REF (Pmode, LABEL1), \
- gen_rtx_SYMBOL_REF (Pmode, LABEL2)), \
- 4, 1)
-
-#define ASM_OUTPUT_DWARF_ADDR_DELTA(FILE,LABEL1,LABEL2) \
- assemble_integer (gen_rtx_MINUS (Pmode, \
- gen_rtx_SYMBOL_REF (Pmode, LABEL1), \
- gen_rtx_SYMBOL_REF (Pmode, LABEL2)), \
- PTR_SIZE, 1)
-
-#define ASM_OUTPUT_DWARF_DELTA(FILE,LABEL1,LABEL2) \
- ASM_OUTPUT_DWARF_DELTA4 (FILE,LABEL1,LABEL2)
-
-#define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
- assemble_integer (GEN_INT (VALUE), 4, 1)
-
-#endif /* UNALIGNED_INT_ASM_OP */
-
#ifdef SET_ASM_OP
#ifndef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
#define ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL(FILE, SY, HI, LO) \
do { \
- fprintf (FILE, "\t%s\t", SET_ASM_OP); \
+ fprintf (FILE, "%s", SET_ASM_OP); \
assemble_name (FILE, SY); \
fputc (',', FILE); \
assemble_name (FILE, HI); \
@@ -463,33 +354,6 @@ static void dwarf2out_stack_adjust PROTO((rtx));
assemble_name (FILE, LO); \
} while (0)
#endif
-#endif /* SET_ASM_OP */
-
-/* This is similar to the default ASM_OUTPUT_ASCII, except that no trailing
- newline is produced. When flag_debug_asm is asserted, we add commentary
- at the end of the line, so we must avoid output of a newline here. */
-#ifndef ASM_OUTPUT_DWARF_STRING
-#define ASM_OUTPUT_DWARF_STRING(FILE,P) \
- do { \
- register int slen = strlen(P); \
- register char *p = (P); \
- register int i; \
- fprintf (FILE, "\t.ascii \""); \
- for (i = 0; i < slen; i++) \
- { \
- register int c = p[i]; \
- if (c == '\"' || c == '\\') \
- putc ('\\', FILE); \
- if (c >= ' ' && c < 0177) \
- putc (c, FILE); \
- else \
- { \
- fprintf (FILE, "\\%o", c); \
- } \
- } \
- fprintf (FILE, "\\0\""); \
- } \
- while (0)
#endif
/* The DWARF 2 CFA column which tracks the return address. Normally this
@@ -499,7 +363,7 @@ static void dwarf2out_stack_adjust PROTO((rtx));
#ifdef PC_REGNUM
#define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (PC_REGNUM)
#else
-#define DWARF_FRAME_RETURN_COLUMN FIRST_PSEUDO_REGISTER
+#define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGISTERS
#endif
#endif
@@ -509,6 +373,12 @@ static void dwarf2out_stack_adjust PROTO((rtx));
#define DWARF_FRAME_REGNUM(REG) DBX_REGISTER_NUMBER (REG)
#endif
+/* The offset from the incoming value of %sp to the top of the stack frame
+ for the current function. */
+#ifndef INCOMING_FRAME_SP_OFFSET
+#define INCOMING_FRAME_SP_OFFSET 0
+#endif
+
/* Hook used by __throw. */
rtx
@@ -517,18 +387,12 @@ expand_builtin_dwarf_fp_regnum ()
return GEN_INT (DWARF_FRAME_REGNUM (HARD_FRAME_POINTER_REGNUM));
}
-/* The offset from the incoming value of %sp to the top of the stack frame
- for the current function. */
-#ifndef INCOMING_FRAME_SP_OFFSET
-#define INCOMING_FRAME_SP_OFFSET 0
-#endif
-
/* Return a pointer to a copy of the section string name S with all
attributes stripped off, and an asterisk prepended (for assemble_name). */
static inline char *
stripattributes (s)
- char *s;
+ const char *s;
{
char *stripped = xmalloc (strlen (s) + 2);
char *p = stripped;
@@ -542,135 +406,34 @@ stripattributes (s)
return stripped;
}
-/* Return the register number described by a given RTL node. */
+/* Generate code to initialize the register size table. */
-static unsigned
-reg_number (rtl)
- register rtx rtl;
+void
+expand_builtin_init_dwarf_reg_sizes (address)
+ tree address;
{
- register unsigned regno = REGNO (rtl);
+ int i;
+ enum machine_mode mode = TYPE_MODE (char_type_node);
+ rtx addr = expand_expr (address, NULL_RTX, VOIDmode, 0);
+ rtx mem = gen_rtx_MEM (BLKmode, addr);
- if (regno >= FIRST_PSEUDO_REGISTER)
+ for (i = 0; i < DWARF_FRAME_REGISTERS; i++)
{
- warning ("internal regno botch: regno = %d\n", regno);
- regno = 0;
- }
-
- regno = DBX_REGISTER_NUMBER (regno);
- return regno;
-}
-
-struct reg_size_range
-{
- int beg;
- int end;
- int size;
-};
-
-/* Given a register number in REG_TREE, return an rtx for its size in bytes.
- We do this in kind of a roundabout way, by building up a list of
- register size ranges and seeing where our register falls in one of those
- ranges. We need to do it this way because REG_TREE is not a constant,
- and the target macros were not designed to make this task easy. */
-
-rtx
-expand_builtin_dwarf_reg_size (reg_tree, target)
- tree reg_tree;
- rtx target;
-{
- enum machine_mode mode;
- int size;
- struct reg_size_range ranges[5];
- tree t, t2;
+ HOST_WIDE_INT offset = DWARF_FRAME_REGNUM (i) * GET_MODE_SIZE (mode);
+ HOST_WIDE_INT size = GET_MODE_SIZE (reg_raw_mode[i]);
- int i = 0;
- int n_ranges = 0;
- int last_size = -1;
-
- for (; i < FIRST_PSEUDO_REGISTER; ++i)
- {
- /* The return address is out of order on the MIPS, and we don't use
- copy_reg for it anyway, so we don't care here how large it is. */
- if (DWARF_FRAME_REGNUM (i) == DWARF_FRAME_RETURN_COLUMN)
+ if (offset < 0)
continue;
- mode = reg_raw_mode[i];
-
- /* CCmode is arbitrarily given a size of 4 bytes. It is more useful
- to use the same size as word_mode, since that reduces the number
- of ranges we need. It should not matter, since the result should
- never be used for a condition code register anyways. */
- if (GET_MODE_CLASS (mode) == MODE_CC)
- mode = word_mode;
-
- size = GET_MODE_SIZE (mode);
-
- /* If this register is not valid in the specified mode and
- we have a previous size, use that for the size of this
- register to avoid making junk tiny ranges. */
- if (! HARD_REGNO_MODE_OK (i, mode) && last_size != -1)
- size = last_size;
-
- if (size != last_size)
- {
- ranges[n_ranges].beg = i;
- ranges[n_ranges].size = last_size = size;
- ++n_ranges;
- if (n_ranges >= 5)
- abort ();
- }
- ranges[n_ranges-1].end = i;
+ emit_move_insn (adjust_address (mem, mode, offset), GEN_INT (size));
}
-
- /* The usual case: fp regs surrounded by general regs. */
- if (n_ranges == 3 && ranges[0].size == ranges[2].size)
- {
- if ((DWARF_FRAME_REGNUM (ranges[1].end)
- - DWARF_FRAME_REGNUM (ranges[1].beg))
- != ranges[1].end - ranges[1].beg)
- abort ();
- t = fold (build (GE_EXPR, integer_type_node, reg_tree,
- build_int_2 (DWARF_FRAME_REGNUM (ranges[1].beg), 0)));
- t2 = fold (build (LE_EXPR, integer_type_node, reg_tree,
- build_int_2 (DWARF_FRAME_REGNUM (ranges[1].end), 0)));
- t = fold (build (TRUTH_ANDIF_EXPR, integer_type_node, t, t2));
- t = fold (build (COND_EXPR, integer_type_node, t,
- build_int_2 (ranges[1].size, 0),
- build_int_2 (ranges[0].size, 0)));
- }
- else
- {
- /* Initialize last_end to be larger than any possible
- DWARF_FRAME_REGNUM. */
- int last_end = 0x7fffffff;
- --n_ranges;
- t = build_int_2 (ranges[n_ranges].size, 0);
- do
- {
- int beg = DWARF_FRAME_REGNUM (ranges[n_ranges].beg);
- int end = DWARF_FRAME_REGNUM (ranges[n_ranges].end);
- if (beg < 0)
- continue;
- if (end >= last_end)
- abort ();
- last_end = end;
- if (end - beg != ranges[n_ranges].end - ranges[n_ranges].beg)
- abort ();
- t2 = fold (build (LE_EXPR, integer_type_node, reg_tree,
- build_int_2 (end, 0)));
- t = fold (build (COND_EXPR, integer_type_node, t2,
- build_int_2 (ranges[n_ranges].size, 0), t));
- }
- while (--n_ranges >= 0);
- }
- return expand_expr (t, target, Pmode, 0);
}
/* Convert a DWARF call frame info. operation to its string name */
-static char *
+static const char *
dwarf_cfi_name (cfi_opc)
- register unsigned cfi_opc;
+ unsigned cfi_opc;
{
switch (cfi_opc)
{
@@ -711,6 +474,18 @@ dwarf_cfi_name (cfi_opc)
case DW_CFA_def_cfa_offset:
return "DW_CFA_def_cfa_offset";
+ /* DWARF 3 */
+ case DW_CFA_def_cfa_expression:
+ return "DW_CFA_def_cfa_expression";
+ case DW_CFA_expression:
+ return "DW_CFA_expression";
+ case DW_CFA_offset_extended_sf:
+ return "DW_CFA_offset_extended_sf";
+ case DW_CFA_def_cfa_sf:
+ return "DW_CFA_def_cfa_sf";
+ case DW_CFA_def_cfa_offset_sf:
+ return "DW_CFA_def_cfa_offset_sf";
+
/* SGI/MIPS specific */
case DW_CFA_MIPS_advance_loc8:
return "DW_CFA_MIPS_advance_loc8";
@@ -733,7 +508,7 @@ dwarf_cfi_name (cfi_opc)
static inline dw_cfi_ref
new_cfi ()
{
- register dw_cfi_ref cfi = (dw_cfi_ref) xmalloc (sizeof (dw_cfi_node));
+ dw_cfi_ref cfi = (dw_cfi_ref) xmalloc (sizeof (dw_cfi_node));
cfi->dw_cfi_next = NULL;
cfi->dw_cfi_oprnd1.dw_cfi_reg_num = 0;
@@ -746,10 +521,10 @@ new_cfi ()
static inline void
add_cfi (list_head, cfi)
- register dw_cfi_ref *list_head;
- register dw_cfi_ref cfi;
+ dw_cfi_ref *list_head;
+ dw_cfi_ref cfi;
{
- register dw_cfi_ref *p;
+ dw_cfi_ref *p;
/* Find the end of the chain. */
for (p = list_head; (*p) != NULL; p = &(*p)->dw_cfi_next)
@@ -765,10 +540,9 @@ dwarf2out_cfi_label ()
{
static char label[20];
static unsigned long label_num = 0;
-
+
ASM_GENERATE_INTERNAL_LABEL (label, "LCFI", label_num++);
ASM_OUTPUT_LABEL (asm_out_file, label);
-
return label;
}
@@ -777,12 +551,12 @@ dwarf2out_cfi_label ()
static void
add_fde_cfi (label, cfi)
- register char *label;
- register dw_cfi_ref cfi;
+ const char *label;
+ dw_cfi_ref cfi;
{
if (label)
{
- register dw_fde_ref fde = &fde_table[fde_table_in_use - 1];
+ dw_fde_ref fde = &fde_table[fde_table_in_use - 1];
if (*label == 0)
label = dwarf2out_cfi_label ();
@@ -790,7 +564,7 @@ add_fde_cfi (label, cfi)
if (fde->dw_fde_current_label == NULL
|| strcmp (label, fde->dw_fde_current_label) != 0)
{
- register dw_cfi_ref xcfi;
+ dw_cfi_ref xcfi;
fde->dw_fde_current_label = label = xstrdup (label);
@@ -811,22 +585,24 @@ add_fde_cfi (label, cfi)
/* Subroutine of lookup_cfa. */
static inline void
-lookup_cfa_1 (cfi, regp, offsetp)
- register dw_cfi_ref cfi;
- register unsigned long *regp;
- register long *offsetp;
+lookup_cfa_1 (cfi, loc)
+ dw_cfi_ref cfi;
+ dw_cfa_location *loc;
{
switch (cfi->dw_cfi_opc)
{
case DW_CFA_def_cfa_offset:
- *offsetp = cfi->dw_cfi_oprnd1.dw_cfi_offset;
+ loc->offset = cfi->dw_cfi_oprnd1.dw_cfi_offset;
break;
case DW_CFA_def_cfa_register:
- *regp = cfi->dw_cfi_oprnd1.dw_cfi_reg_num;
+ loc->reg = cfi->dw_cfi_oprnd1.dw_cfi_reg_num;
break;
case DW_CFA_def_cfa:
- *regp = cfi->dw_cfi_oprnd1.dw_cfi_reg_num;
- *offsetp = cfi->dw_cfi_oprnd2.dw_cfi_offset;
+ loc->reg = cfi->dw_cfi_oprnd1.dw_cfi_reg_num;
+ loc->offset = cfi->dw_cfi_oprnd2.dw_cfi_offset;
+ break;
+ case DW_CFA_def_cfa_expression:
+ get_cfa_from_loc_descr (loc, cfi->dw_cfi_oprnd1.dw_cfi_loc);
break;
default:
break;
@@ -836,34 +612,33 @@ lookup_cfa_1 (cfi, regp, offsetp)
/* Find the previous value for the CFA. */
static void
-lookup_cfa (regp, offsetp)
- register unsigned long *regp;
- register long *offsetp;
+lookup_cfa (loc)
+ dw_cfa_location *loc;
{
- register dw_cfi_ref cfi;
+ dw_cfi_ref cfi;
- *regp = (unsigned long) -1;
- *offsetp = 0;
+ loc->reg = (unsigned long) -1;
+ loc->offset = 0;
+ loc->indirect = 0;
+ loc->base_offset = 0;
for (cfi = cie_cfi_head; cfi; cfi = cfi->dw_cfi_next)
- lookup_cfa_1 (cfi, regp, offsetp);
+ lookup_cfa_1 (cfi, loc);
if (fde_table_in_use)
{
- register dw_fde_ref fde = &fde_table[fde_table_in_use - 1];
+ dw_fde_ref fde = &fde_table[fde_table_in_use - 1];
for (cfi = fde->dw_fde_cfi; cfi; cfi = cfi->dw_cfi_next)
- lookup_cfa_1 (cfi, regp, offsetp);
+ lookup_cfa_1 (cfi, loc);
}
}
/* The current rule for calculating the DWARF2 canonical frame address. */
-static unsigned long cfa_reg;
-static long cfa_offset;
+static dw_cfa_location cfa;
/* The register used for saving registers to the stack, and its offset
from the CFA. */
-static unsigned cfa_store_reg;
-static long cfa_store_offset;
+static dw_cfa_location cfa_store;
/* The running total of the size of arguments pushed onto the stack. */
static long args_size;
@@ -877,46 +652,86 @@ static long old_args_size;
void
dwarf2out_def_cfa (label, reg, offset)
- register char *label;
- register unsigned reg;
- register long offset;
+ const char *label;
+ unsigned reg;
+ long offset;
{
- register dw_cfi_ref cfi;
- unsigned long old_reg;
- long old_offset;
+ dw_cfa_location loc;
+ loc.indirect = 0;
+ loc.base_offset = 0;
+ loc.reg = reg;
+ loc.offset = offset;
+ def_cfa_1 (label, &loc);
+}
- cfa_reg = reg;
- cfa_offset = offset;
- if (cfa_store_reg == reg)
- cfa_store_offset = offset;
+/* This routine does the actual work. The CFA is now calculated from
+ the dw_cfa_location structure. */
- reg = DWARF_FRAME_REGNUM (reg);
- lookup_cfa (&old_reg, &old_offset);
+static void
+def_cfa_1 (label, loc_p)
+ const char *label;
+ dw_cfa_location *loc_p;
+{
+ dw_cfi_ref cfi;
+ dw_cfa_location old_cfa, loc;
+
+ cfa = *loc_p;
+ loc = *loc_p;
+
+ if (cfa_store.reg == loc.reg && loc.indirect == 0)
+ cfa_store.offset = loc.offset;
- if (reg == old_reg && offset == old_offset)
+ loc.reg = DWARF_FRAME_REGNUM (loc.reg);
+ lookup_cfa (&old_cfa);
+
+ /* If nothing changed, no need to issue any call frame instructions. */
+ if (loc.reg == old_cfa.reg && loc.offset == old_cfa.offset
+ && loc.indirect == old_cfa.indirect
+ && (loc.indirect == 0 || loc.base_offset == old_cfa.base_offset))
return;
cfi = new_cfi ();
- if (reg == old_reg)
+ if (loc.reg == old_cfa.reg && !loc.indirect)
{
+ /* Construct a "DW_CFA_def_cfa_offset <offset>" instruction,
+ indicating the CFA register did not change but the offset
+ did. */
cfi->dw_cfi_opc = DW_CFA_def_cfa_offset;
- cfi->dw_cfi_oprnd1.dw_cfi_offset = offset;
+ cfi->dw_cfi_oprnd1.dw_cfi_offset = loc.offset;
}
#ifndef MIPS_DEBUGGING_INFO /* SGI dbx thinks this means no offset. */
- else if (offset == old_offset && old_reg != (unsigned long) -1)
+ else if (loc.offset == old_cfa.offset && old_cfa.reg != (unsigned long) -1
+ && !loc.indirect)
{
+ /* Construct a "DW_CFA_def_cfa_register <register>" instruction,
+ indicating the CFA register has changed to <register> but the
+ offset has not changed. */
cfi->dw_cfi_opc = DW_CFA_def_cfa_register;
- cfi->dw_cfi_oprnd1.dw_cfi_reg_num = reg;
+ cfi->dw_cfi_oprnd1.dw_cfi_reg_num = loc.reg;
}
#endif
- else
+ else if (loc.indirect == 0)
{
+ /* Construct a "DW_CFA_def_cfa <register> <offset>" instruction,
+ indicating the CFA register has changed to <register> with
+ the specified offset. */
cfi->dw_cfi_opc = DW_CFA_def_cfa;
- cfi->dw_cfi_oprnd1.dw_cfi_reg_num = reg;
- cfi->dw_cfi_oprnd2.dw_cfi_offset = offset;
+ cfi->dw_cfi_oprnd1.dw_cfi_reg_num = loc.reg;
+ cfi->dw_cfi_oprnd2.dw_cfi_offset = loc.offset;
+ }
+ else
+ {
+ /* Construct a DW_CFA_def_cfa_expression instruction to
+ calculate the CFA using a full location expression since no
+ register-offset pair is available. */
+ struct dw_loc_descr_struct *loc_list;
+
+ cfi->dw_cfi_opc = DW_CFA_def_cfa_expression;
+ loc_list = build_cfa_loc (&loc);
+ cfi->dw_cfi_oprnd1.dw_cfi_loc = loc_list;
}
add_fde_cfi (label, cfi);
@@ -929,12 +744,12 @@ dwarf2out_def_cfa (label, reg, offset)
static void
reg_save (label, reg, sreg, offset)
- register char * label;
- register unsigned reg;
- register unsigned sreg;
- register long offset;
+ const char *label;
+ unsigned reg;
+ unsigned sreg;
+ long offset;
{
- register dw_cfi_ref cfi = new_cfi ();
+ dw_cfi_ref cfi = new_cfi ();
cfi->dw_cfi_oprnd1.dw_cfi_reg_num = reg;
@@ -949,14 +764,27 @@ reg_save (label, reg, sreg, offset)
else
cfi->dw_cfi_opc = DW_CFA_offset;
+#ifdef ENABLE_CHECKING
+ {
+ /* If we get an offset that is not a multiple of
+ DWARF_CIE_DATA_ALIGNMENT, there is either a bug in the
+ definition of DWARF_CIE_DATA_ALIGNMENT, or a bug in the machine
+ description. */
+ long check_offset = offset / DWARF_CIE_DATA_ALIGNMENT;
+
+ if (check_offset * DWARF_CIE_DATA_ALIGNMENT != offset)
+ abort ();
+ }
+#endif
offset /= DWARF_CIE_DATA_ALIGNMENT;
if (offset < 0)
- {
- cfi->dw_cfi_opc = DW_CFA_GNU_negative_offset_extended;
- offset = -offset;
- }
+ cfi->dw_cfi_opc = DW_CFA_offset_extended_sf;
+
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;
else
{
cfi->dw_cfi_opc = DW_CFA_register;
@@ -969,15 +797,16 @@ reg_save (label, reg, sreg, offset)
/* Add the CFI for saving a register window. LABEL is passed to reg_save.
This CFI tells the unwinder that it needs to restore the window registers
from the previous frame's window save area.
-
+
??? Perhaps we should note in the CIE where windows are saved (instead of
assuming 0(cfa)) and what registers are in the window. */
void
dwarf2out_window_save (label)
- register char * label;
+ const char *label;
{
- register dw_cfi_ref cfi = new_cfi ();
+ dw_cfi_ref cfi = new_cfi ();
+
cfi->dw_cfi_opc = DW_CFA_GNU_window_save;
add_fde_cfi (label, cfi);
}
@@ -987,13 +816,14 @@ dwarf2out_window_save (label)
void
dwarf2out_args_size (label, size)
- char *label;
+ const char *label;
long size;
{
- register dw_cfi_ref cfi;
+ dw_cfi_ref cfi;
if (size == old_args_size)
return;
+
old_args_size = size;
cfi = new_cfi ();
@@ -1007,9 +837,9 @@ dwarf2out_args_size (label, size)
void
dwarf2out_reg_save (label, reg, offset)
- register char * label;
- register unsigned reg;
- register long offset;
+ const char *label;
+ unsigned reg;
+ long offset;
{
reg_save (label, DWARF_FRAME_REGNUM (reg), -1, offset);
}
@@ -1019,8 +849,8 @@ dwarf2out_reg_save (label, reg, offset)
void
dwarf2out_return_save (label, offset)
- register char * label;
- register long offset;
+ const char *label;
+ long offset;
{
reg_save (label, DWARF_FRAME_RETURN_COLUMN, -1, offset);
}
@@ -1030,8 +860,8 @@ dwarf2out_return_save (label, offset)
void
dwarf2out_return_reg (label, sreg)
- register char * label;
- register unsigned sreg;
+ const char *label;
+ unsigned sreg;
{
reg_save (label, DWARF_FRAME_RETURN_COLUMN, sreg, 0);
}
@@ -1041,17 +871,18 @@ dwarf2out_return_reg (label, sreg)
static void
initial_return_save (rtl)
- register rtx rtl;
+ rtx rtl;
{
unsigned int reg = (unsigned int) -1;
- long offset = 0;
+ HOST_WIDE_INT offset = 0;
switch (GET_CODE (rtl))
{
case REG:
/* RA is in a register. */
- reg = reg_number (rtl);
+ reg = DWARF_FRAME_REGNUM (REGNO (rtl));
break;
+
case MEM:
/* RA is on the stack. */
rtl = XEXP (rtl, 0);
@@ -1062,20 +893,25 @@ initial_return_save (rtl)
abort ();
offset = 0;
break;
+
case PLUS:
if (REGNO (XEXP (rtl, 0)) != STACK_POINTER_REGNUM)
abort ();
offset = INTVAL (XEXP (rtl, 1));
break;
+
case MINUS:
if (REGNO (XEXP (rtl, 0)) != STACK_POINTER_REGNUM)
abort ();
offset = -INTVAL (XEXP (rtl, 1));
break;
+
default:
abort ();
}
+
break;
+
case PLUS:
/* The return address is at some offset from any value we can
actually load. For instance, on the SPARC it is in %i7+8. Just
@@ -1084,11 +920,68 @@ initial_return_save (rtl)
abort ();
initial_return_save (XEXP (rtl, 0));
return;
+
default:
abort ();
}
- reg_save (NULL, DWARF_FRAME_RETURN_COLUMN, reg, offset - cfa_offset);
+ reg_save (NULL, DWARF_FRAME_RETURN_COLUMN, reg, offset - cfa.offset);
+}
+
+/* Given a SET, calculate the amount of stack adjustment it
+ contains. */
+
+static long
+stack_adjust_offset (pattern)
+ rtx pattern;
+{
+ rtx src = SET_SRC (pattern);
+ rtx dest = SET_DEST (pattern);
+ HOST_WIDE_INT offset = 0;
+ enum rtx_code code;
+
+ if (dest == stack_pointer_rtx)
+ {
+ /* (set (reg sp) (plus (reg sp) (const_int))) */
+ code = GET_CODE (src);
+ if (! (code == PLUS || code == MINUS)
+ || XEXP (src, 0) != stack_pointer_rtx
+ || GET_CODE (XEXP (src, 1)) != CONST_INT)
+ return 0;
+
+ offset = INTVAL (XEXP (src, 1));
+ }
+ else if (GET_CODE (dest) == MEM)
+ {
+ /* (set (mem (pre_dec (reg sp))) (foo)) */
+ src = XEXP (dest, 0);
+ code = GET_CODE (src);
+
+ if ((code != PRE_DEC && code != PRE_INC && code != PRE_MODIFY)
+ || XEXP (src, 0) != stack_pointer_rtx)
+ return 0;
+
+ if (code == PRE_MODIFY)
+ {
+ rtx val = XEXP (XEXP (src, 1), 1);
+
+ /* We handle only adjustments by constant amount. */
+ if (GET_CODE (XEXP (src, 1)) != PLUS ||
+ GET_CODE (val) != CONST_INT)
+ abort ();
+
+ offset = -INTVAL (val);
+ }
+ else
+ offset = GET_MODE_SIZE (GET_MODE (dest));
+ }
+ else
+ return 0;
+
+ if (code == PLUS || code == PRE_INC)
+ offset = -offset;
+
+ return offset;
}
/* Check INSN to see if it looks like a push or a stack adjustment, and
@@ -1099,27 +992,28 @@ static void
dwarf2out_stack_adjust (insn)
rtx insn;
{
- long offset;
- char *label;
+ HOST_WIDE_INT offset;
+ const char *label;
+ int i;
- if (! asynchronous_exceptions && GET_CODE (insn) == CALL_INSN)
+ if (!flag_asynchronous_unwind_tables && GET_CODE (insn) == CALL_INSN)
{
/* Extract the size of the args from the CALL rtx itself. */
-
insn = PATTERN (insn);
if (GET_CODE (insn) == PARALLEL)
insn = XVECEXP (insn, 0, 0);
if (GET_CODE (insn) == SET)
insn = SET_SRC (insn);
- assert (GET_CODE (insn) == CALL);
+ if (GET_CODE (insn) != CALL)
+ abort ();
+
dwarf2out_args_size ("", INTVAL (XEXP (insn, 1)));
return;
}
/* If only calls can throw, and we have a frame pointer,
save up adjustments until we see the CALL_INSN. */
- else if (! asynchronous_exceptions
- && cfa_reg != STACK_POINTER_REGNUM)
+ else if (!flag_asynchronous_unwind_tables && cfa.reg != STACK_POINTER_REGNUM)
return;
if (GET_CODE (insn) == BARRIER)
@@ -1134,42 +1028,15 @@ dwarf2out_stack_adjust (insn)
#endif
}
else if (GET_CODE (PATTERN (insn)) == SET)
+ offset = stack_adjust_offset (PATTERN (insn));
+ else if (GET_CODE (PATTERN (insn)) == PARALLEL
+ || GET_CODE (PATTERN (insn)) == SEQUENCE)
{
- rtx src, dest;
- enum rtx_code code;
-
- insn = PATTERN (insn);
- src = SET_SRC (insn);
- dest = SET_DEST (insn);
-
- if (dest == stack_pointer_rtx)
- {
- /* (set (reg sp) (plus (reg sp) (const_int))) */
- code = GET_CODE (src);
- if (! (code == PLUS || code == MINUS)
- || XEXP (src, 0) != stack_pointer_rtx
- || GET_CODE (XEXP (src, 1)) != CONST_INT)
- return;
-
- offset = INTVAL (XEXP (src, 1));
- }
- else if (GET_CODE (dest) == MEM)
- {
- /* (set (mem (pre_dec (reg sp))) (foo)) */
- src = XEXP (dest, 0);
- code = GET_CODE (src);
-
- if (! (code == PRE_DEC || code == PRE_INC)
- || XEXP (src, 0) != stack_pointer_rtx)
- return;
-
- offset = GET_MODE_SIZE (GET_MODE (dest));
- }
- else
- return;
-
- if (code == PLUS || code == PRE_INC)
- offset = -offset;
+ /* There may be stack adjustments inside compound insns. Search
+ for them. */
+ for (offset = 0, i = XVECLEN (PATTERN (insn), 0) - 1; i >= 0; i--)
+ if (GET_CODE (XVECEXP (PATTERN (insn), 0, i)) == SET)
+ offset += stack_adjust_offset (XVECEXP (PATTERN (insn), 0, i));
}
else
return;
@@ -1177,61 +1044,266 @@ dwarf2out_stack_adjust (insn)
if (offset == 0)
return;
- if (cfa_reg == STACK_POINTER_REGNUM)
- cfa_offset += offset;
+ if (cfa.reg == STACK_POINTER_REGNUM)
+ cfa.offset += offset;
#ifndef STACK_GROWS_DOWNWARD
offset = -offset;
#endif
+
args_size += offset;
if (args_size < 0)
args_size = 0;
label = dwarf2out_cfi_label ();
- dwarf2out_def_cfa (label, cfa_reg, cfa_offset);
+ def_cfa_1 (label, &cfa);
dwarf2out_args_size (label, args_size);
}
-/* A temporary register used in adjusting SP or setting up the store_reg. */
-static unsigned cfa_temp_reg;
+/* We delay emitting a register save until either (a) we reach the end
+ of the prologue or (b) the register is clobbered. This clusters
+ register saves so that there are fewer pc advances. */
-/* A temporary value used in adjusting SP or setting up the store_reg. */
-static long cfa_temp_value;
+struct queued_reg_save
+{
+ struct queued_reg_save *next;
+ rtx reg;
+ long cfa_offset;
+};
-/* Record call frame debugging information for an expression, which either
- sets SP or FP (adjusting how we calculate the frame address) or saves a
- register to the stack. */
+static struct queued_reg_save *queued_reg_saves;
+static const char *last_reg_save_label;
+
+static void
+queue_reg_save (label, reg, offset)
+ const char *label;
+ rtx reg;
+ long offset;
+{
+ struct queued_reg_save *q = (struct queued_reg_save *) xmalloc (sizeof (*q));
+
+ q->next = queued_reg_saves;
+ q->reg = reg;
+ q->cfa_offset = offset;
+ queued_reg_saves = q;
+
+ last_reg_save_label = label;
+}
+
+static void
+flush_queued_reg_saves ()
+{
+ struct queued_reg_save *q, *next;
+
+ for (q = queued_reg_saves; q ; q = next)
+ {
+ dwarf2out_reg_save (last_reg_save_label, REGNO (q->reg), q->cfa_offset);
+ next = q->next;
+ free (q);
+ }
+
+ queued_reg_saves = NULL;
+ last_reg_save_label = NULL;
+}
+
+static bool
+clobbers_queued_reg_save (insn)
+ 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;
+
+ return false;
+}
+
+
+/* A temporary register holding an integral value used in adjusting SP
+ or setting up the store_reg. The "offset" field holds the integer
+ value, not an offset. */
+static dw_cfa_location cfa_temp;
+
+/* 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.
+
+ This function encodes a state machine mapping rtxes to actions on
+ cfa, cfa_store, and cfa_temp.reg. We describe these rules so
+ users need not read the source code.
+
+ The High-Level Picture
+
+ Changes in the register we use to calculate the CFA: Currently we
+ assume that if you copy the CFA register into another register, we
+ should take the other one as the new CFA register; this seems to
+ work pretty well. If it's wrong for some target, it's simple
+ enough not to set RTX_FRAME_RELATED_P on the insn in question.
+
+ Changes in the register we use for saving registers to the stack:
+ This is usually SP, but not always. Again, we deduce that if you
+ copy SP into another register (and SP is not the CFA register),
+ then the new register is the one we will be using for register
+ saves. This also seems to work.
+
+ Register saves: There's not much guesswork about this one; if
+ 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.
+
+ Except: If the register being saved is the CFA register, and the
+ offset is non-zero, 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.
+
+ Invariants / Summaries of Rules
+
+ cfa current rule for calculating the CFA. It usually
+ consists of a register and an offset.
+ cfa_store register used by prologue code to save things to the stack
+ cfa_store.offset is the offset from the value of
+ cfa_store.reg to the actual CFA
+ cfa_temp register holding an integral value. cfa_temp.offset
+ stores the value, which will be used to adjust the
+ stack pointer. cfa_temp is also used like cfa_store,
+ to track stores to the stack via fp or a temp reg.
+
+ Rules 1- 4: Setting a register's value to cfa.reg or an expression
+ with cfa.reg as the first operand changes the cfa.reg and its
+ cfa.offset. Rule 1 and 4 also set cfa_temp.reg and
+ cfa_temp.offset.
+
+ Rules 6- 9: Set a non-cfa.reg register value to a constant or an
+ expression yielding a constant. This sets cfa_temp.reg
+ and cfa_temp.offset.
+
+ Rule 5: Create a new register cfa_store used to save items to the
+ stack.
+
+ Rules 10-14: Save a register to the stack. Define offset as the
+ difference of the original location and cfa_store's
+ location (or cfa_temp's location if cfa_temp is used).
+
+ The Rules
+
+ "{a,b}" indicates a choice of a xor b.
+ "<reg>:cfa.reg" indicates that <reg> must equal cfa.reg.
+
+ Rule 1:
+ (set <reg1> <reg2>:cfa.reg)
+ effects: cfa.reg = <reg1>
+ cfa.offset unchanged
+ cfa_temp.reg = <reg1>
+ cfa_temp.offset = cfa.offset
+
+ Rule 2:
+ (set sp ({minus,plus,losum} {sp,fp}:cfa.reg
+ {<const_int>,<reg>:cfa_temp.reg}))
+ effects: cfa.reg = sp if fp used
+ cfa.offset += {+/- <const_int>, cfa_temp.offset} if cfa.reg==sp
+ cfa_store.offset += {+/- <const_int>, cfa_temp.offset}
+ if cfa_store.reg==sp
+
+ Rule 3:
+ (set fp ({minus,plus,losum} <reg>:cfa.reg <const_int>))
+ effects: cfa.reg = fp
+ cfa_offset += +/- <const_int>
+
+ Rule 4:
+ (set <reg1> ({plus,losum} <reg2>:cfa.reg <const_int>))
+ constraints: <reg1> != fp
+ <reg1> != sp
+ effects: cfa.reg = <reg1>
+ cfa_temp.reg = <reg1>
+ cfa_temp.offset = cfa.offset
+
+ Rule 5:
+ (set <reg1> (plus <reg2>:cfa_temp.reg sp:cfa.reg))
+ constraints: <reg1> != fp
+ <reg1> != sp
+ effects: cfa_store.reg = <reg1>
+ cfa_store.offset = cfa.offset - cfa_temp.offset
+
+ Rule 6:
+ (set <reg> <const_int>)
+ effects: cfa_temp.reg = <reg>
+ cfa_temp.offset = <const_int>
+
+ Rule 7:
+ (set <reg1>:cfa_temp.reg (ior <reg2>:cfa_temp.reg <const_int>))
+ effects: cfa_temp.reg = <reg1>
+ cfa_temp.offset |= <const_int>
+
+ Rule 8:
+ (set <reg> (high <exp>))
+ effects: none
+
+ Rule 9:
+ (set <reg> (lo_sum <exp> <const_int>))
+ effects: cfa_temp.reg = <reg>
+ cfa_temp.offset = <const_int>
+
+ Rule 10:
+ (set (mem (pre_modify sp:cfa_store (???? <reg1> <const_int>))) <reg2>)
+ effects: cfa_store.offset -= <const_int>
+ cfa.offset = cfa_store.offset if cfa.reg == sp
+ cfa.reg = sp
+ cfa.base_offset = -cfa_store.offset
+
+ Rule 11:
+ (set (mem ({pre_inc,pre_dec} sp:cfa_store.reg)) <reg>)
+ effects: cfa_store.offset += -/+ mode_size(mem)
+ cfa.offset = cfa_store.offset if cfa.reg == sp
+ cfa.reg = sp
+ cfa.base_offset = -cfa_store.offset
+
+ Rule 12:
+ (set (mem ({minus,plus,losum} <reg1>:{cfa_store,cfa_temp} <const_int>))
+
+ <reg2>)
+ effects: cfa.reg = <reg1>
+ cfa.base_offset = -/+ <const_int> - {cfa_store,cfa_temp}.offset
+
+ Rule 13:
+ (set (mem <reg1>:{cfa_store,cfa_temp}) <reg2>)
+ effects: cfa.reg = <reg1>
+ cfa.base_offset = -{cfa_store,cfa_temp}.offset
+
+ Rule 14:
+ (set (mem (postinc <reg1>:cfa_temp <const_int>)) <reg2>)
+ effects: cfa.reg = <reg1>
+ cfa.base_offset = -cfa_temp.offset
+ cfa_temp.offset -= mode_size(mem) */
static void
dwarf2out_frame_debug_expr (expr, label)
rtx expr;
- char *label;
+ const char *label;
{
rtx src, dest;
- long offset;
-
- /* If RTX_FRAME_RELATED_P is set on a PARALLEL, process each member of
- the PARALLEL independantly. The first element is always processed if
- it is a SET. This is for backward compatability. Other elements
- are processed only if they are SETs and the RTX_FRAME_RELATED_P
- flag is set in them. */
-
- if (GET_CODE (expr) == PARALLEL)
- {
+ HOST_WIDE_INT offset;
+
+ /* If RTX_FRAME_RELATED_P is set on a PARALLEL, process each member of
+ the PARALLEL independently. The first element is always processed if
+ it is a SET. This is for backward compatibility. Other elements
+ are processed only if they are SETs and the RTX_FRAME_RELATED_P
+ flag is set in them. */
+ if (GET_CODE (expr) == PARALLEL || GET_CODE (expr) == SEQUENCE)
+ {
int par_index;
int limit = XVECLEN (expr, 0);
for (par_index = 0; par_index < limit; par_index++)
- {
- rtx x = XVECEXP (expr, 0, par_index);
-
- if (GET_CODE (x) == SET &&
- (RTX_FRAME_RELATED_P (x) || par_index == 0))
- dwarf2out_frame_debug_expr (x, label);
- }
+ if (GET_CODE (XVECEXP (expr, 0, par_index)) == SET
+ && (RTX_FRAME_RELATED_P (XVECEXP (expr, 0, par_index))
+ || par_index == 0))
+ dwarf2out_frame_debug_expr (XVECEXP (expr, 0, par_index), label);
+
return;
}
-
+
if (GET_CODE (expr) != SET)
abort ();
@@ -1241,180 +1313,295 @@ dwarf2out_frame_debug_expr (expr, label)
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))
- abort ();
- if (REGNO (dest) != STACK_POINTER_REGNUM
- && !(frame_pointer_needed
- && REGNO (dest) == HARD_FRAME_POINTER_REGNUM))
- abort ();
- cfa_reg = REGNO (dest);
- break;
-
- case PLUS:
- case MINUS:
- if (dest == stack_pointer_rtx)
- {
- /* Adjusting SP. */
- switch (GET_CODE (XEXP (src, 1)))
- {
- case CONST_INT:
- offset = INTVAL (XEXP (src, 1));
- break;
- case REG:
- if ((unsigned) REGNO (XEXP (src, 1)) != cfa_temp_reg)
- abort ();
- offset = cfa_temp_value;
- break;
- default:
- abort ();
- }
-
- if (XEXP (src, 0) == hard_frame_pointer_rtx)
- {
- /* Restoring SP from FP in the epilogue. */
- if (cfa_reg != (unsigned) HARD_FRAME_POINTER_REGNUM)
- abort ();
- cfa_reg = STACK_POINTER_REGNUM;
- }
- else if (XEXP (src, 0) != stack_pointer_rtx)
- abort ();
-
- if (GET_CODE (src) == PLUS)
- offset = -offset;
- if (cfa_reg == STACK_POINTER_REGNUM)
- cfa_offset += offset;
- if (cfa_store_reg == STACK_POINTER_REGNUM)
- cfa_store_offset += offset;
- }
- else if (dest == hard_frame_pointer_rtx)
- {
- /* Either setting the FP from an offset of the SP,
- or adjusting the FP */
- if (! frame_pointer_needed
- || REGNO (dest) != HARD_FRAME_POINTER_REGNUM)
- abort ();
-
- if (XEXP (src, 0) == stack_pointer_rtx
- && GET_CODE (XEXP (src, 1)) == CONST_INT)
- {
- if (cfa_reg != STACK_POINTER_REGNUM)
- abort ();
- offset = INTVAL (XEXP (src, 1));
- if (GET_CODE (src) == PLUS)
- offset = -offset;
- cfa_offset += offset;
- cfa_reg = HARD_FRAME_POINTER_REGNUM;
- }
- else if (XEXP (src, 0) == hard_frame_pointer_rtx
- && GET_CODE (XEXP (src, 1)) == CONST_INT)
- {
- if (cfa_reg != (unsigned) HARD_FRAME_POINTER_REGNUM)
- abort ();
- offset = INTVAL (XEXP (src, 1));
- if (GET_CODE (src) == PLUS)
- offset = -offset;
- cfa_offset += offset;
- }
-
- else
- abort();
- }
- else
- {
- if (GET_CODE (src) != PLUS
- || XEXP (src, 1) != stack_pointer_rtx)
- abort ();
- if (GET_CODE (XEXP (src, 0)) != REG
- || (unsigned) REGNO (XEXP (src, 0)) != cfa_temp_reg)
- abort ();
- if (cfa_reg != STACK_POINTER_REGNUM)
- abort ();
- cfa_store_reg = REGNO (dest);
- cfa_store_offset = cfa_offset - cfa_temp_value;
- }
- break;
-
- case CONST_INT:
- cfa_temp_reg = REGNO (dest);
- cfa_temp_value = INTVAL (src);
- break;
-
- case IOR:
- if (GET_CODE (XEXP (src, 0)) != REG
- || (unsigned) REGNO (XEXP (src, 0)) != cfa_temp_reg
- || (unsigned) REGNO (dest) != cfa_temp_reg
- || GET_CODE (XEXP (src, 1)) != CONST_INT)
- abort ();
- cfa_temp_value |= INTVAL (XEXP (src, 1));
- break;
-
- default:
- abort ();
- }
- dwarf2out_def_cfa (label, cfa_reg, cfa_offset);
- break;
-
- case MEM:
- /* Saving a register to the stack. Make sure dest is relative to the
- CFA register. */
- if (GET_CODE (src) != REG)
- abort ();
- switch (GET_CODE (XEXP (dest, 0)))
- {
- /* With a push. */
- case PRE_INC:
- case PRE_DEC:
- offset = GET_MODE_SIZE (GET_MODE (dest));
- if (GET_CODE (XEXP (dest, 0)) == PRE_INC)
- offset = -offset;
-
- if (REGNO (XEXP (XEXP (dest, 0), 0)) != STACK_POINTER_REGNUM
- || cfa_store_reg != STACK_POINTER_REGNUM)
- abort ();
- cfa_store_offset += offset;
- if (cfa_reg == STACK_POINTER_REGNUM)
- cfa_offset = cfa_store_offset;
-
- offset = -cfa_store_offset;
- break;
-
- /* With an offset. */
- case PLUS:
- case MINUS:
- offset = INTVAL (XEXP (XEXP (dest, 0), 1));
- if (GET_CODE (XEXP (dest, 0)) == MINUS)
- offset = -offset;
-
- if (cfa_store_reg != (unsigned) REGNO (XEXP (XEXP (dest, 0), 0)))
- abort ();
- offset -= cfa_store_offset;
- break;
-
- /* Without an offset. */
- case REG:
- if (cfa_store_reg != (unsigned) REGNO (XEXP (dest, 0)))
- abort();
- offset = -cfa_store_offset;
- break;
-
- default:
- abort ();
- }
- dwarf2out_def_cfa (label, cfa_reg, cfa_offset);
- dwarf2out_reg_save (label, REGNO (src), offset);
- break;
+ {
+ /* Setting FP from SP. */
+ case REG:
+ if (cfa.reg == (unsigned) REGNO (src))
+ /* OK. */
+ ;
+ else
+ abort ();
- default:
- 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:
+ case MINUS:
+ case LO_SUM:
+ if (dest == stack_pointer_rtx)
+ {
+ /* Rule 2 */
+ /* Adjusting SP. */
+ switch (GET_CODE (XEXP (src, 1)))
+ {
+ case CONST_INT:
+ offset = INTVAL (XEXP (src, 1));
+ break;
+ case REG:
+ if ((unsigned) REGNO (XEXP (src, 1)) != cfa_temp.reg)
+ abort ();
+ offset = cfa_temp.offset;
+ break;
+ default:
+ abort ();
+ }
+
+ if (XEXP (src, 0) == hard_frame_pointer_rtx)
+ {
+ /* Restoring SP from FP in the epilogue. */
+ if (cfa.reg != (unsigned) HARD_FRAME_POINTER_REGNUM)
+ abort ();
+ cfa.reg = STACK_POINTER_REGNUM;
+ }
+ else if (GET_CODE (src) == LO_SUM)
+ /* Assume we've set the source reg of the LO_SUM from sp. */
+ ;
+ else if (XEXP (src, 0) != stack_pointer_rtx)
+ abort ();
+
+ if (GET_CODE (src) != MINUS)
+ offset = -offset;
+ if (cfa.reg == STACK_POINTER_REGNUM)
+ cfa.offset += offset;
+ if (cfa_store.reg == STACK_POINTER_REGNUM)
+ cfa_store.offset += offset;
+ }
+ else if (dest == hard_frame_pointer_rtx)
+ {
+ /* Rule 3 */
+ /* Either setting the FP from an offset of the SP,
+ or adjusting the FP */
+ if (! frame_pointer_needed)
+ abort ();
+
+ if (GET_CODE (XEXP (src, 0)) == REG
+ && (unsigned) REGNO (XEXP (src, 0)) == cfa.reg
+ && GET_CODE (XEXP (src, 1)) == CONST_INT)
+ {
+ offset = INTVAL (XEXP (src, 1));
+ if (GET_CODE (src) != MINUS)
+ offset = -offset;
+ cfa.offset += offset;
+ cfa.reg = HARD_FRAME_POINTER_REGNUM;
+ }
+ else
+ abort ();
+ }
+ else
+ {
+ if (GET_CODE (src) == MINUS)
+ abort ();
+
+ /* Rule 4 */
+ if (GET_CODE (XEXP (src, 0)) == REG
+ && REGNO (XEXP (src, 0)) == cfa.reg
+ && GET_CODE (XEXP (src, 1)) == CONST_INT)
+ {
+ /* Setting a temporary CFA register that will be copied
+ into the FP later on. */
+ offset = - INTVAL (XEXP (src, 1));
+ cfa.offset += offset;
+ cfa.reg = REGNO (dest);
+ /* Or used to save regs to the stack. */
+ cfa_temp.reg = cfa.reg;
+ cfa_temp.offset = cfa.offset;
+ }
+
+ /* Rule 5 */
+ else if (GET_CODE (XEXP (src, 0)) == REG
+ && REGNO (XEXP (src, 0)) == cfa_temp.reg
+ && XEXP (src, 1) == stack_pointer_rtx)
+ {
+ /* Setting a scratch register that we will use instead
+ of SP for saving registers to the stack. */
+ if (cfa.reg != STACK_POINTER_REGNUM)
+ abort ();
+ cfa_store.reg = REGNO (dest);
+ cfa_store.offset = cfa.offset - cfa_temp.offset;
+ }
+
+ /* Rule 9 */
+ else if (GET_CODE (src) == LO_SUM
+ && GET_CODE (XEXP (src, 1)) == CONST_INT)
+ {
+ cfa_temp.reg = REGNO (dest);
+ cfa_temp.offset = INTVAL (XEXP (src, 1));
+ }
+ else
+ abort ();
+ }
+ break;
+
+ /* Rule 6 */
+ case CONST_INT:
+ cfa_temp.reg = REGNO (dest);
+ cfa_temp.offset = INTVAL (src);
+ break;
+
+ /* Rule 7 */
+ case IOR:
+ if (GET_CODE (XEXP (src, 0)) != REG
+ || (unsigned) REGNO (XEXP (src, 0)) != cfa_temp.reg
+ || GET_CODE (XEXP (src, 1)) != CONST_INT)
+ abort ();
+
+ if ((unsigned) REGNO (dest) != cfa_temp.reg)
+ cfa_temp.reg = REGNO (dest);
+ cfa_temp.offset |= INTVAL (XEXP (src, 1));
+ break;
+
+ /* Skip over HIGH, assuming it will be followed by a LO_SUM,
+ which will fill in all of the bits. */
+ /* Rule 8 */
+ case HIGH:
+ break;
+
+ default:
+ abort ();
+ }
+
+ def_cfa_1 (label, &cfa);
+ break;
+
+ case MEM:
+ if (GET_CODE (src) != REG)
+ abort ();
+
+ /* Saving a register to the stack. Make sure dest is relative to the
+ CFA register. */
+ switch (GET_CODE (XEXP (dest, 0)))
+ {
+ /* Rule 10 */
+ /* With a push. */
+ case PRE_MODIFY:
+ /* We can't handle variable size modifications. */
+ if (GET_CODE (XEXP (XEXP (XEXP (dest, 0), 1), 1)) != CONST_INT)
+ abort ();
+ offset = -INTVAL (XEXP (XEXP (XEXP (dest, 0), 1), 1));
+
+ if (REGNO (XEXP (XEXP (dest, 0), 0)) != STACK_POINTER_REGNUM
+ || cfa_store.reg != STACK_POINTER_REGNUM)
+ abort ();
+
+ cfa_store.offset += offset;
+ if (cfa.reg == STACK_POINTER_REGNUM)
+ cfa.offset = cfa_store.offset;
+
+ offset = -cfa_store.offset;
+ break;
+
+ /* Rule 11 */
+ case PRE_INC:
+ case PRE_DEC:
+ offset = GET_MODE_SIZE (GET_MODE (dest));
+ if (GET_CODE (XEXP (dest, 0)) == PRE_INC)
+ offset = -offset;
+
+ if (REGNO (XEXP (XEXP (dest, 0), 0)) != STACK_POINTER_REGNUM
+ || cfa_store.reg != STACK_POINTER_REGNUM)
+ abort ();
+ cfa_store.offset += offset;
+ if (cfa.reg == STACK_POINTER_REGNUM)
+ cfa.offset = cfa_store.offset;
+
+ offset = -cfa_store.offset;
+ break;
+
+ /* Rule 12 */
+ /* With an offset. */
+ case PLUS:
+ case MINUS:
+ case LO_SUM:
+ if (GET_CODE (XEXP (XEXP (dest, 0), 1)) != CONST_INT)
+ abort ();
+ offset = INTVAL (XEXP (XEXP (dest, 0), 1));
+ if (GET_CODE (XEXP (dest, 0)) == MINUS)
+ offset = -offset;
+
+ if (cfa_store.reg == (unsigned) REGNO (XEXP (XEXP (dest, 0), 0)))
+ offset -= cfa_store.offset;
+ else if (cfa_temp.reg == (unsigned) REGNO (XEXP (XEXP (dest, 0), 0)))
+ offset -= cfa_temp.offset;
+ else
+ abort ();
+ break;
+
+ /* Rule 13 */
+ /* Without an offset. */
+ case REG:
+ if (cfa_store.reg == (unsigned) REGNO (XEXP (dest, 0)))
+ offset = -cfa_store.offset;
+ else if (cfa_temp.reg == (unsigned) REGNO (XEXP (dest, 0)))
+ offset = -cfa_temp.offset;
+ else
+ abort ();
+ break;
+
+ /* Rule 14 */
+ case POST_INC:
+ if (cfa_temp.reg != (unsigned) REGNO (XEXP (XEXP (dest, 0), 0)))
+ abort ();
+ offset = -cfa_temp.offset;
+ cfa_temp.offset -= GET_MODE_SIZE (GET_MODE (dest));
+ break;
+
+ default:
+ abort ();
+ }
+
+ if (REGNO (src) != STACK_POINTER_REGNUM
+ && REGNO (src) != HARD_FRAME_POINTER_REGNUM
+ && (unsigned) REGNO (src) == cfa.reg)
+ {
+ /* We're storing the current CFA reg into the stack. */
+
+ if (cfa.offset == 0)
+ {
+ /* If the source register is exactly the CFA, assume
+ 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);
+ break;
+ }
+ else
+ {
+ /* Otherwise, we'll need to look in the stack to
+ calculate the CFA. */
+ rtx x = XEXP (dest, 0);
+
+ if (GET_CODE (x) != REG)
+ x = XEXP (x, 0);
+ if (GET_CODE (x) != REG)
+ abort ();
+
+ cfa.reg = REGNO (x);
+ cfa.base_offset = offset;
+ cfa.indirect = 1;
+ def_cfa_1 (label, &cfa);
+ break;
+ }
+ }
+
+ def_cfa_1 (label, &cfa);
+ queue_reg_save (label, src, offset);
+ break;
+
+ default:
+ abort ();
+ }
+}
/* Record call frame debugging information for INSN, which either
sets SP or FP (adjusting how we calculate the frame address) or saves a
@@ -1424,280 +1611,171 @@ void
dwarf2out_frame_debug (insn)
rtx insn;
{
- char *label;
+ const char *label;
rtx src;
if (insn == NULL_RTX)
{
+ /* Flush any queued register saves. */
+ flush_queued_reg_saves ();
+
/* Set up state for generating call frame debug info. */
- lookup_cfa (&cfa_reg, &cfa_offset);
- if (cfa_reg != DWARF_FRAME_REGNUM (STACK_POINTER_REGNUM))
+ lookup_cfa (&cfa);
+ if (cfa.reg != (unsigned long) DWARF_FRAME_REGNUM (STACK_POINTER_REGNUM))
abort ();
- cfa_reg = STACK_POINTER_REGNUM;
- cfa_store_reg = cfa_reg;
- cfa_store_offset = cfa_offset;
- cfa_temp_reg = -1;
- cfa_temp_value = 0;
+
+ cfa.reg = STACK_POINTER_REGNUM;
+ cfa_store = cfa;
+ cfa_temp.reg = -1;
+ cfa_temp.offset = 0;
return;
}
+ if (GET_CODE (insn) != INSN || clobbers_queued_reg_save (insn))
+ flush_queued_reg_saves ();
+
if (! RTX_FRAME_RELATED_P (insn))
{
- dwarf2out_stack_adjust (insn);
+ if (!ACCUMULATE_OUTGOING_ARGS)
+ dwarf2out_stack_adjust (insn);
+
return;
}
label = dwarf2out_cfi_label ();
-
src = find_reg_note (insn, REG_FRAME_RELATED_EXPR, NULL_RTX);
if (src)
insn = XEXP (src, 0);
- else
+ else
insn = PATTERN (insn);
dwarf2out_frame_debug_expr (insn, label);
}
-/* Return the size of an unsigned LEB128 quantity. */
-
-static inline unsigned long
-size_of_uleb128 (value)
- register unsigned long value;
-{
- register unsigned long size = 0;
- register unsigned byte;
-
- do
- {
- byte = (value & 0x7f);
- value >>= 7;
- size += 1;
- }
- while (value != 0);
-
- return size;
-}
-
-/* Return the size of a signed LEB128 quantity. */
-
-static inline unsigned long
-size_of_sleb128 (value)
- register long value;
-{
- register unsigned long size = 0;
- register unsigned byte;
-
- do
- {
- byte = (value & 0x7f);
- value >>= 7;
- size += 1;
- }
- while (!(((value == 0) && ((byte & 0x40) == 0))
- || ((value == -1) && ((byte & 0x40) != 0))));
-
- return size;
-}
-
-/* Output an unsigned LEB128 quantity. */
-
-static void
-output_uleb128 (value)
- register unsigned long value;
-{
- unsigned long save_value = value;
-
- fprintf (asm_out_file, "\t%s\t", ASM_BYTE_OP);
- do
- {
- register unsigned byte = (value & 0x7f);
- value >>= 7;
- if (value != 0)
- /* More bytes to follow. */
- byte |= 0x80;
-
- fprintf (asm_out_file, "0x%x", byte);
- if (value != 0)
- fprintf (asm_out_file, ",");
- }
- while (value != 0);
-
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s ULEB128 0x%lx", ASM_COMMENT_START, save_value);
-}
-
-/* Output an signed LEB128 quantity. */
-
-static void
-output_sleb128 (value)
- register long value;
-{
- register int more;
- register unsigned byte;
- long save_value = value;
-
- fprintf (asm_out_file, "\t%s\t", ASM_BYTE_OP);
- do
- {
- byte = (value & 0x7f);
- /* arithmetic shift */
- value >>= 7;
- more = !((((value == 0) && ((byte & 0x40) == 0))
- || ((value == -1) && ((byte & 0x40) != 0))));
- if (more)
- byte |= 0x80;
-
- fprintf (asm_out_file, "0x%x", byte);
- if (more)
- fprintf (asm_out_file, ",");
- }
-
- while (more);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s SLEB128 %ld", ASM_COMMENT_START, save_value);
-}
-
/* Output a Call Frame Information opcode and its operand(s). */
static void
-output_cfi (cfi, fde)
- register dw_cfi_ref cfi;
- register dw_fde_ref fde;
+output_cfi (cfi, fde, for_eh)
+ dw_cfi_ref cfi;
+ dw_fde_ref fde;
+ int for_eh;
{
if (cfi->dw_cfi_opc == DW_CFA_advance_loc)
- {
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file,
- cfi->dw_cfi_opc
- | (cfi->dw_cfi_oprnd1.dw_cfi_offset & 0x3f));
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DW_CFA_advance_loc 0x%lx",
- ASM_COMMENT_START, cfi->dw_cfi_oprnd1.dw_cfi_offset);
- fputc ('\n', asm_out_file);
- }
-
+ dw2_asm_output_data (1, (cfi->dw_cfi_opc
+ | (cfi->dw_cfi_oprnd1.dw_cfi_offset & 0x3f)),
+ "DW_CFA_advance_loc 0x%lx",
+ cfi->dw_cfi_oprnd1.dw_cfi_offset);
else if (cfi->dw_cfi_opc == DW_CFA_offset)
{
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file,
- cfi->dw_cfi_opc
- | (cfi->dw_cfi_oprnd1.dw_cfi_reg_num & 0x3f));
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DW_CFA_offset, column 0x%lx",
- ASM_COMMENT_START, cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
-
- fputc ('\n', asm_out_file);
- output_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_offset);
- fputc ('\n', asm_out_file);
+ 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);
+ dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_offset, NULL);
}
else if (cfi->dw_cfi_opc == DW_CFA_restore)
- {
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file,
- cfi->dw_cfi_opc
- | (cfi->dw_cfi_oprnd1.dw_cfi_reg_num & 0x3f));
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DW_CFA_restore, column 0x%lx",
- ASM_COMMENT_START, cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
-
- fputc ('\n', asm_out_file);
- }
+ 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);
else
{
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, cfi->dw_cfi_opc);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s %s", ASM_COMMENT_START,
- dwarf_cfi_name (cfi->dw_cfi_opc));
+ dw2_asm_output_data (1, cfi->dw_cfi_opc,
+ "%s", dwarf_cfi_name (cfi->dw_cfi_opc));
- fputc ('\n', asm_out_file);
switch (cfi->dw_cfi_opc)
{
case DW_CFA_set_loc:
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, cfi->dw_cfi_oprnd1.dw_cfi_addr);
- fputc ('\n', asm_out_file);
+ if (for_eh)
+ dw2_asm_output_encoded_addr_rtx (
+ ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/1, /*global=*/0),
+ gen_rtx_SYMBOL_REF (Pmode, cfi->dw_cfi_oprnd1.dw_cfi_addr),
+ NULL);
+ else
+ dw2_asm_output_addr (DWARF2_ADDR_SIZE,
+ cfi->dw_cfi_oprnd1.dw_cfi_addr, NULL);
break;
+
case DW_CFA_advance_loc1:
- ASM_OUTPUT_DWARF_DELTA1 (asm_out_file,
- cfi->dw_cfi_oprnd1.dw_cfi_addr,
- fde->dw_fde_current_label);
- fputc ('\n', asm_out_file);
+ dw2_asm_output_delta (1, cfi->dw_cfi_oprnd1.dw_cfi_addr,
+ fde->dw_fde_current_label, NULL);
fde->dw_fde_current_label = cfi->dw_cfi_oprnd1.dw_cfi_addr;
break;
+
case DW_CFA_advance_loc2:
- ASM_OUTPUT_DWARF_DELTA2 (asm_out_file,
- cfi->dw_cfi_oprnd1.dw_cfi_addr,
- fde->dw_fde_current_label);
- fputc ('\n', asm_out_file);
+ dw2_asm_output_delta (2, cfi->dw_cfi_oprnd1.dw_cfi_addr,
+ fde->dw_fde_current_label, NULL);
fde->dw_fde_current_label = cfi->dw_cfi_oprnd1.dw_cfi_addr;
break;
+
case DW_CFA_advance_loc4:
- ASM_OUTPUT_DWARF_DELTA4 (asm_out_file,
- cfi->dw_cfi_oprnd1.dw_cfi_addr,
- fde->dw_fde_current_label);
- fputc ('\n', asm_out_file);
+ dw2_asm_output_delta (4, cfi->dw_cfi_oprnd1.dw_cfi_addr,
+ fde->dw_fde_current_label, NULL);
fde->dw_fde_current_label = cfi->dw_cfi_oprnd1.dw_cfi_addr;
break;
-#ifdef MIPS_DEBUGGING_INFO
+
case DW_CFA_MIPS_advance_loc8:
- /* TODO: not currently implemented. */
- abort ();
+ dw2_asm_output_delta (8, cfi->dw_cfi_oprnd1.dw_cfi_addr,
+ fde->dw_fde_current_label, NULL);
+ fde->dw_fde_current_label = cfi->dw_cfi_oprnd1.dw_cfi_addr;
break;
-#endif
+
case DW_CFA_offset_extended:
- case DW_CFA_GNU_negative_offset_extended:
case DW_CFA_def_cfa:
- output_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
- fputc ('\n', asm_out_file);
- output_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_offset);
- fputc ('\n', asm_out_file);
+ 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_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);
+ dw2_asm_output_data_sleb128 (cfi->dw_cfi_oprnd2.dw_cfi_offset, NULL);
break;
+
case DW_CFA_restore_extended:
case DW_CFA_undefined:
- output_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
- fputc ('\n', asm_out_file);
- break;
case DW_CFA_same_value:
case DW_CFA_def_cfa_register:
- output_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
- fputc ('\n', asm_out_file);
+ dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num,
+ NULL);
break;
+
case DW_CFA_register:
- output_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
- fputc ('\n', asm_out_file);
- output_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_reg_num);
- fputc ('\n', asm_out_file);
+ 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);
break;
+
case DW_CFA_def_cfa_offset:
- output_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_offset);
- fputc ('\n', asm_out_file);
+ case DW_CFA_GNU_args_size:
+ dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_offset, NULL);
+ break;
+
+ case DW_CFA_def_cfa_offset_sf:
+ dw2_asm_output_data_sleb128 (cfi->dw_cfi_oprnd1.dw_cfi_offset, NULL);
break;
+
case DW_CFA_GNU_window_save:
break;
- case DW_CFA_GNU_args_size:
- output_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_offset);
- fputc ('\n', asm_out_file);
+
+ case DW_CFA_def_cfa_expression:
+ case DW_CFA_expression:
+ output_cfa_loc (cfi);
break;
+
+ case DW_CFA_GNU_negative_offset_extended:
+ /* Obsoleted by DW_CFA_offset_extended_sf. */
+ abort ();
+
default:
break;
}
- }
+ }
}
-#if !defined (EH_FRAME_SECTION)
-#if defined (EH_FRAME_SECTION_ASM_OP)
-#define EH_FRAME_SECTION() eh_frame_section();
-#else
-#if defined (ASM_OUTPUT_SECTION_NAME)
-#define EH_FRAME_SECTION() \
- do { \
- named_section (NULL_TREE, ".eh_frame", 0); \
- } while (0)
-#endif
-#endif
-#endif
-
-/* If we aren't using crtstuff to run ctors, don't use it for EH. */
-#if !defined (HAS_INIT_SECTION) && !defined (INIT_SECTION_ASM_OP)
-#undef EH_FRAME_SECTION
-#endif
-
/* Output the call frame information used to used to record information
that relates to calculating the frame pointer, and records the
location of saved registers. */
@@ -1706,219 +1784,256 @@ static void
output_call_frame_info (for_eh)
int for_eh;
{
- register unsigned long i;
- register dw_fde_ref fde;
- register dw_cfi_ref cfi;
- char l1[20], l2[20];
-#ifdef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
- char ld[20];
-#endif
+ unsigned int i;
+ dw_fde_ref fde;
+ dw_cfi_ref cfi;
+ char l1[20], l2[20], section_start_label[20];
+ int any_lsda_needed = 0;
+ char augmentation[6];
+ int augmentation_size;
+ int fde_encoding = DW_EH_PE_absptr;
+ int per_encoding = DW_EH_PE_absptr;
+ int lsda_encoding = DW_EH_PE_absptr;
+
+ /* If we don't have any functions we'll want to unwind out of, don't emit any
+ EH unwind information. */
+ if (for_eh)
+ {
+ int any_eh_needed = flag_asynchronous_unwind_tables;
- /* Do we want to include a pointer to the exception table? */
- int eh_ptr = for_eh && exception_table_p ();
+ for (i = 0; i < fde_table_in_use; i++)
+ if (fde_table[i].uses_eh_lsda)
+ any_eh_needed = any_lsda_needed = 1;
+ else if (! fde_table[i].nothrow)
+ any_eh_needed = 1;
- fputc ('\n', asm_out_file);
+ if (! any_eh_needed)
+ return;
+ }
/* We're going to be generating comments, so turn on app. */
if (flag_debug_asm)
app_enable ();
if (for_eh)
- {
-#ifdef EH_FRAME_SECTION
- EH_FRAME_SECTION ();
-#else
- tree label = get_file_function_name ('F');
-
- force_data_section ();
- ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE));
- ASM_GLOBALIZE_LABEL (asm_out_file, IDENTIFIER_POINTER (label));
- ASM_OUTPUT_LABEL (asm_out_file, IDENTIFIER_POINTER (label));
-#endif
- assemble_label ("__FRAME_BEGIN__");
- }
+ (*targetm.asm_out.eh_frame_section) ();
else
- ASM_OUTPUT_SECTION (asm_out_file, FRAME_SECTION);
+ named_section_flags (DEBUG_FRAME_SECTION, SECTION_DEBUG);
- /* Output the CIE. */
+ ASM_GENERATE_INTERNAL_LABEL (section_start_label, FRAME_BEGIN_LABEL, for_eh);
+ ASM_OUTPUT_LABEL (asm_out_file, section_start_label);
+
+ /* Output the CIE. */
ASM_GENERATE_INTERNAL_LABEL (l1, CIE_AFTER_SIZE_LABEL, for_eh);
ASM_GENERATE_INTERNAL_LABEL (l2, CIE_END_LABEL, for_eh);
-#ifdef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
- ASM_GENERATE_INTERNAL_LABEL (ld, CIE_LENGTH_LABEL, for_eh);
- if (for_eh)
- ASM_OUTPUT_DWARF_OFFSET4 (asm_out_file, ld);
- else
- ASM_OUTPUT_DWARF_OFFSET (asm_out_file, ld);
-#else
- if (for_eh)
- ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, l2, l1);
- else
- ASM_OUTPUT_DWARF_DELTA (asm_out_file, l2, l1);
-#endif
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s Length of Common Information Entry",
- ASM_COMMENT_START);
-
- fputc ('\n', asm_out_file);
+ dw2_asm_output_delta (for_eh ? 4 : DWARF_OFFSET_SIZE, l2, l1,
+ "Length of Common Information Entry");
ASM_OUTPUT_LABEL (asm_out_file, l1);
- if (for_eh)
- /* Now that the CIE pointer is PC-relative for EH,
- use 0 to identify the CIE. */
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
- else
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, DW_CIE_ID);
+ /* Now that the CIE pointer is PC-relative for EH,
+ use 0 to identify the CIE. */
+ dw2_asm_output_data ((for_eh ? 4 : DWARF_OFFSET_SIZE),
+ (for_eh ? 0 : DW_CIE_ID),
+ "CIE Identifier Tag");
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s CIE Identifier Tag", ASM_COMMENT_START);
+ dw2_asm_output_data (1, DW_CIE_VERSION, "CIE Version");
- fputc ('\n', asm_out_file);
- if (! for_eh && DWARF_OFFSET_SIZE == 8)
+ augmentation[0] = 0;
+ augmentation_size = 0;
+ if (for_eh)
{
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, DW_CIE_ID);
- fputc ('\n', asm_out_file);
- }
+ char *p;
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_CIE_VERSION);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s CIE Version", ASM_COMMENT_START);
+ /* Augmentation:
+ z Indicates that a uleb128 is present to size the
+ augmentation section.
+ L Indicates the encoding (and thus presence) of
+ an LSDA pointer in the FDE augmentation.
+ R Indicates a non-default pointer encoding for
+ FDE code pointers.
+ P Indicates the presence of an encoding + language
+ personality routine in the CIE augmentation. */
- fputc ('\n', asm_out_file);
- if (eh_ptr)
- {
- /* The CIE contains a pointer to the exception region info for the
- frame. Make the augmentation string three bytes (including the
- trailing null) so the pointer is 4-byte aligned. The Solaris ld
- can't handle unaligned relocs. */
- if (flag_debug_asm)
+ fde_encoding = 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);
+
+ p = augmentation + 1;
+ if (eh_personality_libfunc)
{
- ASM_OUTPUT_DWARF_STRING (asm_out_file, "eh");
- fprintf (asm_out_file, "\t%s CIE Augmentation", ASM_COMMENT_START);
+ *p++ = 'P';
+ augmentation_size += 1 + size_of_encoded_value (per_encoding);
}
- else
+ if (any_lsda_needed)
+ {
+ *p++ = 'L';
+ augmentation_size += 1;
+ }
+ if (fde_encoding != DW_EH_PE_absptr)
{
- ASM_OUTPUT_ASCII (asm_out_file, "eh", 3);
+ *p++ = 'R';
+ augmentation_size += 1;
+ }
+ if (p > augmentation + 1)
+ {
+ augmentation[0] = 'z';
+ *p = '\0';
}
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, "__EXCEPTION_TABLE__");
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s pointer to exception region info",
- ASM_COMMENT_START);
- }
- else
- {
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s CIE Augmentation (none)",
- ASM_COMMENT_START);
+ /* Ug. Some platforms can't do unaligned dynamic relocations at all. */
+ if (eh_personality_libfunc && per_encoding == DW_EH_PE_aligned)
+ {
+ int offset = ( 4 /* Length */
+ + 4 /* CIE Id */
+ + 1 /* CIE version */
+ + strlen (augmentation) + 1 /* Augmentation */
+ + size_of_uleb128 (1) /* Code alignment */
+ + size_of_sleb128 (DWARF_CIE_DATA_ALIGNMENT)
+ + 1 /* RA column */
+ + 1 /* Augmentation size */
+ + 1 /* Personality encoding */ );
+ int pad = -offset & (PTR_SIZE - 1);
+
+ augmentation_size += pad;
+
+ /* Augmentations should be small, so there's scarce need to
+ iterate for a solution. Die if we exceed one uleb128 byte. */
+ if (size_of_uleb128 (augmentation_size) != 1)
+ abort ();
+ }
}
- fputc ('\n', asm_out_file);
- output_uleb128 (1);
- if (flag_debug_asm)
- fprintf (asm_out_file, " (CIE Code Alignment Factor)");
+ dw2_asm_output_nstring (augmentation, -1, "CIE Augmentation");
+ 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");
- fputc ('\n', asm_out_file);
- output_sleb128 (DWARF_CIE_DATA_ALIGNMENT);
- if (flag_debug_asm)
- fprintf (asm_out_file, " (CIE Data Alignment Factor)");
+ if (augmentation[0])
+ {
+ dw2_asm_output_data_uleb128 (augmentation_size, "Augmentation size");
+ if (eh_personality_libfunc)
+ {
+ dw2_asm_output_data (1, per_encoding, "Personality (%s)",
+ eh_data_format_name (per_encoding));
+ dw2_asm_output_encoded_addr_rtx (per_encoding,
+ eh_personality_libfunc, NULL);
+ }
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DWARF_FRAME_RETURN_COLUMN);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s CIE RA Column", ASM_COMMENT_START);
+ if (any_lsda_needed)
+ dw2_asm_output_data (1, lsda_encoding, "LSDA Encoding (%s)",
+ eh_data_format_name (lsda_encoding));
- fputc ('\n', asm_out_file);
+ if (fde_encoding != DW_EH_PE_absptr)
+ dw2_asm_output_data (1, fde_encoding, "FDE Encoding (%s)",
+ eh_data_format_name (fde_encoding));
+ }
for (cfi = cie_cfi_head; cfi != NULL; cfi = cfi->dw_cfi_next)
- output_cfi (cfi, NULL);
+ output_cfi (cfi, NULL, for_eh);
/* Pad the CIE out to an address sized boundary. */
- ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE));
+ ASM_OUTPUT_ALIGN (asm_out_file,
+ floor_log2 (for_eh ? PTR_SIZE : DWARF2_ADDR_SIZE));
ASM_OUTPUT_LABEL (asm_out_file, l2);
-#ifdef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
- ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL (asm_out_file, ld, l2, l1);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s CIE Length Symbol", ASM_COMMENT_START);
- fputc ('\n', asm_out_file);
-#endif
/* Loop through all of the FDE's. */
- for (i = 0; i < fde_table_in_use; ++i)
+ for (i = 0; i < fde_table_in_use; i++)
{
fde = &fde_table[i];
- 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);
-#ifdef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
- ASM_GENERATE_INTERNAL_LABEL (ld, FDE_LENGTH_LABEL, for_eh + i*2);
- if (for_eh)
- ASM_OUTPUT_DWARF_OFFSET4 (asm_out_file, ld);
- else
- ASM_OUTPUT_DWARF_OFFSET (asm_out_file, ld);
-#else
+ /* Don't emit EH unwind info for leaf functions that don't need it. */
+ if (for_eh && fde->nothrow && ! fde->uses_eh_lsda)
+ continue;
+
+ ASM_OUTPUT_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,
+ "FDE Length");
+ ASM_OUTPUT_LABEL (asm_out_file, l1);
+
if (for_eh)
- ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, l2, l1);
+ dw2_asm_output_delta (4, l1, section_start_label, "FDE CIE offset");
else
- ASM_OUTPUT_DWARF_DELTA (asm_out_file, l2, l1);
-#endif
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s FDE Length", ASM_COMMENT_START);
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_LABEL (asm_out_file, l1);
+ dw2_asm_output_offset (DWARF_OFFSET_SIZE, section_start_label,
+ "FDE CIE offset");
- /* ??? This always emits a 4 byte offset when for_eh is true, but it
- emits a target dependent sized offset when for_eh is not true.
- This inconsistency may confuse gdb. The only case where we need a
- non-4 byte offset is for the Irix6 N64 ABI, so we may lose SGI
- compatibility if we emit a 4 byte offset. We need a 4 byte offset
- though in order to be compatible with the dwarf_fde struct in frame.c.
- If the for_eh case is changed, then the struct in frame.c has
- to be adjusted appropriately. */
if (for_eh)
- ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, l1, "__FRAME_BEGIN__");
+ {
+ 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");
+ }
else
- ASM_OUTPUT_DWARF_OFFSET (asm_out_file, stripattributes (FRAME_SECTION));
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s FDE CIE offset", ASM_COMMENT_START);
+ {
+ dw2_asm_output_addr (DWARF2_ADDR_SIZE, fde->dw_fde_begin,
+ "FDE initial location");
+ dw2_asm_output_delta (DWARF2_ADDR_SIZE,
+ fde->dw_fde_end, fde->dw_fde_begin,
+ "FDE address range");
+ }
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, fde->dw_fde_begin);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s FDE initial location", ASM_COMMENT_START);
+ if (augmentation[0])
+ {
+ if (any_lsda_needed)
+ {
+ int size = size_of_encoded_value (lsda_encoding);
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_ADDR_DELTA (asm_out_file,
- fde->dw_fde_end, fde->dw_fde_begin);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s FDE address range", ASM_COMMENT_START);
+ if (lsda_encoding == DW_EH_PE_aligned)
+ {
+ int offset = ( 4 /* Length */
+ + 4 /* CIE offset */
+ + 2 * size_of_encoded_value (fde_encoding)
+ + 1 /* Augmentation size */ );
+ int pad = -offset & (PTR_SIZE - 1);
+
+ size += pad;
+ if (size_of_uleb128 (size) != 1)
+ abort ();
+ }
- fputc ('\n', asm_out_file);
+ dw2_asm_output_data_uleb128 (size, "Augmentation size");
+
+ if (fde->uses_eh_lsda)
+ {
+ ASM_GENERATE_INTERNAL_LABEL (l1, "LLSDA",
+ fde->funcdef_number);
+ dw2_asm_output_encoded_addr_rtx (
+ lsda_encoding, gen_rtx_SYMBOL_REF (Pmode, l1),
+ "Language Specific Data Area");
+ }
+ else
+ {
+ if (lsda_encoding == DW_EH_PE_aligned)
+ ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE));
+ dw2_asm_output_data
+ (size_of_encoded_value (lsda_encoding), 0,
+ "Language Specific Data Area (none)");
+ }
+ }
+ else
+ dw2_asm_output_data_uleb128 (0, "Augmentation size");
+ }
/* Loop through the Call Frame Instructions associated with
this FDE. */
fde->dw_fde_current_label = fde->dw_fde_begin;
for (cfi = fde->dw_fde_cfi; cfi != NULL; cfi = cfi->dw_cfi_next)
- output_cfi (cfi, fde);
+ output_cfi (cfi, fde, for_eh);
/* Pad the FDE out to an address sized boundary. */
- ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE));
+ ASM_OUTPUT_ALIGN (asm_out_file,
+ floor_log2 ((for_eh ? PTR_SIZE : DWARF2_ADDR_SIZE)));
ASM_OUTPUT_LABEL (asm_out_file, l2);
-#ifdef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
- ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL (asm_out_file, ld, l2, l1);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s FDE Length Symbol", ASM_COMMENT_START);
- fputc ('\n', asm_out_file);
-#endif
}
-#ifndef EH_FRAME_SECTION
+
+#ifndef EH_FRAME_SECTION_NAME
if (for_eh)
- {
- /* Emit terminating zero for table. */
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
- fputc ('\n', asm_out_file);
- }
+ dw2_asm_output_data (4, 0, "End of Table");
#endif
#ifdef MIPS_DEBUGGING_INFO
/* Work around Irix 6 assembler bug whereby labels at the end of a section
@@ -1935,17 +2050,40 @@ output_call_frame_info (for_eh)
the prologue. */
void
-dwarf2out_begin_prologue ()
+dwarf2out_begin_prologue (line, file)
+ unsigned int line ATTRIBUTE_UNUSED;
+ const char *file ATTRIBUTE_UNUSED;
{
char label[MAX_ARTIFICIAL_LABEL_BYTES];
- register dw_fde_ref fde;
+ dw_fde_ref fde;
+
+ current_function_func_begin_label = 0;
- ++current_funcdef_number;
+#ifdef IA64_UNWIND_INFO
+ /* ??? current_function_func_begin_label is also used by except.c
+ for call-site information. We must emit this label if it might
+ be used. */
+ if ((! flag_exceptions || USING_SJLJ_EXCEPTIONS)
+ && ! dwarf2out_do_frame ())
+ return;
+#else
+ if (! dwarf2out_do_frame ())
+ return;
+#endif
+ current_funcdef_number++;
function_section (current_function_decl);
ASM_GENERATE_INTERNAL_LABEL (label, FUNC_BEGIN_LABEL,
current_funcdef_number);
- ASM_OUTPUT_LABEL (asm_out_file, label);
+ ASM_OUTPUT_DEBUG_LABEL (asm_out_file, FUNC_BEGIN_LABEL,
+ current_funcdef_number);
+ current_function_func_begin_label = get_identifier (label);
+
+#ifdef IA64_UNWIND_INFO
+ /* We can elide the fde allocation if we're not emitting debug info. */
+ if (! dwarf2out_do_frame ())
+ return;
+#endif
/* Expand the fde table if necessary. */
if (fde_table_in_use == fde_table_allocated)
@@ -1965,8 +2103,18 @@ dwarf2out_begin_prologue ()
fde->dw_fde_current_label = NULL;
fde->dw_fde_end = NULL;
fde->dw_fde_cfi = NULL;
+ fde->funcdef_number = current_funcdef_number;
+ fde->nothrow = current_function_nothrow;
+ fde->uses_eh_lsda = cfun->uses_eh_lsda;
args_size = old_args_size = 0;
+
+ /* We only want to output line number information for the genuine dwarf2
+ prologue case, not the eh frame case. */
+#ifdef DWARF2_DEBUGGING_INFO
+ if (file)
+ dwarf2out_source_line (line, file);
+#endif
}
/* Output a marker (i.e. a label) for the absolute end of the generated code
@@ -1980,7 +2128,7 @@ dwarf2out_end_epilogue ()
char label[MAX_ARTIFICIAL_LABEL_BYTES];
/* Output a label to mark the endpoint of the code generated for this
- function. */
+ function. */
ASM_GENERATE_INTERNAL_LABEL (label, FUNC_END_LABEL, current_funcdef_number);
ASM_OUTPUT_LABEL (asm_out_file, label);
fde = &fde_table[fde_table_in_use - 1];
@@ -1991,9 +2139,7 @@ void
dwarf2out_frame_init ()
{
/* Allocate the initial hunk of the fde_table. */
- fde_table
- = (dw_fde_ref) xmalloc (FDE_TABLE_INCREMENT * sizeof (dw_fde_node));
- bzero ((char *) fde_table, FDE_TABLE_INCREMENT * sizeof (dw_fde_node));
+ fde_table = (dw_fde_ref) xcalloc (FDE_TABLE_INCREMENT, sizeof (dw_fde_node));
fde_table_allocated = FDE_TABLE_INCREMENT;
fde_table_in_use = 0;
@@ -2011,33 +2157,20 @@ void
dwarf2out_frame_finish ()
{
/* Output call frame information. */
-#ifdef MIPS_DEBUGGING_INFO
- if (write_symbols == DWARF2_DEBUG)
+ if (write_symbols == DWARF2_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
output_call_frame_info (0);
- if (flag_exceptions && ! exceptions_via_longjmp)
- output_call_frame_info (1);
-#else
- if (write_symbols == DWARF2_DEBUG
- || (flag_exceptions && ! exceptions_via_longjmp))
- output_call_frame_info (1);
-#endif
-}
-
-#endif /* .debug_frame support */
-
-/* And now, the support for symbolic debugging information. */
-#ifdef DWARF2_DEBUGGING_INFO
-
-extern char *getpwd PROTO((void));
-/* NOTE: In the comments in this file, many references are made to
- "Debugging Information Entries". This term is abbreviated as `DIE'
- throughout the remainder of this file. */
+ if (! USING_SJLJ_EXCEPTIONS && (flag_unwind_tables || flag_exceptions))
+ output_call_frame_info (1);
+}
+
+/* And now, the subset of the debugging information support code necessary
+ for emitting location expressions. */
-/* An internal representation of the DWARF output is built, and then
- walked to generate the DWARF debugging info. The walk of the internal
- representation is done after the entire program has been compiled.
- The types below are used to describe the internal representation. */
+typedef struct dw_val_struct *dw_val_ref;
+typedef struct die_struct *dw_die_ref;
+typedef struct dw_loc_descr_struct *dw_loc_descr_ref;
+typedef struct dw_loc_list_struct *dw_loc_list_ref;
/* Each DIE may have a series of attribute/value pairs. Values
can take on several forms. The forms that are used in this
@@ -2046,7 +2179,10 @@ extern char *getpwd PROTO((void));
typedef enum
{
dw_val_class_addr,
+ dw_val_class_offset,
dw_val_class_loc,
+ dw_val_class_loc_list,
+ dw_val_class_range_list,
dw_val_class_const,
dw_val_class_unsigned_const,
dw_val_class_long_long,
@@ -2060,23 +2196,8 @@ typedef enum
}
dw_val_class;
-/* Various DIE's use offsets relative to the beginning of the
- .debug_info section to refer to each other. */
-
-typedef long int dw_offset;
-
-/* Define typedefs here to avoid circular dependencies. */
-
-typedef struct die_struct *dw_die_ref;
-typedef struct dw_attr_struct *dw_attr_ref;
-typedef struct dw_val_struct *dw_val_ref;
-typedef struct dw_line_info_struct *dw_line_info_ref;
-typedef struct dw_separate_line_info_struct *dw_separate_line_info_ref;
-typedef struct dw_loc_descr_struct *dw_loc_descr_ref;
-typedef struct pubname_struct *pubname_ref;
-typedef dw_die_ref *arange_ref;
-
/* Describe a double word constant value. */
+/* ??? Every instance of long_long in the code really means CONST_DOUBLE. */
typedef struct dw_long_long_struct
{
@@ -2094,28 +2215,6 @@ typedef struct dw_fp_struct
}
dw_float_const;
-/* Each entry in the line_info_table maintains the file and
- line number associated with the label generated for that
- entry. The label gives the PC value associated with
- the line number entry. */
-
-typedef struct dw_line_info_struct
-{
- unsigned long dw_file_num;
- unsigned long dw_line_num;
-}
-dw_line_info_entry;
-
-/* Line information for functions in separate sections; each one gets its
- own sequence. */
-typedef struct dw_separate_line_info_struct
-{
- unsigned long dw_file_num;
- unsigned long dw_line_num;
- unsigned long function;
-}
-dw_separate_line_info_entry;
-
/* The dw_val_node describes an attribute's value, as it is
represented internally. */
@@ -2124,15 +2223,21 @@ typedef struct dw_val_struct
dw_val_class val_class;
union
{
- char *val_addr;
+ rtx val_addr;
+ long unsigned val_offset;
+ dw_loc_list_ref val_loc_list;
dw_loc_descr_ref val_loc;
long int val_int;
long unsigned val_unsigned;
dw_long_long_const val_long_long;
dw_float_const val_float;
- dw_die_ref val_die_ref;
+ struct
+ {
+ dw_die_ref die;
+ int external;
+ } val_die_ref;
unsigned val_fde_index;
- char *val_str;
+ struct indirect_string_node *val_str;
char *val_lbl_id;
unsigned char val_flag;
}
@@ -2149,9 +2254,906 @@ typedef struct dw_loc_descr_struct
enum dwarf_location_atom dw_loc_opc;
dw_val_node dw_loc_oprnd1;
dw_val_node dw_loc_oprnd2;
+ int dw_loc_addr;
}
dw_loc_descr_node;
+/* Location lists are ranges + location descriptions for that range,
+ so you can track variables that are in different places over
+ their entire life. */
+typedef struct dw_loc_list_struct
+{
+ dw_loc_list_ref dw_loc_next;
+ const char *begin; /* Label for begin address of range */
+ const char *end; /* Label for end address of range */
+ char *ll_symbol; /* Label for beginning of location list.
+ Only on head of list */
+ const char *section; /* Section this loclist is relative to */
+ dw_loc_descr_ref expr;
+} dw_loc_list_node;
+
+static const char *dwarf_stack_op_name PARAMS ((unsigned));
+static dw_loc_descr_ref new_loc_descr PARAMS ((enum dwarf_location_atom,
+ unsigned long,
+ unsigned long));
+static void add_loc_descr PARAMS ((dw_loc_descr_ref *,
+ dw_loc_descr_ref));
+static unsigned long size_of_loc_descr PARAMS ((dw_loc_descr_ref));
+static unsigned long size_of_locs PARAMS ((dw_loc_descr_ref));
+static void output_loc_operands PARAMS ((dw_loc_descr_ref));
+static void output_loc_sequence PARAMS ((dw_loc_descr_ref));
+
+/* Convert a DWARF stack opcode into its string name. */
+
+static const char *
+dwarf_stack_op_name (op)
+ unsigned op;
+{
+ switch (op)
+ {
+ case DW_OP_addr:
+ return "DW_OP_addr";
+ case DW_OP_deref:
+ return "DW_OP_deref";
+ case DW_OP_const1u:
+ return "DW_OP_const1u";
+ case DW_OP_const1s:
+ return "DW_OP_const1s";
+ case DW_OP_const2u:
+ return "DW_OP_const2u";
+ case DW_OP_const2s:
+ return "DW_OP_const2s";
+ case DW_OP_const4u:
+ return "DW_OP_const4u";
+ case DW_OP_const4s:
+ return "DW_OP_const4s";
+ case DW_OP_const8u:
+ return "DW_OP_const8u";
+ case DW_OP_const8s:
+ return "DW_OP_const8s";
+ case DW_OP_constu:
+ return "DW_OP_constu";
+ case DW_OP_consts:
+ return "DW_OP_consts";
+ case DW_OP_dup:
+ return "DW_OP_dup";
+ case DW_OP_drop:
+ return "DW_OP_drop";
+ case DW_OP_over:
+ return "DW_OP_over";
+ case DW_OP_pick:
+ return "DW_OP_pick";
+ case DW_OP_swap:
+ return "DW_OP_swap";
+ case DW_OP_rot:
+ return "DW_OP_rot";
+ case DW_OP_xderef:
+ return "DW_OP_xderef";
+ case DW_OP_abs:
+ return "DW_OP_abs";
+ case DW_OP_and:
+ return "DW_OP_and";
+ case DW_OP_div:
+ return "DW_OP_div";
+ case DW_OP_minus:
+ return "DW_OP_minus";
+ case DW_OP_mod:
+ return "DW_OP_mod";
+ case DW_OP_mul:
+ return "DW_OP_mul";
+ case DW_OP_neg:
+ return "DW_OP_neg";
+ case DW_OP_not:
+ return "DW_OP_not";
+ case DW_OP_or:
+ return "DW_OP_or";
+ case DW_OP_plus:
+ return "DW_OP_plus";
+ case DW_OP_plus_uconst:
+ return "DW_OP_plus_uconst";
+ case DW_OP_shl:
+ return "DW_OP_shl";
+ case DW_OP_shr:
+ return "DW_OP_shr";
+ case DW_OP_shra:
+ return "DW_OP_shra";
+ case DW_OP_xor:
+ return "DW_OP_xor";
+ case DW_OP_bra:
+ return "DW_OP_bra";
+ case DW_OP_eq:
+ return "DW_OP_eq";
+ case DW_OP_ge:
+ return "DW_OP_ge";
+ case DW_OP_gt:
+ return "DW_OP_gt";
+ case DW_OP_le:
+ return "DW_OP_le";
+ case DW_OP_lt:
+ return "DW_OP_lt";
+ case DW_OP_ne:
+ return "DW_OP_ne";
+ case DW_OP_skip:
+ return "DW_OP_skip";
+ case DW_OP_lit0:
+ return "DW_OP_lit0";
+ case DW_OP_lit1:
+ return "DW_OP_lit1";
+ case DW_OP_lit2:
+ return "DW_OP_lit2";
+ case DW_OP_lit3:
+ return "DW_OP_lit3";
+ case DW_OP_lit4:
+ return "DW_OP_lit4";
+ case DW_OP_lit5:
+ return "DW_OP_lit5";
+ case DW_OP_lit6:
+ return "DW_OP_lit6";
+ case DW_OP_lit7:
+ return "DW_OP_lit7";
+ case DW_OP_lit8:
+ return "DW_OP_lit8";
+ case DW_OP_lit9:
+ return "DW_OP_lit9";
+ case DW_OP_lit10:
+ return "DW_OP_lit10";
+ case DW_OP_lit11:
+ return "DW_OP_lit11";
+ case DW_OP_lit12:
+ return "DW_OP_lit12";
+ case DW_OP_lit13:
+ return "DW_OP_lit13";
+ case DW_OP_lit14:
+ return "DW_OP_lit14";
+ case DW_OP_lit15:
+ return "DW_OP_lit15";
+ case DW_OP_lit16:
+ return "DW_OP_lit16";
+ case DW_OP_lit17:
+ return "DW_OP_lit17";
+ case DW_OP_lit18:
+ return "DW_OP_lit18";
+ case DW_OP_lit19:
+ return "DW_OP_lit19";
+ case DW_OP_lit20:
+ return "DW_OP_lit20";
+ case DW_OP_lit21:
+ return "DW_OP_lit21";
+ case DW_OP_lit22:
+ return "DW_OP_lit22";
+ case DW_OP_lit23:
+ return "DW_OP_lit23";
+ case DW_OP_lit24:
+ return "DW_OP_lit24";
+ case DW_OP_lit25:
+ return "DW_OP_lit25";
+ case DW_OP_lit26:
+ return "DW_OP_lit26";
+ case DW_OP_lit27:
+ return "DW_OP_lit27";
+ case DW_OP_lit28:
+ return "DW_OP_lit28";
+ case DW_OP_lit29:
+ return "DW_OP_lit29";
+ case DW_OP_lit30:
+ return "DW_OP_lit30";
+ case DW_OP_lit31:
+ return "DW_OP_lit31";
+ case DW_OP_reg0:
+ return "DW_OP_reg0";
+ case DW_OP_reg1:
+ return "DW_OP_reg1";
+ case DW_OP_reg2:
+ return "DW_OP_reg2";
+ case DW_OP_reg3:
+ return "DW_OP_reg3";
+ case DW_OP_reg4:
+ return "DW_OP_reg4";
+ case DW_OP_reg5:
+ return "DW_OP_reg5";
+ case DW_OP_reg6:
+ return "DW_OP_reg6";
+ case DW_OP_reg7:
+ return "DW_OP_reg7";
+ case DW_OP_reg8:
+ return "DW_OP_reg8";
+ case DW_OP_reg9:
+ return "DW_OP_reg9";
+ case DW_OP_reg10:
+ return "DW_OP_reg10";
+ case DW_OP_reg11:
+ return "DW_OP_reg11";
+ case DW_OP_reg12:
+ return "DW_OP_reg12";
+ case DW_OP_reg13:
+ return "DW_OP_reg13";
+ case DW_OP_reg14:
+ return "DW_OP_reg14";
+ case DW_OP_reg15:
+ return "DW_OP_reg15";
+ case DW_OP_reg16:
+ return "DW_OP_reg16";
+ case DW_OP_reg17:
+ return "DW_OP_reg17";
+ case DW_OP_reg18:
+ return "DW_OP_reg18";
+ case DW_OP_reg19:
+ return "DW_OP_reg19";
+ case DW_OP_reg20:
+ return "DW_OP_reg20";
+ case DW_OP_reg21:
+ return "DW_OP_reg21";
+ case DW_OP_reg22:
+ return "DW_OP_reg22";
+ case DW_OP_reg23:
+ return "DW_OP_reg23";
+ case DW_OP_reg24:
+ return "DW_OP_reg24";
+ case DW_OP_reg25:
+ return "DW_OP_reg25";
+ case DW_OP_reg26:
+ return "DW_OP_reg26";
+ case DW_OP_reg27:
+ return "DW_OP_reg27";
+ case DW_OP_reg28:
+ return "DW_OP_reg28";
+ case DW_OP_reg29:
+ return "DW_OP_reg29";
+ case DW_OP_reg30:
+ return "DW_OP_reg30";
+ case DW_OP_reg31:
+ return "DW_OP_reg31";
+ case DW_OP_breg0:
+ return "DW_OP_breg0";
+ case DW_OP_breg1:
+ return "DW_OP_breg1";
+ case DW_OP_breg2:
+ return "DW_OP_breg2";
+ case DW_OP_breg3:
+ return "DW_OP_breg3";
+ case DW_OP_breg4:
+ return "DW_OP_breg4";
+ case DW_OP_breg5:
+ return "DW_OP_breg5";
+ case DW_OP_breg6:
+ return "DW_OP_breg6";
+ case DW_OP_breg7:
+ return "DW_OP_breg7";
+ case DW_OP_breg8:
+ return "DW_OP_breg8";
+ case DW_OP_breg9:
+ return "DW_OP_breg9";
+ case DW_OP_breg10:
+ return "DW_OP_breg10";
+ case DW_OP_breg11:
+ return "DW_OP_breg11";
+ case DW_OP_breg12:
+ return "DW_OP_breg12";
+ case DW_OP_breg13:
+ return "DW_OP_breg13";
+ case DW_OP_breg14:
+ return "DW_OP_breg14";
+ case DW_OP_breg15:
+ return "DW_OP_breg15";
+ case DW_OP_breg16:
+ return "DW_OP_breg16";
+ case DW_OP_breg17:
+ return "DW_OP_breg17";
+ case DW_OP_breg18:
+ return "DW_OP_breg18";
+ case DW_OP_breg19:
+ return "DW_OP_breg19";
+ case DW_OP_breg20:
+ return "DW_OP_breg20";
+ case DW_OP_breg21:
+ return "DW_OP_breg21";
+ case DW_OP_breg22:
+ return "DW_OP_breg22";
+ case DW_OP_breg23:
+ return "DW_OP_breg23";
+ case DW_OP_breg24:
+ return "DW_OP_breg24";
+ case DW_OP_breg25:
+ return "DW_OP_breg25";
+ case DW_OP_breg26:
+ return "DW_OP_breg26";
+ case DW_OP_breg27:
+ return "DW_OP_breg27";
+ case DW_OP_breg28:
+ return "DW_OP_breg28";
+ case DW_OP_breg29:
+ return "DW_OP_breg29";
+ case DW_OP_breg30:
+ return "DW_OP_breg30";
+ case DW_OP_breg31:
+ return "DW_OP_breg31";
+ case DW_OP_regx:
+ return "DW_OP_regx";
+ case DW_OP_fbreg:
+ return "DW_OP_fbreg";
+ case DW_OP_bregx:
+ return "DW_OP_bregx";
+ case DW_OP_piece:
+ return "DW_OP_piece";
+ case DW_OP_deref_size:
+ return "DW_OP_deref_size";
+ case DW_OP_xderef_size:
+ return "DW_OP_xderef_size";
+ case DW_OP_nop:
+ return "DW_OP_nop";
+ default:
+ return "OP_<unknown>";
+ }
+}
+
+/* Return a pointer to a newly allocated location description. Location
+ descriptions are simple expression terms that can be strung
+ together to form more complicated location (address) descriptions. */
+
+static inline dw_loc_descr_ref
+new_loc_descr (op, oprnd1, oprnd2)
+ enum dwarf_location_atom op;
+ unsigned long oprnd1;
+ unsigned long oprnd2;
+{
+ /* Use xcalloc here so we clear out all of the long_long constant in
+ the union. */
+ dw_loc_descr_ref descr
+ = (dw_loc_descr_ref) xcalloc (1, sizeof (dw_loc_descr_node));
+
+ descr->dw_loc_opc = op;
+ descr->dw_loc_oprnd1.val_class = dw_val_class_unsigned_const;
+ descr->dw_loc_oprnd1.v.val_unsigned = oprnd1;
+ descr->dw_loc_oprnd2.val_class = dw_val_class_unsigned_const;
+ descr->dw_loc_oprnd2.v.val_unsigned = oprnd2;
+
+ return descr;
+}
+
+
+/* Add a location description term to a location description expression. */
+
+static inline void
+add_loc_descr (list_head, descr)
+ dw_loc_descr_ref *list_head;
+ dw_loc_descr_ref descr;
+{
+ dw_loc_descr_ref *d;
+
+ /* Find the end of the chain. */
+ for (d = list_head; (*d) != NULL; d = &(*d)->dw_loc_next)
+ ;
+
+ *d = descr;
+}
+
+/* Return the size of a location descriptor. */
+
+static unsigned long
+size_of_loc_descr (loc)
+ dw_loc_descr_ref loc;
+{
+ unsigned long size = 1;
+
+ switch (loc->dw_loc_opc)
+ {
+ case DW_OP_addr:
+ size += DWARF2_ADDR_SIZE;
+ break;
+ case DW_OP_const1u:
+ case DW_OP_const1s:
+ size += 1;
+ break;
+ case DW_OP_const2u:
+ case DW_OP_const2s:
+ size += 2;
+ break;
+ case DW_OP_const4u:
+ case DW_OP_const4s:
+ size += 4;
+ break;
+ case DW_OP_const8u:
+ case DW_OP_const8s:
+ size += 8;
+ break;
+ case DW_OP_constu:
+ size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
+ break;
+ case DW_OP_consts:
+ size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int);
+ break;
+ case DW_OP_pick:
+ size += 1;
+ break;
+ case DW_OP_plus_uconst:
+ size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
+ break;
+ case DW_OP_skip:
+ case DW_OP_bra:
+ size += 2;
+ break;
+ case DW_OP_breg0:
+ case DW_OP_breg1:
+ case DW_OP_breg2:
+ case DW_OP_breg3:
+ case DW_OP_breg4:
+ case DW_OP_breg5:
+ case DW_OP_breg6:
+ case DW_OP_breg7:
+ case DW_OP_breg8:
+ case DW_OP_breg9:
+ case DW_OP_breg10:
+ case DW_OP_breg11:
+ case DW_OP_breg12:
+ case DW_OP_breg13:
+ case DW_OP_breg14:
+ case DW_OP_breg15:
+ case DW_OP_breg16:
+ case DW_OP_breg17:
+ case DW_OP_breg18:
+ case DW_OP_breg19:
+ case DW_OP_breg20:
+ case DW_OP_breg21:
+ case DW_OP_breg22:
+ case DW_OP_breg23:
+ case DW_OP_breg24:
+ case DW_OP_breg25:
+ case DW_OP_breg26:
+ case DW_OP_breg27:
+ case DW_OP_breg28:
+ case DW_OP_breg29:
+ case DW_OP_breg30:
+ case DW_OP_breg31:
+ size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int);
+ break;
+ case DW_OP_regx:
+ size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
+ break;
+ case DW_OP_fbreg:
+ size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int);
+ break;
+ case DW_OP_bregx:
+ size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
+ size += size_of_sleb128 (loc->dw_loc_oprnd2.v.val_int);
+ break;
+ case DW_OP_piece:
+ size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
+ break;
+ case DW_OP_deref_size:
+ case DW_OP_xderef_size:
+ size += 1;
+ break;
+ default:
+ break;
+ }
+
+ return size;
+}
+
+/* Return the size of a series of location descriptors. */
+
+static unsigned long
+size_of_locs (loc)
+ dw_loc_descr_ref loc;
+{
+ unsigned long size;
+
+ for (size = 0; loc != NULL; loc = loc->dw_loc_next)
+ {
+ loc->dw_loc_addr = size;
+ size += size_of_loc_descr (loc);
+ }
+
+ return size;
+}
+
+/* Output location description stack opcode's operands (if any). */
+
+static void
+output_loc_operands (loc)
+ dw_loc_descr_ref loc;
+{
+ dw_val_ref val1 = &loc->dw_loc_oprnd1;
+ dw_val_ref val2 = &loc->dw_loc_oprnd2;
+
+ switch (loc->dw_loc_opc)
+ {
+#ifdef DWARF2_DEBUGGING_INFO
+ case DW_OP_addr:
+ dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE, val1->v.val_addr, NULL);
+ break;
+ case DW_OP_const2u:
+ case DW_OP_const2s:
+ dw2_asm_output_data (2, val1->v.val_int, NULL);
+ break;
+ case DW_OP_const4u:
+ case DW_OP_const4s:
+ dw2_asm_output_data (4, val1->v.val_int, NULL);
+ break;
+ case DW_OP_const8u:
+ case DW_OP_const8s:
+ if (HOST_BITS_PER_LONG < 64)
+ abort ();
+ dw2_asm_output_data (8, val1->v.val_int, NULL);
+ break;
+ case DW_OP_skip:
+ case DW_OP_bra:
+ {
+ int offset;
+
+ if (val1->val_class == dw_val_class_loc)
+ offset = val1->v.val_loc->dw_loc_addr - (loc->dw_loc_addr + 3);
+ else
+ abort ();
+
+ dw2_asm_output_data (2, offset, NULL);
+ }
+ break;
+#else
+ case DW_OP_addr:
+ case DW_OP_const2u:
+ case DW_OP_const2s:
+ case DW_OP_const4u:
+ case DW_OP_const4s:
+ case DW_OP_const8u:
+ case DW_OP_const8s:
+ case DW_OP_skip:
+ case DW_OP_bra:
+ /* We currently don't make any attempt to make sure these are
+ aligned properly like we do for the main unwind info, so
+ don't support emitting things larger than a byte if we're
+ only doing unwinding. */
+ abort ();
+#endif
+ case DW_OP_const1u:
+ case DW_OP_const1s:
+ dw2_asm_output_data (1, val1->v.val_int, NULL);
+ break;
+ case DW_OP_constu:
+ dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
+ break;
+ case DW_OP_consts:
+ dw2_asm_output_data_sleb128 (val1->v.val_int, NULL);
+ break;
+ case DW_OP_pick:
+ dw2_asm_output_data (1, val1->v.val_int, NULL);
+ break;
+ case DW_OP_plus_uconst:
+ dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
+ break;
+ case DW_OP_breg0:
+ case DW_OP_breg1:
+ case DW_OP_breg2:
+ case DW_OP_breg3:
+ case DW_OP_breg4:
+ case DW_OP_breg5:
+ case DW_OP_breg6:
+ case DW_OP_breg7:
+ case DW_OP_breg8:
+ case DW_OP_breg9:
+ case DW_OP_breg10:
+ case DW_OP_breg11:
+ case DW_OP_breg12:
+ case DW_OP_breg13:
+ case DW_OP_breg14:
+ case DW_OP_breg15:
+ case DW_OP_breg16:
+ case DW_OP_breg17:
+ case DW_OP_breg18:
+ case DW_OP_breg19:
+ case DW_OP_breg20:
+ case DW_OP_breg21:
+ case DW_OP_breg22:
+ case DW_OP_breg23:
+ case DW_OP_breg24:
+ case DW_OP_breg25:
+ case DW_OP_breg26:
+ case DW_OP_breg27:
+ case DW_OP_breg28:
+ case DW_OP_breg29:
+ case DW_OP_breg30:
+ case DW_OP_breg31:
+ dw2_asm_output_data_sleb128 (val1->v.val_int, NULL);
+ break;
+ case DW_OP_regx:
+ dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
+ break;
+ case DW_OP_fbreg:
+ dw2_asm_output_data_sleb128 (val1->v.val_int, NULL);
+ break;
+ case DW_OP_bregx:
+ dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
+ dw2_asm_output_data_sleb128 (val2->v.val_int, NULL);
+ break;
+ case DW_OP_piece:
+ dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
+ break;
+ case DW_OP_deref_size:
+ case DW_OP_xderef_size:
+ dw2_asm_output_data (1, val1->v.val_int, NULL);
+ break;
+ default:
+ /* Other codes have no operands. */
+ break;
+ }
+}
+
+/* Output a sequence of location operations. */
+
+static void
+output_loc_sequence (loc)
+ dw_loc_descr_ref loc;
+{
+ for (; loc != NULL; loc = loc->dw_loc_next)
+ {
+ /* Output the opcode. */
+ dw2_asm_output_data (1, loc->dw_loc_opc,
+ "%s", dwarf_stack_op_name (loc->dw_loc_opc));
+
+ /* Output the operand(s) (if any). */
+ output_loc_operands (loc);
+ }
+}
+
+/* This routine will generate the correct assembly data for a location
+ description based on a cfi entry with a complex address. */
+
+static void
+output_cfa_loc (cfi)
+ dw_cfi_ref cfi;
+{
+ dw_loc_descr_ref loc;
+ unsigned long size;
+
+ /* Output the size of the block. */
+ loc = cfi->dw_cfi_oprnd1.dw_cfi_loc;
+ size = size_of_locs (loc);
+ dw2_asm_output_data_uleb128 (size, NULL);
+
+ /* Now output the operations themselves. */
+ output_loc_sequence (loc);
+}
+
+/* This function builds a dwarf location descriptor sequence from
+ a dw_cfa_location. */
+
+static struct dw_loc_descr_struct *
+build_cfa_loc (cfa)
+ dw_cfa_location *cfa;
+{
+ struct dw_loc_descr_struct *head, *tmp;
+
+ if (cfa->indirect == 0)
+ abort ();
+
+ if (cfa->base_offset)
+ {
+ if (cfa->reg <= 31)
+ head = new_loc_descr (DW_OP_breg0 + cfa->reg, cfa->base_offset, 0);
+ else
+ head = new_loc_descr (DW_OP_bregx, cfa->reg, cfa->base_offset);
+ }
+ else if (cfa->reg <= 31)
+ head = new_loc_descr (DW_OP_reg0 + cfa->reg, 0, 0);
+ else
+ head = new_loc_descr (DW_OP_regx, cfa->reg, 0);
+
+ head->dw_loc_oprnd1.val_class = dw_val_class_const;
+ tmp = new_loc_descr (DW_OP_deref, 0, 0);
+ add_loc_descr (&head, tmp);
+ if (cfa->offset != 0)
+ {
+ tmp = new_loc_descr (DW_OP_plus_uconst, cfa->offset, 0);
+ add_loc_descr (&head, tmp);
+ }
+
+ return head;
+}
+
+/* This function fills in aa dw_cfa_location structure from a dwarf location
+ descriptor sequence. */
+
+static void
+get_cfa_from_loc_descr (cfa, loc)
+ dw_cfa_location *cfa;
+ struct dw_loc_descr_struct *loc;
+{
+ struct dw_loc_descr_struct *ptr;
+ cfa->offset = 0;
+ cfa->base_offset = 0;
+ cfa->indirect = 0;
+ cfa->reg = -1;
+
+ for (ptr = loc; ptr != NULL; ptr = ptr->dw_loc_next)
+ {
+ enum dwarf_location_atom op = ptr->dw_loc_opc;
+
+ switch (op)
+ {
+ case DW_OP_reg0:
+ case DW_OP_reg1:
+ case DW_OP_reg2:
+ case DW_OP_reg3:
+ case DW_OP_reg4:
+ case DW_OP_reg5:
+ case DW_OP_reg6:
+ case DW_OP_reg7:
+ case DW_OP_reg8:
+ case DW_OP_reg9:
+ case DW_OP_reg10:
+ case DW_OP_reg11:
+ case DW_OP_reg12:
+ case DW_OP_reg13:
+ case DW_OP_reg14:
+ case DW_OP_reg15:
+ case DW_OP_reg16:
+ case DW_OP_reg17:
+ case DW_OP_reg18:
+ case DW_OP_reg19:
+ case DW_OP_reg20:
+ case DW_OP_reg21:
+ case DW_OP_reg22:
+ case DW_OP_reg23:
+ case DW_OP_reg24:
+ case DW_OP_reg25:
+ case DW_OP_reg26:
+ case DW_OP_reg27:
+ case DW_OP_reg28:
+ case DW_OP_reg29:
+ case DW_OP_reg30:
+ case DW_OP_reg31:
+ cfa->reg = op - DW_OP_reg0;
+ break;
+ case DW_OP_regx:
+ cfa->reg = ptr->dw_loc_oprnd1.v.val_int;
+ break;
+ case DW_OP_breg0:
+ case DW_OP_breg1:
+ case DW_OP_breg2:
+ case DW_OP_breg3:
+ case DW_OP_breg4:
+ case DW_OP_breg5:
+ case DW_OP_breg6:
+ case DW_OP_breg7:
+ case DW_OP_breg8:
+ case DW_OP_breg9:
+ case DW_OP_breg10:
+ case DW_OP_breg11:
+ case DW_OP_breg12:
+ case DW_OP_breg13:
+ case DW_OP_breg14:
+ case DW_OP_breg15:
+ case DW_OP_breg16:
+ case DW_OP_breg17:
+ case DW_OP_breg18:
+ case DW_OP_breg19:
+ case DW_OP_breg20:
+ case DW_OP_breg21:
+ case DW_OP_breg22:
+ case DW_OP_breg23:
+ case DW_OP_breg24:
+ case DW_OP_breg25:
+ case DW_OP_breg26:
+ case DW_OP_breg27:
+ case DW_OP_breg28:
+ case DW_OP_breg29:
+ case DW_OP_breg30:
+ case DW_OP_breg31:
+ cfa->reg = op - DW_OP_breg0;
+ cfa->base_offset = ptr->dw_loc_oprnd1.v.val_int;
+ break;
+ case DW_OP_bregx:
+ cfa->reg = ptr->dw_loc_oprnd1.v.val_int;
+ cfa->base_offset = ptr->dw_loc_oprnd2.v.val_int;
+ break;
+ case DW_OP_deref:
+ cfa->indirect = 1;
+ break;
+ case DW_OP_plus_uconst:
+ cfa->offset = ptr->dw_loc_oprnd1.v.val_unsigned;
+ break;
+ default:
+ internal_error ("DW_LOC_OP %s not implemented\n",
+ dwarf_stack_op_name (ptr->dw_loc_opc));
+ }
+ }
+}
+#endif /* .debug_frame support */
+
+/* And now, the support for symbolic debugging information. */
+#ifdef DWARF2_DEBUGGING_INFO
+
+/* .debug_str support. */
+static hashnode indirect_string_alloc PARAMS ((hash_table *));
+static int output_indirect_string PARAMS ((struct cpp_reader *,
+ hashnode, const PTR));
+
+
+static void dwarf2out_init PARAMS ((const char *));
+static void dwarf2out_finish PARAMS ((const char *));
+static void dwarf2out_define PARAMS ((unsigned int, const char *));
+static void dwarf2out_undef PARAMS ((unsigned int, const char *));
+static void dwarf2out_start_source_file PARAMS ((unsigned, const char *));
+static void dwarf2out_end_source_file PARAMS ((unsigned));
+static void dwarf2out_begin_block PARAMS ((unsigned, unsigned));
+static void dwarf2out_end_block PARAMS ((unsigned, unsigned));
+static bool dwarf2out_ignore_block PARAMS ((tree));
+static void dwarf2out_global_decl PARAMS ((tree));
+static void dwarf2out_abstract_function PARAMS ((tree));
+
+/* The debug hooks structure. */
+
+struct gcc_debug_hooks dwarf2_debug_hooks =
+{
+ dwarf2out_init,
+ dwarf2out_finish,
+ dwarf2out_define,
+ dwarf2out_undef,
+ dwarf2out_start_source_file,
+ dwarf2out_end_source_file,
+ dwarf2out_begin_block,
+ dwarf2out_end_block,
+ dwarf2out_ignore_block,
+ dwarf2out_source_line,
+ dwarf2out_begin_prologue,
+ debug_nothing_int, /* end_prologue */
+ dwarf2out_end_epilogue,
+ debug_nothing_tree, /* begin_function */
+ debug_nothing_int, /* end_function */
+ dwarf2out_decl, /* function_decl */
+ dwarf2out_global_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 */
+};
+
+/* NOTE: In the comments in this file, many references are made to
+ "Debugging Information Entries". This term is abbreviated as `DIE'
+ throughout the remainder of this file. */
+
+/* An internal representation of the DWARF output is built, and then
+ walked to generate the DWARF debugging info. The walk of the internal
+ representation is done after the entire program has been compiled.
+ The types below are used to describe the internal representation. */
+
+/* Various DIE's use offsets relative to the beginning of the
+ .debug_info section to refer to each other. */
+
+typedef long int dw_offset;
+
+/* Define typedefs here to avoid circular dependencies. */
+
+typedef struct dw_attr_struct *dw_attr_ref;
+typedef struct dw_line_info_struct *dw_line_info_ref;
+typedef struct dw_separate_line_info_struct *dw_separate_line_info_ref;
+typedef struct pubname_struct *pubname_ref;
+typedef struct dw_ranges_struct *dw_ranges_ref;
+
+/* Each entry in the line_info_table maintains the file and
+ line number associated with the label generated for that
+ entry. The label gives the PC value associated with
+ the line number entry. */
+
+typedef struct dw_line_info_struct
+{
+ unsigned long dw_file_num;
+ unsigned long dw_line_num;
+}
+dw_line_info_entry;
+
+/* Line information for functions in separate sections; each one gets its
+ own sequence. */
+typedef struct dw_separate_line_info_struct
+{
+ unsigned long dw_file_num;
+ unsigned long dw_line_num;
+ unsigned long function;
+}
+dw_separate_line_info_entry;
+
/* Each DIE attribute has a field specifying the attribute kind,
a link to the next attribute in the chain, and an attribute value.
Attributes are typically linked below the DIE they modify. */
@@ -2169,14 +3171,14 @@ dw_attr_node;
typedef struct die_struct
{
enum dwarf_tag die_tag;
+ char *die_symbol;
dw_attr_ref die_attr;
- dw_attr_ref die_attr_last;
dw_die_ref die_parent;
dw_die_ref die_child;
- dw_die_ref die_child_last;
dw_die_ref die_sib;
dw_offset die_offset;
unsigned long die_abbrev;
+ int die_mark;
}
die_node;
@@ -2185,14 +3187,20 @@ die_node;
typedef struct pubname_struct
{
dw_die_ref die;
- char * name;
+ char *name;
}
pubname_entry;
+struct dw_ranges_struct
+{
+ int block_num;
+};
+
/* The limbo die list structure. */
typedef struct limbo_die_struct
{
dw_die_ref die;
+ tree created_for;
struct limbo_die_struct *next;
}
limbo_die_node;
@@ -2227,8 +3235,6 @@ limbo_die_node;
language, and compiler version. */
extern int flag_traditional;
-extern char *version_string;
-extern char *language_string;
/* Fixed size portion of the DWARF compilation unit header. */
#define DWARF_COMPILE_UNIT_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 3)
@@ -2240,8 +3246,24 @@ extern char *language_string;
#define DWARF_PUBNAMES_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 2)
/* Fixed size portion of the address range info. */
-#define DWARF_ARANGES_HEADER_SIZE \
- (DWARF_ROUND (2 * DWARF_OFFSET_SIZE + 4, PTR_SIZE * 2) - DWARF_OFFSET_SIZE)
+#define DWARF_ARANGES_HEADER_SIZE \
+ (DWARF_ROUND (2 * DWARF_OFFSET_SIZE + 4, DWARF2_ADDR_SIZE * 2) \
+ - DWARF_OFFSET_SIZE)
+
+/* Size of padding portion in the address range info. It must be
+ aligned to twice the pointer size. */
+#define DWARF_ARANGES_PAD_SIZE \
+ (DWARF_ROUND (2 * DWARF_OFFSET_SIZE + 4, DWARF2_ADDR_SIZE * 2) \
+ - (2 * DWARF_OFFSET_SIZE + 4))
+
+/* Use assembler line directives if available. */
+#ifndef DWARF2_ASM_LINE_DEBUG_INFO
+#ifdef HAVE_AS_DWARF2_DEBUG_LINE
+#define DWARF2_ASM_LINE_DEBUG_INFO 1
+#else
+#define DWARF2_ASM_LINE_DEBUG_INFO 0
+#endif
+#endif
/* Define the architecture-dependent minimum instruction length (in bytes).
In this implementation of DWARF, this field is used for information
@@ -2249,7 +3271,6 @@ extern char *language_string;
no a priori knowledge of how many instruction bytes are generated
for each source line, and therefore can use only the DW_LNE_set_address
and DW_LNS_fixed_advance_pc line information commands. */
-
#ifndef DWARF_LINE_MIN_INSTR_LENGTH
#define DWARF_LINE_MIN_INSTR_LENGTH 4
#endif
@@ -2258,7 +3279,7 @@ extern char *language_string;
This value was chosen to give a reasonable range of values. */
#define DWARF_LINE_BASE -10
-/* First special line opcde - leave room for the standard opcodes. */
+/* First special line opcode - leave room for the standard opcodes. */
#define DWARF_LINE_OPCODE_BASE 10
/* Range of line offsets in a special line info. opcode. */
@@ -2280,31 +3301,25 @@ static dw_die_ref comp_unit_die;
/* A list of DIEs with a NULL parent waiting to be relocated. */
static limbo_die_node *limbo_die_list = 0;
-/* Pointer to an array of filenames referenced by this compilation unit. */
-static char **file_table;
-
-/* Total number of entries in the table (i.e. array) pointed to by
- `file_table'. This is the *total* and includes both used and unused
- slots. */
-static unsigned file_table_allocated;
-
-/* Number of entries in the file_table which are actually in use. */
-static unsigned file_table_in_use;
+/* Structure used by lookup_filename to manage sets of filenames. */
+struct file_table
+{
+ char **table;
+ unsigned allocated;
+ unsigned in_use;
+ unsigned last_lookup_index;
+};
/* Size (in elements) of increments by which we may expand the filename
table. */
#define FILE_TABLE_INCREMENT 64
+/* Filenames referenced by this compilation unit. */
+static struct file_table file_table;
+
/* Local pointer to the name of the main input file. Initialized in
dwarf2out_init. */
-static char *primary_filename;
-
-/* For Dwarf output, we must assign lexical-blocks id numbers in the order in
- which their beginnings are encountered. We output Dwarf debugging info
- that refers to the beginnings and ends of the ranges of code for each
- lexical block. The labels themselves are generated in final.c, which
- assigns numbers to the blocks in the same way. */
-static unsigned next_block_number = 2;
+static const char *primary_filename;
/* 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
@@ -2321,33 +3336,12 @@ static unsigned decl_die_table_in_use;
decl_die_table. */
#define DECL_DIE_TABLE_INCREMENT 256
-/* Structure used for the decl_scope table. scope is the current declaration
- scope, and previous is the entry that is the parent of this scope. This
- is usually but not always the immediately preceeding entry. */
-
-typedef struct decl_scope_struct
-{
- tree scope;
- int previous;
-}
-decl_scope_node;
-
/* A pointer to the base of a table of references to declaration
scopes. This table is a display which tracks the nesting
of declaration scopes at the current scope and containing
scopes. This table is used to find the proper place to
define type declaration DIE's. */
-static decl_scope_node *decl_scope_table;
-
-/* Number of elements currently allocated for the decl_scope_table. */
-static int decl_scope_table_allocated;
-
-/* Current level of nesting of declaration scopes. */
-static int decl_scope_depth;
-
-/* Size (in elements) of increments by which we may expand the
- decl_scope_table. */
-#define DECL_SCOPE_TABLE_INCREMENT 64
+varray_type decl_scope_table;
/* A pointer to the base of a list of references to DIE's that
are uniquely identified by their tag, presence/absence of
@@ -2402,9 +3396,8 @@ static unsigned pubname_table_in_use;
pubname_table. */
#define PUBNAME_TABLE_INCREMENT 64
-/* A pointer to the base of a table that contains a list of publicly
- accessible names. */
-static arange_ref arange_table;
+/* Array of dies for which we should generate .debug_arange info. */
+static dw_die_ref *arange_table;
/* Number of elements currently allocated for arange_table. */
static unsigned arange_table_allocated;
@@ -2416,38 +3409,26 @@ static unsigned arange_table_in_use;
arange_table. */
#define ARANGE_TABLE_INCREMENT 64
-/* A pointer to the base of a list of pending types which we haven't
- generated DIEs for yet, but which we will have to come back to
- later on. */
+/* Array of dies for which we should generate .debug_ranges info. */
+static dw_ranges_ref ranges_table;
-static tree *pending_types_list;
+/* Number of elements currently allocated for ranges_table. */
+static unsigned ranges_table_allocated;
-/* Number of elements currently allocated for the pending_types_list. */
-static unsigned pending_types_allocated;
+/* Number of elements in ranges_table currently in use. */
+static unsigned ranges_table_in_use;
-/* Number of elements of pending_types_list currently in use. */
-static unsigned pending_types;
+/* Size (in elements) of increments by which we may expand the
+ ranges_table. */
+#define RANGES_TABLE_INCREMENT 64
-/* Size (in elements) of increments by which we may expand the pending
- types list. Actually, a single hunk of space of this size should
- be enough for most typical programs. */
-#define PENDING_TYPES_INCREMENT 64
+/* Whether we have location lists that need outputting */
+static unsigned have_location_lists;
/* A pointer to the base of a list of incomplete types which might be
- completed at some later time. */
-
-static tree *incomplete_types_list;
-
-/* Number of elements currently allocated for the incomplete_types_list. */
-static unsigned incomplete_types_allocated;
-
-/* Number of elements of incomplete_types_list currently in use. */
-static unsigned incomplete_types;
-
-/* Size (in elements) of increments by which we may expand the incomplete
- types list. Actually, a single hunk of space of this size should
- be enough for most typical programs. */
-#define INCOMPLETE_TYPES_INCREMENT 64
+ completed at some later time. incomplete_types_list needs to be a VARRAY
+ because we want to tell the garbage collector about it. */
+varray_type incomplete_types;
/* Record whether the function being analyzed contains inlined functions. */
static int current_function_has_inlines;
@@ -2455,248 +3436,320 @@ static int current_function_has_inlines;
static int comp_unit_has_inlines;
#endif
-/* A pointer to the ..._DECL node which we have most recently been working
- on. We keep this around just in case something about it looks screwy and
- we want to tell the user what the source coordinates for the actual
- declaration are. */
-static tree dwarf_last_decl;
+/* Array of RTXes referenced by the debugging information, which therefore
+ must be kept around forever. This is a GC root. */
+static varray_type used_rtx_varray;
/* Forward declarations for functions defined in this file. */
-static void addr_const_to_string PROTO((dyn_string_t, rtx));
-static char *addr_to_string PROTO((rtx));
-static int is_pseudo_reg PROTO((rtx));
-static tree type_main_variant PROTO((tree));
-static int is_tagged_type PROTO((tree));
-static char *dwarf_tag_name PROTO((unsigned));
-static char *dwarf_attr_name PROTO((unsigned));
-static char *dwarf_form_name PROTO((unsigned));
-static char *dwarf_stack_op_name PROTO((unsigned));
+static int is_pseudo_reg PARAMS ((rtx));
+static tree type_main_variant PARAMS ((tree));
+static int is_tagged_type PARAMS ((tree));
+static const char *dwarf_tag_name PARAMS ((unsigned));
+static const char *dwarf_attr_name PARAMS ((unsigned));
+static const char *dwarf_form_name PARAMS ((unsigned));
#if 0
-static char *dwarf_type_encoding_name PROTO((unsigned));
+static const char *dwarf_type_encoding_name PARAMS ((unsigned));
#endif
-static tree decl_ultimate_origin PROTO((tree));
-static tree block_ultimate_origin PROTO((tree));
-static tree decl_class_context PROTO((tree));
-static void add_dwarf_attr PROTO((dw_die_ref, dw_attr_ref));
-static void add_AT_flag PROTO((dw_die_ref,
- enum dwarf_attribute,
- unsigned));
-static void add_AT_int PROTO((dw_die_ref,
- enum dwarf_attribute, long));
-static void add_AT_unsigned PROTO((dw_die_ref,
- enum dwarf_attribute,
- unsigned long));
-static void add_AT_long_long PROTO((dw_die_ref,
- enum dwarf_attribute,
- unsigned long, unsigned long));
-static void add_AT_float PROTO((dw_die_ref,
- enum dwarf_attribute,
- unsigned, long *));
-static void add_AT_string PROTO((dw_die_ref,
- enum dwarf_attribute, char *));
-static void add_AT_die_ref PROTO((dw_die_ref,
- enum dwarf_attribute,
- dw_die_ref));
-static void add_AT_fde_ref PROTO((dw_die_ref,
- enum dwarf_attribute,
- unsigned));
-static void add_AT_loc PROTO((dw_die_ref,
- enum dwarf_attribute,
- dw_loc_descr_ref));
-static void add_AT_addr PROTO((dw_die_ref,
- enum dwarf_attribute, char *));
-static void add_AT_lbl_id PROTO((dw_die_ref,
- enum dwarf_attribute, char *));
-static void add_AT_lbl_offset PROTO((dw_die_ref,
- enum dwarf_attribute, char *));
-static int is_extern_subr_die PROTO((dw_die_ref));
-static dw_attr_ref get_AT PROTO((dw_die_ref,
- enum dwarf_attribute));
-static char *get_AT_low_pc PROTO((dw_die_ref));
-static char *get_AT_hi_pc PROTO((dw_die_ref));
-static char *get_AT_string PROTO((dw_die_ref,
- enum dwarf_attribute));
-static int get_AT_flag PROTO((dw_die_ref,
- enum dwarf_attribute));
-static unsigned get_AT_unsigned PROTO((dw_die_ref,
- enum dwarf_attribute));
-static int is_c_family PROTO((void));
-static int is_fortran PROTO((void));
-static void remove_AT PROTO((dw_die_ref,
- enum dwarf_attribute));
-static void remove_children PROTO((dw_die_ref));
-static void add_child_die PROTO((dw_die_ref, dw_die_ref));
-static dw_die_ref new_die PROTO((enum dwarf_tag, dw_die_ref));
-static dw_die_ref lookup_type_die PROTO((tree));
-static void equate_type_number_to_die PROTO((tree, dw_die_ref));
-static dw_die_ref lookup_decl_die PROTO((tree));
-static void equate_decl_number_to_die PROTO((tree, dw_die_ref));
-static dw_loc_descr_ref new_loc_descr PROTO((enum dwarf_location_atom,
- unsigned long, unsigned long));
-static void add_loc_descr PROTO((dw_loc_descr_ref *,
- dw_loc_descr_ref));
-static void print_spaces PROTO((FILE *));
-static void print_die PROTO((dw_die_ref, FILE *));
-static void print_dwarf_line_table PROTO((FILE *));
-static void add_sibling_attributes PROTO((dw_die_ref));
-static void build_abbrev_table PROTO((dw_die_ref));
-static unsigned long size_of_string PROTO((char *));
-static unsigned long size_of_loc_descr PROTO((dw_loc_descr_ref));
-static unsigned long size_of_locs PROTO((dw_loc_descr_ref));
-static int constant_size PROTO((long unsigned));
-static unsigned long size_of_die PROTO((dw_die_ref));
-static void calc_die_sizes PROTO((dw_die_ref));
-static unsigned long size_of_line_prolog PROTO((void));
-static unsigned long size_of_line_info PROTO((void));
-static unsigned long size_of_pubnames PROTO((void));
-static unsigned long size_of_aranges PROTO((void));
-static enum dwarf_form value_format PROTO((dw_val_ref));
-static void output_value_format PROTO((dw_val_ref));
-static void output_abbrev_section PROTO((void));
-static void output_loc_operands PROTO((dw_loc_descr_ref));
-static unsigned long sibling_offset PROTO((dw_die_ref));
-static void output_die PROTO((dw_die_ref));
-static void output_compilation_unit_header PROTO((void));
-static char *dwarf2_name PROTO((tree, int));
-static void add_pubname PROTO((tree, dw_die_ref));
-static void output_pubnames PROTO((void));
-static void add_arange PROTO((tree, dw_die_ref));
-static void output_aranges PROTO((void));
-static void output_line_info PROTO((void));
-static int is_body_block PROTO((tree));
-static dw_die_ref base_type_die PROTO((tree));
-static tree root_type PROTO((tree));
-static int is_base_type PROTO((tree));
-static dw_die_ref modified_type_die PROTO((tree, int, int, dw_die_ref));
-static int type_is_enum PROTO((tree));
-static dw_loc_descr_ref reg_loc_descriptor PROTO((rtx));
-static dw_loc_descr_ref based_loc_descr PROTO((unsigned, long));
-static int is_based_loc PROTO((rtx));
-static dw_loc_descr_ref mem_loc_descriptor PROTO((rtx));
-static dw_loc_descr_ref concat_loc_descriptor PROTO((rtx, rtx));
-static dw_loc_descr_ref loc_descriptor PROTO((rtx));
-static unsigned ceiling PROTO((unsigned, unsigned));
-static tree field_type PROTO((tree));
-static unsigned simple_type_align_in_bits PROTO((tree));
-static unsigned simple_type_size_in_bits PROTO((tree));
-static unsigned field_byte_offset PROTO((tree));
-static void add_AT_location_description PROTO((dw_die_ref,
- enum dwarf_attribute, rtx));
-static void add_data_member_location_attribute PROTO((dw_die_ref, tree));
-static void add_const_value_attribute PROTO((dw_die_ref, rtx));
-static void add_location_or_const_value_attribute PROTO((dw_die_ref, tree));
-static void add_name_attribute PROTO((dw_die_ref, char *));
-static void add_bound_info PROTO((dw_die_ref,
- enum dwarf_attribute, tree));
-static void add_subscript_info PROTO((dw_die_ref, tree));
-static void add_byte_size_attribute PROTO((dw_die_ref, tree));
-static void add_bit_offset_attribute PROTO((dw_die_ref, tree));
-static void add_bit_size_attribute PROTO((dw_die_ref, tree));
-static void add_prototyped_attribute PROTO((dw_die_ref, tree));
-static void add_abstract_origin_attribute PROTO((dw_die_ref, tree));
-static void add_pure_or_virtual_attribute PROTO((dw_die_ref, tree));
-static void add_src_coords_attributes PROTO((dw_die_ref, tree));
-static void add_name_and_src_coords_attributes PROTO((dw_die_ref, tree));
-static void push_decl_scope PROTO((tree));
-static dw_die_ref scope_die_for PROTO((tree, dw_die_ref));
-static void pop_decl_scope PROTO((void));
-static void add_type_attribute PROTO((dw_die_ref, tree, int, int,
- dw_die_ref));
-static char *type_tag PROTO((tree));
-static tree member_declared_type PROTO((tree));
+static tree decl_ultimate_origin PARAMS ((tree));
+static tree block_ultimate_origin PARAMS ((tree));
+static tree decl_class_context PARAMS ((tree));
+static void add_dwarf_attr PARAMS ((dw_die_ref, dw_attr_ref));
+static inline dw_val_class AT_class PARAMS ((dw_attr_ref));
+static void add_AT_flag PARAMS ((dw_die_ref,
+ enum dwarf_attribute,
+ unsigned));
+static inline unsigned AT_flag PARAMS ((dw_attr_ref));
+static void add_AT_int PARAMS ((dw_die_ref,
+ enum dwarf_attribute, long));
+static inline long int AT_int PARAMS ((dw_attr_ref));
+static void add_AT_unsigned PARAMS ((dw_die_ref,
+ enum dwarf_attribute,
+ unsigned long));
+static inline unsigned long AT_unsigned PARAMS ((dw_attr_ref));
+static void add_AT_long_long PARAMS ((dw_die_ref,
+ enum dwarf_attribute,
+ unsigned long,
+ unsigned long));
+static void add_AT_float PARAMS ((dw_die_ref,
+ enum dwarf_attribute,
+ unsigned, long *));
+static void add_AT_string PARAMS ((dw_die_ref,
+ enum dwarf_attribute,
+ const char *));
+static inline const char *AT_string PARAMS ((dw_attr_ref));
+static int AT_string_form PARAMS ((dw_attr_ref));
+static void add_AT_die_ref PARAMS ((dw_die_ref,
+ enum dwarf_attribute,
+ dw_die_ref));
+static inline dw_die_ref AT_ref PARAMS ((dw_attr_ref));
+static inline int AT_ref_external PARAMS ((dw_attr_ref));
+static inline void set_AT_ref_external PARAMS ((dw_attr_ref, int));
+static void add_AT_fde_ref PARAMS ((dw_die_ref,
+ enum dwarf_attribute,
+ unsigned));
+static void add_AT_loc PARAMS ((dw_die_ref,
+ enum dwarf_attribute,
+ dw_loc_descr_ref));
+static inline dw_loc_descr_ref AT_loc PARAMS ((dw_attr_ref));
+static void add_AT_loc_list PARAMS ((dw_die_ref,
+ enum dwarf_attribute,
+ dw_loc_list_ref));
+static inline dw_loc_list_ref AT_loc_list PARAMS ((dw_attr_ref));
+static void add_AT_addr PARAMS ((dw_die_ref,
+ enum dwarf_attribute,
+ rtx));
+static inline rtx AT_addr PARAMS ((dw_attr_ref));
+static void add_AT_lbl_id PARAMS ((dw_die_ref,
+ enum dwarf_attribute,
+ const char *));
+static void add_AT_lbl_offset PARAMS ((dw_die_ref,
+ enum dwarf_attribute,
+ const char *));
+static void add_AT_offset PARAMS ((dw_die_ref,
+ enum dwarf_attribute,
+ unsigned long));
+static void add_AT_range_list PARAMS ((dw_die_ref,
+ enum dwarf_attribute,
+ unsigned long));
+static inline const char *AT_lbl PARAMS ((dw_attr_ref));
+static dw_attr_ref get_AT PARAMS ((dw_die_ref,
+ enum dwarf_attribute));
+static const char *get_AT_low_pc PARAMS ((dw_die_ref));
+static const char *get_AT_hi_pc PARAMS ((dw_die_ref));
+static const char *get_AT_string PARAMS ((dw_die_ref,
+ enum dwarf_attribute));
+static int get_AT_flag PARAMS ((dw_die_ref,
+ enum dwarf_attribute));
+static unsigned get_AT_unsigned PARAMS ((dw_die_ref,
+ enum dwarf_attribute));
+static inline dw_die_ref get_AT_ref PARAMS ((dw_die_ref,
+ enum dwarf_attribute));
+static int is_c_family PARAMS ((void));
+static int is_cxx PARAMS ((void));
+static int is_java PARAMS ((void));
+static int is_fortran PARAMS ((void));
+static void remove_AT PARAMS ((dw_die_ref,
+ enum dwarf_attribute));
+static inline void free_die PARAMS ((dw_die_ref));
+static void remove_children PARAMS ((dw_die_ref));
+static void add_child_die PARAMS ((dw_die_ref, dw_die_ref));
+static dw_die_ref new_die PARAMS ((enum dwarf_tag, dw_die_ref,
+ tree));
+static dw_die_ref lookup_type_die PARAMS ((tree));
+static void equate_type_number_to_die PARAMS ((tree, dw_die_ref));
+static dw_die_ref lookup_decl_die PARAMS ((tree));
+static void equate_decl_number_to_die PARAMS ((tree, dw_die_ref));
+static void print_spaces PARAMS ((FILE *));
+static void print_die PARAMS ((dw_die_ref, FILE *));
+static void print_dwarf_line_table PARAMS ((FILE *));
+static void reverse_die_lists PARAMS ((dw_die_ref));
+static void reverse_all_dies PARAMS ((dw_die_ref));
+static dw_die_ref push_new_compile_unit PARAMS ((dw_die_ref, dw_die_ref));
+static dw_die_ref pop_compile_unit PARAMS ((dw_die_ref));
+static void loc_checksum PARAMS ((dw_loc_descr_ref,
+ struct md5_ctx *));
+static void attr_checksum PARAMS ((dw_attr_ref,
+ struct md5_ctx *));
+static void die_checksum PARAMS ((dw_die_ref,
+ struct md5_ctx *));
+static void compute_section_prefix PARAMS ((dw_die_ref));
+static int is_type_die PARAMS ((dw_die_ref));
+static int is_comdat_die PARAMS ((dw_die_ref));
+static int is_symbol_die PARAMS ((dw_die_ref));
+static void assign_symbol_names PARAMS ((dw_die_ref));
+static void break_out_includes PARAMS ((dw_die_ref));
+static void add_sibling_attributes PARAMS ((dw_die_ref));
+static void build_abbrev_table PARAMS ((dw_die_ref));
+static void output_location_lists PARAMS ((dw_die_ref));
+static int constant_size PARAMS ((long unsigned));
+static unsigned long size_of_die PARAMS ((dw_die_ref));
+static void calc_die_sizes PARAMS ((dw_die_ref));
+static void mark_dies PARAMS ((dw_die_ref));
+static void unmark_dies PARAMS ((dw_die_ref));
+static unsigned long size_of_pubnames PARAMS ((void));
+static unsigned long size_of_aranges PARAMS ((void));
+static enum dwarf_form value_format PARAMS ((dw_attr_ref));
+static void output_value_format PARAMS ((dw_attr_ref));
+static void output_abbrev_section PARAMS ((void));
+static void output_die_symbol PARAMS ((dw_die_ref));
+static void output_die PARAMS ((dw_die_ref));
+static void output_compilation_unit_header PARAMS ((void));
+static void output_comp_unit PARAMS ((dw_die_ref));
+static const char *dwarf2_name PARAMS ((tree, int));
+static void add_pubname PARAMS ((tree, dw_die_ref));
+static void output_pubnames PARAMS ((void));
+static void add_arange PARAMS ((tree, dw_die_ref));
+static void output_aranges PARAMS ((void));
+static unsigned int add_ranges PARAMS ((tree));
+static void output_ranges PARAMS ((void));
+static void output_line_info PARAMS ((void));
+static void output_file_names PARAMS ((void));
+static dw_die_ref base_type_die PARAMS ((tree));
+static tree root_type PARAMS ((tree));
+static int is_base_type PARAMS ((tree));
+static dw_die_ref modified_type_die PARAMS ((tree, int, int, dw_die_ref));
+static int type_is_enum PARAMS ((tree));
+static unsigned int reg_number PARAMS ((rtx));
+static dw_loc_descr_ref reg_loc_descriptor PARAMS ((rtx));
+static dw_loc_descr_ref int_loc_descriptor PARAMS ((HOST_WIDE_INT));
+static dw_loc_descr_ref based_loc_descr PARAMS ((unsigned, long));
+static int is_based_loc PARAMS ((rtx));
+static dw_loc_descr_ref mem_loc_descriptor PARAMS ((rtx, enum machine_mode mode));
+static dw_loc_descr_ref concat_loc_descriptor PARAMS ((rtx, rtx));
+static dw_loc_descr_ref loc_descriptor PARAMS ((rtx));
+static dw_loc_descr_ref loc_descriptor_from_tree PARAMS ((tree, int));
+static HOST_WIDE_INT ceiling PARAMS ((HOST_WIDE_INT, unsigned int));
+static tree field_type PARAMS ((tree));
+static unsigned int simple_type_align_in_bits PARAMS ((tree));
+static unsigned int simple_decl_align_in_bits PARAMS ((tree));
+static unsigned HOST_WIDE_INT simple_type_size_in_bits PARAMS ((tree));
+static HOST_WIDE_INT field_byte_offset PARAMS ((tree));
+static void add_AT_location_description PARAMS ((dw_die_ref,
+ enum dwarf_attribute, rtx));
+static void add_data_member_location_attribute PARAMS ((dw_die_ref, tree));
+static void add_const_value_attribute PARAMS ((dw_die_ref, rtx));
+static rtx rtl_for_decl_location PARAMS ((tree));
+static void add_location_or_const_value_attribute PARAMS ((dw_die_ref, tree));
+static void tree_add_const_value_attribute PARAMS ((dw_die_ref, tree));
+static void add_name_attribute PARAMS ((dw_die_ref, const char *));
+static void add_bound_info PARAMS ((dw_die_ref,
+ enum dwarf_attribute, tree));
+static void add_subscript_info PARAMS ((dw_die_ref, tree));
+static void add_byte_size_attribute PARAMS ((dw_die_ref, tree));
+static void add_bit_offset_attribute PARAMS ((dw_die_ref, tree));
+static void add_bit_size_attribute PARAMS ((dw_die_ref, tree));
+static void add_prototyped_attribute PARAMS ((dw_die_ref, tree));
+static void add_abstract_origin_attribute PARAMS ((dw_die_ref, tree));
+static void add_pure_or_virtual_attribute PARAMS ((dw_die_ref, tree));
+static void add_src_coords_attributes PARAMS ((dw_die_ref, tree));
+static void add_name_and_src_coords_attributes PARAMS ((dw_die_ref, tree));
+static void push_decl_scope PARAMS ((tree));
+static void pop_decl_scope PARAMS ((void));
+static dw_die_ref scope_die_for PARAMS ((tree, dw_die_ref));
+static inline int local_scope_p PARAMS ((dw_die_ref));
+static inline int class_scope_p PARAMS ((dw_die_ref));
+static void add_type_attribute PARAMS ((dw_die_ref, tree, int, int,
+ dw_die_ref));
+static const char *type_tag PARAMS ((tree));
+static tree member_declared_type PARAMS ((tree));
#if 0
-static char *decl_start_label PROTO((tree));
+static const char *decl_start_label PARAMS ((tree));
#endif
-static void gen_array_type_die PROTO((tree, dw_die_ref));
-static void gen_set_type_die PROTO((tree, dw_die_ref));
+static void gen_array_type_die PARAMS ((tree, dw_die_ref));
+static void gen_set_type_die PARAMS ((tree, dw_die_ref));
#if 0
-static void gen_entry_point_die PROTO((tree, dw_die_ref));
+static void gen_entry_point_die PARAMS ((tree, dw_die_ref));
#endif
-static void pend_type PROTO((tree));
-static void output_pending_types_for_scope PROTO((dw_die_ref));
-static void gen_inlined_enumeration_type_die PROTO((tree, dw_die_ref));
-static void gen_inlined_structure_type_die PROTO((tree, dw_die_ref));
-static void gen_inlined_union_type_die PROTO((tree, dw_die_ref));
-static void gen_enumeration_type_die PROTO((tree, dw_die_ref));
-static dw_die_ref gen_formal_parameter_die PROTO((tree, dw_die_ref));
-static void gen_unspecified_parameters_die PROTO((tree, dw_die_ref));
-static void gen_formal_types_die PROTO((tree, dw_die_ref));
-static void gen_subprogram_die PROTO((tree, dw_die_ref));
-static void gen_variable_die PROTO((tree, dw_die_ref));
-static void gen_label_die PROTO((tree, dw_die_ref));
-static void gen_lexical_block_die PROTO((tree, dw_die_ref, int));
-static void gen_inlined_subroutine_die PROTO((tree, dw_die_ref, int));
-static void gen_field_die PROTO((tree, dw_die_ref));
-static void gen_ptr_to_mbr_type_die PROTO((tree, dw_die_ref));
-static void gen_compile_unit_die PROTO((char *));
-static void gen_string_type_die PROTO((tree, dw_die_ref));
-static void gen_inheritance_die PROTO((tree, dw_die_ref));
-static void gen_member_die PROTO((tree, dw_die_ref));
-static void gen_struct_or_union_type_die PROTO((tree, dw_die_ref));
-static void gen_subroutine_type_die PROTO((tree, dw_die_ref));
-static void gen_typedef_die PROTO((tree, dw_die_ref));
-static void gen_type_die PROTO((tree, dw_die_ref));
-static void gen_tagged_type_instantiation_die PROTO((tree, dw_die_ref));
-static void gen_block_die PROTO((tree, dw_die_ref, int));
-static void decls_for_scope PROTO((tree, dw_die_ref, int));
-static int is_redundant_typedef PROTO((tree));
-static void gen_decl_die PROTO((tree, dw_die_ref));
-static unsigned lookup_filename PROTO((char *));
+static void gen_inlined_enumeration_type_die PARAMS ((tree, dw_die_ref));
+static void gen_inlined_structure_type_die PARAMS ((tree, dw_die_ref));
+static void gen_inlined_union_type_die PARAMS ((tree, dw_die_ref));
+static void gen_enumeration_type_die PARAMS ((tree, dw_die_ref));
+static dw_die_ref gen_formal_parameter_die PARAMS ((tree, dw_die_ref));
+static void gen_unspecified_parameters_die PARAMS ((tree, dw_die_ref));
+static void gen_formal_types_die PARAMS ((tree, dw_die_ref));
+static void gen_subprogram_die PARAMS ((tree, dw_die_ref));
+static void gen_variable_die PARAMS ((tree, dw_die_ref));
+static void gen_label_die PARAMS ((tree, dw_die_ref));
+static void gen_lexical_block_die PARAMS ((tree, dw_die_ref, int));
+static void gen_inlined_subroutine_die PARAMS ((tree, dw_die_ref, int));
+static void gen_field_die PARAMS ((tree, dw_die_ref));
+static void gen_ptr_to_mbr_type_die PARAMS ((tree, dw_die_ref));
+static dw_die_ref gen_compile_unit_die PARAMS ((const char *));
+static void gen_string_type_die PARAMS ((tree, dw_die_ref));
+static void gen_inheritance_die PARAMS ((tree, dw_die_ref));
+static void gen_member_die PARAMS ((tree, dw_die_ref));
+static void gen_struct_or_union_type_die PARAMS ((tree, dw_die_ref));
+static void gen_subroutine_type_die PARAMS ((tree, dw_die_ref));
+static void gen_typedef_die PARAMS ((tree, dw_die_ref));
+static void gen_type_die PARAMS ((tree, dw_die_ref));
+static void gen_tagged_type_instantiation_die PARAMS ((tree, dw_die_ref));
+static void gen_block_die PARAMS ((tree, dw_die_ref, int));
+static void decls_for_scope PARAMS ((tree, dw_die_ref, int));
+static int is_redundant_typedef PARAMS ((tree));
+static void gen_decl_die PARAMS ((tree, dw_die_ref));
+static unsigned lookup_filename PARAMS ((const char *));
+static void init_file_table PARAMS ((void));
+static void retry_incomplete_types PARAMS ((void));
+static void gen_type_die_for_member PARAMS ((tree, tree, dw_die_ref));
+static void splice_child_die PARAMS ((dw_die_ref, dw_die_ref));
+static int file_info_cmp PARAMS ((const void *, const void *));
+static dw_loc_list_ref new_loc_list PARAMS ((dw_loc_descr_ref,
+ const char *, const char *,
+ const char *, unsigned));
+static void add_loc_descr_to_loc_list PARAMS ((dw_loc_list_ref *,
+ dw_loc_descr_ref,
+ const char *, const char *, const char *));
+static void output_loc_list PARAMS ((dw_loc_list_ref));
+static char *gen_internal_sym PARAMS ((const char *));
+static void mark_limbo_die_list PARAMS ((void *));
/* Section names used to hold DWARF debugging information. */
#ifndef DEBUG_INFO_SECTION
#define DEBUG_INFO_SECTION ".debug_info"
#endif
-#ifndef ABBREV_SECTION
-#define ABBREV_SECTION ".debug_abbrev"
+#ifndef DEBUG_ABBREV_SECTION
+#define DEBUG_ABBREV_SECTION ".debug_abbrev"
#endif
-#ifndef ARANGES_SECTION
-#define ARANGES_SECTION ".debug_aranges"
+#ifndef DEBUG_ARANGES_SECTION
+#define DEBUG_ARANGES_SECTION ".debug_aranges"
#endif
-#ifndef DW_MACINFO_SECTION
-#define DW_MACINFO_SECTION ".debug_macinfo"
+#ifndef DEBUG_MACINFO_SECTION
+#define DEBUG_MACINFO_SECTION ".debug_macinfo"
#endif
#ifndef DEBUG_LINE_SECTION
#define DEBUG_LINE_SECTION ".debug_line"
#endif
-#ifndef LOC_SECTION
-#define LOC_SECTION ".debug_loc"
+#ifndef DEBUG_LOC_SECTION
+#define DEBUG_LOC_SECTION ".debug_loc"
+#endif
+#ifndef DEBUG_PUBNAMES_SECTION
+#define DEBUG_PUBNAMES_SECTION ".debug_pubnames"
#endif
-#ifndef PUBNAMES_SECTION
-#define PUBNAMES_SECTION ".debug_pubnames"
+#ifndef DEBUG_STR_SECTION
+#define DEBUG_STR_SECTION ".debug_str"
#endif
-#ifndef STR_SECTION
-#define STR_SECTION ".debug_str"
+#ifndef DEBUG_RANGES_SECTION
+#define DEBUG_RANGES_SECTION ".debug_ranges"
#endif
/* Standard ELF section names for compiled code and data. */
-#ifndef TEXT_SECTION
-#define TEXT_SECTION ".text"
+#ifndef TEXT_SECTION_NAME
+#define TEXT_SECTION_NAME ".text"
#endif
-#ifndef DATA_SECTION
-#define DATA_SECTION ".data"
-#endif
-#ifndef BSS_SECTION
-#define BSS_SECTION ".bss"
+
+/* Section flags for .debug_str section. */
+#ifdef HAVE_GAS_SHF_MERGE
+#define DEBUG_STR_SECTION_FLAGS \
+ (SECTION_DEBUG | SECTION_MERGE | SECTION_STRINGS | 1)
+#else
+#define DEBUG_STR_SECTION_FLAGS SECTION_DEBUG
#endif
/* Labels we insert at beginning sections we can reference instead of
- the section names themselves. */
+ the section names themselves. */
#ifndef TEXT_SECTION_LABEL
-#define TEXT_SECTION_LABEL "Ltext"
+#define TEXT_SECTION_LABEL "Ltext"
#endif
#ifndef DEBUG_LINE_SECTION_LABEL
-#define DEBUG_LINE_SECTION_LABEL "Ldebug_line"
+#define DEBUG_LINE_SECTION_LABEL "Ldebug_line"
#endif
#ifndef DEBUG_INFO_SECTION_LABEL
-#define DEBUG_INFO_SECTION_LABEL "Ldebug_info"
+#define DEBUG_INFO_SECTION_LABEL "Ldebug_info"
#endif
-#ifndef ABBREV_SECTION_LABEL
-#define ABBREV_SECTION_LABEL "Ldebug_abbrev"
+#ifndef DEBUG_ABBREV_SECTION_LABEL
+#define DEBUG_ABBREV_SECTION_LABEL "Ldebug_abbrev"
+#endif
+#ifndef DEBUG_LOC_SECTION_LABEL
+#define DEBUG_LOC_SECTION_LABEL "Ldebug_loc"
+#endif
+#ifndef DEBUG_RANGES_SECTION_LABEL
+#define DEBUG_RANGES_SECTION_LABEL "Ldebug_ranges"
+#endif
+#ifndef DEBUG_MACINFO_SECTION_LABEL
+#define DEBUG_MACINFO_SECTION_LABEL "Ldebug_macinfo"
#endif
-
/* Definitions of defaults for formats and names of various special
(artificial) labels which may be generated within this file (when the -g
@@ -2709,6 +3762,9 @@ static char text_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char abbrev_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char debug_info_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char debug_line_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
+static char macinfo_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
+static char loc_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
+static char ranges_section_label[2 * MAX_ARTIFICIAL_LABEL_BYTES];
#ifndef TEXT_END_LABEL
#define TEXT_END_LABEL "Letext"
@@ -2719,9 +3775,6 @@ static char debug_line_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
#ifndef BSS_END_LABEL
#define BSS_END_LABEL "Lebss"
#endif
-#ifndef INSN_LABEL_FMT
-#define INSN_LABEL_FMT "LI%u_"
-#endif
#ifndef BLOCK_BEGIN_LABEL
#define BLOCK_BEGIN_LABEL "LBB"
#endif
@@ -2740,172 +3793,28 @@ static char debug_line_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
#ifndef SEPARATE_LINE_CODE_LABEL
#define SEPARATE_LINE_CODE_LABEL "LSM"
#endif
-
-/* Convert a reference to the assembler name of a C-level name. This
- macro has the same effect as ASM_OUTPUT_LABELREF, but copies to
- a string rather than writing to a file. */
-#ifndef ASM_NAME_TO_STRING
-#define ASM_NAME_TO_STRING(STR, NAME) \
- do { \
- if ((NAME)[0] == '*') \
- dyn_string_append (STR, NAME + 1); \
- else \
- { \
- char *newstr; \
- STRIP_NAME_ENCODING (newstr, NAME); \
- dyn_string_append (STR, user_label_prefix); \
- dyn_string_append (STR, newstr); \
- } \
- } \
- while (0)
-#endif
-/* Convert an integer constant expression into assembler syntax. Addition
- and subtraction are the only arithmetic that may appear in these
- expressions. This is an adaptation of output_addr_const in final.c.
- Here, the target of the conversion is a string buffer. We can't use
- output_addr_const directly, because it writes to a file. */
-
-static void
-addr_const_to_string (str, x)
- dyn_string_t str;
- rtx x;
-{
- char buf1[256];
-
-restart:
- switch (GET_CODE (x))
- {
- case PC:
- if (flag_pic)
- dyn_string_append (str, ",");
- else
- abort ();
- break;
-
- case SYMBOL_REF:
- ASM_NAME_TO_STRING (str, XSTR (x, 0));
- break;
-
- case LABEL_REF:
- ASM_GENERATE_INTERNAL_LABEL (buf1, "L", CODE_LABEL_NUMBER (XEXP (x, 0)));
- ASM_NAME_TO_STRING (str, buf1);
- break;
-
- case CODE_LABEL:
- ASM_GENERATE_INTERNAL_LABEL (buf1, "L", CODE_LABEL_NUMBER (x));
- ASM_NAME_TO_STRING (str, buf1);
- break;
-
- case CONST_INT:
- sprintf (buf1, HOST_WIDE_INT_PRINT_DEC, INTVAL (x));
- dyn_string_append (str, buf1);
- break;
-
- case CONST:
- /* This used to output parentheses around the expression, but that does
- not work on the 386 (either ATT or BSD assembler). */
- addr_const_to_string (str, XEXP (x, 0));
- break;
-
- case CONST_DOUBLE:
- if (GET_MODE (x) == VOIDmode)
- {
- /* We can use %d if the number is one word and positive. */
- if (CONST_DOUBLE_HIGH (x))
- sprintf (buf1, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
- CONST_DOUBLE_HIGH (x), CONST_DOUBLE_LOW (x));
- else if (CONST_DOUBLE_LOW (x) < 0)
- sprintf (buf1, HOST_WIDE_INT_PRINT_HEX, CONST_DOUBLE_LOW (x));
- else
- sprintf (buf1, HOST_WIDE_INT_PRINT_DEC,
- CONST_DOUBLE_LOW (x));
- dyn_string_append (str, buf1);
- }
- else
- /* We can't handle floating point constants; PRINT_OPERAND must
- handle them. */
- output_operand_lossage ("floating constant misused");
- break;
-
- case PLUS:
- /* Some assemblers need integer constants to appear last (eg masm). */
- if (GET_CODE (XEXP (x, 0)) == CONST_INT)
- {
- addr_const_to_string (str, XEXP (x, 1));
- if (INTVAL (XEXP (x, 0)) >= 0)
- dyn_string_append (str, "+");
-
- addr_const_to_string (str, XEXP (x, 0));
- }
- else
- {
- addr_const_to_string (str, XEXP (x, 0));
- if (INTVAL (XEXP (x, 1)) >= 0)
- dyn_string_append (str, "+");
-
- addr_const_to_string (str, XEXP (x, 1));
- }
- break;
-
- case MINUS:
- /* Avoid outputting things like x-x or x+5-x, since some assemblers
- can't handle that. */
- x = simplify_subtraction (x);
- if (GET_CODE (x) != MINUS)
- goto restart;
-
- addr_const_to_string (str, XEXP (x, 0));
- dyn_string_append (str, "-");
- if (GET_CODE (XEXP (x, 1)) == CONST_INT
- && INTVAL (XEXP (x, 1)) < 0)
- {
- dyn_string_append (str, ASM_OPEN_PAREN);
- addr_const_to_string (str, XEXP (x, 1));
- dyn_string_append (str, ASM_CLOSE_PAREN);
- }
- else
- addr_const_to_string (str, XEXP (x, 1));
- break;
+/* We allow a language front-end to designate a function that is to be
+ called to "demangle" any name before it it put into a DIE. */
- case ZERO_EXTEND:
- case SIGN_EXTEND:
- addr_const_to_string (str, XEXP (x, 0));
- break;
+static const char *(*demangle_name_func) PARAMS ((const char *));
- default:
- output_operand_lossage ("invalid expression as operand");
- }
-}
-
-/* Convert an address constant to a string, and return a pointer to
- a copy of the result, located on the heap. */
-
-static char *
-addr_to_string (x)
- rtx x;
+void
+dwarf2out_set_demangle_name_func (func)
+ const char *(*func) PARAMS ((const char *));
{
- dyn_string_t ds = dyn_string_new (256);
- char *s;
-
- addr_const_to_string (ds, x);
-
- /* Return the dynamically allocated string, but free the
- dyn_string_t itself. */
- s = ds->s;
- free (ds);
- return s;
+ demangle_name_func = func;
}
/* Test if rtl node points to a pseudo register. */
static inline int
is_pseudo_reg (rtl)
- register rtx rtl;
+ rtx rtl;
{
- return (((GET_CODE (rtl) == REG) && (REGNO (rtl) >= FIRST_PSEUDO_REGISTER))
- || ((GET_CODE (rtl) == SUBREG)
- && (REGNO (XEXP (rtl, 0)) >= FIRST_PSEUDO_REGISTER)));
+ return ((GET_CODE (rtl) == REG && REGNO (rtl) >= FIRST_PSEUDO_REGISTER)
+ || (GET_CODE (rtl) == SUBREG
+ && REGNO (SUBREG_REG (rtl)) >= FIRST_PSEUDO_REGISTER));
}
/* Return a reference to a type, with its const and volatile qualifiers
@@ -2913,15 +3822,15 @@ is_pseudo_reg (rtl)
static inline tree
type_main_variant (type)
- register tree type;
+ tree type;
{
type = TYPE_MAIN_VARIANT (type);
- /* There really should be only one main variant among any group of variants
- of a given type (and all of the MAIN_VARIANT values for all members of
- the group should point to that one type) but sometimes the C front-end
- messes this up for array types, so we work around that bug here. */
-
+ /* ??? There really should be only one main variant among any group of
+ variants of a given type (and all of the MAIN_VARIANT values for all
+ members of the group should point to that one type) but sometimes the C
+ front-end messes this up for array types, so we work around that bug
+ here. */
if (TREE_CODE (type) == ARRAY_TYPE)
while (type != TYPE_MAIN_VARIANT (type))
type = TYPE_MAIN_VARIANT (type);
@@ -2933,9 +3842,9 @@ type_main_variant (type)
static inline int
is_tagged_type (type)
- register tree type;
+ tree type;
{
- register enum tree_code code = TREE_CODE (type);
+ enum tree_code code = TREE_CODE (type);
return (code == RECORD_TYPE || code == UNION_TYPE
|| code == QUAL_UNION_TYPE || code == ENUMERAL_TYPE);
@@ -2943,9 +3852,9 @@ is_tagged_type (type)
/* Convert a DIE tag into its string name. */
-static char *
+static const char *
dwarf_tag_name (tag)
- register unsigned tag;
+ unsigned tag;
{
switch (tag)
{
@@ -3053,6 +3962,10 @@ dwarf_tag_name (tag)
return "DW_TAG_function_template";
case DW_TAG_class_template:
return "DW_TAG_class_template";
+ case DW_TAG_GNU_BINCL:
+ return "DW_TAG_GNU_BINCL";
+ case DW_TAG_GNU_EINCL:
+ return "DW_TAG_GNU_EINCL";
default:
return "DW_TAG_<unknown>";
}
@@ -3060,9 +3973,9 @@ dwarf_tag_name (tag)
/* Convert a DWARF attribute code into its string name. */
-static char *
+static const char *
dwarf_attr_name (attr)
- register unsigned attr;
+ unsigned attr;
{
switch (attr)
{
@@ -3191,6 +4104,31 @@ dwarf_attr_name (attr)
case DW_AT_vtable_elem_location:
return "DW_AT_vtable_elem_location";
+ case DW_AT_allocated:
+ return "DW_AT_allocated";
+ case DW_AT_associated:
+ return "DW_AT_associated";
+ case DW_AT_data_location:
+ return "DW_AT_data_location";
+ case DW_AT_stride:
+ return "DW_AT_stride";
+ case DW_AT_entry_pc:
+ return "DW_AT_entry_pc";
+ case DW_AT_use_UTF8:
+ return "DW_AT_use_UTF8";
+ case DW_AT_extension:
+ return "DW_AT_extension";
+ case DW_AT_ranges:
+ return "DW_AT_ranges";
+ case DW_AT_trampoline:
+ return "DW_AT_trampoline";
+ case DW_AT_call_column:
+ return "DW_AT_call_column";
+ case DW_AT_call_file:
+ return "DW_AT_call_file";
+ case DW_AT_call_line:
+ return "DW_AT_call_line";
+
case DW_AT_MIPS_fde:
return "DW_AT_MIPS_fde";
case DW_AT_MIPS_loop_begin:
@@ -3226,6 +4164,9 @@ dwarf_attr_name (attr)
return "DW_AT_body_begin";
case DW_AT_body_end:
return "DW_AT_body_end";
+ case DW_AT_VMS_rtnbeg_pd_address:
+ return "DW_AT_VMS_rtnbeg_pd_address";
+
default:
return "DW_AT_<unknown>";
}
@@ -3233,9 +4174,9 @@ dwarf_attr_name (attr)
/* Convert a DWARF value form code into its string name. */
-static char *
+static const char *
dwarf_form_name (form)
- register unsigned form;
+ unsigned form;
{
switch (form)
{
@@ -3286,315 +4227,12 @@ dwarf_form_name (form)
}
}
-/* Convert a DWARF stack opcode into its string name. */
-
-static char *
-dwarf_stack_op_name (op)
- register unsigned op;
-{
- switch (op)
- {
- case DW_OP_addr:
- return "DW_OP_addr";
- case DW_OP_deref:
- return "DW_OP_deref";
- case DW_OP_const1u:
- return "DW_OP_const1u";
- case DW_OP_const1s:
- return "DW_OP_const1s";
- case DW_OP_const2u:
- return "DW_OP_const2u";
- case DW_OP_const2s:
- return "DW_OP_const2s";
- case DW_OP_const4u:
- return "DW_OP_const4u";
- case DW_OP_const4s:
- return "DW_OP_const4s";
- case DW_OP_const8u:
- return "DW_OP_const8u";
- case DW_OP_const8s:
- return "DW_OP_const8s";
- case DW_OP_constu:
- return "DW_OP_constu";
- case DW_OP_consts:
- return "DW_OP_consts";
- case DW_OP_dup:
- return "DW_OP_dup";
- case DW_OP_drop:
- return "DW_OP_drop";
- case DW_OP_over:
- return "DW_OP_over";
- case DW_OP_pick:
- return "DW_OP_pick";
- case DW_OP_swap:
- return "DW_OP_swap";
- case DW_OP_rot:
- return "DW_OP_rot";
- case DW_OP_xderef:
- return "DW_OP_xderef";
- case DW_OP_abs:
- return "DW_OP_abs";
- case DW_OP_and:
- return "DW_OP_and";
- case DW_OP_div:
- return "DW_OP_div";
- case DW_OP_minus:
- return "DW_OP_minus";
- case DW_OP_mod:
- return "DW_OP_mod";
- case DW_OP_mul:
- return "DW_OP_mul";
- case DW_OP_neg:
- return "DW_OP_neg";
- case DW_OP_not:
- return "DW_OP_not";
- case DW_OP_or:
- return "DW_OP_or";
- case DW_OP_plus:
- return "DW_OP_plus";
- case DW_OP_plus_uconst:
- return "DW_OP_plus_uconst";
- case DW_OP_shl:
- return "DW_OP_shl";
- case DW_OP_shr:
- return "DW_OP_shr";
- case DW_OP_shra:
- return "DW_OP_shra";
- case DW_OP_xor:
- return "DW_OP_xor";
- case DW_OP_bra:
- return "DW_OP_bra";
- case DW_OP_eq:
- return "DW_OP_eq";
- case DW_OP_ge:
- return "DW_OP_ge";
- case DW_OP_gt:
- return "DW_OP_gt";
- case DW_OP_le:
- return "DW_OP_le";
- case DW_OP_lt:
- return "DW_OP_lt";
- case DW_OP_ne:
- return "DW_OP_ne";
- case DW_OP_skip:
- return "DW_OP_skip";
- case DW_OP_lit0:
- return "DW_OP_lit0";
- case DW_OP_lit1:
- return "DW_OP_lit1";
- case DW_OP_lit2:
- return "DW_OP_lit2";
- case DW_OP_lit3:
- return "DW_OP_lit3";
- case DW_OP_lit4:
- return "DW_OP_lit4";
- case DW_OP_lit5:
- return "DW_OP_lit5";
- case DW_OP_lit6:
- return "DW_OP_lit6";
- case DW_OP_lit7:
- return "DW_OP_lit7";
- case DW_OP_lit8:
- return "DW_OP_lit8";
- case DW_OP_lit9:
- return "DW_OP_lit9";
- case DW_OP_lit10:
- return "DW_OP_lit10";
- case DW_OP_lit11:
- return "DW_OP_lit11";
- case DW_OP_lit12:
- return "DW_OP_lit12";
- case DW_OP_lit13:
- return "DW_OP_lit13";
- case DW_OP_lit14:
- return "DW_OP_lit14";
- case DW_OP_lit15:
- return "DW_OP_lit15";
- case DW_OP_lit16:
- return "DW_OP_lit16";
- case DW_OP_lit17:
- return "DW_OP_lit17";
- case DW_OP_lit18:
- return "DW_OP_lit18";
- case DW_OP_lit19:
- return "DW_OP_lit19";
- case DW_OP_lit20:
- return "DW_OP_lit20";
- case DW_OP_lit21:
- return "DW_OP_lit21";
- case DW_OP_lit22:
- return "DW_OP_lit22";
- case DW_OP_lit23:
- return "DW_OP_lit23";
- case DW_OP_lit24:
- return "DW_OP_lit24";
- case DW_OP_lit25:
- return "DW_OP_lit25";
- case DW_OP_lit26:
- return "DW_OP_lit26";
- case DW_OP_lit27:
- return "DW_OP_lit27";
- case DW_OP_lit28:
- return "DW_OP_lit28";
- case DW_OP_lit29:
- return "DW_OP_lit29";
- case DW_OP_lit30:
- return "DW_OP_lit30";
- case DW_OP_lit31:
- return "DW_OP_lit31";
- case DW_OP_reg0:
- return "DW_OP_reg0";
- case DW_OP_reg1:
- return "DW_OP_reg1";
- case DW_OP_reg2:
- return "DW_OP_reg2";
- case DW_OP_reg3:
- return "DW_OP_reg3";
- case DW_OP_reg4:
- return "DW_OP_reg4";
- case DW_OP_reg5:
- return "DW_OP_reg5";
- case DW_OP_reg6:
- return "DW_OP_reg6";
- case DW_OP_reg7:
- return "DW_OP_reg7";
- case DW_OP_reg8:
- return "DW_OP_reg8";
- case DW_OP_reg9:
- return "DW_OP_reg9";
- case DW_OP_reg10:
- return "DW_OP_reg10";
- case DW_OP_reg11:
- return "DW_OP_reg11";
- case DW_OP_reg12:
- return "DW_OP_reg12";
- case DW_OP_reg13:
- return "DW_OP_reg13";
- case DW_OP_reg14:
- return "DW_OP_reg14";
- case DW_OP_reg15:
- return "DW_OP_reg15";
- case DW_OP_reg16:
- return "DW_OP_reg16";
- case DW_OP_reg17:
- return "DW_OP_reg17";
- case DW_OP_reg18:
- return "DW_OP_reg18";
- case DW_OP_reg19:
- return "DW_OP_reg19";
- case DW_OP_reg20:
- return "DW_OP_reg20";
- case DW_OP_reg21:
- return "DW_OP_reg21";
- case DW_OP_reg22:
- return "DW_OP_reg22";
- case DW_OP_reg23:
- return "DW_OP_reg23";
- case DW_OP_reg24:
- return "DW_OP_reg24";
- case DW_OP_reg25:
- return "DW_OP_reg25";
- case DW_OP_reg26:
- return "DW_OP_reg26";
- case DW_OP_reg27:
- return "DW_OP_reg27";
- case DW_OP_reg28:
- return "DW_OP_reg28";
- case DW_OP_reg29:
- return "DW_OP_reg29";
- case DW_OP_reg30:
- return "DW_OP_reg30";
- case DW_OP_reg31:
- return "DW_OP_reg31";
- case DW_OP_breg0:
- return "DW_OP_breg0";
- case DW_OP_breg1:
- return "DW_OP_breg1";
- case DW_OP_breg2:
- return "DW_OP_breg2";
- case DW_OP_breg3:
- return "DW_OP_breg3";
- case DW_OP_breg4:
- return "DW_OP_breg4";
- case DW_OP_breg5:
- return "DW_OP_breg5";
- case DW_OP_breg6:
- return "DW_OP_breg6";
- case DW_OP_breg7:
- return "DW_OP_breg7";
- case DW_OP_breg8:
- return "DW_OP_breg8";
- case DW_OP_breg9:
- return "DW_OP_breg9";
- case DW_OP_breg10:
- return "DW_OP_breg10";
- case DW_OP_breg11:
- return "DW_OP_breg11";
- case DW_OP_breg12:
- return "DW_OP_breg12";
- case DW_OP_breg13:
- return "DW_OP_breg13";
- case DW_OP_breg14:
- return "DW_OP_breg14";
- case DW_OP_breg15:
- return "DW_OP_breg15";
- case DW_OP_breg16:
- return "DW_OP_breg16";
- case DW_OP_breg17:
- return "DW_OP_breg17";
- case DW_OP_breg18:
- return "DW_OP_breg18";
- case DW_OP_breg19:
- return "DW_OP_breg19";
- case DW_OP_breg20:
- return "DW_OP_breg20";
- case DW_OP_breg21:
- return "DW_OP_breg21";
- case DW_OP_breg22:
- return "DW_OP_breg22";
- case DW_OP_breg23:
- return "DW_OP_breg23";
- case DW_OP_breg24:
- return "DW_OP_breg24";
- case DW_OP_breg25:
- return "DW_OP_breg25";
- case DW_OP_breg26:
- return "DW_OP_breg26";
- case DW_OP_breg27:
- return "DW_OP_breg27";
- case DW_OP_breg28:
- return "DW_OP_breg28";
- case DW_OP_breg29:
- return "DW_OP_breg29";
- case DW_OP_breg30:
- return "DW_OP_breg30";
- case DW_OP_breg31:
- return "DW_OP_breg31";
- case DW_OP_regx:
- return "DW_OP_regx";
- case DW_OP_fbreg:
- return "DW_OP_fbreg";
- case DW_OP_bregx:
- return "DW_OP_bregx";
- case DW_OP_piece:
- return "DW_OP_piece";
- case DW_OP_deref_size:
- return "DW_OP_deref_size";
- case DW_OP_xderef_size:
- return "DW_OP_xderef_size";
- case DW_OP_nop:
- return "DW_OP_nop";
- default:
- return "OP_<unknown>";
- }
-}
-
/* Convert a DWARF type code into its string name. */
#if 0
-static char *
+static const char *
dwarf_type_encoding_name (enc)
- register unsigned enc;
+ unsigned enc;
{
switch (enc)
{
@@ -3628,9 +4266,15 @@ dwarf_type_encoding_name (enc)
static tree
decl_ultimate_origin (decl)
- register tree decl;
+ tree decl;
{
-#ifdef ENABLE_CHECKING
+ /* output_inline_function sets DECL_ABSTRACT_ORIGIN for all the
+ nodes in the function to point to themselves; ignore that if
+ we're trying to output the abstract instance of this function. */
+ if (DECL_ABSTRACT (decl) && DECL_ABSTRACT_ORIGIN (decl) == decl)
+ return NULL_TREE;
+
+#ifdef ENABLE_CHECKING
if (DECL_FROM_INLINE (DECL_ORIGIN (decl)))
/* Since the DECL_ABSTRACT_ORIGIN for a DECL is supposed to be the
most distant ancestor, this should never happen. */
@@ -3648,23 +4292,28 @@ decl_ultimate_origin (decl)
static tree
block_ultimate_origin (block)
- register tree block;
+ tree block;
{
- register tree immediate_origin = BLOCK_ABSTRACT_ORIGIN (block);
+ tree immediate_origin = BLOCK_ABSTRACT_ORIGIN (block);
+
+ /* output_inline_function sets BLOCK_ABSTRACT_ORIGIN for all the
+ nodes in the function to point to themselves; ignore that if
+ we're trying to output the abstract instance of this function. */
+ if (BLOCK_ABSTRACT (block) && immediate_origin == block)
+ return NULL_TREE;
if (immediate_origin == NULL_TREE)
return NULL_TREE;
else
{
- register tree ret_val;
- register tree lookahead = immediate_origin;
+ tree ret_val;
+ tree lookahead = immediate_origin;
do
{
ret_val = lookahead;
- lookahead = (TREE_CODE (ret_val) == BLOCK)
- ? BLOCK_ABSTRACT_ORIGIN (ret_val)
- : NULL;
+ lookahead = (TREE_CODE (ret_val) == BLOCK
+ ? BLOCK_ABSTRACT_ORIGIN (ret_val) : NULL);
}
while (lookahead != NULL && lookahead != ret_val);
@@ -3688,43 +4337,43 @@ decl_class_context (decl)
context = TYPE_MAIN_VARIANT
(TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)))));
- if (context && TREE_CODE_CLASS (TREE_CODE (context)) != 't')
+ if (context && !TYPE_P (context))
context = NULL_TREE;
return context;
}
-/* Add an attribute/value pair to a DIE */
+/* Add an attribute/value pair to a DIE. We build the lists up in reverse
+ addition order, and correct that in reverse_all_dies. */
static inline void
add_dwarf_attr (die, attr)
- register dw_die_ref die;
- register dw_attr_ref attr;
+ dw_die_ref die;
+ dw_attr_ref attr;
{
if (die != NULL && attr != NULL)
{
- if (die->die_attr == NULL)
- {
- die->die_attr = attr;
- die->die_attr_last = attr;
- }
- else
- {
- die->die_attr_last->dw_attr_next = attr;
- die->die_attr_last = attr;
- }
+ attr->dw_attr_next = die->die_attr;
+ die->die_attr = attr;
}
}
+static inline dw_val_class
+AT_class (a)
+ dw_attr_ref a;
+{
+ return a->dw_attr_val.val_class;
+}
+
/* Add a flag value attribute to a DIE. */
static inline void
add_AT_flag (die, attr_kind, flag)
- register dw_die_ref die;
- register enum dwarf_attribute attr_kind;
- register unsigned flag;
+ dw_die_ref die;
+ enum dwarf_attribute attr_kind;
+ unsigned flag;
{
- register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
+ dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
attr->dw_attr_next = NULL;
attr->dw_attr = attr_kind;
@@ -3733,15 +4382,25 @@ add_AT_flag (die, attr_kind, flag)
add_dwarf_attr (die, attr);
}
+static inline unsigned
+AT_flag (a)
+ dw_attr_ref a;
+{
+ if (a && AT_class (a) == dw_val_class_flag)
+ return a->dw_attr_val.v.val_flag;
+
+ abort ();
+}
+
/* Add a signed integer attribute value to a DIE. */
static inline void
add_AT_int (die, attr_kind, int_val)
- register dw_die_ref die;
- register enum dwarf_attribute attr_kind;
- register long int int_val;
+ dw_die_ref die;
+ enum dwarf_attribute attr_kind;
+ long int int_val;
{
- register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
+ dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
attr->dw_attr_next = NULL;
attr->dw_attr = attr_kind;
@@ -3750,15 +4409,25 @@ add_AT_int (die, attr_kind, int_val)
add_dwarf_attr (die, attr);
}
+static inline long int
+AT_int (a)
+ dw_attr_ref a;
+{
+ if (a && AT_class (a) == dw_val_class_const)
+ return a->dw_attr_val.v.val_int;
+
+ abort ();
+}
+
/* Add an unsigned integer attribute value to a DIE. */
static inline void
add_AT_unsigned (die, attr_kind, unsigned_val)
- register dw_die_ref die;
- register enum dwarf_attribute attr_kind;
- register unsigned long unsigned_val;
+ dw_die_ref die;
+ enum dwarf_attribute attr_kind;
+ unsigned long unsigned_val;
{
- register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
+ dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
attr->dw_attr_next = NULL;
attr->dw_attr = attr_kind;
@@ -3767,16 +4436,26 @@ add_AT_unsigned (die, attr_kind, unsigned_val)
add_dwarf_attr (die, attr);
}
+static inline unsigned long
+AT_unsigned (a)
+ dw_attr_ref a;
+{
+ if (a && AT_class (a) == dw_val_class_unsigned_const)
+ return a->dw_attr_val.v.val_unsigned;
+
+ abort ();
+}
+
/* Add an unsigned double integer attribute value to a DIE. */
static inline void
add_AT_long_long (die, attr_kind, val_hi, val_low)
- register dw_die_ref die;
- register enum dwarf_attribute attr_kind;
- register unsigned long val_hi;
- register unsigned long val_low;
+ dw_die_ref die;
+ enum dwarf_attribute attr_kind;
+ unsigned long val_hi;
+ unsigned long val_low;
{
- register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
+ dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
attr->dw_attr_next = NULL;
attr->dw_attr = attr_kind;
@@ -3790,12 +4469,12 @@ add_AT_long_long (die, attr_kind, val_hi, val_low)
static inline void
add_AT_float (die, attr_kind, length, array)
- register dw_die_ref die;
- register enum dwarf_attribute attr_kind;
- register unsigned length;
- register long *array;
+ dw_die_ref die;
+ enum dwarf_attribute attr_kind;
+ unsigned length;
+ long *array;
{
- register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
+ dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
attr->dw_attr_next = NULL;
attr->dw_attr = attr_kind;
@@ -3809,45 +4488,141 @@ add_AT_float (die, attr_kind, length, array)
static inline void
add_AT_string (die, attr_kind, str)
- register dw_die_ref die;
- register enum dwarf_attribute attr_kind;
- register char *str;
+ dw_die_ref die;
+ enum dwarf_attribute attr_kind;
+ const char *str;
{
- register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
+ dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
+ struct indirect_string_node *node;
+
+ if (! debug_str_hash)
+ {
+ debug_str_hash = ht_create (10);
+ debug_str_hash->alloc_node = indirect_string_alloc;
+ }
+
+ node = (struct indirect_string_node *)
+ ht_lookup (debug_str_hash, (const unsigned char *) str,
+ strlen (str), HT_ALLOC);
+ node->refcount++;
attr->dw_attr_next = NULL;
attr->dw_attr = attr_kind;
attr->dw_attr_val.val_class = dw_val_class_str;
- attr->dw_attr_val.v.val_str = xstrdup (str);
+ attr->dw_attr_val.v.val_str = node;
add_dwarf_attr (die, attr);
}
+static inline const char *
+AT_string (a)
+ dw_attr_ref a;
+{
+ if (a && AT_class (a) == dw_val_class_str)
+ return (const char *) HT_STR (&a->dw_attr_val.v.val_str->id);
+
+ abort ();
+}
+
+/* Find out whether a string should be output inline in DIE
+ or out-of-line in .debug_str section. */
+
+static int
+AT_string_form (a)
+ dw_attr_ref a;
+{
+ if (a && AT_class (a) == dw_val_class_str)
+ {
+ struct indirect_string_node *node;
+ unsigned int len;
+ extern int const_labelno;
+ char label[32];
+
+ node = a->dw_attr_val.v.val_str;
+ if (node->form)
+ return node->form;
+
+ len = HT_LEN (&node->id) + 1;
+
+ /* If the string is shorter or equal to the size of the reference, it is
+ always better to put it inline. */
+ if (len <= DWARF_OFFSET_SIZE || node->refcount == 0)
+ return node->form = DW_FORM_string;
+
+ /* If we cannot expect the linker to merge strings in .debug_str
+ section, only put it into .debug_str if it is worth even in this
+ single module. */
+ if ((DEBUG_STR_SECTION_FLAGS & SECTION_MERGE) == 0
+ && (len - DWARF_OFFSET_SIZE) * node->refcount <= len)
+ return node->form = DW_FORM_string;
+
+ ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
+ ++const_labelno;
+ node->label = xstrdup (label);
+
+ return node->form = DW_FORM_strp;
+ }
+
+ abort ();
+}
+
/* Add a DIE reference attribute value to a DIE. */
static inline void
add_AT_die_ref (die, attr_kind, targ_die)
- register dw_die_ref die;
- register enum dwarf_attribute attr_kind;
- register dw_die_ref targ_die;
+ dw_die_ref die;
+ enum dwarf_attribute attr_kind;
+ dw_die_ref targ_die;
{
- register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
+ dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
attr->dw_attr_next = NULL;
attr->dw_attr = attr_kind;
attr->dw_attr_val.val_class = dw_val_class_die_ref;
- attr->dw_attr_val.v.val_die_ref = targ_die;
+ attr->dw_attr_val.v.val_die_ref.die = targ_die;
+ attr->dw_attr_val.v.val_die_ref.external = 0;
add_dwarf_attr (die, attr);
}
+static inline dw_die_ref
+AT_ref (a)
+ dw_attr_ref a;
+{
+ if (a && AT_class (a) == dw_val_class_die_ref)
+ return a->dw_attr_val.v.val_die_ref.die;
+
+ abort ();
+}
+
+static inline int
+AT_ref_external (a)
+ dw_attr_ref a;
+{
+ if (a && AT_class (a) == dw_val_class_die_ref)
+ return a->dw_attr_val.v.val_die_ref.external;
+
+ return 0;
+}
+
+static inline void
+set_AT_ref_external (a, i)
+ dw_attr_ref a;
+ int i;
+{
+ if (a && AT_class (a) == dw_val_class_die_ref)
+ a->dw_attr_val.v.val_die_ref.external = i;
+ else
+ abort ();
+}
+
/* Add an FDE reference attribute value to a DIE. */
static inline void
add_AT_fde_ref (die, attr_kind, targ_fde)
- register dw_die_ref die;
- register enum dwarf_attribute attr_kind;
- register unsigned targ_fde;
+ dw_die_ref die;
+ enum dwarf_attribute attr_kind;
+ unsigned targ_fde;
{
- register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
+ dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
attr->dw_attr_next = NULL;
attr->dw_attr = attr_kind;
@@ -3860,11 +4635,11 @@ add_AT_fde_ref (die, attr_kind, targ_fde)
static inline void
add_AT_loc (die, attr_kind, loc)
- register dw_die_ref die;
- register enum dwarf_attribute attr_kind;
- register dw_loc_descr_ref loc;
+ dw_die_ref die;
+ enum dwarf_attribute attr_kind;
+ dw_loc_descr_ref loc;
{
- register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
+ dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
attr->dw_attr_next = NULL;
attr->dw_attr = attr_kind;
@@ -3873,15 +4648,51 @@ add_AT_loc (die, attr_kind, loc)
add_dwarf_attr (die, attr);
}
+static inline dw_loc_descr_ref
+AT_loc (a)
+ dw_attr_ref a;
+{
+ if (a && AT_class (a) == dw_val_class_loc)
+ return a->dw_attr_val.v.val_loc;
+
+ abort ();
+}
+
+static inline void
+add_AT_loc_list (die, attr_kind, loc_list)
+ dw_die_ref die;
+ enum dwarf_attribute attr_kind;
+ dw_loc_list_ref loc_list;
+{
+ dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
+
+ attr->dw_attr_next = NULL;
+ attr->dw_attr = attr_kind;
+ attr->dw_attr_val.val_class = dw_val_class_loc_list;
+ attr->dw_attr_val.v.val_loc_list = loc_list;
+ add_dwarf_attr (die, attr);
+ have_location_lists = 1;
+}
+
+static inline dw_loc_list_ref
+AT_loc_list (a)
+ dw_attr_ref a;
+{
+ if (a && AT_class (a) == dw_val_class_loc_list)
+ return a->dw_attr_val.v.val_loc_list;
+
+ abort ();
+}
+
/* Add an address constant attribute value to a DIE. */
static inline void
add_AT_addr (die, attr_kind, addr)
- register dw_die_ref die;
- register enum dwarf_attribute attr_kind;
- char *addr;
+ dw_die_ref die;
+ enum dwarf_attribute attr_kind;
+ rtx addr;
{
- register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
+ dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
attr->dw_attr_next = NULL;
attr->dw_attr = attr_kind;
@@ -3890,15 +4701,25 @@ add_AT_addr (die, attr_kind, addr)
add_dwarf_attr (die, attr);
}
+static inline rtx
+AT_addr (a)
+ dw_attr_ref a;
+{
+ if (a && AT_class (a) == dw_val_class_addr)
+ return a->dw_attr_val.v.val_addr;
+
+ abort ();
+}
+
/* Add a label identifier attribute value to a DIE. */
static inline void
add_AT_lbl_id (die, attr_kind, lbl_id)
- register dw_die_ref die;
- register enum dwarf_attribute attr_kind;
- register char *lbl_id;
+ dw_die_ref die;
+ enum dwarf_attribute attr_kind;
+ const char *lbl_id;
{
- register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
+ dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
attr->dw_attr_next = NULL;
attr->dw_attr = attr_kind;
@@ -3911,69 +4732,82 @@ add_AT_lbl_id (die, attr_kind, lbl_id)
static inline void
add_AT_lbl_offset (die, attr_kind, label)
- register dw_die_ref die;
- register enum dwarf_attribute attr_kind;
- register char *label;
+ dw_die_ref die;
+ enum dwarf_attribute attr_kind;
+ const char *label;
{
- register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
+ dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
attr->dw_attr_next = NULL;
attr->dw_attr = attr_kind;
attr->dw_attr_val.val_class = dw_val_class_lbl_offset;
- attr->dw_attr_val.v.val_lbl_id = label;
+ attr->dw_attr_val.v.val_lbl_id = xstrdup (label);
add_dwarf_attr (die, attr);
-
}
-/* Test if die refers to an external subroutine. */
+/* Add an offset attribute value to a DIE. */
-static inline int
-is_extern_subr_die (die)
- register dw_die_ref die;
+static inline void
+add_AT_offset (die, attr_kind, offset)
+ dw_die_ref die;
+ enum dwarf_attribute attr_kind;
+ unsigned long offset;
{
- register dw_attr_ref a;
- register int is_subr = FALSE;
- register int is_extern = FALSE;
+ dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
- if (die != NULL && die->die_tag == DW_TAG_subprogram)
- {
- is_subr = TRUE;
- for (a = die->die_attr; a != NULL; a = a->dw_attr_next)
- {
- if (a->dw_attr == DW_AT_external
- && a->dw_attr_val.val_class == dw_val_class_flag
- && a->dw_attr_val.v.val_flag != 0)
- {
- is_extern = TRUE;
- break;
- }
- }
- }
+ attr->dw_attr_next = NULL;
+ attr->dw_attr = attr_kind;
+ attr->dw_attr_val.val_class = dw_val_class_offset;
+ attr->dw_attr_val.v.val_offset = offset;
+ add_dwarf_attr (die, attr);
+}
+
+/* Add an range_list attribute value to a DIE. */
+
+static void
+add_AT_range_list (die, attr_kind, offset)
+ dw_die_ref die;
+ enum dwarf_attribute attr_kind;
+ unsigned long offset;
+{
+ dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
- return is_subr && is_extern;
+ attr->dw_attr_next = NULL;
+ attr->dw_attr = attr_kind;
+ attr->dw_attr_val.val_class = dw_val_class_range_list;
+ attr->dw_attr_val.v.val_offset = offset;
+ add_dwarf_attr (die, attr);
+}
+
+static inline const char *
+AT_lbl (a)
+ dw_attr_ref a;
+{
+ if (a && (AT_class (a) == dw_val_class_lbl_id
+ || AT_class (a) == dw_val_class_lbl_offset))
+ return a->dw_attr_val.v.val_lbl_id;
+
+ abort ();
}
/* Get the attribute of type attr_kind. */
static inline dw_attr_ref
get_AT (die, attr_kind)
- register dw_die_ref die;
- register enum dwarf_attribute attr_kind;
+ dw_die_ref die;
+ enum dwarf_attribute attr_kind;
{
- register dw_attr_ref a;
- register dw_die_ref spec = NULL;
-
+ dw_attr_ref a;
+ dw_die_ref spec = NULL;
+
if (die != NULL)
{
for (a = die->die_attr; a != NULL; a = a->dw_attr_next)
- {
- if (a->dw_attr == attr_kind)
- return a;
-
- if (a->dw_attr == DW_AT_specification
- || a->dw_attr == DW_AT_abstract_origin)
- spec = a->dw_attr_val.v.val_die_ref;
- }
+ if (a->dw_attr == attr_kind)
+ return a;
+ else if (a->dw_attr == DW_AT_specification
+ || a->dw_attr == DW_AT_abstract_origin)
+ spec = AT_ref (a);
if (spec)
return get_AT (spec, attr_kind);
@@ -3982,54 +4816,43 @@ get_AT (die, attr_kind)
return NULL;
}
-/* Return the "low pc" attribute value, typically associated with
- a subprogram DIE. Return null if the "low pc" attribute is
- either not prsent, or if it cannot be represented as an
- assembler label identifier. */
+/* Return the "low pc" attribute value, typically associated with a subprogram
+ DIE. Return null if the "low pc" attribute is either not present, or if it
+ cannot be represented as an assembler label identifier. */
-static inline char *
+static inline const char *
get_AT_low_pc (die)
- register dw_die_ref die;
+ dw_die_ref die;
{
- register dw_attr_ref a = get_AT (die, DW_AT_low_pc);
-
- if (a && a->dw_attr_val.val_class == dw_val_class_lbl_id)
- return a->dw_attr_val.v.val_lbl_id;
+ dw_attr_ref a = get_AT (die, DW_AT_low_pc);
- return NULL;
+ return a ? AT_lbl (a) : NULL;
}
-/* Return the "high pc" attribute value, typically associated with
- a subprogram DIE. Return null if the "high pc" attribute is
- either not prsent, or if it cannot be represented as an
- assembler label identifier. */
+/* Return the "high pc" attribute value, typically associated with a subprogram
+ DIE. Return null if the "high pc" attribute is either not present, or if it
+ cannot be represented as an assembler label identifier. */
-static inline char *
+static inline const char *
get_AT_hi_pc (die)
- register dw_die_ref die;
+ dw_die_ref die;
{
- register dw_attr_ref a = get_AT (die, DW_AT_high_pc);
+ dw_attr_ref a = get_AT (die, DW_AT_high_pc);
- if (a && a->dw_attr_val.val_class == dw_val_class_lbl_id)
- return a->dw_attr_val.v.val_lbl_id;
-
- return NULL;
+ return a ? AT_lbl (a) : NULL;
}
/* Return the value of the string attribute designated by ATTR_KIND, or
NULL if it is not present. */
-static inline char *
+static inline const char *
get_AT_string (die, attr_kind)
- register dw_die_ref die;
- register enum dwarf_attribute attr_kind;
+ dw_die_ref die;
+ enum dwarf_attribute attr_kind;
{
- register dw_attr_ref a = get_AT (die, attr_kind);
+ dw_attr_ref a = get_AT (die, attr_kind);
- if (a && a->dw_attr_val.val_class == dw_val_class_str)
- return a->dw_attr_val.v.val_str;
-
- return NULL;
+ return a ? AT_string (a) : NULL;
}
/* Return the value of the flag attribute designated by ATTR_KIND, or -1
@@ -4037,15 +4860,12 @@ get_AT_string (die, attr_kind)
static inline int
get_AT_flag (die, attr_kind)
- register dw_die_ref die;
- register enum dwarf_attribute attr_kind;
+ dw_die_ref die;
+ enum dwarf_attribute attr_kind;
{
- register dw_attr_ref a = get_AT (die, attr_kind);
-
- if (a && a->dw_attr_val.val_class == dw_val_class_flag)
- return a->dw_attr_val.v.val_flag;
+ dw_attr_ref a = get_AT (die, attr_kind);
- return -1;
+ return a ? AT_flag (a) : 0;
}
/* Return the value of the unsigned attribute designated by ATTR_KIND, or 0
@@ -4053,148 +4873,214 @@ get_AT_flag (die, attr_kind)
static inline unsigned
get_AT_unsigned (die, attr_kind)
- register dw_die_ref die;
- register enum dwarf_attribute attr_kind;
+ dw_die_ref die;
+ enum dwarf_attribute attr_kind;
{
- register dw_attr_ref a = get_AT (die, attr_kind);
+ dw_attr_ref a = get_AT (die, attr_kind);
- if (a && a->dw_attr_val.val_class == dw_val_class_unsigned_const)
- return a->dw_attr_val.v.val_unsigned;
+ return a ? AT_unsigned (a) : 0;
+}
- return 0;
+static inline dw_die_ref
+get_AT_ref (die, attr_kind)
+ dw_die_ref die;
+ enum dwarf_attribute attr_kind;
+{
+ dw_attr_ref a = get_AT (die, attr_kind);
+
+ return a ? AT_ref (a) : NULL;
}
static inline int
is_c_family ()
{
- register unsigned lang = get_AT_unsigned (comp_unit_die, DW_AT_language);
+ unsigned lang = get_AT_unsigned (comp_unit_die, DW_AT_language);
return (lang == DW_LANG_C || lang == DW_LANG_C89
|| lang == DW_LANG_C_plus_plus);
-}
+}
+
+static inline int
+is_cxx ()
+{
+ return (get_AT_unsigned (comp_unit_die, DW_AT_language)
+ == DW_LANG_C_plus_plus);
+}
static inline int
is_fortran ()
{
- register unsigned lang = get_AT_unsigned (comp_unit_die, DW_AT_language);
+ unsigned lang = get_AT_unsigned (comp_unit_die, DW_AT_language);
return (lang == DW_LANG_Fortran77 || lang == DW_LANG_Fortran90);
-}
+}
-/* Remove the specified attribute if present. */
+static inline int
+is_java ()
+{
+ unsigned lang = get_AT_unsigned (comp_unit_die, DW_AT_language);
+
+ return (lang == DW_LANG_Java);
+}
+
+/* Free up the memory used by A. */
+static inline void free_AT PARAMS ((dw_attr_ref));
static inline void
-remove_AT (die, attr_kind)
- register dw_die_ref die;
- register enum dwarf_attribute attr_kind;
+free_AT (a)
+ dw_attr_ref a;
{
- register dw_attr_ref a;
- register dw_attr_ref removed = NULL;;
-
- if (die != NULL)
+ switch (AT_class (a))
{
- if (die->die_attr->dw_attr == attr_kind)
- {
- removed = die->die_attr;
- if (die->die_attr_last == die->die_attr)
- die->die_attr_last = NULL;
+ case dw_val_class_str:
+ if (a->dw_attr_val.v.val_str->refcount)
+ a->dw_attr_val.v.val_str->refcount--;
+ break;
- die->die_attr = die->die_attr->dw_attr_next;
- }
+ case dw_val_class_lbl_id:
+ case dw_val_class_lbl_offset:
+ free (a->dw_attr_val.v.val_lbl_id);
+ break;
- else
- for (a = die->die_attr; a->dw_attr_next != NULL;
- a = a->dw_attr_next)
- if (a->dw_attr_next->dw_attr == attr_kind)
- {
- removed = a->dw_attr_next;
- if (die->die_attr_last == a->dw_attr_next)
- die->die_attr_last = a;
+ case dw_val_class_float:
+ free (a->dw_attr_val.v.val_float.array);
+ break;
- a->dw_attr_next = a->dw_attr_next->dw_attr_next;
- break;
- }
+ default:
+ break;
+ }
+
+ free (a);
+}
+
+/* Remove the specified attribute if present. */
+
+static void
+remove_AT (die, attr_kind)
+ dw_die_ref die;
+ enum dwarf_attribute attr_kind;
+{
+ dw_attr_ref *p;
+ dw_attr_ref removed = NULL;
+
+ if (die != NULL)
+ {
+ for (p = &(die->die_attr); *p; p = &((*p)->dw_attr_next))
+ if ((*p)->dw_attr == attr_kind)
+ {
+ removed = *p;
+ *p = (*p)->dw_attr_next;
+ break;
+ }
if (removed != 0)
- free (removed);
+ free_AT (removed);
}
}
-/* Discard the children of this DIE. */
+/* Free up the memory used by DIE. */
static inline void
+free_die (die)
+ dw_die_ref die;
+{
+ remove_children (die);
+ free (die);
+}
+
+/* Discard the children of this DIE. */
+
+static void
remove_children (die)
- register dw_die_ref die;
+ dw_die_ref die;
{
- register dw_die_ref child_die = die->die_child;
+ dw_die_ref child_die = die->die_child;
die->die_child = NULL;
- die->die_child_last = NULL;
while (child_die != NULL)
{
- register dw_die_ref tmp_die = child_die;
- register dw_attr_ref a;
+ dw_die_ref tmp_die = child_die;
+ dw_attr_ref a;
child_die = child_die->die_sib;
-
- for (a = tmp_die->die_attr; a != NULL; )
+
+ for (a = tmp_die->die_attr; a != NULL;)
{
- register dw_attr_ref tmp_a = a;
+ dw_attr_ref tmp_a = a;
a = a->dw_attr_next;
- free (tmp_a);
+ free_AT (tmp_a);
}
- free (tmp_die);
+ free_die (tmp_die);
}
}
-/* Add a child DIE below its parent. */
+/* Add a child DIE below its parent. We build the lists up in reverse
+ addition order, and correct that in reverse_all_dies. */
static inline void
add_child_die (die, child_die)
- register dw_die_ref die;
- register dw_die_ref child_die;
+ dw_die_ref die;
+ dw_die_ref child_die;
{
if (die != NULL && child_die != NULL)
{
if (die == child_die)
abort ();
+
child_die->die_parent = die;
- child_die->die_sib = NULL;
+ child_die->die_sib = die->die_child;
+ die->die_child = child_die;
+ }
+}
- if (die->die_child == NULL)
- {
- die->die_child = child_die;
- die->die_child_last = child_die;
- }
- else
- {
- die->die_child_last->die_sib = child_die;
- die->die_child_last = child_die;
- }
+/* Move CHILD, which must be a child of PARENT or the DIE for which PARENT
+ is the specification, to the front of PARENT's list of children. */
+
+static void
+splice_child_die (parent, child)
+ dw_die_ref parent, child;
+{
+ dw_die_ref *p;
+
+ /* We want the declaration DIE from inside the class, not the
+ specification DIE at toplevel. */
+ if (child->die_parent != parent)
+ {
+ dw_die_ref tmp = get_AT_ref (child, DW_AT_specification);
+
+ if (tmp)
+ child = tmp;
}
+
+ if (child->die_parent != parent
+ && child->die_parent != get_AT_ref (parent, DW_AT_specification))
+ abort ();
+
+ for (p = &(child->die_parent->die_child); *p; p = &((*p)->die_sib))
+ if (*p == child)
+ {
+ *p = child->die_sib;
+ break;
+ }
+
+ child->die_sib = parent->die_child;
+ parent->die_child = child;
}
/* Return a pointer to a newly created DIE node. */
static inline dw_die_ref
-new_die (tag_value, parent_die)
- register enum dwarf_tag tag_value;
- register dw_die_ref parent_die;
+new_die (tag_value, parent_die, t)
+ enum dwarf_tag tag_value;
+ dw_die_ref parent_die;
+ tree t;
{
- register dw_die_ref die = (dw_die_ref) xmalloc (sizeof (die_node));
+ dw_die_ref die = (dw_die_ref) xcalloc (1, sizeof (die_node));
die->die_tag = tag_value;
- die->die_abbrev = 0;
- die->die_offset = 0;
- die->die_child = NULL;
- die->die_parent = NULL;
- die->die_sib = NULL;
- die->die_child_last = NULL;
- die->die_attr = NULL;
- die->die_attr_last = NULL;
if (parent_die != NULL)
add_child_die (parent_die, die);
@@ -4204,6 +5090,7 @@ new_die (tag_value, parent_die)
limbo_node = (limbo_die_node *) xmalloc (sizeof (limbo_die_node));
limbo_node->die = die;
+ limbo_node->created_for = t;
limbo_node->next = limbo_die_list;
limbo_die_list = limbo_node;
}
@@ -4215,17 +5102,20 @@ new_die (tag_value, parent_die)
static inline dw_die_ref
lookup_type_die (type)
- register tree type;
+ tree type;
{
+ if (TREE_CODE (type) == VECTOR_TYPE)
+ type = TYPE_DEBUG_REPRESENTATION_TYPE (type);
+
return (dw_die_ref) TYPE_SYMTAB_POINTER (type);
}
/* Equate a DIE to a given type specifier. */
-static void
+static inline void
equate_type_number_to_die (type, type_die)
- register tree type;
- register dw_die_ref type_die;
+ tree type;
+ dw_die_ref type_die;
{
TYPE_SYMTAB_POINTER (type) = (char *) type_die;
}
@@ -4234,23 +5124,22 @@ equate_type_number_to_die (type, type_die)
static inline dw_die_ref
lookup_decl_die (decl)
- register tree decl;
+ tree decl;
{
- register unsigned decl_id = DECL_UID (decl);
+ unsigned decl_id = DECL_UID (decl);
- return (decl_id < decl_die_table_in_use
- ? decl_die_table[decl_id] : NULL);
+ return (decl_id < decl_die_table_in_use ? decl_die_table[decl_id] : NULL);
}
/* Equate a DIE to a particular declaration. */
static void
equate_decl_number_to_die (decl, decl_die)
- register tree decl;
- register dw_die_ref decl_die;
+ tree decl;
+ dw_die_ref decl_die;
{
- register unsigned decl_id = DECL_UID (decl);
- register unsigned num_allocated;
+ unsigned int decl_id = DECL_UID (decl);
+ unsigned int num_allocated;
if (decl_id >= decl_die_table_allocated)
{
@@ -4263,7 +5152,7 @@ equate_decl_number_to_die (decl, decl_die)
= (dw_die_ref *) xrealloc (decl_die_table,
sizeof (dw_die_ref) * num_allocated);
- bzero ((char *) &decl_die_table[decl_die_table_allocated],
+ memset ((char *) &decl_die_table[decl_die_table_allocated], 0,
(num_allocated - decl_die_table_allocated) * sizeof (dw_die_ref));
decl_die_table_allocated = num_allocated;
}
@@ -4273,45 +5162,6 @@ equate_decl_number_to_die (decl, decl_die)
decl_die_table[decl_id] = decl_die;
}
-
-/* Return a pointer to a newly allocated location description. Location
- descriptions are simple expression terms that can be strung
- together to form more complicated location (address) descriptions. */
-
-static inline dw_loc_descr_ref
-new_loc_descr (op, oprnd1, oprnd2)
- register enum dwarf_location_atom op;
- register unsigned long oprnd1;
- register unsigned long oprnd2;
-{
- register dw_loc_descr_ref descr
- = (dw_loc_descr_ref) xmalloc (sizeof (dw_loc_descr_node));
-
- descr->dw_loc_next = NULL;
- descr->dw_loc_opc = op;
- descr->dw_loc_oprnd1.val_class = dw_val_class_unsigned_const;
- descr->dw_loc_oprnd1.v.val_unsigned = oprnd1;
- descr->dw_loc_oprnd2.val_class = dw_val_class_unsigned_const;
- descr->dw_loc_oprnd2.v.val_unsigned = oprnd2;
-
- return descr;
-}
-
-/* Add a location description term to a location description expression. */
-
-static inline void
-add_loc_descr (list_head, descr)
- register dw_loc_descr_ref *list_head;
- register dw_loc_descr_ref descr;
-{
- register dw_loc_descr_ref *d;
-
- /* Find the end of the chain. */
- for (d = list_head; (*d) != NULL; d = &(*d)->dw_loc_next)
- ;
-
- *d = descr;
-}
/* Keep track of the number of spaces used to indent the
output of the debugging routines that print the structure of
@@ -4335,8 +5185,8 @@ print_die (die, outfile)
dw_die_ref die;
FILE *outfile;
{
- register dw_attr_ref a;
- register dw_die_ref c;
+ dw_attr_ref a;
+ dw_die_ref c;
print_spaces (outfile);
fprintf (outfile, "DIE %4lu: %s\n",
@@ -4350,45 +5200,59 @@ print_die (die, outfile)
print_spaces (outfile);
fprintf (outfile, " %s: ", dwarf_attr_name (a->dw_attr));
- switch (a->dw_attr_val.val_class)
+ switch (AT_class (a))
{
case dw_val_class_addr:
fprintf (outfile, "address");
break;
+ case dw_val_class_offset:
+ fprintf (outfile, "offset");
+ break;
case dw_val_class_loc:
fprintf (outfile, "location descriptor");
break;
+ case dw_val_class_loc_list:
+ fprintf (outfile, "location list -> label:%s",
+ AT_loc_list (a)->ll_symbol);
+ break;
+ case dw_val_class_range_list:
+ fprintf (outfile, "range list");
+ break;
case dw_val_class_const:
- fprintf (outfile, "%ld", a->dw_attr_val.v.val_int);
+ fprintf (outfile, "%ld", AT_int (a));
break;
case dw_val_class_unsigned_const:
- fprintf (outfile, "%lu", a->dw_attr_val.v.val_unsigned);
+ fprintf (outfile, "%lu", AT_unsigned (a));
break;
case dw_val_class_long_long:
fprintf (outfile, "constant (%lu,%lu)",
- a->dw_attr_val.v.val_long_long.hi,
- a->dw_attr_val.v.val_long_long.low);
+ 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");
break;
case dw_val_class_flag:
- fprintf (outfile, "%u", a->dw_attr_val.v.val_flag);
+ fprintf (outfile, "%u", AT_flag (a));
break;
case dw_val_class_die_ref:
- if (a->dw_attr_val.v.val_die_ref != NULL)
- fprintf (outfile, "die -> %lu",
- a->dw_attr_val.v.val_die_ref->die_offset);
+ if (AT_ref (a) != NULL)
+ {
+ if (AT_ref (a)->die_symbol)
+ fprintf (outfile, "die -> label: %s", AT_ref (a)->die_symbol);
+ else
+ fprintf (outfile, "die -> %lu", AT_ref (a)->die_offset);
+ }
else
fprintf (outfile, "die -> <null>");
break;
case dw_val_class_lbl_id:
case dw_val_class_lbl_offset:
- fprintf (outfile, "label: %s", a->dw_attr_val.v.val_lbl_id);
+ fprintf (outfile, "label: %s", AT_lbl (a));
break;
case dw_val_class_str:
- if (a->dw_attr_val.v.val_str != NULL)
- fprintf (outfile, "\"%s\"", a->dw_attr_val.v.val_str);
+ if (AT_string (a) != NULL)
+ fprintf (outfile, "\"%s\"", AT_string (a));
else
fprintf (outfile, "<null>");
break;
@@ -4407,6 +5271,8 @@ print_die (die, outfile)
print_indent -= 4;
}
+ if (print_indent == 0)
+ fprintf (outfile, "\n");
}
/* Print the contents of the source code line number correspondence table.
@@ -4416,15 +5282,15 @@ static void
print_dwarf_line_table (outfile)
FILE *outfile;
{
- register unsigned i;
- register dw_line_info_ref line_info;
+ unsigned i;
+ dw_line_info_ref line_info;
fprintf (outfile, "\n\nDWARF source line information\n");
- for (i = 1; i < line_info_table_in_use; ++i)
+ for (i = 1; i < line_info_table_in_use; i++)
{
line_info = &line_info_table[i];
fprintf (outfile, "%5d: ", i);
- fprintf (outfile, "%-20s", file_table[line_info->dw_file_num]);
+ fprintf (outfile, "%-20s", file_table.table[line_info->dw_file_num]);
fprintf (outfile, "%6ld", line_info->dw_line_num);
fprintf (outfile, "\n");
}
@@ -4449,56 +5315,474 @@ debug_dwarf ()
{
print_indent = 0;
print_die (comp_unit_die, stderr);
- print_dwarf_line_table (stderr);
+ if (! DWARF2_ASM_LINE_DEBUG_INFO)
+ print_dwarf_line_table (stderr);
}
-/* Traverse the DIE, and add a sibling attribute if it may have the
- effect of speeding up access to siblings. To save some space,
- avoid generating sibling attributes for DIE's without children. */
+/* We build up the lists of children and attributes by pushing new ones
+ onto the beginning of the list. Reverse the lists for DIE so that
+ they are in order of addition. */
static void
-add_sibling_attributes(die)
- register dw_die_ref die;
+reverse_die_lists (die)
+ dw_die_ref die;
{
- register dw_die_ref c;
- register dw_attr_ref attr;
- if (die != comp_unit_die && die->die_child != NULL)
+ dw_die_ref c, cp, cn;
+ dw_attr_ref a, ap, an;
+
+ for (a = die->die_attr, ap = 0; a; a = an)
{
- attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node));
- attr->dw_attr_next = NULL;
- attr->dw_attr = DW_AT_sibling;
- attr->dw_attr_val.val_class = dw_val_class_die_ref;
- attr->dw_attr_val.v.val_die_ref = die->die_sib;
+ an = a->dw_attr_next;
+ a->dw_attr_next = ap;
+ ap = a;
+ }
- /* Add the sibling link to the front of the attribute list. */
- attr->dw_attr_next = die->die_attr;
- if (die->die_attr == NULL)
- die->die_attr_last = attr;
+ die->die_attr = ap;
- die->die_attr = attr;
+ for (c = die->die_child, cp = 0; c; c = cn)
+ {
+ cn = c->die_sib;
+ c->die_sib = cp;
+ cp = c;
+ }
+
+ die->die_child = cp;
+}
+
+/* reverse_die_lists only reverses the single die you pass it. Since we used to
+ reverse all dies in add_sibling_attributes, which runs through all the dies,
+ it would reverse all the dies. Now, however, since we don't call
+ reverse_die_lists in add_sibling_attributes, we need a routine to
+ recursively reverse all the dies. This is that routine. */
+
+static void
+reverse_all_dies (die)
+ dw_die_ref die;
+{
+ dw_die_ref c;
+
+ reverse_die_lists (die);
+
+ for (c = die->die_child; c; c = c->die_sib)
+ reverse_all_dies (c);
+}
+
+/* Start a new compilation unit DIE for an include file. OLD_UNIT is the CU
+ for the enclosing include file, if any. BINCL_DIE is the DW_TAG_GNU_BINCL
+ DIE that marks the start of the DIEs for this include file. */
+
+static dw_die_ref
+push_new_compile_unit (old_unit, bincl_die)
+ dw_die_ref old_unit, bincl_die;
+{
+ const char *filename = get_AT_string (bincl_die, DW_AT_name);
+ dw_die_ref new_unit = gen_compile_unit_die (filename);
+
+ new_unit->die_sib = old_unit;
+ return new_unit;
+}
+
+/* Close an include-file CU and reopen the enclosing one. */
+
+static dw_die_ref
+pop_compile_unit (old_unit)
+ dw_die_ref old_unit;
+{
+ dw_die_ref new_unit = old_unit->die_sib;
+
+ old_unit->die_sib = NULL;
+ return new_unit;
+}
+
+#define CHECKSUM(FOO) md5_process_bytes (&(FOO), sizeof (FOO), ctx)
+#define CHECKSUM_STRING(FOO) md5_process_bytes ((FOO), strlen (FOO), ctx)
+
+/* Calculate the checksum of a location expression. */
+
+static inline void
+loc_checksum (loc, ctx)
+ dw_loc_descr_ref loc;
+ struct md5_ctx *ctx;
+{
+ CHECKSUM (loc->dw_loc_opc);
+ CHECKSUM (loc->dw_loc_oprnd1);
+ CHECKSUM (loc->dw_loc_oprnd2);
+}
+
+/* Calculate the checksum of an attribute. */
+
+static void
+attr_checksum (at, ctx)
+ dw_attr_ref at;
+ struct md5_ctx *ctx;
+{
+ dw_loc_descr_ref loc;
+ rtx r;
+
+ CHECKSUM (at->dw_attr);
+
+ /* We don't care about differences in file numbering. */
+ if (at->dw_attr == DW_AT_decl_file
+ /* Or that this was compiled with a different compiler snapshot; if
+ the output is the same, that's what matters. */
+ || at->dw_attr == DW_AT_producer)
+ return;
+
+ switch (AT_class (at))
+ {
+ case dw_val_class_const:
+ CHECKSUM (at->dw_attr_val.v.val_int);
+ break;
+ case dw_val_class_unsigned_const:
+ CHECKSUM (at->dw_attr_val.v.val_unsigned);
+ break;
+ 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);
+ break;
+ case dw_val_class_flag:
+ CHECKSUM (at->dw_attr_val.v.val_flag);
+ break;
+ case dw_val_class_str:
+ CHECKSUM_STRING (AT_string (at));
+ break;
+
+ case dw_val_class_addr:
+ r = AT_addr (at);
+ switch (GET_CODE (r))
+ {
+ case SYMBOL_REF:
+ CHECKSUM_STRING (XSTR (r, 0));
+ break;
+
+ default:
+ abort ();
+ }
+ break;
+
+ case dw_val_class_offset:
+ CHECKSUM (at->dw_attr_val.v.val_offset);
+ break;
+
+ case dw_val_class_loc:
+ for (loc = AT_loc (at); loc; loc = loc->dw_loc_next)
+ loc_checksum (loc, ctx);
+ break;
+
+ case dw_val_class_die_ref:
+ if (AT_ref (at)->die_offset)
+ CHECKSUM (AT_ref (at)->die_offset);
+ /* FIXME else use target die name or something. */
+
+ case dw_val_class_fde_ref:
+ case dw_val_class_lbl_id:
+ case dw_val_class_lbl_offset:
+ break;
+
+ default:
+ break;
+ }
+}
+
+/* Calculate the checksum of a DIE. */
+
+static void
+die_checksum (die, ctx)
+ dw_die_ref die;
+ struct md5_ctx *ctx;
+{
+ dw_die_ref c;
+ dw_attr_ref a;
+
+ CHECKSUM (die->die_tag);
+
+ for (a = die->die_attr; a; a = a->dw_attr_next)
+ attr_checksum (a, ctx);
+
+ for (c = die->die_child; c; c = c->die_sib)
+ die_checksum (c, ctx);
+}
+
+#undef CHECKSUM
+#undef CHECKSUM_STRING
+
+/* The prefix to attach to symbols on DIEs in the current comdat debug
+ info section. */
+static char *comdat_symbol_id;
+
+/* The index of the current symbol within the current comdat CU. */
+static unsigned int comdat_symbol_number;
+
+/* Calculate the MD5 checksum of the compilation unit DIE UNIT_DIE and its
+ children, and set comdat_symbol_id accordingly. */
+
+static void
+compute_section_prefix (unit_die)
+ dw_die_ref unit_die;
+{
+ const char *base = lbasename (get_AT_string (unit_die, DW_AT_name));
+ char *name = (char *) alloca (strlen (base) + 64);
+ char *p;
+ int i;
+ unsigned char checksum[16];
+ struct md5_ctx ctx;
+
+ /* Compute the checksum of the DIE, then append part of it as hex digits to
+ the name filename of the unit. */
+
+ md5_init_ctx (&ctx);
+ die_checksum (unit_die, &ctx);
+ md5_finish_ctx (&ctx, checksum);
+
+ sprintf (name, "%s.", base);
+ clean_symbol_name (name);
+
+ p = name + strlen (name);
+ for (i = 0; i < 4; i++)
+ {
+ sprintf (p, "%.2x", checksum[i]);
+ p += 2;
+ }
+
+ comdat_symbol_id = unit_die->die_symbol = xstrdup (name);
+ comdat_symbol_number = 0;
+}
+
+/* Returns nonzero if DIE represents a type, in the sense of TYPE_P. */
+
+static int
+is_type_die (die)
+ dw_die_ref die;
+{
+ switch (die->die_tag)
+ {
+ case DW_TAG_array_type:
+ case DW_TAG_class_type:
+ case DW_TAG_enumeration_type:
+ case DW_TAG_pointer_type:
+ case DW_TAG_reference_type:
+ case DW_TAG_string_type:
+ case DW_TAG_structure_type:
+ case DW_TAG_subroutine_type:
+ case DW_TAG_union_type:
+ case DW_TAG_ptr_to_member_type:
+ case DW_TAG_set_type:
+ case DW_TAG_subrange_type:
+ case DW_TAG_base_type:
+ case DW_TAG_const_type:
+ case DW_TAG_file_type:
+ case DW_TAG_packed_type:
+ case DW_TAG_volatile_type:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+/* Returns 1 iff C is the sort of DIE that should go into a COMDAT CU.
+ Basically, we want to choose the bits that are likely to be shared between
+ compilations (types) and leave out the bits that are specific to individual
+ compilations (functions). */
+
+static int
+is_comdat_die (c)
+ dw_die_ref c;
+{
+ /* I think we want to leave base types and __vtbl_ptr_type in the main CU, as
+ we do for stabs. The advantage is a greater likelihood of sharing between
+ objects that don't include headers in the same order (and therefore would
+ put the base types in a different comdat). jason 8/28/00 */
+
+ if (c->die_tag == DW_TAG_base_type)
+ return 0;
+
+ if (c->die_tag == DW_TAG_pointer_type
+ || c->die_tag == DW_TAG_reference_type
+ || c->die_tag == DW_TAG_const_type
+ || c->die_tag == DW_TAG_volatile_type)
+ {
+ dw_die_ref t = get_AT_ref (c, DW_AT_type);
+
+ return t ? is_comdat_die (t) : 0;
+ }
+
+ return is_type_die (c);
+}
+
+/* Returns 1 iff C is the sort of DIE that might be referred to from another
+ compilation unit. */
+
+static int
+is_symbol_die (c)
+ dw_die_ref c;
+{
+ return (is_type_die (c)
+ || (get_AT (c, DW_AT_declaration)
+ && !get_AT (c, DW_AT_specification)));
+}
+
+static char *
+gen_internal_sym (prefix)
+ const char *prefix;
+{
+ char buf[256];
+ static int label_num;
+
+ ASM_GENERATE_INTERNAL_LABEL (buf, prefix, label_num++);
+ return xstrdup (buf);
+}
+
+/* Assign symbols to all worthy DIEs under DIE. */
+
+static void
+assign_symbol_names (die)
+ dw_die_ref die;
+{
+ dw_die_ref c;
+
+ if (is_symbol_die (die))
+ {
+ if (comdat_symbol_id)
+ {
+ char *p = alloca (strlen (comdat_symbol_id) + 64);
+
+ sprintf (p, "%s.%s.%x", DIE_LABEL_PREFIX,
+ comdat_symbol_id, comdat_symbol_number++);
+ die->die_symbol = xstrdup (p);
+ }
+ else
+ die->die_symbol = gen_internal_sym ("LDIE");
}
for (c = die->die_child; c != NULL; c = c->die_sib)
+ assign_symbol_names (c);
+}
+
+/* Traverse the DIE (which is always comp_unit_die), and set up
+ additional compilation units for each of the include files we see
+ bracketed by BINCL/EINCL. */
+
+static void
+break_out_includes (die)
+ dw_die_ref die;
+{
+ dw_die_ref *ptr;
+ dw_die_ref unit = NULL;
+ limbo_die_node *node;
+
+ for (ptr = &(die->die_child); *ptr; )
+ {
+ dw_die_ref c = *ptr;
+
+ if (c->die_tag == DW_TAG_GNU_BINCL || c->die_tag == DW_TAG_GNU_EINCL
+ || (unit && is_comdat_die (c)))
+ {
+ /* This DIE is for a secondary CU; remove it from the main one. */
+ *ptr = c->die_sib;
+
+ if (c->die_tag == DW_TAG_GNU_BINCL)
+ {
+ unit = push_new_compile_unit (unit, c);
+ free_die (c);
+ }
+ else if (c->die_tag == DW_TAG_GNU_EINCL)
+ {
+ unit = pop_compile_unit (unit);
+ free_die (c);
+ }
+ else
+ add_child_die (unit, c);
+ }
+ else
+ {
+ /* Leave this DIE in the main CU. */
+ ptr = &(c->die_sib);
+ continue;
+ }
+ }
+
+#if 0
+ /* We can only use this in debugging, since the frontend doesn't check
+ to make sure that we leave every include file we enter. */
+ if (unit != NULL)
+ abort ();
+#endif
+
+ assign_symbol_names (die);
+ for (node = limbo_die_list; node; node = node->next)
+ {
+ compute_section_prefix (node->die);
+ assign_symbol_names (node->die);
+ }
+}
+
+/* Traverse the DIE and add a sibling attribute if it may have the
+ effect of speeding up access to siblings. To save some space,
+ avoid generating sibling attributes for DIE's without children. */
+
+static void
+add_sibling_attributes (die)
+ dw_die_ref die;
+{
+ dw_die_ref c;
+
+ if (die->die_tag != DW_TAG_compile_unit
+ && die->die_sib && die->die_child != NULL)
+ /* Add the sibling link to the front of the attribute list. */
+ add_AT_die_ref (die, DW_AT_sibling, die->die_sib);
+
+ for (c = die->die_child; c != NULL; c = c->die_sib)
add_sibling_attributes (c);
}
-/* The format of each DIE (and its attribute value pairs)
- is encoded in an abbreviation table. This routine builds the
- abbreviation table and assigns a unique abbreviation id for
- each abbreviation entry. The children of each die are visited
- recursively. */
+/* Output all location lists for the DIE and its children. */
+
+static void
+output_location_lists (die)
+ dw_die_ref die;
+{
+ dw_die_ref c;
+ dw_attr_ref d_attr;
+
+ for (d_attr = die->die_attr; d_attr; d_attr = d_attr->dw_attr_next)
+ if (AT_class (d_attr) == dw_val_class_loc_list)
+ output_loc_list (AT_loc_list (d_attr));
+
+ for (c = die->die_child; c != NULL; c = c->die_sib)
+ output_location_lists (c);
+
+}
+/* The format of each DIE (and its attribute value pairs) is encoded in an
+ abbreviation table. This routine builds the abbreviation table and assigns
+ a unique abbreviation id for each abbreviation entry. The children of each
+ die are visited recursively. */
static void
build_abbrev_table (die)
- register dw_die_ref die;
+ dw_die_ref die;
{
- register unsigned long abbrev_id;
- register unsigned long n_alloc;
- register dw_die_ref c;
- register dw_attr_ref d_attr, a_attr;
+ unsigned long abbrev_id;
+ unsigned int n_alloc;
+ dw_die_ref c;
+ dw_attr_ref d_attr, a_attr;
+
+ /* Scan the DIE references, and mark as external any that refer to
+ DIEs from other CUs (i.e. those which are not marked). */
+ for (d_attr = die->die_attr; d_attr; d_attr = d_attr->dw_attr_next)
+ if (AT_class (d_attr) == dw_val_class_die_ref
+ && AT_ref (d_attr)->die_mark == 0)
+ {
+ if (AT_ref (d_attr)->die_symbol == 0)
+ abort ();
+
+ set_AT_ref_external (d_attr, 1);
+ }
+
for (abbrev_id = 1; abbrev_id < abbrev_die_table_in_use; ++abbrev_id)
{
- register dw_die_ref abbrev = abbrev_die_table[abbrev_id];
+ dw_die_ref abbrev = abbrev_die_table[abbrev_id];
if (abbrev->die_tag == die->die_tag)
{
@@ -4510,8 +5794,7 @@ build_abbrev_table (die)
while (a_attr != NULL && d_attr != NULL)
{
if ((a_attr->dw_attr != d_attr->dw_attr)
- || (value_format (&a_attr->dw_attr_val)
- != value_format (&d_attr->dw_attr_val)))
+ || (value_format (a_attr) != value_format (d_attr)))
break;
a_attr = a_attr->dw_attr_next;
@@ -4529,11 +5812,11 @@ build_abbrev_table (die)
if (abbrev_die_table_in_use >= abbrev_die_table_allocated)
{
n_alloc = abbrev_die_table_allocated + ABBREV_DIE_TABLE_INCREMENT;
- abbrev_die_table
+ abbrev_die_table
= (dw_die_ref *) xrealloc (abbrev_die_table,
sizeof (dw_die_ref) * n_alloc);
- bzero ((char *) &abbrev_die_table[abbrev_die_table_allocated],
+ memset ((char *) &abbrev_die_table[abbrev_die_table_allocated], 0,
(n_alloc - abbrev_die_table_allocated) * sizeof (dw_die_ref));
abbrev_die_table_allocated = n_alloc;
}
@@ -4547,137 +5830,6 @@ build_abbrev_table (die)
build_abbrev_table (c);
}
-/* Return the size of a string, including the null byte.
-
- This used to treat backslashes as escapes, and hence they were not included
- in the count. However, that conflicts with what ASM_OUTPUT_ASCII does,
- which treats a backslash as a backslash, escaping it if necessary, and hence
- we must include them in the count. */
-
-static unsigned long
-size_of_string (str)
- register char *str;
-{
- return strlen (str) + 1;
-}
-
-/* Return the size of a location descriptor. */
-
-static unsigned long
-size_of_loc_descr (loc)
- register dw_loc_descr_ref loc;
-{
- register unsigned long size = 1;
-
- switch (loc->dw_loc_opc)
- {
- case DW_OP_addr:
- size += PTR_SIZE;
- break;
- case DW_OP_const1u:
- case DW_OP_const1s:
- size += 1;
- break;
- case DW_OP_const2u:
- case DW_OP_const2s:
- size += 2;
- break;
- case DW_OP_const4u:
- case DW_OP_const4s:
- size += 4;
- break;
- case DW_OP_const8u:
- case DW_OP_const8s:
- size += 8;
- break;
- case DW_OP_constu:
- size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
- break;
- case DW_OP_consts:
- size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int);
- break;
- case DW_OP_pick:
- size += 1;
- break;
- case DW_OP_plus_uconst:
- size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
- break;
- case DW_OP_skip:
- case DW_OP_bra:
- size += 2;
- break;
- case DW_OP_breg0:
- case DW_OP_breg1:
- case DW_OP_breg2:
- case DW_OP_breg3:
- case DW_OP_breg4:
- case DW_OP_breg5:
- case DW_OP_breg6:
- case DW_OP_breg7:
- case DW_OP_breg8:
- case DW_OP_breg9:
- case DW_OP_breg10:
- case DW_OP_breg11:
- case DW_OP_breg12:
- case DW_OP_breg13:
- case DW_OP_breg14:
- case DW_OP_breg15:
- case DW_OP_breg16:
- case DW_OP_breg17:
- case DW_OP_breg18:
- case DW_OP_breg19:
- case DW_OP_breg20:
- case DW_OP_breg21:
- case DW_OP_breg22:
- case DW_OP_breg23:
- case DW_OP_breg24:
- case DW_OP_breg25:
- case DW_OP_breg26:
- case DW_OP_breg27:
- case DW_OP_breg28:
- case DW_OP_breg29:
- case DW_OP_breg30:
- case DW_OP_breg31:
- size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int);
- break;
- case DW_OP_regx:
- size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
- break;
- case DW_OP_fbreg:
- size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int);
- break;
- case DW_OP_bregx:
- size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
- size += size_of_sleb128 (loc->dw_loc_oprnd2.v.val_int);
- break;
- case DW_OP_piece:
- size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
- break;
- case DW_OP_deref_size:
- case DW_OP_xderef_size:
- size += 1;
- break;
- default:
- break;
- }
-
- return size;
-}
-
-/* Return the size of a series of location descriptors. */
-
-static unsigned long
-size_of_locs (loc)
- register dw_loc_descr_ref loc;
-{
- register unsigned long size = 0;
-
- for (; loc != NULL; loc = loc->dw_loc_next)
- size += size_of_loc_descr (loc);
-
- return size;
-}
-
/* Return the power-of-two number of bytes necessary to represent VALUE. */
static int
@@ -4697,42 +5849,50 @@ constant_size (value)
return log;
}
-/* Return the size of a DIE, as it is represented in the
+/* Return the size of a DIE as it is represented in the
.debug_info section. */
static unsigned long
size_of_die (die)
- register dw_die_ref die;
+ dw_die_ref die;
{
- register unsigned long size = 0;
- register dw_attr_ref a;
+ unsigned long size = 0;
+ dw_attr_ref a;
size += size_of_uleb128 (die->die_abbrev);
for (a = die->die_attr; a != NULL; a = a->dw_attr_next)
{
- switch (a->dw_attr_val.val_class)
+ switch (AT_class (a))
{
case dw_val_class_addr:
- size += PTR_SIZE;
+ size += DWARF2_ADDR_SIZE;
+ break;
+ case dw_val_class_offset:
+ size += DWARF_OFFSET_SIZE;
break;
case dw_val_class_loc:
{
- register unsigned long lsize
- = size_of_locs (a->dw_attr_val.v.val_loc);
+ unsigned long lsize = size_of_locs (AT_loc (a));
/* Block length. */
size += constant_size (lsize);
size += lsize;
}
break;
+ case dw_val_class_loc_list:
+ size += DWARF_OFFSET_SIZE;
+ break;
+ case dw_val_class_range_list:
+ size += DWARF_OFFSET_SIZE;
+ break;
case dw_val_class_const:
- size += 4;
+ size += size_of_sleb128 (AT_int (a));
break;
case dw_val_class_unsigned_const:
- size += constant_size (a->dw_attr_val.v.val_unsigned);
+ size += constant_size (AT_unsigned (a));
break;
case dw_val_class_long_long:
- size += 1 + 8; /* block */
+ 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 */
@@ -4747,13 +5907,16 @@ size_of_die (die)
size += DWARF_OFFSET_SIZE;
break;
case dw_val_class_lbl_id:
- size += PTR_SIZE;
+ size += DWARF2_ADDR_SIZE;
break;
case dw_val_class_lbl_offset:
size += DWARF_OFFSET_SIZE;
break;
case dw_val_class_str:
- size += size_of_string (a->dw_attr_val.v.val_str);
+ if (AT_string_form (a) == DW_FORM_strp)
+ size += DWARF_OFFSET_SIZE;
+ else
+ size += HT_LEN (&a->dw_attr_val.v.val_str->id) + 1;
break;
default:
abort ();
@@ -4763,17 +5926,17 @@ size_of_die (die)
return size;
}
-/* Size the debugging information associated with a given DIE.
- Visits the DIE's children recursively. Updates the global
- variable next_die_offset, on each time through. Uses the
- current value of next_die_offset to update the die_offset
- field in each DIE. */
+/* Size the debugging information associated with a given DIE. Visits the
+ DIE's children recursively. Updates the global variable next_die_offset, on
+ each time through. Uses the current value of next_die_offset to update the
+ die_offset field in each DIE. */
static void
calc_die_sizes (die)
dw_die_ref die;
{
- register dw_die_ref c;
+ dw_die_ref c;
+
die->die_offset = next_die_offset;
next_die_offset += size_of_die (die);
@@ -4785,202 +5948,33 @@ calc_die_sizes (die)
next_die_offset += 1;
}
-/* Return the size of the line information prolog generated for the
- compilation unit. */
+/* Set the marks for a die and its children. We do this so
+ that we know whether or not a reference needs to use FORM_ref_addr; only
+ DIEs in the same CU will be marked. We used to clear out the offset
+ and use that as the flag, but ran into ordering problems. */
-static unsigned long
-size_of_line_prolog ()
+static void
+mark_dies (die)
+ dw_die_ref die;
{
- register unsigned long size;
- register unsigned long ft_index;
-
- size = DWARF_LINE_PROLOG_HEADER_SIZE;
-
- /* Count the size of the table giving number of args for each
- standard opcode. */
- size += DWARF_LINE_OPCODE_BASE - 1;
-
- /* Include directory table is empty (at present). Count only the
- null byte used to terminate the table. */
- size += 1;
-
- for (ft_index = 1; ft_index < file_table_in_use; ++ft_index)
- {
- /* File name entry. */
- size += size_of_string (file_table[ft_index]);
-
- /* Include directory index. */
- size += size_of_uleb128 (0);
-
- /* Modification time. */
- size += size_of_uleb128 (0);
-
- /* File length in bytes. */
- size += size_of_uleb128 (0);
- }
+ dw_die_ref c;
- /* Count the file table terminator. */
- size += 1;
- return size;
+ die->die_mark = 1;
+ for (c = die->die_child; c; c = c->die_sib)
+ mark_dies (c);
}
-/* Return the size of the line information generated for this
- compilation unit. */
+/* Clear the marks for a die and its children. */
-static unsigned long
-size_of_line_info ()
+static void
+unmark_dies (die)
+ dw_die_ref die;
{
- register unsigned long size;
- register unsigned long lt_index;
- register unsigned long current_line;
- register long line_offset;
- register long line_delta;
- register unsigned long current_file;
- register unsigned long function;
- unsigned long size_of_set_address;
-
- /* Size of a DW_LNE_set_address instruction. */
- size_of_set_address = 1 + size_of_uleb128 (1 + PTR_SIZE) + 1 + PTR_SIZE;
-
- /* Version number. */
- size = 2;
-
- /* Prolog length specifier. */
- size += DWARF_OFFSET_SIZE;
-
- /* Prolog. */
- size += size_of_line_prolog ();
-
- current_file = 1;
- current_line = 1;
- for (lt_index = 1; lt_index < line_info_table_in_use; ++lt_index)
- {
- register dw_line_info_ref line_info = &line_info_table[lt_index];
-
- if (line_info->dw_line_num == current_line
- && line_info->dw_file_num == current_file)
- continue;
-
- /* Advance pc instruction. */
- /* ??? See the DW_LNS_advance_pc comment in output_line_info. */
- if (0)
- size += 1 + 2;
- else
- size += size_of_set_address;
-
- if (line_info->dw_file_num != current_file)
- {
- /* Set file number instruction. */
- size += 1;
- current_file = line_info->dw_file_num;
- size += size_of_uleb128 (current_file);
- }
-
- if (line_info->dw_line_num != current_line)
- {
- line_offset = line_info->dw_line_num - current_line;
- line_delta = line_offset - DWARF_LINE_BASE;
- current_line = line_info->dw_line_num;
- if (line_delta >= 0 && line_delta < (DWARF_LINE_RANGE - 1))
- /* 1-byte special line number instruction. */
- size += 1;
- else
- {
- /* Advance line instruction. */
- size += 1;
- size += size_of_sleb128 (line_offset);
- /* Generate line entry instruction. */
- size += 1;
- }
- }
- }
-
- /* Advance pc instruction. */
- if (0)
- size += 1 + 2;
- else
- size += size_of_set_address;
-
- /* End of line number info. marker. */
- size += 1 + size_of_uleb128 (1) + 1;
-
- function = 0;
- current_file = 1;
- current_line = 1;
- for (lt_index = 0; lt_index < separate_line_info_table_in_use; )
- {
- register dw_separate_line_info_ref line_info
- = &separate_line_info_table[lt_index];
-
- if (line_info->dw_line_num == current_line
- && line_info->dw_file_num == current_file
- && line_info->function == function)
- goto cont;
-
- if (function != line_info->function)
- {
- function = line_info->function;
- /* Set address register instruction. */
- size += size_of_set_address;
- }
- else
- {
- /* Advance pc instruction. */
- if (0)
- size += 1 + 2;
- else
- size += size_of_set_address;
- }
-
- if (line_info->dw_file_num != current_file)
- {
- /* Set file number instruction. */
- size += 1;
- current_file = line_info->dw_file_num;
- size += size_of_uleb128 (current_file);
- }
-
- if (line_info->dw_line_num != current_line)
- {
- line_offset = line_info->dw_line_num - current_line;
- line_delta = line_offset - DWARF_LINE_BASE;
- current_line = line_info->dw_line_num;
- if (line_delta >= 0 && line_delta < (DWARF_LINE_RANGE - 1))
- /* 1-byte special line number instruction. */
- size += 1;
- else
- {
- /* Advance line instruction. */
- size += 1;
- size += size_of_sleb128 (line_offset);
-
- /* Generate line entry instruction. */
- size += 1;
- }
- }
-
- cont:
- ++lt_index;
-
- /* If we're done with a function, end its sequence. */
- if (lt_index == separate_line_info_table_in_use
- || separate_line_info_table[lt_index].function != function)
- {
- current_file = 1;
- current_line = 1;
-
- /* Advance pc instruction. */
- if (0)
- size += 1 + 2;
- else
- size += size_of_set_address;
+ dw_die_ref c;
- /* End of line number info. marker. */
- size += 1 + size_of_uleb128 (1) + 1;
- }
- }
-
- return size;
+ die->die_mark = 0;
+ for (c = die->die_child; c; c = c->die_sib)
+ unmark_dies (c);
}
/* Return the size of the .debug_pubnames table generated for the
@@ -4989,14 +5983,14 @@ size_of_line_info ()
static unsigned long
size_of_pubnames ()
{
- register unsigned long size;
- register unsigned i;
+ unsigned long size;
+ unsigned i;
size = DWARF_PUBNAMES_HEADER_SIZE;
- for (i = 0; i < pubname_table_in_use; ++i)
+ for (i = 0; i < pubname_table_in_use; i++)
{
- register pubname_ref p = &pubname_table[i];
- size += DWARF_OFFSET_SIZE + size_of_string (p->name);
+ pubname_ref p = &pubname_table[i];
+ size += DWARF_OFFSET_SIZE + strlen (p->name) + 1;
}
size += DWARF_OFFSET_SIZE;
@@ -5008,31 +6002,42 @@ size_of_pubnames ()
static unsigned long
size_of_aranges ()
{
- register unsigned long size;
+ unsigned long size;
size = DWARF_ARANGES_HEADER_SIZE;
/* Count the address/length pair for this compilation unit. */
- size += 2 * PTR_SIZE;
- size += 2 * PTR_SIZE * arange_table_in_use;
+ size += 2 * DWARF2_ADDR_SIZE;
+ size += 2 * DWARF2_ADDR_SIZE * arange_table_in_use;
/* Count the two zero words used to terminated the address range table. */
- size += 2 * PTR_SIZE;
+ size += 2 * DWARF2_ADDR_SIZE;
return size;
}
/* Select the encoding of an attribute value. */
static enum dwarf_form
-value_format (v)
- dw_val_ref v;
+value_format (a)
+ dw_attr_ref a;
{
- switch (v->val_class)
+ switch (a->dw_attr_val.val_class)
{
case dw_val_class_addr:
return DW_FORM_addr;
+ case dw_val_class_range_list:
+ case dw_val_class_offset:
+ if (DWARF_OFFSET_SIZE == 4)
+ return DW_FORM_data4;
+ if (DWARF_OFFSET_SIZE == 8)
+ return DW_FORM_data8;
+ abort ();
+ case dw_val_class_loc_list:
+ /* FIXME: Could be DW_FORM_data8, with a > 32 bit size
+ .debug_loc section */
+ return DW_FORM_data4;
case dw_val_class_loc:
- switch (constant_size (size_of_locs (v->v.val_loc)))
+ switch (constant_size (size_of_locs (AT_loc (a))))
{
case 1:
return DW_FORM_block1;
@@ -5042,9 +6047,9 @@ value_format (v)
abort ();
}
case dw_val_class_const:
- return DW_FORM_data4;
+ return DW_FORM_sdata;
case dw_val_class_unsigned_const:
- switch (constant_size (v->v.val_unsigned))
+ switch (constant_size (AT_unsigned (a)))
{
case 1:
return DW_FORM_data1;
@@ -5064,7 +6069,10 @@ value_format (v)
case dw_val_class_flag:
return DW_FORM_flag;
case dw_val_class_die_ref:
- return DW_FORM_ref;
+ if (AT_ref_external (a))
+ return DW_FORM_ref_addr;
+ else
+ return DW_FORM_ref;
case dw_val_class_fde_ref:
return DW_FORM_data;
case dw_val_class_lbl_id:
@@ -5072,7 +6080,8 @@ value_format (v)
case dw_val_class_lbl_offset:
return DW_FORM_data;
case dw_val_class_str:
- return DW_FORM_string;
+ return AT_string_form (a);
+
default:
abort ();
}
@@ -5081,16 +6090,12 @@ value_format (v)
/* Output the encoding of an attribute value. */
static void
-output_value_format (v)
- dw_val_ref v;
+output_value_format (a)
+ dw_attr_ref a;
{
- enum dwarf_form form = value_format (v);
-
- output_uleb128 (form);
- if (flag_debug_asm)
- fprintf (asm_out_file, " (%s)", dwarf_form_name (form));
+ enum dwarf_form form = value_format (a);
- fputc ('\n', asm_out_file);
+ dw2_asm_output_data_uleb128 (form, "(%s)", dwarf_form_name (form));
}
/* Output the .debug_abbrev section which defines the DIE abbreviation
@@ -5102,186 +6107,149 @@ output_abbrev_section ()
unsigned long abbrev_id;
dw_attr_ref a_attr;
+
for (abbrev_id = 1; abbrev_id < abbrev_die_table_in_use; ++abbrev_id)
{
- register dw_die_ref abbrev = abbrev_die_table[abbrev_id];
-
- output_uleb128 (abbrev_id);
- if (flag_debug_asm)
- fprintf (asm_out_file, " (abbrev code)");
+ dw_die_ref abbrev = abbrev_die_table[abbrev_id];
- fputc ('\n', asm_out_file);
- output_uleb128 (abbrev->die_tag);
- if (flag_debug_asm)
- fprintf (asm_out_file, " (TAG: %s)",
- dwarf_tag_name (abbrev->die_tag));
+ dw2_asm_output_data_uleb128 (abbrev_id, "(abbrev code)");
+ dw2_asm_output_data_uleb128 (abbrev->die_tag, "(TAG: %s)",
+ dwarf_tag_name (abbrev->die_tag));
- fputc ('\n', asm_out_file);
- fprintf (asm_out_file, "\t%s\t0x%x", ASM_BYTE_OP,
- abbrev->die_child != NULL ? DW_children_yes : DW_children_no);
-
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s %s",
- ASM_COMMENT_START,
- (abbrev->die_child != NULL
- ? "DW_children_yes" : "DW_children_no"));
-
- fputc ('\n', asm_out_file);
+ if (abbrev->die_child != NULL)
+ dw2_asm_output_data (1, DW_children_yes, "DW_children_yes");
+ else
+ dw2_asm_output_data (1, DW_children_no, "DW_children_no");
for (a_attr = abbrev->die_attr; a_attr != NULL;
a_attr = a_attr->dw_attr_next)
{
- output_uleb128 (a_attr->dw_attr);
- if (flag_debug_asm)
- fprintf (asm_out_file, " (%s)",
- dwarf_attr_name (a_attr->dw_attr));
-
- fputc ('\n', asm_out_file);
- output_value_format (&a_attr->dw_attr_val);
+ dw2_asm_output_data_uleb128 (a_attr->dw_attr, "(%s)",
+ dwarf_attr_name (a_attr->dw_attr));
+ output_value_format (a_attr);
}
- fprintf (asm_out_file, "\t%s\t0,0\n", ASM_BYTE_OP);
+ dw2_asm_output_data (1, 0, NULL);
+ dw2_asm_output_data (1, 0, NULL);
}
- /* We need to properly terminate the abbrev table for this
- compilation unit, as per the standard, and not rely on
- workarounds in e.g. gdb. */
- fprintf (asm_out_file, "\t%s\t0\n", ASM_BYTE_OP);
+ /* Terminate the table. */
+ dw2_asm_output_data (1, 0, NULL);
}
-/* Output location description stack opcode's operands (if any). */
+/* Output a symbol we can use to refer to this DIE from another CU. */
+
+static inline void
+output_die_symbol (die)
+ dw_die_ref die;
+{
+ char *sym = die->die_symbol;
+
+ if (sym == 0)
+ return;
+
+ if (strncmp (sym, DIE_LABEL_PREFIX, sizeof (DIE_LABEL_PREFIX) - 1) == 0)
+ /* We make these global, not weak; if the target doesn't support
+ .linkonce, it doesn't support combining the sections, so debugging
+ will break. */
+ ASM_GLOBALIZE_LABEL (asm_out_file, sym);
+
+ ASM_OUTPUT_LABEL (asm_out_file, sym);
+}
+
+/* Return a new location list, given the begin and end range, and the
+ expression. gensym tells us whether to generate a new internal symbol for
+ this location list node, which is done for the head of the list only. */
+
+static inline dw_loc_list_ref
+new_loc_list (expr, begin, end, section, gensym)
+ dw_loc_descr_ref expr;
+ const char *begin;
+ const char *end;
+ const char *section;
+ unsigned gensym;
+{
+ dw_loc_list_ref retlist
+ = (dw_loc_list_ref) xcalloc (1, sizeof (dw_loc_list_node));
+
+ retlist->begin = begin;
+ retlist->end = end;
+ retlist->expr = expr;
+ retlist->section = section;
+ if (gensym)
+ retlist->ll_symbol = gen_internal_sym ("LLST");
+
+ return retlist;
+}
+
+/* Add a location description expression to a location list */
+
+static inline void
+add_loc_descr_to_loc_list (list_head, descr, begin, end, section)
+ dw_loc_list_ref *list_head;
+ dw_loc_descr_ref descr;
+ const char *begin;
+ const char *end;
+ const char *section;
+{
+ dw_loc_list_ref *d;
+
+ /* Find the end of the chain. */
+ for (d = list_head; (*d) != NULL; d = &(*d)->dw_loc_next)
+ ;
+
+ /* Add a new location list node to the list */
+ *d = new_loc_list (descr, begin, end, section, 0);
+}
+
+/* Output the location list given to us */
static void
-output_loc_operands (loc)
- register dw_loc_descr_ref loc;
+output_loc_list (list_head)
+ dw_loc_list_ref list_head;
{
- register dw_val_ref val1 = &loc->dw_loc_oprnd1;
- register dw_val_ref val2 = &loc->dw_loc_oprnd2;
+ dw_loc_list_ref curr = list_head;
- switch (loc->dw_loc_opc)
+ 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)
{
- case DW_OP_addr:
- ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, val1->v.val_addr);
- fputc ('\n', asm_out_file);
- break;
- case DW_OP_const1u:
- case DW_OP_const1s:
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, val1->v.val_flag);
- fputc ('\n', asm_out_file);
- break;
- case DW_OP_const2u:
- case DW_OP_const2s:
- ASM_OUTPUT_DWARF_DATA2 (asm_out_file, val1->v.val_int);
- fputc ('\n', asm_out_file);
- break;
- case DW_OP_const4u:
- case DW_OP_const4s:
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, val1->v.val_int);
- fputc ('\n', asm_out_file);
- break;
- case DW_OP_const8u:
- case DW_OP_const8s:
- abort ();
- fputc ('\n', asm_out_file);
- break;
- case DW_OP_constu:
- output_uleb128 (val1->v.val_unsigned);
- fputc ('\n', asm_out_file);
- break;
- case DW_OP_consts:
- output_sleb128 (val1->v.val_int);
- fputc ('\n', asm_out_file);
- break;
- case DW_OP_pick:
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, val1->v.val_int);
- fputc ('\n', asm_out_file);
- break;
- case DW_OP_plus_uconst:
- output_uleb128 (val1->v.val_unsigned);
- fputc ('\n', asm_out_file);
- break;
- case DW_OP_skip:
- case DW_OP_bra:
- ASM_OUTPUT_DWARF_DATA2 (asm_out_file, val1->v.val_int);
- fputc ('\n', asm_out_file);
- break;
- case DW_OP_breg0:
- case DW_OP_breg1:
- case DW_OP_breg2:
- case DW_OP_breg3:
- case DW_OP_breg4:
- case DW_OP_breg5:
- case DW_OP_breg6:
- case DW_OP_breg7:
- case DW_OP_breg8:
- case DW_OP_breg9:
- case DW_OP_breg10:
- case DW_OP_breg11:
- case DW_OP_breg12:
- case DW_OP_breg13:
- case DW_OP_breg14:
- case DW_OP_breg15:
- case DW_OP_breg16:
- case DW_OP_breg17:
- case DW_OP_breg18:
- case DW_OP_breg19:
- case DW_OP_breg20:
- case DW_OP_breg21:
- case DW_OP_breg22:
- case DW_OP_breg23:
- case DW_OP_breg24:
- case DW_OP_breg25:
- case DW_OP_breg26:
- case DW_OP_breg27:
- case DW_OP_breg28:
- case DW_OP_breg29:
- case DW_OP_breg30:
- case DW_OP_breg31:
- output_sleb128 (val1->v.val_int);
- fputc ('\n', asm_out_file);
- break;
- case DW_OP_regx:
- output_uleb128 (val1->v.val_unsigned);
- fputc ('\n', asm_out_file);
- break;
- case DW_OP_fbreg:
- output_sleb128 (val1->v.val_int);
- fputc ('\n', asm_out_file);
- break;
- case DW_OP_bregx:
- output_uleb128 (val1->v.val_unsigned);
- fputc ('\n', asm_out_file);
- output_sleb128 (val2->v.val_int);
- fputc ('\n', asm_out_file);
- break;
- case DW_OP_piece:
- output_uleb128 (val1->v.val_unsigned);
- fputc ('\n', asm_out_file);
- break;
- case DW_OP_deref_size:
- case DW_OP_xderef_size:
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, val1->v.val_flag);
- fputc ('\n', asm_out_file);
- break;
- default:
- break;
+ /* 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");
}
-}
-/* Compute the offset of a sibling. */
+ for (curr = list_head; curr != NULL; curr=curr->dw_loc_next)
+ {
+ unsigned long size;
-static unsigned long
-sibling_offset (die)
- dw_die_ref die;
-{
- unsigned long offset;
+ 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);
+ size = size_of_locs (curr->expr);
+
+ /* Output the block length for this list of location operations. */
+ if (size > 0xffff)
+ abort ();
+ dw2_asm_output_data (2, size, "%s", "Location expression size");
- if (die->die_child_last == NULL)
- offset = die->die_offset + size_of_die (die);
- else
- offset = sibling_offset (die->die_child_last) + 1;
+ output_loc_sequence (curr->expr);
+ }
- return offset;
+ dw2_asm_output_data (DWARF_OFFSET_SIZE, 0,
+ "Location list terminator begin (%s)",
+ list_head->ll_symbol);
+ dw2_asm_output_data (DWARF_OFFSET_SIZE, 0,
+ "Location list terminator end (%s)",
+ list_head->ll_symbol);
}
/* Output the DIE and its attributes. Called recursively to generate
@@ -5289,208 +6257,176 @@ sibling_offset (die)
static void
output_die (die)
- register dw_die_ref die;
+ dw_die_ref die;
{
- register dw_attr_ref a;
- register dw_die_ref c;
- register unsigned long ref_offset;
- register unsigned long size;
- register dw_loc_descr_ref loc;
+ dw_attr_ref a;
+ dw_die_ref c;
+ unsigned long size;
- output_uleb128 (die->die_abbrev);
- if (flag_debug_asm)
- fprintf (asm_out_file, " (DIE (0x%lx) %s)",
- die->die_offset, dwarf_tag_name (die->die_tag));
+ /* If someone in another CU might refer to us, set up a symbol for
+ them to point to. */
+ if (die->die_symbol)
+ output_die_symbol (die);
- fputc ('\n', asm_out_file);
+ dw2_asm_output_data_uleb128 (die->die_abbrev, "(DIE (0x%lx) %s)",
+ die->die_offset, dwarf_tag_name (die->die_tag));
for (a = die->die_attr; a != NULL; a = a->dw_attr_next)
{
- switch (a->dw_attr_val.val_class)
+ const char *name = dwarf_attr_name (a->dw_attr);
+
+ switch (AT_class (a))
{
case dw_val_class_addr:
- ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file,
- a->dw_attr_val.v.val_addr);
+ dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE, AT_addr (a), "%s", name);
break;
- case dw_val_class_loc:
- size = size_of_locs (a->dw_attr_val.v.val_loc);
+ case dw_val_class_offset:
+ dw2_asm_output_data (DWARF_OFFSET_SIZE, a->dw_attr_val.v.val_offset,
+ "%s", name);
+ break;
- /* Output the block length for this list of location operations. */
- switch (constant_size (size))
- {
- case 1:
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, size);
- break;
- case 2:
- ASM_OUTPUT_DWARF_DATA2 (asm_out_file, size);
- break;
- default:
- abort ();
- }
+ case dw_val_class_range_list:
+ {
+ char *p = strchr (ranges_section_label, '\0');
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s %s",
- ASM_COMMENT_START, dwarf_attr_name (a->dw_attr));
+ sprintf (p, "+0x%lx", a->dw_attr_val.v.val_offset);
+ dw2_asm_output_offset (DWARF_OFFSET_SIZE, ranges_section_label,
+ "%s", name);
+ *p = '\0';
+ }
+ break;
- fputc ('\n', asm_out_file);
- for (loc = a->dw_attr_val.v.val_loc; loc != NULL;
- loc = loc->dw_loc_next)
- {
- /* Output the opcode. */
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, loc->dw_loc_opc);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s %s", ASM_COMMENT_START,
- dwarf_stack_op_name (loc->dw_loc_opc));
+ case dw_val_class_loc:
+ size = size_of_locs (AT_loc (a));
- fputc ('\n', asm_out_file);
+ /* Output the block length for this list of location operations. */
+ dw2_asm_output_data (constant_size (size), size, "%s", name);
- /* Output the operand(s) (if any). */
- output_loc_operands (loc);
- }
+ output_loc_sequence (AT_loc (a));
break;
case dw_val_class_const:
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, a->dw_attr_val.v.val_int);
+ /* ??? It would be slightly more efficient to use a scheme like is
+ used for unsigned constants below, but gdb 4.x does not sign
+ extend. Gdb 5.x does sign extend. */
+ dw2_asm_output_data_sleb128 (AT_int (a), "%s", name);
break;
case dw_val_class_unsigned_const:
- switch (constant_size (a->dw_attr_val.v.val_unsigned))
- {
- case 1:
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file,
- a->dw_attr_val.v.val_unsigned);
- break;
- case 2:
- ASM_OUTPUT_DWARF_DATA2 (asm_out_file,
- a->dw_attr_val.v.val_unsigned);
- break;
- case 4:
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
- a->dw_attr_val.v.val_unsigned);
- break;
- case 8:
- ASM_OUTPUT_DWARF_DATA8 (asm_out_file,
- a->dw_attr_val.v.val_long_long.hi,
- a->dw_attr_val.v.val_long_long.low);
- break;
- default:
- abort ();
- }
+ dw2_asm_output_data (constant_size (AT_unsigned (a)),
+ AT_unsigned (a), "%s", name);
break;
case dw_val_class_long_long:
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 8);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s %s",
- ASM_COMMENT_START, dwarf_attr_name (a->dw_attr));
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA8 (asm_out_file,
- a->dw_attr_val.v.val_long_long.hi,
- a->dw_attr_val.v.val_long_long.low);
-
- if (flag_debug_asm)
- fprintf (asm_out_file,
- "\t%s long long constant", ASM_COMMENT_START);
-
- fputc ('\n', asm_out_file);
+ {
+ unsigned HOST_WIDE_INT first, second;
+
+ dw2_asm_output_data (1,
+ 2 * HOST_BITS_PER_LONG / HOST_BITS_PER_CHAR,
+ "%s", name);
+
+ if (WORDS_BIG_ENDIAN)
+ {
+ first = a->dw_attr_val.v.val_long_long.hi;
+ second = a->dw_attr_val.v.val_long_long.low;
+ }
+ else
+ {
+ first = a->dw_attr_val.v.val_long_long.low;
+ second = a->dw_attr_val.v.val_long_long.hi;
+ }
+
+ dw2_asm_output_data (HOST_BITS_PER_LONG / HOST_BITS_PER_CHAR,
+ first, "long long constant");
+ dw2_asm_output_data (HOST_BITS_PER_LONG / HOST_BITS_PER_CHAR,
+ second, NULL);
+ }
break;
case dw_val_class_float:
{
- register unsigned int i;
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file,
- a->dw_attr_val.v.val_float.length * 4);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s %s",
- ASM_COMMENT_START, dwarf_attr_name (a->dw_attr));
-
- fputc ('\n', asm_out_file);
- for (i = 0; i < a->dw_attr_val.v.val_float.length; ++i)
- {
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
- a->dw_attr_val.v.val_float.array[i]);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s fp constant word %u",
- ASM_COMMENT_START, i);
+ unsigned int i;
- fputc ('\n', asm_out_file);
- }
- break;
+ 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);
+ break;
}
case dw_val_class_flag:
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, a->dw_attr_val.v.val_flag);
+ dw2_asm_output_data (1, AT_flag (a), "%s", name);
+ break;
+
+ case dw_val_class_loc_list:
+ {
+ char *sym = AT_loc_list (a)->ll_symbol;
+
+ if (sym == 0)
+ abort ();
+ dw2_asm_output_delta (DWARF_OFFSET_SIZE, sym,
+ loc_section_label, "%s", name);
+ }
break;
case dw_val_class_die_ref:
- if (a->dw_attr_val.v.val_die_ref != NULL)
- ref_offset = a->dw_attr_val.v.val_die_ref->die_offset;
- else if (a->dw_attr == DW_AT_sibling)
- ref_offset = sibling_offset(die);
- else
- abort ();
+ if (AT_ref_external (a))
+ {
+ char *sym = AT_ref (a)->die_symbol;
- ASM_OUTPUT_DWARF_DATA (asm_out_file, ref_offset);
+ if (sym == 0)
+ abort ();
+ dw2_asm_output_offset (DWARF2_ADDR_SIZE, sym, "%s", name);
+ }
+ else if (AT_ref (a)->die_offset == 0)
+ abort ();
+ else
+ dw2_asm_output_data (DWARF_OFFSET_SIZE, AT_ref (a)->die_offset,
+ "%s", name);
break;
case dw_val_class_fde_ref:
{
char l1[20];
- ASM_GENERATE_INTERNAL_LABEL
- (l1, FDE_AFTER_SIZE_LABEL, a->dw_attr_val.v.val_fde_index * 2);
- ASM_OUTPUT_DWARF_OFFSET (asm_out_file, l1);
- fprintf (asm_out_file, " - %d", DWARF_OFFSET_SIZE);
+
+ ASM_GENERATE_INTERNAL_LABEL (l1, FDE_LABEL,
+ a->dw_attr_val.v.val_fde_index * 2);
+ dw2_asm_output_offset (DWARF_OFFSET_SIZE, l1, "%s", name);
}
break;
case dw_val_class_lbl_id:
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, a->dw_attr_val.v.val_lbl_id);
+ dw2_asm_output_addr (DWARF2_ADDR_SIZE, AT_lbl (a), "%s", name);
break;
case dw_val_class_lbl_offset:
- ASM_OUTPUT_DWARF_OFFSET (asm_out_file, a->dw_attr_val.v.val_lbl_id);
+ dw2_asm_output_offset (DWARF_OFFSET_SIZE, AT_lbl (a), "%s", name);
break;
case dw_val_class_str:
- if (flag_debug_asm)
- ASM_OUTPUT_DWARF_STRING (asm_out_file, a->dw_attr_val.v.val_str);
+ if (AT_string_form (a) == DW_FORM_strp)
+ dw2_asm_output_offset (DWARF_OFFSET_SIZE,
+ a->dw_attr_val.v.val_str->label,
+ "%s: \"%s\"", name, AT_string (a));
else
- ASM_OUTPUT_ASCII (asm_out_file,
- a->dw_attr_val.v.val_str,
- (int) strlen (a->dw_attr_val.v.val_str) + 1);
+ dw2_asm_output_nstring (AT_string (a), -1, "%s", name);
break;
default:
abort ();
}
-
- if (a->dw_attr_val.val_class != dw_val_class_loc
- && a->dw_attr_val.val_class != dw_val_class_long_long
- && a->dw_attr_val.val_class != dw_val_class_float)
- {
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s %s",
- ASM_COMMENT_START, dwarf_attr_name (a->dw_attr));
-
- fputc ('\n', asm_out_file);
- }
}
for (c = die->die_child; c != NULL; c = c->die_sib)
output_die (c);
+ /* Add null byte to terminate sibling list. */
if (die->die_child != NULL)
- {
- /* Add null byte to terminate sibling list. */
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s end of children of DIE 0x%lx",
- ASM_COMMENT_START, die->die_offset);
-
- fputc ('\n', asm_out_file);
- }
+ dw2_asm_output_data (1, 0, "end of children of DIE 0x%lx",
+ die->die_offset);
}
/* Output the compilation unit that appears at the beginning of the
@@ -5499,35 +6435,62 @@ output_die (die)
static void
output_compilation_unit_header ()
{
- ASM_OUTPUT_DWARF_DATA (asm_out_file, next_die_offset - DWARF_OFFSET_SIZE);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s Length of Compilation Unit Info.",
- ASM_COMMENT_START);
+ dw2_asm_output_data (DWARF_OFFSET_SIZE, next_die_offset - DWARF_OFFSET_SIZE,
+ "Length of Compilation Unit Info");
+ dw2_asm_output_data (2, DWARF_VERSION, "DWARF version number");
+ dw2_asm_output_offset (DWARF_OFFSET_SIZE, abbrev_section_label,
+ "Offset Into Abbrev. Section");
+ dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Pointer Size (in bytes)");
+}
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA2 (asm_out_file, DWARF_VERSION);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DWARF version number", ASM_COMMENT_START);
+/* Output the compilation unit DIE and its children. */
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_OFFSET (asm_out_file, abbrev_section_label);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s Offset Into Abbrev. Section",
- ASM_COMMENT_START);
+static void
+output_comp_unit (die)
+ dw_die_ref die;
+{
+ const char *secname;
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, PTR_SIZE);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s Pointer Size (in bytes)", ASM_COMMENT_START);
+ /* Even if there are no children of this DIE, we must output the information
+ about the compilation unit. Otherwise, on an empty translation unit, we
+ will generate a present, but empty, .debug_info section. IRIX 6.5 `nm'
+ will then complain when examining the file. First mark all the DIEs in
+ this CU so we know which get local refs. */
+ mark_dies (die);
+
+ build_abbrev_table (die);
+
+ /* Initialize the beginning DIE offset - and calculate sizes/offsets. */
+ next_die_offset = DWARF_COMPILE_UNIT_HEADER_SIZE;
+ calc_die_sizes (die);
- fputc ('\n', asm_out_file);
+ if (die->die_symbol)
+ {
+ char *tmp = (char *) alloca (strlen (die->die_symbol) + 24);
+
+ sprintf (tmp, ".gnu.linkonce.wi.%s", die->die_symbol);
+ secname = tmp;
+ die->die_symbol = NULL;
+ }
+ else
+ secname = (const char *) DEBUG_INFO_SECTION;
+
+ /* Output debugging information. */
+ named_section_flags (secname, SECTION_DEBUG);
+ output_compilation_unit_header ();
+ output_die (die);
+
+ /* Leave the marks on the main CU, so we can check them in
+ output_pubnames. */
+ if (die->die_symbol)
+ unmark_dies (die);
}
/* The DWARF2 pubname for a nested thingy looks like "A::f". The output
of decl_printable_name for C++ looks like "A::f(int)". Let's drop the
argument list, and maybe the scope. */
-static char *
+static const char *
dwarf2_name (decl, scope)
tree decl;
int scope;
@@ -5550,13 +6513,14 @@ add_pubname (decl, die)
if (pubname_table_in_use == pubname_table_allocated)
{
pubname_table_allocated += PUBNAME_TABLE_INCREMENT;
- pubname_table = (pubname_ref) xrealloc
- (pubname_table, pubname_table_allocated * sizeof (pubname_entry));
+ pubname_table
+ = (pubname_ref) xrealloc (pubname_table,
+ (pubname_table_allocated
+ * sizeof (pubname_entry)));
}
p = &pubname_table[pubname_table_in_use++];
p->die = die;
-
p->name = xstrdup (dwarf2_name (decl, 1));
}
@@ -5567,59 +6531,32 @@ add_pubname (decl, die)
static void
output_pubnames ()
{
- register unsigned i;
- register unsigned long pubnames_length = size_of_pubnames ();
-
- ASM_OUTPUT_DWARF_DATA (asm_out_file, pubnames_length);
+ unsigned i;
+ unsigned long pubnames_length = size_of_pubnames ();
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s Length of Public Names Info.",
- ASM_COMMENT_START);
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA2 (asm_out_file, DWARF_VERSION);
-
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DWARF Version", ASM_COMMENT_START);
+ dw2_asm_output_data (DWARF_OFFSET_SIZE, pubnames_length,
+ "Length of Public Names Info");
+ dw2_asm_output_data (2, DWARF_VERSION, "DWARF Version");
+ dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_info_section_label,
+ "Offset of Compilation Unit Info");
+ dw2_asm_output_data (DWARF_OFFSET_SIZE, next_die_offset,
+ "Compilation Unit Length");
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_OFFSET (asm_out_file, debug_info_section_label);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s Offset of Compilation Unit Info.",
- ASM_COMMENT_START);
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA (asm_out_file, next_die_offset);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s Compilation Unit Length", ASM_COMMENT_START);
-
- fputc ('\n', asm_out_file);
- for (i = 0; i < pubname_table_in_use; ++i)
+ for (i = 0; i < pubname_table_in_use; i++)
{
- register pubname_ref pub = &pubname_table[i];
+ pubname_ref pub = &pubname_table[i];
- ASM_OUTPUT_DWARF_DATA (asm_out_file, pub->die->die_offset);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DIE offset", ASM_COMMENT_START);
+ /* We shouldn't see pubnames for DIEs outside of the main CU. */
+ if (pub->die->die_mark == 0)
+ abort ();
- fputc ('\n', asm_out_file);
+ dw2_asm_output_data (DWARF_OFFSET_SIZE, pub->die->die_offset,
+ "DIE offset");
- if (flag_debug_asm)
- {
- ASM_OUTPUT_DWARF_STRING (asm_out_file, pub->name);
- fprintf (asm_out_file, "%s external name", ASM_COMMENT_START);
- }
- else
- {
- ASM_OUTPUT_ASCII (asm_out_file, pub->name,
- (int) strlen (pub->name) + 1);
- }
-
- fputc ('\n', asm_out_file);
+ dw2_asm_output_nstring (pub->name, -1, "external name");
}
- ASM_OUTPUT_DWARF_DATA (asm_out_file, 0);
- fputc ('\n', asm_out_file);
+ dw2_asm_output_data (DWARF_OFFSET_SIZE, 0, NULL);
}
/* Add a new entry to .debug_aranges if appropriate. */
@@ -5635,9 +6572,8 @@ add_arange (decl, die)
if (arange_table_in_use == arange_table_allocated)
{
arange_table_allocated += ARANGE_TABLE_INCREMENT;
- arange_table
- = (arange_ref) xrealloc (arange_table,
- arange_table_allocated * sizeof (dw_die_ref));
+ arange_table = (dw_die_ref *)
+ xrealloc (arange_table, arange_table_allocated * sizeof (dw_die_ref));
}
arange_table[arange_table_in_use++] = die;
@@ -5650,163 +6586,463 @@ add_arange (decl, die)
static void
output_aranges ()
{
- register unsigned i;
- register unsigned long aranges_length = size_of_aranges ();
+ unsigned i;
+ unsigned long aranges_length = size_of_aranges ();
- ASM_OUTPUT_DWARF_DATA (asm_out_file, aranges_length);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s Length of Address Ranges Info.",
- ASM_COMMENT_START);
+ dw2_asm_output_data (DWARF_OFFSET_SIZE, aranges_length,
+ "Length of Address Ranges Info");
+ dw2_asm_output_data (2, DWARF_VERSION, "DWARF Version");
+ dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_info_section_label,
+ "Offset of Compilation Unit Info");
+ dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Size of Address");
+ dw2_asm_output_data (1, 0, "Size of Segment Descriptor");
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA2 (asm_out_file, DWARF_VERSION);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DWARF Version", ASM_COMMENT_START);
+ /* We need to align to twice the pointer size here. */
+ if (DWARF_ARANGES_PAD_SIZE)
+ {
+ /* Pad using a 2 byte words so that padding is correct for any
+ pointer size. */
+ dw2_asm_output_data (2, 0, "Pad to %d byte boundary",
+ 2 * DWARF2_ADDR_SIZE);
+ for (i = 2; i < (unsigned) DWARF_ARANGES_PAD_SIZE; i += 2)
+ dw2_asm_output_data (2, 0, NULL);
+ }
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_OFFSET (asm_out_file, debug_info_section_label);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s Offset of Compilation Unit Info.",
- ASM_COMMENT_START);
+ dw2_asm_output_addr (DWARF2_ADDR_SIZE, text_section_label, "Address");
+ dw2_asm_output_delta (DWARF2_ADDR_SIZE, text_end_label,
+ text_section_label, "Length");
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, PTR_SIZE);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s Size of Address", ASM_COMMENT_START);
+ for (i = 0; i < arange_table_in_use; i++)
+ {
+ dw_die_ref die = arange_table[i];
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s Size of Segment Descriptor",
- ASM_COMMENT_START);
+ /* We shouldn't see aranges for DIEs outside of the main CU. */
+ if (die->die_mark == 0)
+ abort ();
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 4);
- if (PTR_SIZE == 8)
- fprintf (asm_out_file, ",0,0");
+ if (die->die_tag == DW_TAG_subprogram)
+ {
+ dw2_asm_output_addr (DWARF2_ADDR_SIZE, get_AT_low_pc (die),
+ "Address");
+ dw2_asm_output_delta (DWARF2_ADDR_SIZE, get_AT_hi_pc (die),
+ get_AT_low_pc (die), "Length");
+ }
+ else
+ {
+ /* A static variable; extract the symbol from DW_AT_location.
+ Note that this code isn't currently hit, as we only emit
+ aranges for functions (jason 9/23/99). */
+ dw_attr_ref a = get_AT (die, DW_AT_location);
+ dw_loc_descr_ref loc;
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s Pad to %d byte boundary",
- ASM_COMMENT_START, 2 * PTR_SIZE);
+ if (! a || AT_class (a) != dw_val_class_loc)
+ abort ();
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, text_section_label);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s Address", ASM_COMMENT_START);
+ loc = AT_loc (a);
+ if (loc->dw_loc_opc != DW_OP_addr)
+ abort ();
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_ADDR_DELTA (asm_out_file, text_end_label,
- text_section_label);
- if (flag_debug_asm)
- fprintf (asm_out_file, "%s Length", ASM_COMMENT_START);
+ dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE,
+ loc->dw_loc_oprnd1.v.val_addr, "Address");
+ dw2_asm_output_data (DWARF2_ADDR_SIZE,
+ get_AT_unsigned (die, DW_AT_byte_size),
+ "Length");
+ }
+ }
+
+ /* Output the terminator words. */
+ dw2_asm_output_data (DWARF2_ADDR_SIZE, 0, NULL);
+ dw2_asm_output_data (DWARF2_ADDR_SIZE, 0, NULL);
+}
- fputc ('\n', asm_out_file);
- for (i = 0; i < arange_table_in_use; ++i)
+/* Add a new entry to .debug_ranges. Return the offset at which it
+ was placed. */
+
+static unsigned int
+add_ranges (block)
+ tree block;
+{
+ unsigned int in_use = ranges_table_in_use;
+
+ if (in_use == ranges_table_allocated)
+ {
+ ranges_table_allocated += RANGES_TABLE_INCREMENT;
+ ranges_table = (dw_ranges_ref)
+ xrealloc (ranges_table, (ranges_table_allocated
+ * sizeof (struct dw_ranges_struct)));
+ }
+
+ ranges_table[in_use].block_num = (block ? BLOCK_NUMBER (block) : 0);
+ ranges_table_in_use = in_use + 1;
+
+ return in_use * 2 * DWARF2_ADDR_SIZE;
+}
+
+static void
+output_ranges ()
+{
+ unsigned i;
+ static const char *const start_fmt = "Offset 0x%x";
+ const char *fmt = start_fmt;
+
+ for (i = 0; i < ranges_table_in_use; i++)
{
- dw_die_ref a = arange_table[i];
+ int block_num = ranges_table[i].block_num;
+
+ if (block_num)
+ {
+ char blabel[MAX_ARTIFICIAL_LABEL_BYTES];
+ char elabel[MAX_ARTIFICIAL_LABEL_BYTES];
- if (a->die_tag == DW_TAG_subprogram)
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, get_AT_low_pc (a));
+ ASM_GENERATE_INTERNAL_LABEL (blabel, BLOCK_BEGIN_LABEL, block_num);
+ ASM_GENERATE_INTERNAL_LABEL (elabel, BLOCK_END_LABEL, block_num);
+
+ /* If all code is in the text section, then the compilation
+ unit base address defaults to DW_AT_low_pc, which is the
+ base of the text section. */
+ if (separate_line_info_table_in_use == 0)
+ {
+ dw2_asm_output_delta (DWARF2_ADDR_SIZE, blabel,
+ text_section_label,
+ fmt, i * 2 * DWARF2_ADDR_SIZE);
+ dw2_asm_output_delta (DWARF2_ADDR_SIZE, elabel,
+ text_section_label, NULL);
+ }
+
+ /* Otherwise, we add a DW_AT_entry_pc attribute to force the
+ compilation unit base address to zero, which allows us to
+ use absolute addresses, and not worry about whether the
+ target supports cross-section arithmetic. */
+ else
+ {
+ dw2_asm_output_addr (DWARF2_ADDR_SIZE, blabel,
+ fmt, i * 2 * DWARF2_ADDR_SIZE);
+ dw2_asm_output_addr (DWARF2_ADDR_SIZE, elabel, NULL);
+ }
+
+ fmt = NULL;
+ }
else
{
- char *name = get_AT_string (a, DW_AT_MIPS_linkage_name);
- if (! name)
- name = get_AT_string (a, DW_AT_name);
+ dw2_asm_output_data (DWARF2_ADDR_SIZE, 0, NULL);
+ dw2_asm_output_data (DWARF2_ADDR_SIZE, 0, NULL);
+ fmt = start_fmt;
+ }
+ }
+}
+
+/* Data structure containing information about input files. */
+struct file_info
+{
+ char *path; /* Complete file name. */
+ char *fname; /* File name part. */
+ int length; /* Length of entire string. */
+ int file_idx; /* Index in input file table. */
+ int dir_idx; /* Index in directory table. */
+};
+
+/* Data structure containing information about directories with source
+ files. */
+struct dir_info
+{
+ char *path; /* Path including directory name. */
+ int length; /* Path length. */
+ int prefix; /* Index of directory entry which is a prefix. */
+ int count; /* Number of files in this directory. */
+ int dir_idx; /* Index of directory used as base. */
+ int used; /* Used in the end? */
+};
+
+/* Callback function for file_info comparison. We sort by looking at
+ the directories in the path. */
+
+static int
+file_info_cmp (p1, p2)
+ const void *p1;
+ const void *p2;
+{
+ const struct file_info *s1 = p1;
+ const struct file_info *s2 = p2;
+ unsigned char *cp1;
+ unsigned char *cp2;
+
+ /* Take care of file names without directories. We need to make sure that
+ we return consistent values to qsort since some will get confused if
+ we return the same value when identical operands are passed in opposite
+ orders. So if neither has a directory, return 0 and otherwise return
+ 1 or -1 depending on which one has the directory. */
+ if ((s1->path == s1->fname || s2->path == s2->fname))
+ return (s2->path == s2->fname) - (s1->path == s1->fname);
+
+ cp1 = (unsigned char *) s1->path;
+ cp2 = (unsigned char *) s2->path;
+
+ while (1)
+ {
+ ++cp1;
+ ++cp2;
+ /* Reached the end of the first path? If so, handle like above. */
+ if ((cp1 == (unsigned char *) s1->fname)
+ || (cp2 == (unsigned char *) s2->fname))
+ return ((cp2 == (unsigned char *) s2->fname)
+ - (cp1 == (unsigned char *) s1->fname));
+
+ /* Character of current path component the same? */
+ else if (*cp1 != *cp2)
+ return *cp1 - *cp2;
+ }
+}
+
+/* Output the directory table and the file name table. We try to minimize
+ the total amount of memory needed. A heuristic is used to avoid large
+ slowdowns with many input files. */
+
+static void
+output_file_names ()
+{
+ struct file_info *files;
+ struct dir_info *dirs;
+ int *saved;
+ int *savehere;
+ int *backmap;
+ int ndirs;
+ int idx_offset;
+ int i;
+ int idx;
+
+ /* Allocate the various arrays we need. */
+ files = (struct file_info *) alloca (file_table.in_use
+ * sizeof (struct file_info));
+ dirs = (struct dir_info *) alloca (file_table.in_use
+ * sizeof (struct dir_info));
+
+ /* Sort the file names. */
+ for (i = 1; i < (int) file_table.in_use; i++)
+ {
+ char *f;
+
+ /* Skip all leading "./". */
+ f = file_table.table[i];
+ while (f[0] == '.' && f[1] == '/')
+ f += 2;
+
+ /* Create a new array entry. */
+ files[i].path = f;
+ files[i].length = strlen (f);
+ files[i].file_idx = i;
+
+ /* Search for the file name part. */
+ f = strrchr (f, '/');
+ files[i].fname = f == NULL ? files[i].path : f + 1;
+ }
+
+ qsort (files + 1, file_table.in_use - 1, sizeof (files[0]), file_info_cmp);
+
+ /* Find all the different directories used. */
+ dirs[0].path = files[1].path;
+ dirs[0].length = files[1].fname - files[1].path;
+ dirs[0].prefix = -1;
+ dirs[0].count = 1;
+ dirs[0].dir_idx = 0;
+ dirs[0].used = 0;
+ files[1].dir_idx = 0;
+ ndirs = 1;
+
+ for (i = 2; i < (int) file_table.in_use; i++)
+ if (files[i].fname - files[i].path == dirs[ndirs - 1].length
+ && memcmp (dirs[ndirs - 1].path, files[i].path,
+ dirs[ndirs - 1].length) == 0)
+ {
+ /* Same directory as last entry. */
+ files[i].dir_idx = ndirs - 1;
+ ++dirs[ndirs - 1].count;
+ }
+ else
+ {
+ int j;
+
+ /* This is a new directory. */
+ dirs[ndirs].path = files[i].path;
+ dirs[ndirs].length = files[i].fname - files[i].path;
+ dirs[ndirs].count = 1;
+ dirs[ndirs].dir_idx = ndirs;
+ dirs[ndirs].used = 0;
+ files[i].dir_idx = ndirs;
+
+ /* Search for a prefix. */
+ dirs[ndirs].prefix = -1;
+ for (j = 0; j < ndirs; j++)
+ if (dirs[j].length < dirs[ndirs].length
+ && dirs[j].length > 1
+ && (dirs[ndirs].prefix == -1
+ || dirs[j].length > dirs[dirs[ndirs].prefix].length)
+ && memcmp (dirs[j].path, dirs[ndirs].path, dirs[j].length) == 0)
+ dirs[ndirs].prefix = j;
+
+ ++ndirs;
+ }
+
+ /* Now to the actual work. We have to find a subset of the directories which
+ allow expressing the file name using references to the directory table
+ with the least amount of characters. We do not do an exhaustive search
+ where we would have to check out every combination of every single
+ possible prefix. Instead we use a heuristic which provides nearly optimal
+ results in most cases and never is much off. */
+ saved = (int *) alloca (ndirs * sizeof (int));
+ savehere = (int *) alloca (ndirs * sizeof (int));
+
+ memset (saved, '\0', ndirs * sizeof (saved[0]));
+ for (i = 0; i < ndirs; i++)
+ {
+ int j;
+ int total;
+
+ /* We can always save some space for the current directory. But this
+ does not mean it will be enough to justify adding the directory. */
+ savehere[i] = dirs[i].length;
+ total = (savehere[i] - saved[i]) * dirs[i].count;
+
+ for (j = i + 1; j < ndirs; j++)
+ {
+ savehere[j] = 0;
+ if (saved[j] < dirs[i].length)
+ {
+ /* Determine whether the dirs[i] path is a prefix of the
+ dirs[j] path. */
+ int k;
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, name);
+ k = dirs[j].prefix;
+ while (k != -1 && k != i)
+ k = dirs[k].prefix;
+
+ if (k == i)
+ {
+ /* Yes it is. We can possibly safe some memory but
+ writing the filenames in dirs[j] relative to
+ dirs[i]. */
+ savehere[j] = dirs[i].length;
+ total += (savehere[j] - saved[j]) * dirs[j].count;
+ }
+ }
}
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s Address", ASM_COMMENT_START);
+ /* Check whether we can safe enough to justify adding the dirs[i]
+ directory. */
+ if (total > dirs[i].length + 1)
+ {
+ /* It's worthwhile adding. */
+ for (j = i; j < ndirs; j++)
+ if (savehere[j] > 0)
+ {
+ /* Remember how much we saved for this directory so far. */
+ saved[j] = savehere[j];
- fputc ('\n', asm_out_file);
- if (a->die_tag == DW_TAG_subprogram)
- ASM_OUTPUT_DWARF_ADDR_DELTA (asm_out_file, get_AT_hi_pc (a),
- get_AT_low_pc (a));
- else
- ASM_OUTPUT_DWARF_ADDR_DATA (asm_out_file,
- get_AT_unsigned (a, DW_AT_byte_size));
+ /* Remember the prefix directory. */
+ dirs[j].dir_idx = i;
+ }
+ }
+ }
- if (flag_debug_asm)
- fprintf (asm_out_file, "%s Length", ASM_COMMENT_START);
+ /* We have to emit them in the order they appear in the file_table array
+ since the index is used in the debug info generation. To do this
+ efficiently we generate a back-mapping of the indices first. */
+ backmap = (int *) alloca (file_table.in_use * sizeof (int));
+ for (i = 1; i < (int) file_table.in_use; i++)
+ {
+ backmap[files[i].file_idx] = i;
- fputc ('\n', asm_out_file);
+ /* Mark this directory as used. */
+ dirs[dirs[files[i].dir_idx].dir_idx].used = 1;
}
- /* Output the terminator words. */
- ASM_OUTPUT_DWARF_ADDR_DATA (asm_out_file, 0);
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_ADDR_DATA (asm_out_file, 0);
- fputc ('\n', asm_out_file);
+ /* That was it. We are ready to emit the information. First emit the
+ directory name table. We have to make sure the first actually emitted
+ directory name has index one; zero is reserved for the current working
+ directory. Make sure we do not confuse these indices with the one for the
+ constructed table (even though most of the time they are identical). */
+ idx = 1;
+ idx_offset = dirs[0].length > 0 ? 1 : 0;
+ for (i = 1 - idx_offset; i < ndirs; i++)
+ if (dirs[i].used != 0)
+ {
+ dirs[i].used = idx++;
+ dw2_asm_output_nstring (dirs[i].path, dirs[i].length - 1,
+ "Directory Entry: 0x%x", dirs[i].used);
+ }
+
+ dw2_asm_output_data (1, 0, "End directory table");
+
+ /* Correct the index for the current working directory entry if it
+ exists. */
+ if (idx_offset == 0)
+ dirs[0].used = 0;
+
+ /* Now write all the file names. */
+ for (i = 1; i < (int) file_table.in_use; i++)
+ {
+ int file_idx = backmap[i];
+ int dir_idx = dirs[files[file_idx].dir_idx].dir_idx;
+
+ dw2_asm_output_nstring (files[file_idx].path + dirs[dir_idx].length, -1,
+ "File Entry: 0x%x", i);
+
+ /* Include directory index. */
+ dw2_asm_output_data_uleb128 (dirs[dir_idx].used, NULL);
+
+ /* Modification time. */
+ dw2_asm_output_data_uleb128 (0, NULL);
+
+ /* File length in bytes. */
+ dw2_asm_output_data_uleb128 (0, NULL);
+ }
+
+ dw2_asm_output_data (1, 0, "End file name table");
}
-/* Output the source line number correspondence information. This
- information goes into the .debug_line section.
- If the format of this data changes, then the function size_of_line_info
- must also be adjusted the same way. */
+/* Output the source line number correspondence information. This
+ information goes into the .debug_line section. */
static void
output_line_info ()
{
+ char l1[20], l2[20], p1[20], p2[20];
char line_label[MAX_ARTIFICIAL_LABEL_BYTES];
char prev_line_label[MAX_ARTIFICIAL_LABEL_BYTES];
- register unsigned opc;
- register unsigned n_op_args;
- register unsigned long ft_index;
- register unsigned long lt_index;
- register unsigned long current_line;
- register long line_offset;
- register long line_delta;
- register unsigned long current_file;
- register unsigned long function;
-
- ASM_OUTPUT_DWARF_DATA (asm_out_file, size_of_line_info ());
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s Length of Source Line Info.",
- ASM_COMMENT_START);
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA2 (asm_out_file, DWARF_VERSION);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DWARF Version", ASM_COMMENT_START);
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA (asm_out_file, size_of_line_prolog ());
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s Prolog Length", ASM_COMMENT_START);
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DWARF_LINE_MIN_INSTR_LENGTH);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s Minimum Instruction Length",
- ASM_COMMENT_START);
+ unsigned opc;
+ unsigned n_op_args;
+ unsigned long lt_index;
+ unsigned long current_line;
+ long line_offset;
+ long line_delta;
+ unsigned long current_file;
+ unsigned long function;
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DWARF_LINE_DEFAULT_IS_STMT_START);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s Default is_stmt_start flag",
- ASM_COMMENT_START);
+ ASM_GENERATE_INTERNAL_LABEL (l1, LINE_NUMBER_BEGIN_LABEL, 0);
+ ASM_GENERATE_INTERNAL_LABEL (l2, LINE_NUMBER_END_LABEL, 0);
+ ASM_GENERATE_INTERNAL_LABEL (p1, LN_PROLOG_AS_LABEL, 0);
+ ASM_GENERATE_INTERNAL_LABEL (p2, LN_PROLOG_END_LABEL, 0);
- fputc ('\n', asm_out_file);
- fprintf (asm_out_file, "\t%s\t%d", ASM_BYTE_OP, DWARF_LINE_BASE);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s Line Base Value (Special Opcodes)",
- ASM_COMMENT_START);
+ dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1,
+ "Length of Source Line Info");
+ ASM_OUTPUT_LABEL (asm_out_file, l1);
- fputc ('\n', asm_out_file);
- fprintf (asm_out_file, "\t%s\t%u", ASM_BYTE_OP, DWARF_LINE_RANGE);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s Line Range Value (Special Opcodes)",
- ASM_COMMENT_START);
+ dw2_asm_output_data (2, DWARF_VERSION, "DWARF Version");
+ dw2_asm_output_delta (DWARF_OFFSET_SIZE, p2, p1, "Prolog Length");
+ ASM_OUTPUT_LABEL (asm_out_file, p1);
- fputc ('\n', asm_out_file);
- fprintf (asm_out_file, "\t%s\t%u", ASM_BYTE_OP, DWARF_LINE_OPCODE_BASE);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s Special Opcode Base", ASM_COMMENT_START);
+ dw2_asm_output_data (1, DWARF_LINE_MIN_INSTR_LENGTH,
+ "Minimum Instruction Length");
+ dw2_asm_output_data (1, DWARF_LINE_DEFAULT_IS_STMT_START,
+ "Default is_stmt_start flag");
+ dw2_asm_output_data (1, DWARF_LINE_BASE,
+ "Line Base Value (Special Opcodes)");
+ dw2_asm_output_data (1, DWARF_LINE_RANGE,
+ "Line Range Value (Special Opcodes)");
+ dw2_asm_output_data (1, DWARF_LINE_OPCODE_BASE,
+ "Special Opcode Base");
- fputc ('\n', asm_out_file);
- for (opc = 1; opc < DWARF_LINE_OPCODE_BASE; ++opc)
+ for (opc = 1; opc < DWARF_LINE_OPCODE_BASE; opc++)
{
switch (opc)
{
@@ -5821,55 +7057,14 @@ output_line_info ()
n_op_args = 0;
break;
}
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, n_op_args);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s opcode: 0x%x has %d args",
- ASM_COMMENT_START, opc, n_op_args);
- fputc ('\n', asm_out_file);
- }
-
- if (flag_debug_asm)
- fprintf (asm_out_file, "%s Include Directory Table\n", ASM_COMMENT_START);
-
- /* Include directory table is empty, at present */
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
- fputc ('\n', asm_out_file);
- if (flag_debug_asm)
- fprintf (asm_out_file, "%s File Name Table\n", ASM_COMMENT_START);
-
- for (ft_index = 1; ft_index < file_table_in_use; ++ft_index)
- {
- if (flag_debug_asm)
- {
- ASM_OUTPUT_DWARF_STRING (asm_out_file, file_table[ft_index]);
- fprintf (asm_out_file, "%s File Entry: 0x%lx",
- ASM_COMMENT_START, ft_index);
- }
- else
- {
- ASM_OUTPUT_ASCII (asm_out_file,
- file_table[ft_index],
- (int) strlen (file_table[ft_index]) + 1);
- }
-
- fputc ('\n', asm_out_file);
- /* Include directory index */
- output_uleb128 (0);
- fputc ('\n', asm_out_file);
-
- /* Modification time */
- output_uleb128 (0);
- fputc ('\n', asm_out_file);
-
- /* File length in bytes */
- output_uleb128 (0);
- fputc ('\n', asm_out_file);
+ dw2_asm_output_data (1, n_op_args, "opcode: 0x%x has %d args",
+ opc, n_op_args);
}
- /* Terminate the file name table */
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
- fputc ('\n', asm_out_file);
+ /* Write out the information about the files we use. */
+ output_file_names ();
+ ASM_OUTPUT_LABEL (asm_out_file, p2);
/* We used to set the address register to the first location in the text
section here, but that didn't accomplish anything since we already
@@ -5882,7 +7077,12 @@ output_line_info ()
strcpy (prev_line_label, text_section_label);
for (lt_index = 1; lt_index < line_info_table_in_use; ++lt_index)
{
- register dw_line_info_ref line_info = &line_info_table[lt_index];
+ dw_line_info_ref line_info = &line_info_table[lt_index];
+
+#if 0
+ /* Disable this optimization for now; GDB wants to see two line notes
+ at the beginning of a function so it can find the end of the
+ prologue. */
/* Don't emit anything for redundant notes. Just updating the
address doesn't accomplish anything, because we already assume
@@ -5890,45 +7090,35 @@ output_line_info ()
if (line_info->dw_line_num == current_line
&& line_info->dw_file_num == current_file)
continue;
+#endif
+
+ /* Emit debug info for the address of the current line.
+
+ Unfortunately, we have little choice here currently, and must always
+ use the most general form. GCC does not know the address delta
+ itself, so we can't use DW_LNS_advance_pc. Many ports do have length
+ attributes which will give an upper bound on the address range. We
+ could perhaps use length attributes to determine when it is safe to
+ use DW_LNS_fixed_advance_pc. */
- /* Emit debug info for the address of the current line, choosing
- the encoding that uses the least amount of space. */
- /* ??? Unfortunately, we have little choice here currently, and must
- always use the most general form. Gcc does not know the address
- delta itself, so we can't use DW_LNS_advance_pc. There are no known
- dwarf2 aware assemblers at this time, so we can't use any special
- pseudo ops that would allow the assembler to optimally encode this for
- us. Many ports do have length attributes which will give an upper
- bound on the address range. We could perhaps use length attributes
- to determine when it is safe to use DW_LNS_fixed_advance_pc. */
ASM_GENERATE_INTERNAL_LABEL (line_label, LINE_CODE_LABEL, lt_index);
if (0)
{
/* This can handle deltas up to 0xffff. This takes 3 bytes. */
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_fixed_advance_pc);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DW_LNS_fixed_advance_pc",
- ASM_COMMENT_START);
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, line_label, prev_line_label);
- fputc ('\n', asm_out_file);
+ dw2_asm_output_data (1, DW_LNS_fixed_advance_pc,
+ "DW_LNS_fixed_advance_pc");
+ dw2_asm_output_delta (2, line_label, prev_line_label, NULL);
}
else
{
- /* This can handle any delta. This takes 4+PTR_SIZE bytes. */
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DW_LNE_set_address",
- ASM_COMMENT_START);
- fputc ('\n', asm_out_file);
- output_uleb128 (1 + PTR_SIZE);
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address);
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, line_label);
- fputc ('\n', asm_out_file);
+ /* This can handle any delta. This takes
+ 4+DWARF2_ADDR_SIZE bytes. */
+ dw2_asm_output_data (1, 0, "DW_LNE_set_address");
+ dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE, NULL);
+ dw2_asm_output_data (1, DW_LNE_set_address, NULL);
+ dw2_asm_output_addr (DWARF2_ADDR_SIZE, line_label, NULL);
}
+
strcpy (prev_line_label, line_label);
/* Emit debug info for the source file of the current line, if
@@ -5936,16 +7126,9 @@ output_line_info ()
if (line_info->dw_file_num != current_file)
{
current_file = line_info->dw_file_num;
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_set_file);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DW_LNS_set_file", ASM_COMMENT_START);
-
- fputc ('\n', asm_out_file);
- output_uleb128 (current_file);
- if (flag_debug_asm)
- fprintf (asm_out_file, " (\"%s\")", file_table[current_file]);
-
- fputc ('\n', asm_out_file);
+ dw2_asm_output_data (1, DW_LNS_set_file, "DW_LNS_set_file");
+ dw2_asm_output_data_uleb128 (current_file, "(\"%s\")",
+ file_table.table[current_file]);
}
/* Emit debug info for the current line number, choosing the encoding
@@ -5956,96 +7139,60 @@ output_line_info ()
line_delta = line_offset - DWARF_LINE_BASE;
current_line = line_info->dw_line_num;
if (line_delta >= 0 && line_delta < (DWARF_LINE_RANGE - 1))
- {
- /* This can handle deltas from -10 to 234, using the current
- definitions of DWARF_LINE_BASE and DWARF_LINE_RANGE. This
- takes 1 byte. */
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file,
- DWARF_LINE_OPCODE_BASE + line_delta);
- if (flag_debug_asm)
- fprintf (asm_out_file,
- "\t%s line %ld", ASM_COMMENT_START, current_line);
-
- fputc ('\n', asm_out_file);
- }
+ /* This can handle deltas from -10 to 234, using the current
+ definitions of DWARF_LINE_BASE and DWARF_LINE_RANGE. This
+ takes 1 byte. */
+ dw2_asm_output_data (1, DWARF_LINE_OPCODE_BASE + line_delta,
+ "line %lu", current_line);
else
{
/* This can handle any delta. This takes at least 4 bytes,
depending on the value being encoded. */
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_advance_line);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s advance to line %ld",
- ASM_COMMENT_START, current_line);
-
- fputc ('\n', asm_out_file);
- output_sleb128 (line_offset);
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_copy);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DW_LNS_copy", ASM_COMMENT_START);
- fputc ('\n', asm_out_file);
+ dw2_asm_output_data (1, DW_LNS_advance_line,
+ "advance to line %lu", current_line);
+ dw2_asm_output_data_sleb128 (line_offset, NULL);
+ dw2_asm_output_data (1, DW_LNS_copy, "DW_LNS_copy");
}
}
else
- {
- /* We still need to start a new row, so output a copy insn. */
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_copy);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DW_LNS_copy", ASM_COMMENT_START);
- fputc ('\n', asm_out_file);
- }
+ /* We still need to start a new row, so output a copy insn. */
+ dw2_asm_output_data (1, DW_LNS_copy, "DW_LNS_copy");
}
/* Emit debug info for the address of the end of the function. */
if (0)
{
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_fixed_advance_pc);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DW_LNS_fixed_advance_pc",
- ASM_COMMENT_START);
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, text_end_label, prev_line_label);
- fputc ('\n', asm_out_file);
+ dw2_asm_output_data (1, DW_LNS_fixed_advance_pc,
+ "DW_LNS_fixed_advance_pc");
+ dw2_asm_output_delta (2, text_end_label, prev_line_label, NULL);
}
else
{
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DW_LNE_set_address", ASM_COMMENT_START);
- fputc ('\n', asm_out_file);
- output_uleb128 (1 + PTR_SIZE);
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address);
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, text_end_label);
- fputc ('\n', asm_out_file);
+ dw2_asm_output_data (1, 0, "DW_LNE_set_address");
+ dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE, NULL);
+ dw2_asm_output_data (1, DW_LNE_set_address, NULL);
+ dw2_asm_output_addr (DWARF2_ADDR_SIZE, text_end_label, NULL);
}
- /* Output the marker for the end of the line number info. */
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DW_LNE_end_sequence", ASM_COMMENT_START);
-
- fputc ('\n', asm_out_file);
- output_uleb128 (1);
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_end_sequence);
- fputc ('\n', asm_out_file);
+ dw2_asm_output_data (1, 0, "DW_LNE_end_sequence");
+ dw2_asm_output_data_uleb128 (1, NULL);
+ dw2_asm_output_data (1, DW_LNE_end_sequence, NULL);
function = 0;
current_file = 1;
current_line = 1;
- for (lt_index = 0; lt_index < separate_line_info_table_in_use; )
+ for (lt_index = 0; lt_index < separate_line_info_table_in_use;)
{
- register dw_separate_line_info_ref line_info
+ dw_separate_line_info_ref line_info
= &separate_line_info_table[lt_index];
+#if 0
/* Don't emit anything for redundant notes. */
if (line_info->dw_line_num == current_line
&& line_info->dw_file_num == current_file
&& line_info->function == function)
goto cont;
+#endif
/* Emit debug info for the address of the current line. If this is
a new function, or the first line of a function, then we need
@@ -6057,49 +7204,29 @@ output_line_info ()
function = line_info->function;
/* Set the address register to the first line in the function */
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DW_LNE_set_address",
- ASM_COMMENT_START);
-
- fputc ('\n', asm_out_file);
- output_uleb128 (1 + PTR_SIZE);
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address);
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, line_label);
- fputc ('\n', asm_out_file);
+ dw2_asm_output_data (1, 0, "DW_LNE_set_address");
+ dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE, NULL);
+ dw2_asm_output_data (1, DW_LNE_set_address, NULL);
+ dw2_asm_output_addr (DWARF2_ADDR_SIZE, line_label, NULL);
}
else
{
/* ??? See the DW_LNS_advance_pc comment above. */
if (0)
{
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_fixed_advance_pc);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DW_LNS_fixed_advance_pc",
- ASM_COMMENT_START);
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, line_label,
- prev_line_label);
- fputc ('\n', asm_out_file);
+ dw2_asm_output_data (1, DW_LNS_fixed_advance_pc,
+ "DW_LNS_fixed_advance_pc");
+ dw2_asm_output_delta (2, line_label, prev_line_label, NULL);
}
else
{
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DW_LNE_set_address",
- ASM_COMMENT_START);
- fputc ('\n', asm_out_file);
- output_uleb128 (1 + PTR_SIZE);
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address);
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, line_label);
- fputc ('\n', asm_out_file);
+ dw2_asm_output_data (1, 0, "DW_LNE_set_address");
+ dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE, NULL);
+ dw2_asm_output_data (1, DW_LNE_set_address, NULL);
+ dw2_asm_output_addr (DWARF2_ADDR_SIZE, line_label, NULL);
}
}
+
strcpy (prev_line_label, line_label);
/* Emit debug info for the source file of the current line, if
@@ -6107,16 +7234,9 @@ output_line_info ()
if (line_info->dw_file_num != current_file)
{
current_file = line_info->dw_file_num;
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_set_file);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DW_LNS_set_file", ASM_COMMENT_START);
-
- fputc ('\n', asm_out_file);
- output_uleb128 (current_file);
- if (flag_debug_asm)
- fprintf (asm_out_file, " (\"%s\")", file_table[current_file]);
-
- fputc ('\n', asm_out_file);
+ dw2_asm_output_data (1, DW_LNS_set_file, "DW_LNS_set_file");
+ dw2_asm_output_data_uleb128 (current_file, "(\"%s\")",
+ file_table.table[current_file]);
}
/* Emit debug info for the current line number, choosing the encoding
@@ -6127,42 +7247,24 @@ output_line_info ()
line_delta = line_offset - DWARF_LINE_BASE;
current_line = line_info->dw_line_num;
if (line_delta >= 0 && line_delta < (DWARF_LINE_RANGE - 1))
- {
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file,
- DWARF_LINE_OPCODE_BASE + line_delta);
- if (flag_debug_asm)
- fprintf (asm_out_file,
- "\t%s line %ld", ASM_COMMENT_START, current_line);
-
- fputc ('\n', asm_out_file);
- }
+ dw2_asm_output_data (1, DWARF_LINE_OPCODE_BASE + line_delta,
+ "line %lu", current_line);
else
{
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_advance_line);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s advance to line %ld",
- ASM_COMMENT_START, current_line);
-
- fputc ('\n', asm_out_file);
- output_sleb128 (line_offset);
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_copy);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DW_LNS_copy", ASM_COMMENT_START);
- fputc ('\n', asm_out_file);
+ dw2_asm_output_data (1, DW_LNS_advance_line,
+ "advance to line %lu", current_line);
+ dw2_asm_output_data_sleb128 (line_offset, NULL);
+ dw2_asm_output_data (1, DW_LNS_copy, "DW_LNS_copy");
}
}
else
- {
- /* We still need to start a new row, so output a copy insn. */
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_copy);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DW_LNS_copy", ASM_COMMENT_START);
- fputc ('\n', asm_out_file);
- }
+ dw2_asm_output_data (1, DW_LNS_copy, "DW_LNS_copy");
+#if 0
cont:
- ++lt_index;
+#endif
+
+ lt_index++;
/* If we're done with a function, end its sequence. */
if (lt_index == separate_line_info_table_in_use
@@ -6175,76 +7277,29 @@ output_line_info ()
ASM_GENERATE_INTERNAL_LABEL (line_label, FUNC_END_LABEL, function);
if (0)
{
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_fixed_advance_pc);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DW_LNS_fixed_advance_pc",
- ASM_COMMENT_START);
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, line_label,
- prev_line_label);
- fputc ('\n', asm_out_file);
+ dw2_asm_output_data (1, DW_LNS_fixed_advance_pc,
+ "DW_LNS_fixed_advance_pc");
+ dw2_asm_output_delta (2, line_label, prev_line_label, NULL);
}
else
{
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DW_LNE_set_address",
- ASM_COMMENT_START);
- fputc ('\n', asm_out_file);
- output_uleb128 (1 + PTR_SIZE);
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address);
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, line_label);
- fputc ('\n', asm_out_file);
+ dw2_asm_output_data (1, 0, "DW_LNE_set_address");
+ dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE, NULL);
+ dw2_asm_output_data (1, DW_LNE_set_address, NULL);
+ dw2_asm_output_addr (DWARF2_ADDR_SIZE, line_label, NULL);
}
/* Output the marker for the end of this sequence. */
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
- if (flag_debug_asm)
- fprintf (asm_out_file, "\t%s DW_LNE_end_sequence",
- ASM_COMMENT_START);
-
- fputc ('\n', asm_out_file);
- output_uleb128 (1);
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_end_sequence);
- fputc ('\n', asm_out_file);
- }
- }
-}
-
-/* Given a pointer to a BLOCK node return non-zero if (and only if) the node
- in question represents the outermost pair of curly braces (i.e. the "body
- block") of a function or method.
-
- For any BLOCK node representing a "body block" of a function or method, the
- BLOCK_SUPERCONTEXT of the node will point to another BLOCK node which
- represents the outermost (function) scope for the function or method (i.e.
- the one which includes the formal parameters). The BLOCK_SUPERCONTEXT of
- *that* node in turn will point to the relevant FUNCTION_DECL node. */
-
-static inline int
-is_body_block (stmt)
- register tree stmt;
-{
- if (TREE_CODE (stmt) == BLOCK)
- {
- register tree parent = BLOCK_SUPERCONTEXT (stmt);
-
- if (TREE_CODE (parent) == BLOCK)
- {
- register tree grandparent = BLOCK_SUPERCONTEXT (parent);
-
- if (TREE_CODE (grandparent) == FUNCTION_DECL)
- return 1;
+ dw2_asm_output_data (1, 0, "DW_LNE_end_sequence");
+ dw2_asm_output_data_uleb128 (1, NULL);
+ dw2_asm_output_data (1, DW_LNE_end_sequence, NULL);
}
}
- return 0;
+ /* Output the marker for the end of the line number info. */
+ ASM_OUTPUT_LABEL (asm_out_file, l2);
}
-
+
/* Given a pointer to a tree node for some base type, return a pointer to
a DIE that describes the given type.
@@ -6253,27 +7308,32 @@ is_body_block (stmt)
static dw_die_ref
base_type_die (type)
- register tree type;
+ tree type;
{
- register dw_die_ref base_type_result;
- register char *type_name;
- register enum dwarf_type encoding;
- register tree name = TYPE_NAME (type);
+ dw_die_ref base_type_result;
+ const char *type_name;
+ enum dwarf_type encoding;
+ tree name = TYPE_NAME (type);
- if (TREE_CODE (type) == ERROR_MARK
- || TREE_CODE (type) == VOID_TYPE)
+ if (TREE_CODE (type) == ERROR_MARK || TREE_CODE (type) == VOID_TYPE)
return 0;
- if (TREE_CODE (name) == TYPE_DECL)
- name = DECL_NAME (name);
- type_name = IDENTIFIER_POINTER (name);
+ if (name)
+ {
+ if (TREE_CODE (name) == TYPE_DECL)
+ name = DECL_NAME (name);
+
+ type_name = IDENTIFIER_POINTER (name);
+ }
+ else
+ type_name = "__unknown__";
switch (TREE_CODE (type))
{
case INTEGER_TYPE:
/* Carefully distinguish the C character types, without messing
up if the language is not C. Note that we check only for the names
- that contain spaces; other names might occur by coincidence in other
+ that contain spaces; other names might occur by coincidence in other
languages. */
if (! (TYPE_PRECISION (type) == CHAR_TYPE_SIZE
&& (type == char_type_node
@@ -6286,7 +7346,7 @@ base_type_die (type)
encoding = DW_ATE_signed;
break;
}
- /* else fall through */
+ /* else fall through. */
case CHAR_TYPE:
/* GNU Pascal/Ada CHAR type. Not used in C. */
@@ -6300,8 +7360,13 @@ base_type_die (type)
encoding = DW_ATE_float;
break;
+ /* Dwarf2 doesn't know anything about complex ints, so use
+ a user defined type for it. */
case COMPLEX_TYPE:
- encoding = DW_ATE_complex_float;
+ if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
+ encoding = DW_ATE_complex_float;
+ else
+ encoding = DW_ATE_lo_user;
break;
case BOOLEAN_TYPE:
@@ -6310,10 +7375,14 @@ base_type_die (type)
break;
default:
- abort (); /* No other TREE_CODEs are Dwarf fundamental types. */
+ /* No other TREE_CODEs are Dwarf fundamental types. */
+ abort ();
}
- base_type_result = new_die (DW_TAG_base_type, comp_unit_die);
+ base_type_result = new_die (DW_TAG_base_type, comp_unit_die, type);
+ if (demangle_name_func)
+ type_name = (*demangle_name_func) (type_name);
+
add_AT_string (base_type_result, DW_AT_name, type_name);
add_AT_unsigned (base_type_result, DW_AT_byte_size,
int_size_in_bytes (type));
@@ -6333,7 +7402,7 @@ base_type_die (type)
static tree
root_type (type)
- register tree type;
+ tree type;
{
if (TREE_CODE (type) == ERROR_MARK)
return error_mark_node;
@@ -6357,7 +7426,7 @@ root_type (type)
static inline int
is_base_type (type)
- register tree type;
+ tree type;
{
switch (TREE_CODE (type))
{
@@ -6383,6 +7452,7 @@ is_base_type (type)
case FILE_TYPE:
case OFFSET_TYPE:
case LANG_TYPE:
+ case VECTOR_TYPE:
return 0;
default:
@@ -6397,62 +7467,78 @@ is_base_type (type)
static dw_die_ref
modified_type_die (type, is_const_type, is_volatile_type, context_die)
- register tree type;
- register int is_const_type;
- register int is_volatile_type;
- register dw_die_ref context_die;
+ tree type;
+ int is_const_type;
+ int is_volatile_type;
+ dw_die_ref context_die;
{
- register enum tree_code code = TREE_CODE (type);
- register dw_die_ref mod_type_die = NULL;
- register dw_die_ref sub_die = NULL;
- register tree item_type = NULL;
+ enum tree_code code = TREE_CODE (type);
+ dw_die_ref mod_type_die = NULL;
+ dw_die_ref sub_die = NULL;
+ tree item_type = NULL;
if (code != ERROR_MARK)
{
- type = build_type_variant (type, is_const_type, is_volatile_type);
+ tree qualified_type;
- mod_type_die = lookup_type_die (type);
- if (mod_type_die)
- return mod_type_die;
+ /* See if we already have the appropriately qualified variant of
+ this type. */
+ qualified_type
+ = get_qualified_type (type,
+ ((is_const_type ? TYPE_QUAL_CONST : 0)
+ | (is_volatile_type
+ ? TYPE_QUAL_VOLATILE : 0)));
+
+ /* If we do, then we can just use its DIE, if it exists. */
+ if (qualified_type)
+ {
+ mod_type_die = lookup_type_die (qualified_type);
+ if (mod_type_die)
+ return mod_type_die;
+ }
- /* Handle C typedef types. */
- if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
- && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
+ /* Handle C typedef types. */
+ if (qualified_type && TYPE_NAME (qualified_type)
+ && TREE_CODE (TYPE_NAME (qualified_type)) == TYPE_DECL
+ && DECL_ORIGINAL_TYPE (TYPE_NAME (qualified_type)))
{
- tree dtype = TREE_TYPE (TYPE_NAME (type));
- if (type == dtype)
+ tree type_name = TYPE_NAME (qualified_type);
+ tree dtype = TREE_TYPE (type_name);
+
+ if (qualified_type == dtype)
{
/* For a named type, use the typedef. */
- gen_type_die (type, context_die);
- mod_type_die = lookup_type_die (type);
+ gen_type_die (qualified_type, context_die);
+ mod_type_die = lookup_type_die (qualified_type);
}
-
else if (is_const_type < TYPE_READONLY (dtype)
|| is_volatile_type < TYPE_VOLATILE (dtype))
/* cv-unqualified version of named type. Just use the unnamed
type to which it refers. */
mod_type_die
- = modified_type_die (DECL_ORIGINAL_TYPE (TYPE_NAME (type)),
+ = modified_type_die (DECL_ORIGINAL_TYPE (type_name),
is_const_type, is_volatile_type,
context_die);
+
/* Else cv-qualified version of named type; fall through. */
}
if (mod_type_die)
- /* OK */;
+ /* OK. */
+ ;
else if (is_const_type)
{
- mod_type_die = new_die (DW_TAG_const_type, comp_unit_die);
+ mod_type_die = new_die (DW_TAG_const_type, comp_unit_die, type);
sub_die = modified_type_die (type, 0, is_volatile_type, context_die);
}
else if (is_volatile_type)
{
- mod_type_die = new_die (DW_TAG_volatile_type, comp_unit_die);
+ mod_type_die = new_die (DW_TAG_volatile_type, comp_unit_die, type);
sub_die = modified_type_die (type, 0, 0, context_die);
}
else if (code == POINTER_TYPE)
{
- mod_type_die = new_die (DW_TAG_pointer_type, comp_unit_die);
+ mod_type_die = new_die (DW_TAG_pointer_type, comp_unit_die, type);
add_AT_unsigned (mod_type_die, DW_AT_byte_size, PTR_SIZE);
#if 0
add_AT_unsigned (mod_type_die, DW_AT_address_class, 0);
@@ -6461,11 +7547,11 @@ modified_type_die (type, is_const_type, is_volatile_type, context_die)
}
else if (code == REFERENCE_TYPE)
{
- mod_type_die = new_die (DW_TAG_reference_type, comp_unit_die);
+ mod_type_die = new_die (DW_TAG_reference_type, comp_unit_die, type);
add_AT_unsigned (mod_type_die, DW_AT_byte_size, PTR_SIZE);
#if 0
add_AT_unsigned (mod_type_die, DW_AT_address_class, 0);
-#endif
+#endif
item_type = TREE_TYPE (type);
}
else if (is_base_type (type))
@@ -6484,6 +7570,10 @@ modified_type_die (type, is_const_type, is_volatile_type, context_die)
if (mod_type_die == NULL)
abort ();
}
+
+ /* We want to equate the qualified type to the die below. */
+ if (qualified_type)
+ type = qualified_type;
}
equate_type_number_to_die (type, mod_type_die);
@@ -6504,24 +7594,43 @@ modified_type_die (type, is_const_type, is_volatile_type, context_die)
}
/* Given a pointer to an arbitrary ..._TYPE tree node, return true if it is
- an enumerated type. */
+ an enumerated type. */
static inline int
type_is_enum (type)
- register tree type;
+ tree type;
{
return TREE_CODE (type) == ENUMERAL_TYPE;
}
-/* Return a location descriptor that designates a machine register. */
+/* Return the register number described by a given RTL node. */
+
+static unsigned int
+reg_number (rtl)
+ rtx rtl;
+{
+ unsigned regno = REGNO (rtl);
+
+ if (regno >= FIRST_PSEUDO_REGISTER)
+ abort ();
+
+ return DBX_REGISTER_NUMBER (regno);
+}
+
+/* Return a location descriptor that designates a machine register or
+ zero if there is no such. */
static dw_loc_descr_ref
reg_loc_descriptor (rtl)
- register rtx rtl;
+ rtx rtl;
{
- register dw_loc_descr_ref loc_result = NULL;
- register unsigned reg = reg_number (rtl);
+ dw_loc_descr_ref loc_result = NULL;
+ unsigned reg;
+ if (REGNO (rtl) >= FIRST_PSEUDO_REGISTER)
+ return 0;
+
+ reg = reg_number (rtl);
if (reg <= 31)
loc_result = new_loc_descr (DW_OP_reg0 + reg, 0, 0);
else
@@ -6530,6 +7639,46 @@ reg_loc_descriptor (rtl)
return loc_result;
}
+/* Return a location descriptor that designates a constant. */
+
+static dw_loc_descr_ref
+int_loc_descriptor (i)
+ HOST_WIDE_INT i;
+{
+ enum dwarf_location_atom op;
+
+ /* Pick the smallest representation of a constant, rather than just
+ defaulting to the LEB encoding. */
+ if (i >= 0)
+ {
+ if (i <= 31)
+ op = DW_OP_lit0 + i;
+ else if (i <= 0xff)
+ op = DW_OP_const1u;
+ else if (i <= 0xffff)
+ op = DW_OP_const2u;
+ else if (HOST_BITS_PER_WIDE_INT == 32
+ || i <= 0xffffffff)
+ op = DW_OP_const4u;
+ else
+ op = DW_OP_constu;
+ }
+ else
+ {
+ if (i >= -0x80)
+ op = DW_OP_const1s;
+ else if (i >= -0x8000)
+ op = DW_OP_const2s;
+ else if (HOST_BITS_PER_WIDE_INT == 32
+ || i >= -0x80000000)
+ op = DW_OP_const4s;
+ else
+ op = DW_OP_consts;
+ }
+
+ return new_loc_descr (op, i, 0);
+}
+
/* Return a location descriptor that designates a base+offset location. */
static dw_loc_descr_ref
@@ -6537,13 +7686,13 @@ based_loc_descr (reg, offset)
unsigned reg;
long int offset;
{
- register dw_loc_descr_ref loc_result;
+ dw_loc_descr_ref loc_result;
/* For the "frame base", we use the frame pointer or stack pointer
registers, since the RTL for local variables is relative to one of
them. */
- register unsigned fp_reg = DBX_REGISTER_NUMBER (frame_pointer_needed
- ? HARD_FRAME_POINTER_REGNUM
- : STACK_POINTER_REGNUM);
+ unsigned fp_reg = DBX_REGISTER_NUMBER (frame_pointer_needed
+ ? HARD_FRAME_POINTER_REGNUM
+ : STACK_POINTER_REGNUM);
if (reg == fp_reg)
loc_result = new_loc_descr (DW_OP_fbreg, offset, 0);
@@ -6559,11 +7708,12 @@ based_loc_descr (reg, offset)
static inline int
is_based_loc (rtl)
- register rtx rtl;
+ rtx rtl;
{
- return (GET_CODE (rtl) == PLUS
- && ((GET_CODE (XEXP (rtl, 0)) == REG
- && GET_CODE (XEXP (rtl, 1)) == CONST_INT)));
+ return (GET_CODE (rtl) == PLUS
+ && ((GET_CODE (XEXP (rtl, 0)) == REG
+ && REGNO (XEXP (rtl, 0)) < FIRST_PSEUDO_REGISTER
+ && GET_CODE (XEXP (rtl, 1)) == CONST_INT)));
}
/* The following routine converts the RTL for a variable or parameter
@@ -6574,34 +7724,53 @@ is_based_loc (rtl)
When creating memory location descriptors, we are effectively transforming
the RTL for a memory-resident object into its Dwarf postfix expression
equivalent. This routine recursively descends an RTL tree, turning
- it into Dwarf postfix code as it goes. */
+ it into Dwarf postfix code as it goes.
+
+ MODE is the mode of the memory reference, needed to handle some
+ autoincrement addressing modes.
+
+ Return 0 if we can't represent the location. */
static dw_loc_descr_ref
-mem_loc_descriptor (rtl)
- register rtx rtl;
+mem_loc_descriptor (rtl, mode)
+ rtx rtl;
+ enum machine_mode mode;
{
dw_loc_descr_ref mem_loc_result = NULL;
- /* Note that for a dynamically sized array, the location we will generate a
+
+ /* 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. */
+#ifdef ASM_SIMPLIFY_DWARF_ADDR
+ rtl = ASM_SIMPLIFY_DWARF_ADDR (rtl);
+#endif
+
switch (GET_CODE (rtl))
{
+ case POST_INC:
+ case POST_DEC:
+ case POST_MODIFY:
+ /* POST_INC and POST_DEC can be handled just like a SUBREG. So we
+ just fall into the SUBREG code. */
+
+ /* ... fall through ... */
+
case SUBREG:
/* The case of a subreg may arise when we have a local (register)
variable or a formal (register) parameter which doesn't quite fill
up an entire register. For now, just assume that it is
legitimate to make the Dwarf info refer to the whole register which
contains the given subreg. */
- rtl = XEXP (rtl, 0);
+ rtl = SUBREG_REG (rtl);
- /* ... fall through ... */
+ /* ... fall through ... */
case REG:
/* Whenever a register number forms a part of the description of the
method for calculating the (dynamic) address of a memory resident
- object, DWARF rules require the register number be referred to as
+ object, DWARF rules require the register number be referred to as
a "base register". This distinction is not based in any way upon
what category of register the hardware believes the given register
belongs to. This is strictly DWARF terminology we're dealing with
@@ -6612,45 +7781,109 @@ mem_loc_descriptor (rtl)
the object in question was allocated to a register (rather than in
memory) so DWARF consumers need to be aware of the subtle
distinction between OP_REG and OP_BASEREG. */
- mem_loc_result = based_loc_descr (reg_number (rtl), 0);
+ if (REGNO (rtl) < FIRST_PSEUDO_REGISTER)
+ mem_loc_result = based_loc_descr (reg_number (rtl), 0);
break;
case MEM:
- mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0));
- add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_deref, 0, 0));
+ mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl));
+ if (mem_loc_result != 0)
+ add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_deref, 0, 0));
break;
+ case LABEL_REF:
+ /* Some ports can transform a symbol ref into a label ref, because
+ the symbol ref is too far away and has to be dumped into a constant
+ pool. */
case CONST:
case SYMBOL_REF:
+ /* Alternatively, the symbol in the constant pool might be referenced
+ by a different symbol. */
+ if (GET_CODE (rtl) == SYMBOL_REF && CONSTANT_POOL_ADDRESS_P (rtl))
+ {
+ rtx tmp = get_pool_constant (rtl);
+
+ if (GET_CODE (tmp) == SYMBOL_REF)
+ rtl = tmp;
+ }
+
mem_loc_result = new_loc_descr (DW_OP_addr, 0, 0);
mem_loc_result->dw_loc_oprnd1.val_class = dw_val_class_addr;
- mem_loc_result->dw_loc_oprnd1.v.val_addr = addr_to_string (rtl);
+ mem_loc_result->dw_loc_oprnd1.v.val_addr = rtl;
+ VARRAY_PUSH_RTX (used_rtx_varray, rtl);
break;
+ case PRE_MODIFY:
+ /* Extract the PLUS expression nested inside and fall into
+ PLUS code below. */
+ rtl = XEXP (rtl, 1);
+ goto plus;
+
+ case PRE_INC:
+ case PRE_DEC:
+ /* Turn these into a PLUS expression and fall into the PLUS code
+ below. */
+ rtl = gen_rtx_PLUS (word_mode, XEXP (rtl, 0),
+ GEN_INT (GET_CODE (rtl) == PRE_INC
+ ? GET_MODE_UNIT_SIZE (mode)
+ : -GET_MODE_UNIT_SIZE (mode)));
+
+ /* ... fall through ... */
+
case PLUS:
+ plus:
if (is_based_loc (rtl))
mem_loc_result = based_loc_descr (reg_number (XEXP (rtl, 0)),
INTVAL (XEXP (rtl, 1)));
else
{
- add_loc_descr (&mem_loc_result, mem_loc_descriptor (XEXP (rtl, 0)));
- add_loc_descr (&mem_loc_result, mem_loc_descriptor (XEXP (rtl, 1)));
- add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_plus, 0, 0));
+ mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), mode);
+ if (mem_loc_result == 0)
+ break;
+
+ if (GET_CODE (XEXP (rtl, 1)) == CONST_INT
+ && INTVAL (XEXP (rtl, 1)) >= 0)
+ add_loc_descr (&mem_loc_result,
+ new_loc_descr (DW_OP_plus_uconst,
+ INTVAL (XEXP (rtl, 1)), 0));
+ else
+ {
+ add_loc_descr (&mem_loc_result,
+ mem_loc_descriptor (XEXP (rtl, 1), mode));
+ add_loc_descr (&mem_loc_result,
+ new_loc_descr (DW_OP_plus, 0, 0));
+ }
}
break;
case MULT:
- /* If a pseudo-reg is optimized away, it is possible for it to
- be replaced with a MEM containing a multiply. */
- add_loc_descr (&mem_loc_result, mem_loc_descriptor (XEXP (rtl, 0)));
- add_loc_descr (&mem_loc_result, mem_loc_descriptor (XEXP (rtl, 1)));
- add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_mul, 0, 0));
- break;
+ {
+ /* 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);
+
+ 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));
+ break;
+ }
case CONST_INT:
- mem_loc_result = new_loc_descr (DW_OP_constu, INTVAL (rtl), 0);
+ 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 ();
}
@@ -6663,21 +7896,24 @@ mem_loc_descriptor (rtl)
static dw_loc_descr_ref
concat_loc_descriptor (x0, x1)
- register rtx x0, x1;
+ rtx x0, 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);
+
+ if (x0_ref == 0 || x1_ref == 0)
+ return 0;
- if (!is_pseudo_reg (x0)
- && (GET_CODE (x0) != MEM || !is_pseudo_reg (XEXP (x0, 0))))
- add_loc_descr (&cc_loc_result, loc_descriptor (x0));
+ cc_loc_result = x0_ref;
add_loc_descr (&cc_loc_result,
- new_loc_descr (DW_OP_piece, GET_MODE_SIZE (GET_MODE (x0)), 0));
+ new_loc_descr (DW_OP_piece,
+ GET_MODE_SIZE (GET_MODE (x0)), 0));
- if (!is_pseudo_reg (x1)
- && (GET_CODE (x1) != MEM || !is_pseudo_reg (XEXP (x1, 0))))
- add_loc_descr (&cc_loc_result, loc_descriptor (x1));
+ add_loc_descr (&cc_loc_result, x1_ref);
add_loc_descr (&cc_loc_result,
- new_loc_descr (DW_OP_piece, GET_MODE_SIZE (GET_MODE (x1)), 0));
+ new_loc_descr (DW_OP_piece,
+ GET_MODE_SIZE (GET_MODE (x1)), 0));
return cc_loc_result;
}
@@ -6686,13 +7922,16 @@ concat_loc_descriptor (x0, x1)
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
memory location we provide a Dwarf postfix expression describing how to
- generate the (dynamic) address of the object onto the address stack. */
+ generate the (dynamic) address of the object onto the address stack.
+
+ If we don't know how to describe it, return 0. */
static dw_loc_descr_ref
loc_descriptor (rtl)
- register rtx rtl;
+ rtx rtl;
{
dw_loc_descr_ref loc_result = NULL;
+
switch (GET_CODE (rtl))
{
case SUBREG:
@@ -6701,16 +7940,16 @@ loc_descriptor (rtl)
up an entire register. For now, just assume that it is
legitimate to make the Dwarf info refer to the whole register which
contains the given subreg. */
- rtl = XEXP (rtl, 0);
+ rtl = SUBREG_REG (rtl);
- /* ... fall through ... */
+ /* ... fall through ... */
case REG:
loc_result = reg_loc_descriptor (rtl);
break;
case MEM:
- loc_result = mem_loc_descriptor (XEXP (rtl, 0));
+ loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl));
break;
case CONCAT:
@@ -6724,13 +7963,348 @@ loc_descriptor (rtl)
return loc_result;
}
-/* Given an unsigned value, round it up to the lowest multiple of `boundary'
+/* Similar, but generate the descriptor from trees instead of rtl. This comes
+ up particularly with variable length arrays. If ADDRESSP is nonzero, we are
+ looking for an address. Otherwise, we return a value. If we can't make a
+ descriptor, return 0. */
+
+static dw_loc_descr_ref
+loc_descriptor_from_tree (loc, addressp)
+ tree loc;
+ int addressp;
+{
+ dw_loc_descr_ref ret, ret1;
+ int indirect_p = 0;
+ int unsignedp = TREE_UNSIGNED (TREE_TYPE (loc));
+ enum dwarf_location_atom op;
+
+ /* ??? Most of the time we do not take proper care for sign/zero
+ extending the values properly. Hopefully this won't be a real
+ problem... */
+
+ switch (TREE_CODE (loc))
+ {
+ 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
+ only user of this is Ada, which encodes the needed information using
+ the names of types. */
+ return 0;
+
+ case CALL_EXPR:
+ return 0;
+
+ case ADDR_EXPR:
+ /* We can support this only if we can look through conversions and
+ find an INDIRECT_EXPR. */
+ for (loc = TREE_OPERAND (loc, 0);
+ TREE_CODE (loc) == CONVERT_EXPR || TREE_CODE (loc) == NOP_EXPR
+ || TREE_CODE (loc) == NON_LVALUE_EXPR
+ || TREE_CODE (loc) == VIEW_CONVERT_EXPR
+ || TREE_CODE (loc) == SAVE_EXPR;
+ loc = TREE_OPERAND (loc, 0))
+ ;
+
+ return (TREE_CODE (loc) == INDIRECT_REF
+ ? loc_descriptor_from_tree (TREE_OPERAND (loc, 0), addressp)
+ : 0);
+
+ case VAR_DECL:
+ case PARM_DECL:
+ {
+ rtx rtl = rtl_for_decl_location (loc);
+
+ if (rtl == NULL_RTX)
+ return 0;
+ else if (CONSTANT_P (rtl))
+ {
+ ret = new_loc_descr (DW_OP_addr, 0, 0);
+ ret->dw_loc_oprnd1.val_class = dw_val_class_addr;
+ ret->dw_loc_oprnd1.v.val_addr = rtl;
+ indirect_p = 1;
+ }
+ else
+ {
+ enum machine_mode mode = GET_MODE (rtl);
+
+ if (GET_CODE (rtl) == MEM)
+ {
+ indirect_p = 1;
+ rtl = XEXP (rtl, 0);
+ }
+
+ ret = mem_loc_descriptor (rtl, mode);
+ }
+ }
+ break;
+
+ case INDIRECT_REF:
+ ret = loc_descriptor_from_tree (TREE_OPERAND (loc, 0), 0);
+ indirect_p = 1;
+ break;
+
+ case COMPOUND_EXPR:
+ return loc_descriptor_from_tree (TREE_OPERAND (loc, 1), addressp);
+
+ case NOP_EXPR:
+ case CONVERT_EXPR:
+ case NON_LVALUE_EXPR:
+ case VIEW_CONVERT_EXPR:
+ case SAVE_EXPR:
+ return loc_descriptor_from_tree (TREE_OPERAND (loc, 0), addressp);
+
+ case COMPONENT_REF:
+ case BIT_FIELD_REF:
+ case ARRAY_REF:
+ case ARRAY_RANGE_REF:
+ {
+ tree obj, offset;
+ HOST_WIDE_INT bitsize, bitpos, bytepos;
+ enum machine_mode mode;
+ int volatilep;
+
+ obj = get_inner_reference (loc, &bitsize, &bitpos, &offset, &mode,
+ &unsignedp, &volatilep);
+
+ if (obj == loc)
+ return 0;
+
+ ret = loc_descriptor_from_tree (obj, 1);
+ if (ret == 0
+ || bitpos % BITS_PER_UNIT != 0 || bitsize % BITS_PER_UNIT != 0)
+ return 0;
+
+ if (offset != NULL_TREE)
+ {
+ /* Variable offset. */
+ add_loc_descr (&ret, loc_descriptor_from_tree (offset, 0));
+ add_loc_descr (&ret, new_loc_descr (DW_OP_plus, 0, 0));
+ }
+
+ if (!addressp)
+ indirect_p = 1;
+
+ bytepos = bitpos / BITS_PER_UNIT;
+ if (bytepos > 0)
+ add_loc_descr (&ret, new_loc_descr (DW_OP_plus_uconst, bytepos, 0));
+ else if (bytepos < 0)
+ {
+ add_loc_descr (&ret, int_loc_descriptor (bytepos));
+ add_loc_descr (&ret, new_loc_descr (DW_OP_plus, 0, 0));
+ }
+ break;
+ }
+
+ case INTEGER_CST:
+ if (host_integerp (loc, 0))
+ ret = int_loc_descriptor (tree_low_cst (loc, 0));
+ else
+ return 0;
+ break;
+
+ case TRUTH_AND_EXPR:
+ case TRUTH_ANDIF_EXPR:
+ case BIT_AND_EXPR:
+ op = DW_OP_and;
+ goto do_binop;
+
+ case TRUTH_XOR_EXPR:
+ case BIT_XOR_EXPR:
+ op = DW_OP_xor;
+ goto do_binop;
+
+ case TRUTH_OR_EXPR:
+ case TRUTH_ORIF_EXPR:
+ case BIT_IOR_EXPR:
+ op = DW_OP_or;
+ goto do_binop;
+
+ case TRUNC_DIV_EXPR:
+ op = DW_OP_div;
+ goto do_binop;
+
+ case MINUS_EXPR:
+ op = DW_OP_minus;
+ goto do_binop;
+
+ case TRUNC_MOD_EXPR:
+ op = DW_OP_mod;
+ goto do_binop;
+
+ case MULT_EXPR:
+ op = DW_OP_mul;
+ goto do_binop;
+
+ case LSHIFT_EXPR:
+ op = DW_OP_shl;
+ goto do_binop;
+
+ case RSHIFT_EXPR:
+ op = (unsignedp ? DW_OP_shr : DW_OP_shra);
+ goto do_binop;
+
+ case PLUS_EXPR:
+ if (TREE_CODE (TREE_OPERAND (loc, 1)) == INTEGER_CST
+ && host_integerp (TREE_OPERAND (loc, 1), 0))
+ {
+ ret = loc_descriptor_from_tree (TREE_OPERAND (loc, 0), 0);
+ if (ret == 0)
+ return 0;
+
+ add_loc_descr (&ret,
+ new_loc_descr (DW_OP_plus_uconst,
+ tree_low_cst (TREE_OPERAND (loc, 1),
+ 0),
+ 0));
+ break;
+ }
+
+ op = DW_OP_plus;
+ goto do_binop;
+
+ case LE_EXPR:
+ if (TREE_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))))
+ return 0;
+
+ op = DW_OP_ge;
+ goto do_binop;
+
+ case LT_EXPR:
+ if (TREE_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))))
+ return 0;
+
+ op = DW_OP_gt;
+ goto do_binop;
+
+ case EQ_EXPR:
+ op = DW_OP_eq;
+ goto do_binop;
+
+ case NE_EXPR:
+ op = DW_OP_ne;
+ goto do_binop;
+
+ do_binop:
+ ret = loc_descriptor_from_tree (TREE_OPERAND (loc, 0), 0);
+ ret1 = loc_descriptor_from_tree (TREE_OPERAND (loc, 1), 0);
+ if (ret == 0 || ret1 == 0)
+ return 0;
+
+ add_loc_descr (&ret, ret1);
+ add_loc_descr (&ret, new_loc_descr (op, 0, 0));
+ break;
+
+ case TRUTH_NOT_EXPR:
+ case BIT_NOT_EXPR:
+ op = DW_OP_not;
+ goto do_unop;
+
+ case ABS_EXPR:
+ op = DW_OP_abs;
+ goto do_unop;
+
+ case NEGATE_EXPR:
+ op = DW_OP_neg;
+ goto do_unop;
+
+ do_unop:
+ ret = loc_descriptor_from_tree (TREE_OPERAND (loc, 0), 0);
+ if (ret == 0)
+ return 0;
+
+ add_loc_descr (&ret, new_loc_descr (op, 0, 0));
+ break;
+
+ 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));
+
+ /* ... fall through ... */
+
+ case COND_EXPR:
+ {
+ dw_loc_descr_ref lhs
+ = loc_descriptor_from_tree (TREE_OPERAND (loc, 1), 0);
+ dw_loc_descr_ref rhs
+ = loc_descriptor_from_tree (TREE_OPERAND (loc, 2), 0);
+ dw_loc_descr_ref bra_node, jump_node, tmp;
+
+ ret = loc_descriptor_from_tree (TREE_OPERAND (loc, 0), 0);
+ if (ret == 0 || lhs == 0 || rhs == 0)
+ return 0;
+
+ bra_node = new_loc_descr (DW_OP_bra, 0, 0);
+ add_loc_descr (&ret, bra_node);
+
+ add_loc_descr (&ret, rhs);
+ jump_node = new_loc_descr (DW_OP_skip, 0, 0);
+ add_loc_descr (&ret, jump_node);
+
+ add_loc_descr (&ret, lhs);
+ bra_node->dw_loc_oprnd1.val_class = dw_val_class_loc;
+ bra_node->dw_loc_oprnd1.v.val_loc = lhs;
+
+ /* ??? Need a node to point the skip at. Use a nop. */
+ tmp = new_loc_descr (DW_OP_nop, 0, 0);
+ add_loc_descr (&ret, tmp);
+ jump_node->dw_loc_oprnd1.val_class = dw_val_class_loc;
+ jump_node->dw_loc_oprnd1.v.val_loc = tmp;
+ }
+ break;
+
+ default:
+ abort ();
+ }
+
+ /* Show if we can't fill the request for an address. */
+ if (addressp && indirect_p == 0)
+ return 0;
+
+ /* If we've got an address and don't want one, dereference. */
+ if (!addressp && indirect_p > 0)
+ {
+ HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (loc));
+
+ if (size > DWARF2_ADDR_SIZE || size == -1)
+ return 0;
+ else if (size == DWARF2_ADDR_SIZE)
+ op = DW_OP_deref;
+ else
+ op = DW_OP_deref_size;
+
+ add_loc_descr (&ret, new_loc_descr (op, size, 0));
+ }
+
+ return ret;
+}
+
+/* Given a value, round it up to the lowest multiple of `boundary'
which is not less than the value itself. */
-static inline unsigned
+static inline HOST_WIDE_INT
ceiling (value, boundary)
- register unsigned value;
- register unsigned boundary;
+ HOST_WIDE_INT value;
+ unsigned int boundary;
{
return (((value + boundary - 1) / boundary) * boundary);
}
@@ -6742,9 +8316,9 @@ ceiling (value, boundary)
static inline tree
field_type (decl)
- register tree decl;
+ tree decl;
{
- register tree type;
+ tree type;
if (TREE_CODE (decl) == ERROR_MARK)
return integer_type_node;
@@ -6756,129 +8330,135 @@ field_type (decl)
return type;
}
-/* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
- node, return the alignment in bits for the type, or else return
- BITS_PER_WORD if the node actually turns out to be an
- ERROR_MARK node. */
+/* Given a pointer to a tree node, return the alignment in bits for
+ it, or else return BITS_PER_WORD if the node actually turns out to
+ be an ERROR_MARK node. */
static inline unsigned
simple_type_align_in_bits (type)
- register tree type;
+ tree type;
{
return (TREE_CODE (type) != ERROR_MARK) ? TYPE_ALIGN (type) : BITS_PER_WORD;
}
+static inline unsigned
+simple_decl_align_in_bits (decl)
+ tree decl;
+{
+ return (TREE_CODE (decl) != ERROR_MARK) ? DECL_ALIGN (decl) : BITS_PER_WORD;
+}
+
/* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
node, return the size in bits for the type if it is a constant, or else
return the alignment for the type if the type's size is not constant, or
else return BITS_PER_WORD if the type actually turns out to be an
ERROR_MARK node. */
-static inline unsigned
+static inline unsigned HOST_WIDE_INT
simple_type_size_in_bits (type)
- register tree type;
+ tree type;
{
+
if (TREE_CODE (type) == ERROR_MARK)
return BITS_PER_WORD;
+ else if (TYPE_SIZE (type) == NULL_TREE)
+ return 0;
+ else if (host_integerp (TYPE_SIZE (type), 1))
+ return tree_low_cst (TYPE_SIZE (type), 1);
else
- {
- register tree type_size_tree = TYPE_SIZE (type);
-
- if (TREE_CODE (type_size_tree) != INTEGER_CST)
- return TYPE_ALIGN (type);
-
- return (unsigned) TREE_INT_CST_LOW (type_size_tree);
- }
+ return TYPE_ALIGN (type);
}
-/* Given a pointer to what is assumed to be a FIELD_DECL node, compute and
- return the byte offset of the lowest addressed byte of the "containing
- object" for the given FIELD_DECL, or return 0 if we are unable to
- determine what that offset is, either because the argument turns out to
- be a pointer to an ERROR_MARK node, or because the offset is actually
- variable. (We can't handle the latter case just yet). */
+/* Given a pointer to a FIELD_DECL, compute and return the byte offset of the
+ lowest addressed byte of the "containing object" for the given FIELD_DECL,
+ or return 0 if we are unable to determine what that offset is, either
+ because the argument turns out to be a pointer to an ERROR_MARK node, or
+ because the offset is actually variable. (We can't handle the latter case
+ just yet). */
-static unsigned
+static HOST_WIDE_INT
field_byte_offset (decl)
- register tree decl;
-{
- register unsigned type_align_in_bytes;
- register unsigned type_align_in_bits;
- register unsigned type_size_in_bits;
- register unsigned object_offset_in_align_units;
- register unsigned object_offset_in_bits;
- register unsigned object_offset_in_bytes;
- register tree type;
- register tree bitpos_tree;
- register tree field_size_tree;
- register unsigned bitpos_int;
- register unsigned deepest_bitpos;
- register unsigned field_size_in_bits;
+ tree decl;
+{
+ unsigned int type_align_in_bits;
+ unsigned int decl_align_in_bits;
+ unsigned HOST_WIDE_INT type_size_in_bits;
+ HOST_WIDE_INT object_offset_in_bits;
+ tree type;
+ tree field_size_tree;
+ HOST_WIDE_INT bitpos_int;
+ HOST_WIDE_INT deepest_bitpos;
+ unsigned HOST_WIDE_INT field_size_in_bits;
if (TREE_CODE (decl) == ERROR_MARK)
return 0;
-
- if (TREE_CODE (decl) != FIELD_DECL)
+ else if (TREE_CODE (decl) != FIELD_DECL)
abort ();
type = field_type (decl);
-
- bitpos_tree = DECL_FIELD_BITPOS (decl);
field_size_tree = DECL_SIZE (decl);
- /* We cannot yet cope with fields whose positions or sizes are variable, so
+ /* The size could be unspecified if there was an error, or for
+ a flexible array member. */
+ if (! field_size_tree)
+ field_size_tree = bitsize_zero_node;
+
+ /* We cannot yet cope with fields whose positions are variable, so
for now, when we see such things, we simply return 0. Someday, we may
be able to handle such cases, but it will be damn difficult. */
- if (TREE_CODE (bitpos_tree) != INTEGER_CST)
+ if (! host_integerp (bit_position (decl), 0))
return 0;
- bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree);
- if (TREE_CODE (field_size_tree) != INTEGER_CST)
- return 0;
+ bitpos_int = int_bit_position (decl);
+
+ /* If we don't know the size of the field, pretend it's a full word. */
+ if (host_integerp (field_size_tree, 1))
+ field_size_in_bits = tree_low_cst (field_size_tree, 1);
+ else
+ field_size_in_bits = BITS_PER_WORD;
- field_size_in_bits = (unsigned) TREE_INT_CST_LOW (field_size_tree);
type_size_in_bits = simple_type_size_in_bits (type);
type_align_in_bits = simple_type_align_in_bits (type);
- type_align_in_bytes = type_align_in_bits / BITS_PER_UNIT;
-
- /* Note that the GCC front-end doesn't make any attempt to keep track of
- the starting bit offset (relative to the start of the containing
- structure type) of the hypothetical "containing object" for a bit-
- field. Thus, when computing the byte offset value for the start of the
- "containing object" of a bit-field, we must deduce this information on
- our own. This can be rather tricky to do in some cases. For example,
- handling the following structure type definition when compiling for an
- i386/i486 target (which only aligns long long's to 32-bit boundaries)
- can be very tricky:
+ decl_align_in_bits = simple_decl_align_in_bits (decl);
+
+ /* The GCC front-end doesn't make any attempt to keep track of the starting
+ bit offset (relative to the start of the containing structure type) of the
+ hypothetical "containing object" for a bit-field. Thus, when computing
+ the byte offset value for the start of the "containing object" of a
+ bit-field, we must deduce this information on our own. This can be rather
+ tricky to do in some cases. For example, handling the following structure
+ type definition when compiling for an i386/i486 target (which only aligns
+ long long's to 32-bit boundaries) can be very tricky:
struct S { int field1; long long field2:31; };
- Fortunately, there is a simple rule-of-thumb which can be
- used in such cases. When compiling for an i386/i486, GCC will allocate
- 8 bytes for the structure shown above. It decides to do this based upon
- one simple rule for bit-field allocation. Quite simply, GCC allocates
- each "containing object" for each bit-field at the first (i.e. lowest
- addressed) legitimate alignment boundary (based upon the required
- minimum alignment for the declared type of the field) which it can
- possibly use, subject to the condition that there is still enough
- available space remaining in the containing object (when allocated at
- the selected point) to fully accommodate all of the bits of the
- bit-field itself. This simple rule makes it obvious why GCC allocates
- 8 bytes for each object of the structure type shown above. When looking
- for a place to allocate the "containing object" for `field2', the
- compiler simply tries to allocate a 64-bit "containing object" at each
- successive 32-bit boundary (starting at zero) until it finds a place to
- allocate that 64- bit field such that at least 31 contiguous (and
- previously unallocated) bits remain within that selected 64 bit field.
- (As it turns out, for the example above, the compiler finds that it is
- OK to allocate the "containing object" 64-bit field at bit-offset zero
- within the structure type.) Here we attempt to work backwards from the
- limited set of facts we're given, and we try to deduce from those facts,
- where GCC must have believed that the containing object started (within
- the structure type). The value we deduce is then used (by the callers of
- this routine) to generate DW_AT_location and DW_AT_bit_offset attributes
- for fields (both bit-fields and, in the case of DW_AT_location, regular
- fields as well). */
+ Fortunately, there is a simple rule-of-thumb which can be used in such
+ cases. When compiling for an i386/i486, GCC will allocate 8 bytes for the
+ structure shown above. It decides to do this based upon one simple rule
+ for bit-field allocation. GCC allocates each "containing object" for each
+ bit-field at the first (i.e. lowest addressed) legitimate alignment
+ boundary (based upon the required minimum alignment for the declared type
+ of the field) which it can possibly use, subject to the condition that
+ there is still enough available space remaining in the containing object
+ (when allocated at the selected point) to fully accommodate all of the
+ bits of the bit-field itself.
+
+ This simple rule makes it obvious why GCC allocates 8 bytes for each
+ object of the structure type shown above. When looking for a place to
+ allocate the "containing object" for `field2', the compiler simply tries
+ to allocate a 64-bit "containing object" at each successive 32-bit
+ boundary (starting at zero) until it finds a place to allocate that 64-
+ bit field such that at least 31 contiguous (and previously unallocated)
+ bits remain within that selected 64 bit field. (As it turns out, for the
+ example above, the compiler finds it is OK to allocate the "containing
+ object" 64-bit field at bit-offset zero within the structure type.)
+
+ Here we attempt to work backwards from the limited set of facts we're
+ given, and we try to deduce from those facts, where GCC must have believed
+ that the containing object started (within the structure type). The value
+ we deduce is then used (by the callers of this routine) to generate
+ DW_AT_location and DW_AT_bit_offset attributes for fields (both bit-fields
+ and, in the case of DW_AT_location, regular fields as well). */
/* Figure out the bit-distance from the start of the structure to the
"deepest" bit of the bit-field. */
@@ -6886,16 +8466,25 @@ field_byte_offset (decl)
/* This is the tricky part. Use some fancy footwork to deduce where the
lowest addressed bit of the containing object must be. */
- object_offset_in_bits
- = ceiling (deepest_bitpos, type_align_in_bits) - type_size_in_bits;
+ object_offset_in_bits = deepest_bitpos - type_size_in_bits;
- /* Compute the offset of the containing object in "alignment units". */
- object_offset_in_align_units = object_offset_in_bits / type_align_in_bits;
+ /* Round up to type_align by default. This works best for bitfields. */
+ object_offset_in_bits += type_align_in_bits - 1;
+ object_offset_in_bits /= type_align_in_bits;
+ object_offset_in_bits *= type_align_in_bits;
- /* Compute the offset of the containing object in bytes. */
- object_offset_in_bytes = object_offset_in_align_units * type_align_in_bytes;
+ if (object_offset_in_bits > bitpos_int)
+ {
+ /* Sigh, the decl must be packed. */
+ object_offset_in_bits = deepest_bitpos - type_size_in_bits;
- return object_offset_in_bytes;
+ /* Round up to decl_align instead. */
+ object_offset_in_bits += decl_align_in_bits - 1;
+ object_offset_in_bits /= decl_align_in_bits;
+ object_offset_in_bits *= decl_align_in_bits;
+ }
+
+ return object_offset_in_bits / BITS_PER_UNIT;
}
/* The following routines define various Dwarf attributes and any data
@@ -6911,74 +8500,109 @@ static void
add_AT_location_description (die, attr_kind, rtl)
dw_die_ref die;
enum dwarf_attribute attr_kind;
- register rtx rtl;
-{
- /* Handle a special case. If we are about to output a location descriptor
- for a variable or parameter which has been optimized out of existence,
- don't do that. A variable which has been optimized out
- of existence will have a DECL_RTL value which denotes a pseudo-reg.
- Currently, in some rare cases, variables can have DECL_RTL values which
- look like (MEM (REG pseudo-reg#)). These cases are due to bugs
- elsewhere in the compiler. We treat such cases as if the variable(s) in
- question had been optimized out of existence. */
-
- if (is_pseudo_reg (rtl)
- || (GET_CODE (rtl) == MEM
- && is_pseudo_reg (XEXP (rtl, 0)))
- || (GET_CODE (rtl) == CONCAT
- && is_pseudo_reg (XEXP (rtl, 0))
- && is_pseudo_reg (XEXP (rtl, 1))))
- return;
+ rtx rtl;
+{
+ dw_loc_descr_ref descr = loc_descriptor (rtl);
+
+ if (descr != 0)
+ add_AT_loc (die, attr_kind, descr);
+}
+
+/* Attach the specialized form of location attribute used for data members of
+ struct and union types. In the special case of a FIELD_DECL node which
+ represents a bit-field, the "offset" part of this special location
+ descriptor must indicate the distance in bytes from the lowest-addressed
+ byte of the containing struct or union type to the lowest-addressed byte of
+ the "containing object" for the bit-field. (See the `field_byte_offset'
+ function above).
- add_AT_loc (die, attr_kind, loc_descriptor (rtl));
-}
-
-/* Attach the specialized form of location attribute used for data
- members of struct and union types. In the special case of a
- FIELD_DECL node which represents a bit-field, the "offset" part
- of this special location descriptor must indicate the distance
- in bytes from the lowest-addressed byte of the containing struct
- or union type to the lowest-addressed byte of the "containing
- object" for the bit-field. (See the `field_byte_offset' function
- above).. For any given bit-field, the "containing object" is a
- hypothetical object (of some integral or enum type) within which
- the given bit-field lives. The type of this hypothetical
- "containing object" is always the same as the declared type of
- the individual bit-field itself (for GCC anyway... the DWARF
- spec doesn't actually mandate this). Note that it is the size
- (in bytes) of the hypothetical "containing object" which will
- be given in the DW_AT_byte_size attribute for this bit-field.
- (See the `byte_size_attribute' function below.) It is also used
- when calculating the value of the DW_AT_bit_offset attribute.
- (See the `bit_offset_attribute' function below). */
+ For any given bit-field, the "containing object" is a hypothetical object
+ (of some integral or enum type) within which the given bit-field lives. The
+ type of this hypothetical "containing object" is always the same as the
+ declared type of the individual bit-field itself (for GCC anyway... the
+ DWARF spec doesn't actually mandate this). Note that it is the size (in
+ bytes) of the hypothetical "containing object" which will be given in the
+ DW_AT_byte_size attribute for this bit-field. (See the
+ `byte_size_attribute' function below.) It is also used when calculating the
+ value of the DW_AT_bit_offset attribute. (See the `bit_offset_attribute'
+ function below.) */
static void
add_data_member_location_attribute (die, decl)
- register dw_die_ref die;
- register tree decl;
+ dw_die_ref die;
+ tree decl;
{
- register unsigned long offset;
- register dw_loc_descr_ref loc_descr;
- register enum dwarf_location_atom op;
+ long offset;
+ dw_loc_descr_ref loc_descr = 0;
if (TREE_CODE (decl) == TREE_VEC)
- offset = TREE_INT_CST_LOW (BINFO_OFFSET (decl));
+ {
+ /* We're working on the TAG_inheritance for a base class. */
+ if (TREE_VIA_VIRTUAL (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
+ type. We need to extract the appropriate offset from our
+ vtable. The following dwarf expression means
+
+ BaseAddr = ObAddr + *((*ObAddr) - Offset)
+
+ This is specific to the V3 ABI, of course. */
+
+ dw_loc_descr_ref tmp;
+
+ /* Make a copy of the object address. */
+ tmp = new_loc_descr (DW_OP_dup, 0, 0);
+ add_loc_descr (&loc_descr, tmp);
+
+ /* Extract the vtable address. */
+ tmp = new_loc_descr (DW_OP_deref, 0, 0);
+ add_loc_descr (&loc_descr, tmp);
+
+ /* Calculate the address of the offset. */
+ offset = tree_low_cst (BINFO_VPTR_FIELD (decl), 0);
+ if (offset >= 0)
+ abort ();
+
+ tmp = int_loc_descriptor (-offset);
+ add_loc_descr (&loc_descr, tmp);
+ tmp = new_loc_descr (DW_OP_minus, 0, 0);
+ add_loc_descr (&loc_descr, tmp);
+
+ /* Extract the offset. */
+ tmp = new_loc_descr (DW_OP_deref, 0, 0);
+ add_loc_descr (&loc_descr, tmp);
+
+ /* Add it to the object address. */
+ tmp = new_loc_descr (DW_OP_plus, 0, 0);
+ add_loc_descr (&loc_descr, tmp);
+ }
+ else
+ offset = tree_low_cst (BINFO_OFFSET (decl), 0);
+ }
else
offset = field_byte_offset (decl);
- /* The DWARF2 standard says that we should assume that the structure address
- is already on the stack, so we can specify a structure field address
- by using DW_OP_plus_uconst. */
+ if (! loc_descr)
+ {
+ enum dwarf_location_atom op;
+
+ /* The DWARF2 standard says that we should assume that the structure
+ address is already on the stack, so we can specify a structure field
+ address by using DW_OP_plus_uconst. */
#ifdef MIPS_DEBUGGING_INFO
- /* ??? The SGI dwarf reader does not handle the DW_OP_plus_uconst operator
- correctly. It works only if we leave the offset on the stack. */
- op = DW_OP_constu;
+ /* ??? The SGI dwarf reader does not handle the DW_OP_plus_uconst
+ operator correctly. It works only if we leave the offset on the
+ stack. */
+ op = DW_OP_constu;
#else
- op = DW_OP_plus_uconst;
+ op = DW_OP_plus_uconst;
#endif
- loc_descr = new_loc_descr (op, offset, 0);
+ loc_descr = new_loc_descr (op, offset, 0);
+ }
+
add_AT_loc (die, DW_AT_data_member_location, loc_descr);
}
@@ -6990,18 +8614,35 @@ add_data_member_location_attribute (die, decl)
static void
add_const_value_attribute (die, rtl)
- register dw_die_ref die;
- register rtx rtl;
+ dw_die_ref die;
+ rtx rtl;
{
switch (GET_CODE (rtl))
{
case CONST_INT:
- /* Note that a CONST_INT rtx could represent either an integer or a
- floating-point constant. A CONST_INT is used whenever the constant
- will fit into a single word. In all such cases, the original mode
- of the constant value is wiped out, and the CONST_INT rtx is
- assigned VOIDmode. */
- add_AT_unsigned (die, DW_AT_const_value, (unsigned) INTVAL (rtl));
+ /* Note that a CONST_INT rtx could represent either an integer
+ or a floating-point constant. A CONST_INT is used whenever
+ the constant will fit into a single word. In all such
+ cases, the original mode of the constant value is wiped
+ out, and the CONST_INT rtx is assigned VOIDmode. */
+ {
+ HOST_WIDE_INT val = INTVAL (rtl);
+
+ /* ??? We really should be using HOST_WIDE_INT throughout. */
+ if (val < 0 && (long) val == val)
+ add_AT_int (die, DW_AT_const_value, (long) val);
+ else if ((unsigned long) val == (unsigned HOST_WIDE_INT) val)
+ add_AT_unsigned (die, DW_AT_const_value, (unsigned long) val);
+ else
+ {
+#if HOST_BITS_PER_LONG * 2 == HOST_BITS_PER_WIDE_INT
+ add_AT_long_long (die, DW_AT_const_value,
+ val >> HOST_BITS_PER_LONG, val);
+#else
+ abort ();
+#endif
+ }
+ }
break;
case CONST_DOUBLE:
@@ -7010,12 +8651,12 @@ add_const_value_attribute (die, rtl)
constant requires more than one word in order to be adequately
represented. We output CONST_DOUBLEs as blocks. */
{
- register enum machine_mode mode = GET_MODE (rtl);
+ enum machine_mode mode = GET_MODE (rtl);
if (GET_MODE_CLASS (mode) == MODE_FLOAT)
{
- register unsigned length = GET_MODE_SIZE (mode) / sizeof (long);
- long array[4];
+ unsigned length = GET_MODE_SIZE (mode) / 4;
+ long *array = (long *) xmalloc (sizeof (long) * length);
REAL_VALUE_TYPE rv;
REAL_VALUE_FROM_CONST_DOUBLE (rv, rtl);
@@ -7041,8 +8682,14 @@ add_const_value_attribute (die, rtl)
add_AT_float (die, DW_AT_const_value, length, array);
}
else
- add_AT_long_long (die, DW_AT_const_value,
- CONST_DOUBLE_HIGH (rtl), CONST_DOUBLE_LOW (rtl));
+ {
+ /* ??? We really should be using HOST_WIDE_INT throughout. */
+ if (HOST_BITS_PER_LONG != HOST_BITS_PER_WIDE_INT)
+ abort ();
+
+ add_AT_long_long (die, DW_AT_const_value,
+ CONST_DOUBLE_HIGH (rtl), CONST_DOUBLE_LOW (rtl));
+ }
}
break;
@@ -7053,7 +8700,8 @@ add_const_value_attribute (die, rtl)
case SYMBOL_REF:
case LABEL_REF:
case CONST:
- add_AT_addr (die, DW_AT_const_value, addr_to_string (rtl));
+ add_AT_addr (die, DW_AT_const_value, rtl);
+ VARRAY_PUSH_RTX (used_rtx_varray, rtl);
break;
case PLUS:
@@ -7063,10 +8711,10 @@ add_const_value_attribute (die, rtl)
variable (for the inlining) which acts as a stand-in for the
corresponding formal parameter (of the inline function) will look
like (plus:SI (reg:SI FRAME_PTR) (const_int ...)). This is not
- exactly a compile-time constant expression, but it isn't the address
- of the (artificial) local variable either. Rather, it represents the
+ exactly a compile-time constant expression, but it isn't the address
+ of the (artificial) local variable either. Rather, it represents the
*value* which the artificial local variable always has during its
- lifetime. We currently have no way to represent such quasi-constant
+ lifetime. We currently have no way to represent such quasi-constant
values in Dwarf, so for now we just punt and generate nothing. */
break;
@@ -7077,39 +8725,19 @@ add_const_value_attribute (die, rtl)
}
-/* Generate *either* an DW_AT_location attribute or else an DW_AT_const_value
- data attribute for a variable or a parameter. We generate the
- DW_AT_const_value attribute only in those cases where the given variable
- or parameter does not have a true "location" either in memory or in a
- register. This can happen (for example) when a constant is passed as an
- actual argument in a call to an inline function. (It's possible that
- these things can crop up in other ways also.) Note that one type of
- constant value which can be passed into an inlined function is a constant
- pointer. This can happen for example if an actual argument in an inlined
- function call evaluates to a compile-time constant address. */
-
-static void
-add_location_or_const_value_attribute (die, decl)
- register dw_die_ref die;
- register tree decl;
+static rtx
+rtl_for_decl_location (decl)
+ tree decl;
{
- register rtx rtl;
- register tree declared_type;
- register tree passed_type;
-
- if (TREE_CODE (decl) == ERROR_MARK)
- return;
-
- if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != PARM_DECL)
- abort ();
+ rtx rtl;
/* Here we have to decide where we are going to say the parameter "lives"
(as far as the debugger is concerned). We only have a couple of
choices. GCC provides us with DECL_RTL and with DECL_INCOMING_RTL.
- DECL_RTL normally indicates where the parameter lives during most of the
+ DECL_RTL normally indicates where the parameter lives during most of the
activation of the function. If optimization is enabled however, this
- could be either NULL or else a pseudo-reg. Both of those cases indicate
+ could be either NULL or else a pseudo-reg. Both of those cases indicate
that the parameter doesn't really live anywhere (as far as the code
generation parts of GCC are concerned) during most of the function's
activation. That will happen (for example) if the parameter is never
@@ -7152,52 +8780,61 @@ add_location_or_const_value_attribute (die, decl)
the correct data, so we allow for such exceptional cases below.
Note that our goal here is to describe the place where the given formal
- parameter lives during most of the function's activation (i.e. between
- the end of the prologue and the start of the epilogue). We'll do that
- as best as we can. Note however that if the given formal parameter is
- modified sometime during the execution of the function, then a stack
- backtrace (at debug-time) will show the function as having been
- called with the *new* value rather than the value which was
- originally passed in. This happens rarely enough that it is not
- a major problem, but it *is* a problem, and I'd like to fix it.
-
- A future version of dwarf2out.c may generate two additional
- attributes for any given DW_TAG_formal_parameter DIE which will
- describe the "passed type" and the "passed location" for the
- given formal parameter in addition to the attributes we now
- generate to indicate the "declared type" and the "active
- location" for each parameter. This additional set of attributes
- could be used by debuggers for stack backtraces. Separately, note
- that sometimes DECL_RTL can be NULL and DECL_INCOMING_RTL can be
- NULL also. 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
+ parameter lives during most of the function's activation (i.e. between the
+ end of the prologue and the start of the epilogue). We'll do that as best
+ as we can. Note however that if the given formal parameter is modified
+ sometime during the execution of the function, then a stack backtrace (at
+ debug-time) will show the function as having been called with the *new*
+ value rather than the value which was originally passed in. This happens
+ rarely enough that it is not a major problem, but it *is* a problem, and
+ I'd like to fix it.
+
+ A future version of dwarf2out.c may generate two additional attributes for
+ any given DW_TAG_formal_parameter DIE which will describe the "passed
+ type" and the "passed location" for the given formal parameter in addition
+ to the attributes we now generate to indicate the "declared type" and the
+ "active location" for each parameter. This additional set of attributes
+ could be used by debuggers for stack backtraces. Separately, note that
+ sometimes DECL_RTL can be NULL and DECL_INCOMING_RTL can be NULL also.
+ 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). */
/* Use DECL_RTL as the "location" unless we find something better. */
- rtl = DECL_RTL (decl);
+ rtl = DECL_RTL_IF_SET (decl);
- if (TREE_CODE (decl) == PARM_DECL)
+ /* When generating abstract instances, ignore everything except
+ constants and symbols living in memory. */
+ if (! reload_completed)
+ {
+ if (rtl
+ && (CONSTANT_P (rtl)
+ || (GET_CODE (rtl) == MEM
+ && CONSTANT_P (XEXP (rtl, 0)))))
+ return rtl;
+ rtl = NULL_RTX;
+ }
+ else if (TREE_CODE (decl) == PARM_DECL)
{
if (rtl == NULL_RTX || is_pseudo_reg (rtl))
{
- declared_type = type_main_variant (TREE_TYPE (decl));
- passed_type = type_main_variant (DECL_ARG_TYPE (decl));
+ tree declared_type = type_main_variant (TREE_TYPE (decl));
+ tree passed_type = type_main_variant (DECL_ARG_TYPE (decl));
/* This decl represents a formal parameter which was optimized out.
Note that DECL_INCOMING_RTL may be NULL in here, but we handle
- all* cases where (rtl == NULL_RTX) just below. */
+ all cases where (rtl == NULL_RTX) just below. */
if (declared_type == passed_type)
rtl = DECL_INCOMING_RTL (decl);
else if (! BYTES_BIG_ENDIAN
&& TREE_CODE (declared_type) == INTEGER_TYPE
&& (GET_MODE_SIZE (TYPE_MODE (declared_type))
<= GET_MODE_SIZE (TYPE_MODE (passed_type))))
- rtl = DECL_INCOMING_RTL (decl);
+ rtl = DECL_INCOMING_RTL (decl);
}
/* If the parm was passed in registers, but lives on the stack, then
@@ -7228,19 +8865,62 @@ add_location_or_const_value_attribute (die, decl)
{
int offset = (UNITS_PER_WORD
- GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (decl))));
+
rtl = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (decl)),
plus_constant (XEXP (rtl, 0), offset));
}
}
+ if (rtl != NULL_RTX)
+ {
+ rtl = eliminate_regs (rtl, 0, NULL_RTX);
+#ifdef LEAF_REG_REMAP
+ if (current_function_uses_only_leaf_regs)
+ leaf_renumber_regs_insn (rtl);
+#endif
+ }
+
+ /* A variable with no DECL_RTL but a DECL_INITIAL is a compile-time constant,
+ and will have been substituted directly into all expressions that use it.
+ C does not have such a concept, but C++ and other languages do. */
+ else if (TREE_CODE (decl) == VAR_DECL && DECL_INITIAL (decl))
+ rtl = expand_expr (DECL_INITIAL (decl), NULL_RTX, VOIDmode,
+ EXPAND_INITIALIZER);
+
+ return rtl;
+}
+
+/* Generate *either* an DW_AT_location attribute or else an DW_AT_const_value
+ data attribute for a variable or a parameter. We generate the
+ DW_AT_const_value attribute only in those cases where the given variable
+ or parameter does not have a true "location" either in memory or in a
+ register. This can happen (for example) when a constant is passed as an
+ actual argument in a call to an inline function. (It's possible that
+ these things can crop up in other ways also.) Note that one type of
+ constant value which can be passed into an inlined function is a constant
+ pointer. This can happen for example if an actual argument in an inlined
+ function call evaluates to a compile-time constant address. */
+
+static void
+add_location_or_const_value_attribute (die, decl)
+ dw_die_ref die;
+ tree decl;
+{
+ rtx rtl;
+
+ if (TREE_CODE (decl) == ERROR_MARK)
+ return;
+ else if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != PARM_DECL)
+ abort ();
+
+ rtl = rtl_for_decl_location (decl);
if (rtl == NULL_RTX)
return;
- rtl = eliminate_regs (rtl, 0, NULL_RTX);
-#ifdef LEAF_REG_REMAP
- if (current_function_uses_only_leaf_regs)
- leaf_renumber_regs_insn (rtl);
-#endif
+ /* If we don't look past the constant pool, we risk emitting a
+ reference to a constant pool entry that isn't referenced from
+ code, and thus is not emitted. */
+ rtl = avoid_constant_pool_reference (rtl);
switch (GET_CODE (rtl))
{
@@ -7272,16 +8952,55 @@ add_location_or_const_value_attribute (die, decl)
}
}
+/* If we don't have a copy of this variable in memory for some reason (such
+ as a C++ member constant that doesn't have an out-of-line definition),
+ we should tell the debugger about the constant value. */
+
+static void
+tree_add_const_value_attribute (var_die, decl)
+ dw_die_ref var_die;
+ tree decl;
+{
+ tree init = DECL_INITIAL (decl);
+ tree type = TREE_TYPE (decl);
+
+ if (TREE_READONLY (decl) && ! TREE_THIS_VOLATILE (decl) && init
+ && initializer_constant_valid_p (init, type) == null_pointer_node)
+ /* OK */;
+ else
+ return;
+
+ switch (TREE_CODE (type))
+ {
+ case INTEGER_TYPE:
+ if (host_integerp (init, 0))
+ add_AT_unsigned (var_die, DW_AT_const_value,
+ tree_low_cst (init, 0));
+ else
+ add_AT_long_long (var_die, DW_AT_const_value,
+ TREE_INT_CST_HIGH (init),
+ TREE_INT_CST_LOW (init));
+ break;
+
+ default:;
+ }
+}
+
/* Generate an DW_AT_name attribute given some string value to be included as
the value of the attribute. */
static inline void
add_name_attribute (die, name_string)
- register dw_die_ref die;
- register char *name_string;
+ dw_die_ref die;
+ const char *name_string;
{
if (name_string != NULL && *name_string != 0)
- add_AT_string (die, DW_AT_name, name_string);
+ {
+ if (demangle_name_func)
+ name_string = (*demangle_name_func) (name_string);
+
+ add_AT_string (die, DW_AT_name, name_string);
+ }
}
/* Given a tree node describing an array bound (either lower or upper) output
@@ -7289,40 +9008,34 @@ add_name_attribute (die, name_string)
static void
add_bound_info (subrange_die, bound_attr, bound)
- register dw_die_ref subrange_die;
- register enum dwarf_attribute bound_attr;
- register tree bound;
+ dw_die_ref subrange_die;
+ enum dwarf_attribute bound_attr;
+ tree bound;
{
- register unsigned bound_value = 0;
-
- /* If this is an Ada unconstrained array type, then don't emit any debug
- info because the array bounds are unknown. They are parameterized when
- the type is instantiated. */
- if (contains_placeholder_p (bound))
- return;
-
switch (TREE_CODE (bound))
{
case ERROR_MARK:
return;
- /* All fixed-bounds are represented by INTEGER_CST nodes. */
+ /* All fixed-bounds are represented by INTEGER_CST nodes. */
case INTEGER_CST:
- bound_value = TREE_INT_CST_LOW (bound);
- if (bound_attr == DW_AT_lower_bound
- && ((is_c_family () && bound_value == 0)
- || (is_fortran () && bound_value == 1)))
- /* use the default */;
+ if (! host_integerp (bound, 0)
+ || (bound_attr == DW_AT_lower_bound
+ && (((is_c_family () || is_java ()) && integer_zerop (bound))
+ || (is_fortran () && integer_onep (bound)))))
+ /* use the default */
+ ;
else
- add_AT_unsigned (subrange_die, bound_attr, bound_value);
+ add_AT_unsigned (subrange_die, bound_attr, tree_low_cst (bound, 0));
break;
case CONVERT_EXPR:
case NOP_EXPR:
case NON_LVALUE_EXPR:
+ case VIEW_CONVERT_EXPR:
add_bound_info (subrange_die, bound_attr, TREE_OPERAND (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
@@ -7338,7 +9051,7 @@ add_bound_info (subrange_die, bound_attr, bound)
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 a array
+ 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.
@@ -7346,21 +9059,21 @@ add_bound_info (subrange_die, bound_attr, bound)
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 (! optimize || GET_CODE (SAVE_EXPR_RTL (bound)) == MEM)
+ if (SAVE_EXPR_RTL (bound)
+ && (! optimize || GET_CODE (SAVE_EXPR_RTL (bound)) == MEM))
{
- register dw_die_ref ctx = lookup_decl_die (current_function_decl);
- register dw_die_ref decl_die = new_die (DW_TAG_variable, ctx);
- register rtx loc = SAVE_EXPR_RTL (bound);
+ 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);
+ loc = gen_rtx_MEM (GET_MODE (loc), new_addr);
}
add_AT_flag (decl_die, DW_AT_artificial, 1);
@@ -7372,15 +9085,55 @@ add_bound_info (subrange_die, bound_attr, bound)
/* Else leave out the attribute. */
break;
- case MAX_EXPR:
case VAR_DECL:
- case COMPONENT_REF:
- /* ??? These types of bounds can be created by the Ada front end,
- and it isn't clear how to emit debug info for them. */
- break;
+ case PARM_DECL:
+ {
+ dw_die_ref decl_die = lookup_decl_die (bound);
+
+ /* ??? Can this happen, or should the variable have been bound
+ first? Probably it can, since I imagine that we try to create
+ the types of parameters in the order in which they exist in
+ the list, and won't have created a forward reference to a
+ later parameter. */
+ if (decl_die != NULL)
+ add_AT_die_ref (subrange_die, bound_attr, decl_die);
+ break;
+ }
default:
- abort ();
+ {
+ /* Otherwise try to create a stack operation procedure to
+ evaluate the value of the array bound. */
+
+ dw_die_ref ctx, decl_die;
+ dw_loc_descr_ref loc;
+
+ loc = loc_descriptor_from_tree (bound, 0);
+ if (loc == NULL)
+ break;
+
+ if (current_function_decl == 0)
+ ctx = comp_unit_die;
+ 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);
+ add_AT_loc (decl_die, DW_AT_location, loc);
+
+ add_AT_die_ref (subrange_die, bound_attr, decl_die);
+ break;
+ }
}
}
@@ -7389,22 +9142,22 @@ add_bound_info (subrange_die, bound_attr, bound)
static void
add_subscript_info (type_die, type)
- register dw_die_ref type_die;
- register tree type;
+ dw_die_ref type_die;
+ tree type;
{
#ifndef MIPS_DEBUGGING_INFO
- register unsigned dimension_number;
+ unsigned dimension_number;
#endif
- register tree lower, upper;
- register dw_die_ref subrange_die;
+ tree lower, upper;
+ dw_die_ref subrange_die;
- /* The GNU compilers represent multidimensional array types as sequences of
+ /* The GNU compilers represent multidimensional array types as sequences of
one dimensional array types whose element types are themselves array
types. Here we squish that down, so that each multidimensional array
- type gets only one array_type DIE in the Dwarf debugging info. The draft
+ type gets only one array_type DIE in the Dwarf debugging info. The draft
Dwarf specification say that we are allowed to do this kind of
compression in C (because there is no difference between an array or
- arrays and a multidimensional array in C) but for other source languages
+ arrays and a multidimensional array in C) but for other source languages
(e.g. Ada) we probably shouldn't do this. */
/* ??? The SGI dwarf reader fails for multidimensional arrays with a
@@ -7415,14 +9168,14 @@ add_subscript_info (type_die, type)
for (dimension_number = 0;
TREE_CODE (type) == ARRAY_TYPE;
type = TREE_TYPE (type), dimension_number++)
- {
#endif
- register tree domain = TYPE_DOMAIN (type);
+ {
+ tree domain = TYPE_DOMAIN (type);
/* Arrays come in three flavors: Unspecified bounds, fixed bounds,
- and (in GNU C only) variable bounds. Handle all three forms
+ and (in GNU C only) variable bounds. Handle all three forms
here. */
- subrange_die = new_die (DW_TAG_subrange_type, type_die);
+ subrange_die = new_die (DW_TAG_subrange_type, type_die, NULL);
if (domain)
{
/* We have an array type with specified bounds. */
@@ -7439,7 +9192,7 @@ add_subscript_info (type_die, type)
&& TYPE_NAME (domain) == NULL_TREE
&& TREE_CODE (TREE_TYPE (domain)) == INTEGER_TYPE
&& TYPE_NAME (TREE_TYPE (domain)) == NULL_TREE)
- ;
+ ;
else
add_type_attribute (subrange_die, TREE_TYPE (domain), 0, 0,
type_die);
@@ -7456,24 +9209,19 @@ add_subscript_info (type_die, type)
if (upper)
add_bound_info (subrange_die, DW_AT_upper_bound, upper);
}
- else
- /* We have an array type with an unspecified length. The DWARF-2
- spec does not say how to handle this; let's just leave out the
- bounds. */
- {;}
-
-#ifndef MIPS_DEBUGGING_INFO
+ /* Otherwise we have an array type with an unspecified length. The
+ DWARF-2 spec does not say how to handle this; let's just leave out the
+ bounds. */
}
-#endif
}
static void
add_byte_size_attribute (die, tree_node)
dw_die_ref die;
- register tree tree_node;
+ tree tree_node;
{
- register unsigned size;
+ unsigned size;
switch (TREE_CODE (tree_node))
{
@@ -7501,7 +9249,6 @@ add_byte_size_attribute (die, tree_node)
indicates that the byte size of the entity in question is variable. We
have no good way of expressing this fact in Dwarf at the present time,
so just let the -1 pass on through. */
-
add_AT_unsigned (die, DW_AT_byte_size, size);
}
@@ -7510,13 +9257,12 @@ add_byte_size_attribute (die, tree_node)
"containing object" for the bit-field to the highest order bit of the
bit-field itself.
- For any given bit-field, the "containing object" is a hypothetical
- object (of some integral or enum type) within which the given bit-field
- lives. The type of this hypothetical "containing object" is always the
- same as the declared type of the individual bit-field itself. The
- determination of the exact location of the "containing object" for a
- bit-field is rather complicated. It's handled by the
- `field_byte_offset' function (above).
+ For any given bit-field, the "containing object" is a hypothetical object
+ (of some integral or enum type) within which the given bit-field lives. The
+ type of this hypothetical "containing object" is always the same as the
+ declared type of the individual bit-field itself. The determination of the
+ exact location of the "containing object" for a bit-field is rather
+ complicated. It's handled by the `field_byte_offset' function (above).
Note that it is the size (in bytes) of the hypothetical "containing object"
which will be given in the DW_AT_byte_size attribute for this bit-field.
@@ -7524,16 +9270,15 @@ add_byte_size_attribute (die, tree_node)
static inline void
add_bit_offset_attribute (die, decl)
- register dw_die_ref die;
- register tree decl;
+ dw_die_ref die;
+ tree decl;
{
- register unsigned object_offset_in_bytes = field_byte_offset (decl);
- register tree type = DECL_BIT_FIELD_TYPE (decl);
- register tree bitpos_tree = DECL_FIELD_BITPOS (decl);
- register unsigned bitpos_int;
- register unsigned highest_order_object_bit_offset;
- register unsigned highest_order_field_bit_offset;
- register unsigned bit_offset;
+ HOST_WIDE_INT object_offset_in_bytes = field_byte_offset (decl);
+ tree type = DECL_BIT_FIELD_TYPE (decl);
+ HOST_WIDE_INT bitpos_int;
+ HOST_WIDE_INT highest_order_object_bit_offset;
+ HOST_WIDE_INT highest_order_field_bit_offset;
+ HOST_WIDE_INT unsigned bit_offset;
/* Must be a field and a bit field. */
if (!type
@@ -7542,15 +9287,16 @@ add_bit_offset_attribute (die, decl)
/* We can't yet handle bit-fields whose offsets are variable, so if we
encounter such things, just return without generating any attribute
- whatsoever. */
- if (TREE_CODE (bitpos_tree) != INTEGER_CST)
+ whatsoever. Likewise for variable or too large size. */
+ if (! host_integerp (bit_position (decl), 0)
+ || ! host_integerp (DECL_SIZE (decl), 1))
return;
- bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree);
+ bitpos_int = int_bit_position (decl);
/* Note that the bit offset is always the distance (in bits) from the
- highest-order bit of the "containing object" to the highest-order bit of
- the bit-field itself. Since the "high-order end" of any object or field
+ highest-order bit of the "containing object" to the highest-order bit of
+ the bit-field itself. Since the "high-order end" of any object or field
is different on big-endian and little-endian machines, the computation
below must take account of these differences. */
highest_order_object_bit_offset = object_offset_in_bytes * BITS_PER_UNIT;
@@ -7558,9 +9304,7 @@ add_bit_offset_attribute (die, decl)
if (! BYTES_BIG_ENDIAN)
{
- highest_order_field_bit_offset
- += (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl));
-
+ highest_order_field_bit_offset += tree_low_cst (DECL_SIZE (decl), 0);
highest_order_object_bit_offset += simple_type_size_in_bits (type);
}
@@ -7577,15 +9321,16 @@ add_bit_offset_attribute (die, decl)
static inline void
add_bit_size_attribute (die, decl)
- register dw_die_ref die;
- register tree decl;
+ dw_die_ref die;
+ tree decl;
{
/* Must be a field and a bit field. */
if (TREE_CODE (decl) != FIELD_DECL
|| ! DECL_BIT_FIELD_TYPE (decl))
abort ();
- add_AT_unsigned (die, DW_AT_bit_size,
- (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl)));
+
+ if (host_integerp (DECL_SIZE (decl), 1))
+ add_AT_unsigned (die, DW_AT_bit_size, tree_low_cst (DECL_SIZE (decl), 1));
}
/* If the compiled language is ANSI C, then add a 'prototyped'
@@ -7593,30 +9338,51 @@ add_bit_size_attribute (die, decl)
static inline void
add_prototyped_attribute (die, func_type)
- register dw_die_ref die;
- register tree func_type;
+ dw_die_ref die;
+ tree func_type;
{
if (get_AT_unsigned (comp_unit_die, DW_AT_language) == DW_LANG_C89
&& TYPE_ARG_TYPES (func_type) != NULL)
add_AT_flag (die, DW_AT_prototyped, 1);
}
-
/* Add an 'abstract_origin' attribute below a given DIE. The DIE is found
by looking in either the type declaration or object declaration
equate table. */
static inline void
add_abstract_origin_attribute (die, origin)
- register dw_die_ref die;
- register tree origin;
+ dw_die_ref die;
+ tree origin;
{
dw_die_ref origin_die = NULL;
- if (TREE_CODE_CLASS (TREE_CODE (origin)) == 'd')
+
+ if (TREE_CODE (origin) != FUNCTION_DECL)
+ {
+ /* We may have gotten separated from the block for the inlined
+ function, if we're in an exception handler or some such; make
+ sure that the abstract function has been written out.
+
+ Doing this for nested functions is wrong, however; functions are
+ distinct units, and our context might not even be inline. */
+ tree fn = origin;
+
+ if (TYPE_P (fn))
+ fn = TYPE_STUB_DECL (fn);
+
+ fn = decl_function_context (fn);
+ if (fn)
+ dwarf2out_abstract_function (fn);
+ }
+
+ if (DECL_P (origin))
origin_die = lookup_decl_die (origin);
- else if (TREE_CODE_CLASS (TREE_CODE (origin)) == 't')
+ else if (TYPE_P (origin))
origin_die = lookup_type_die (origin);
+ if (origin_die == NULL)
+ abort ();
+
add_AT_die_ref (die, DW_AT_abstract_origin, origin_die);
}
@@ -7624,16 +9390,18 @@ add_abstract_origin_attribute (die, origin)
static inline void
add_pure_or_virtual_attribute (die, func_decl)
- register dw_die_ref die;
- register tree func_decl;
+ dw_die_ref die;
+ tree func_decl;
{
if (DECL_VINDEX (func_decl))
{
add_AT_unsigned (die, DW_AT_virtuality, DW_VIRTUALITY_virtual);
- add_AT_loc (die, DW_AT_vtable_elem_location,
- new_loc_descr (DW_OP_constu,
- TREE_INT_CST_LOW (DECL_VINDEX (func_decl)),
- 0));
+
+ if (host_integerp (DECL_VINDEX (func_decl), 0))
+ add_AT_loc (die, DW_AT_vtable_elem_location,
+ new_loc_descr (DW_OP_constu,
+ tree_low_cst (DECL_VINDEX (func_decl), 0),
+ 0));
/* GNU extension: Record what type this method came from originally. */
if (debug_info_level > DINFO_LEVEL_TERSE)
@@ -7646,10 +9414,10 @@ add_pure_or_virtual_attribute (die, func_decl)
static void
add_src_coords_attributes (die, decl)
- register dw_die_ref die;
- register tree decl;
+ dw_die_ref die;
+ tree decl;
{
- register unsigned file_index = lookup_filename (DECL_SOURCE_FILE (decl));
+ unsigned file_index = lookup_filename (DECL_SOURCE_FILE (decl));
add_AT_unsigned (die, DW_AT_decl_file, file_index);
add_AT_unsigned (die, DW_AT_decl_line, DECL_SOURCE_LINE (decl));
@@ -7660,96 +9428,78 @@ add_src_coords_attributes (die, decl)
static void
add_name_and_src_coords_attributes (die, decl)
- register dw_die_ref die;
- register tree decl;
+ dw_die_ref die;
+ tree decl;
{
- register tree decl_name;
+ tree decl_name;
- decl_name = DECL_NAME (decl);
+ decl_name = DECL_NAME (decl);
if (decl_name != NULL && IDENTIFIER_POINTER (decl_name) != NULL)
{
add_name_attribute (die, dwarf2_name (decl, 0));
- add_src_coords_attributes (die, decl);
+ if (! DECL_ARTIFICIAL (decl))
+ add_src_coords_attributes (die, decl);
+
if ((TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == VAR_DECL)
- && DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl))
+ && TREE_PUBLIC (decl)
+ && DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl)
+ && !DECL_ABSTRACT (decl))
add_AT_string (die, DW_AT_MIPS_linkage_name,
IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
}
+
+#ifdef VMS_DEBUGGING_INFO
+ /* Get the function's name, as described by its RTL. This may be different
+ from the DECL_NAME name used in the source file. */
+ if (TREE_CODE (decl) == FUNCTION_DECL && TREE_ASM_WRITTEN (decl))
+ {
+ add_AT_addr (die, DW_AT_VMS_rtnbeg_pd_address,
+ XEXP (DECL_RTL (decl), 0));
+ VARRAY_PUSH_RTX (used_rtx_varray, XEXP (DECL_RTL (decl), 0));
+ }
+#endif
}
-/* Push a new declaration scope. */
+/* Push a new declaration scope. */
static void
push_decl_scope (scope)
tree scope;
{
- tree containing_scope;
- int i;
-
- /* Make room in the decl_scope_table, if necessary. */
- if (decl_scope_table_allocated == decl_scope_depth)
- {
- decl_scope_table_allocated += DECL_SCOPE_TABLE_INCREMENT;
- decl_scope_table
- = (decl_scope_node *) xrealloc (decl_scope_table,
- (decl_scope_table_allocated
- * sizeof (decl_scope_node)));
- }
-
- decl_scope_table[decl_scope_depth].scope = scope;
-
- /* Sometimes, while recursively emitting subtypes within a class type,
- we end up recuring on a subtype at a higher level then the current
- subtype. In such a case, we need to search the decl_scope_table to
- find the parent of this subtype. */
-
- if (AGGREGATE_TYPE_P (scope))
- containing_scope = TYPE_CONTEXT (scope);
- else
- containing_scope = NULL_TREE;
+ VARRAY_PUSH_TREE (decl_scope_table, scope);
+}
- /* The normal case. */
- if (decl_scope_depth == 0
- || containing_scope == NULL_TREE
- /* Ignore namespaces for the moment. */
- || TREE_CODE (containing_scope) == NAMESPACE_DECL
- || containing_scope == decl_scope_table[decl_scope_depth - 1].scope)
- decl_scope_table[decl_scope_depth].previous = decl_scope_depth - 1;
- else
- {
- /* We need to search for the containing_scope. */
- for (i = 0; i < decl_scope_depth; i++)
- if (decl_scope_table[i].scope == containing_scope)
- break;
+/* Pop a declaration scope. */
- if (i == decl_scope_depth)
- abort ();
- else
- decl_scope_table[decl_scope_depth].previous = i;
- }
+static inline void
+pop_decl_scope ()
+{
+ if (VARRAY_ACTIVE_SIZE (decl_scope_table) <= 0)
+ abort ();
- decl_scope_depth++;
+ VARRAY_POP (decl_scope_table);
}
-/* Return the DIE for the scope that immediately contains this declaration. */
+/* Return the DIE for the scope that immediately contains this type.
+ Non-named types get global scope. Named types nested in other
+ types get their containing scope if it's open, or global scope
+ otherwise. All other types (i.e. function-local named types) get
+ the current active scope. */
static dw_die_ref
scope_die_for (t, context_die)
- register tree t;
- register dw_die_ref context_die;
-{
- register dw_die_ref scope_die = NULL;
- register tree containing_scope;
- register int i;
-
- /* Walk back up the declaration tree looking for a place to define
- this type. */
- if (TREE_CODE_CLASS (TREE_CODE (t)) == 't')
- containing_scope = TYPE_CONTEXT (t);
- else if (TREE_CODE (t) == FUNCTION_DECL && DECL_VINDEX (t))
- containing_scope = decl_class_context (t);
- else
- containing_scope = DECL_CONTEXT (t);
+ tree t;
+ dw_die_ref context_die;
+{
+ dw_die_ref scope_die = NULL;
+ tree containing_scope;
+ int i;
+
+ /* Non-types always go in the current scope. */
+ if (! TYPE_P (t))
+ abort ();
+
+ containing_scope = TYPE_CONTEXT (t);
/* Ignore namespaces for the moment. */
if (containing_scope && TREE_CODE (containing_scope) == NAMESPACE_DECL)
@@ -7761,44 +9511,19 @@ scope_die_for (t, context_die)
if (containing_scope && TREE_CODE (containing_scope) == FUNCTION_TYPE)
containing_scope = NULL_TREE;
- /* Function-local tags and functions get stuck in limbo until they are
- fixed up by decls_for_scope. */
- if (context_die == NULL && containing_scope != NULL_TREE
- && (TREE_CODE (t) == FUNCTION_DECL || is_tagged_type (t)))
- return NULL;
-
if (containing_scope == NULL_TREE)
scope_die = comp_unit_die;
- else
+ else if (TYPE_P (containing_scope))
{
- for (i = decl_scope_depth - 1, scope_die = context_die;
- i >= 0 && decl_scope_table[i].scope != containing_scope;
- (scope_die = scope_die->die_parent,
- i = decl_scope_table[i].previous))
- ;
-
- /* ??? Integrate_decl_tree does not handle BLOCK_TYPE_TAGS, nor
- does it try to handle types defined by TYPE_DECLs. Such types
- thus have an incorrect TYPE_CONTEXT, which points to the block
- they were originally defined in, instead of the current block
- created by function inlining. We try to detect that here and
- work around it. */
-
- if (i < 0 && scope_die == comp_unit_die
- && TREE_CODE (containing_scope) == BLOCK
- && is_tagged_type (t)
- && (block_ultimate_origin (decl_scope_table[decl_scope_depth - 1].scope)
- == containing_scope))
- {
- scope_die = context_die;
- /* Since the checks below are no longer applicable. */
- i = 0;
- }
+ /* For types, we can just look up the appropriate DIE. But
+ first we check to see if we're in the middle of emitting it
+ so we know where the new DIE should go. */
+ for (i = VARRAY_ACTIVE_SIZE (decl_scope_table) - 1; i >= 0; --i)
+ if (VARRAY_TREE (decl_scope_table, i) == containing_scope)
+ break;
if (i < 0)
{
- if (TREE_CODE_CLASS (TREE_CODE (containing_scope)) != 't')
- abort ();
if (debug_info_level > DINFO_LEVEL_TERSE
&& !TREE_ASM_WRITTEN (containing_scope))
abort ();
@@ -7806,18 +9531,38 @@ scope_die_for (t, context_die)
/* If none of the current dies are suitable, we get file scope. */
scope_die = comp_unit_die;
}
+ else
+ scope_die = lookup_type_die (containing_scope);
}
+ else
+ scope_die = context_die;
return scope_die;
}
-/* Pop a declaration scope. */
-static inline void
-pop_decl_scope ()
+/* Returns nonzero if CONTEXT_DIE is internal to a function. */
+
+static inline int
+local_scope_p (context_die)
+ dw_die_ref context_die;
{
- if (decl_scope_depth <= 0)
- abort ();
- --decl_scope_depth;
+ for (; context_die; context_die = context_die->die_parent)
+ if (context_die->die_tag == DW_TAG_inlined_subroutine
+ || context_die->die_tag == DW_TAG_subprogram)
+ return 1;
+
+ return 0;
+}
+
+/* Returns nonzero if CONTEXT_DIE is a class. */
+
+static inline int
+class_scope_p (context_die)
+ dw_die_ref context_die;
+{
+ return (context_die
+ && (context_die->die_tag == DW_TAG_structure_type
+ || context_die->die_tag == DW_TAG_union_type));
}
/* Many forms of DIEs require a "type description" attribute. This
@@ -7826,14 +9571,14 @@ pop_decl_scope ()
static void
add_type_attribute (object_die, type, decl_const, decl_volatile, context_die)
- register dw_die_ref object_die;
- register tree type;
- register int decl_const;
- register int decl_volatile;
- register dw_die_ref context_die;
+ dw_die_ref object_die;
+ tree type;
+ int decl_const;
+ int decl_volatile;
+ dw_die_ref context_die;
{
- register enum tree_code code = TREE_CODE (type);
- register dw_die_ref type_die = NULL;
+ enum tree_code code = TREE_CODE (type);
+ dw_die_ref type_die = NULL;
/* ??? If this type is an unnamed subrange type of an integral or
floating-point type, use the inner type. This is because we have no
@@ -7843,19 +9588,18 @@ add_type_attribute (object_die, type, decl_const, decl_volatile, context_die)
&& TREE_TYPE (type) != 0 && TYPE_NAME (type) == 0)
type = TREE_TYPE (type), code = TREE_CODE (type);
- if (code == ERROR_MARK)
- return;
-
- /* Handle a special case. For functions whose return type is void, we
- generate *no* type attribute. (Note that no object may have type
- `void', so this only applies to function return types). */
- if (code == VOID_TYPE)
+ if (code == ERROR_MARK
+ /* Handle a special case. For functions whose return type is void, we
+ generate *no* type attribute. (Note that no object may have type
+ `void', so this only applies to function return types). */
+ || code == VOID_TYPE)
return;
type_die = modified_type_die (type,
decl_const || TYPE_READONLY (type),
decl_volatile || TYPE_VOLATILE (type),
context_die);
+
if (type_die != NULL)
add_AT_die_ref (object_die, DW_AT_type, type_die);
}
@@ -7864,21 +9608,21 @@ add_type_attribute (object_die, type, decl_const, decl_volatile, context_die)
a pointer to the (string) tag name for the given type, or zero if the type
was declared without a tag. */
-static char *
+static const char *
type_tag (type)
- register tree type;
+ tree type;
{
- register char *name = 0;
+ const char *name = 0;
if (TYPE_NAME (type) != 0)
{
- register tree t = 0;
+ tree t = 0;
/* Find the IDENTIFIER_NODE for the type name. */
if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
t = TYPE_NAME (type);
- /* The g++ front end makes the TYPE_NAME of *each* tagged type point to
+ /* The g++ front end makes the TYPE_NAME of *each* tagged type point to
a TYPE_DECL node, regardless of whether or not a `typedef' was
involved. */
else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
@@ -7898,23 +9642,23 @@ type_tag (type)
static inline tree
member_declared_type (member)
- register tree member;
+ tree member;
{
return (DECL_BIT_FIELD_TYPE (member)
- ? DECL_BIT_FIELD_TYPE (member)
- : TREE_TYPE (member));
+ ? DECL_BIT_FIELD_TYPE (member) : TREE_TYPE (member));
}
/* Get the decl's label, as described by its RTL. This may be different
from the DECL_NAME name used in the source file. */
#if 0
-static char *
+static const char *
decl_start_label (decl)
- register tree decl;
+ tree decl;
{
rtx x;
- char *fnname;
+ const char *fnname;
+
x = DECL_RTL (decl);
if (GET_CODE (x) != MEM)
abort ();
@@ -7934,12 +9678,12 @@ decl_start_label (decl)
static void
gen_array_type_die (type, context_die)
- register tree type;
- register dw_die_ref context_die;
+ tree type;
+ dw_die_ref context_die;
{
- register dw_die_ref scope_die = scope_die_for (type, context_die);
- register dw_die_ref array_die;
- register tree element_type;
+ dw_die_ref scope_die = scope_die_for (type, context_die);
+ dw_die_ref array_die;
+ tree element_type;
/* ??? The SGI dwarf reader fails for array of array of enum types unless
the inner array type comes before the outer array type. Thus we must
@@ -7948,7 +9692,7 @@ gen_array_type_die (type, context_die)
gen_type_die (TREE_TYPE (type), context_die);
#endif
- array_die = new_die (DW_TAG_array_type, scope_die);
+ array_die = new_die (DW_TAG_array_type, scope_die, type);
#if 0
/* We default the array ordering. SDB will probably do
@@ -7970,6 +9714,7 @@ gen_array_type_die (type, context_die)
#endif
add_subscript_info (array_die, type);
+ add_name_attribute (array_die, type_tag (type));
equate_type_number_to_die (type, array_die);
/* Add representation of the type of the elements of this array type. */
@@ -7991,11 +9736,11 @@ gen_array_type_die (type, context_die)
static void
gen_set_type_die (type, context_die)
- register tree type;
- register dw_die_ref context_die;
+ tree type;
+ dw_die_ref context_die;
{
- register dw_die_ref type_die
- = new_die (DW_TAG_set_type, scope_die_for (type, context_die));
+ dw_die_ref type_die
+ = new_die (DW_TAG_set_type, scope_die_for (type, context_die), type);
equate_type_number_to_die (type, type_die);
add_type_attribute (type_die, TREE_TYPE (type), 0, 0, context_die);
@@ -8004,11 +9749,12 @@ gen_set_type_die (type, context_die)
#if 0
static void
gen_entry_point_die (decl, context_die)
- register tree decl;
- register dw_die_ref context_die;
+ tree decl;
+ dw_die_ref context_die;
{
- register tree origin = decl_ultimate_origin (decl);
- register dw_die_ref decl_die = new_die (DW_TAG_entry_point, context_die);
+ tree origin = decl_ultimate_origin (decl);
+ dw_die_ref decl_die = new_die (DW_TAG_entry_point, context_die, decl);
+
if (origin != NULL)
add_abstract_origin_attribute (decl_die, origin);
else
@@ -8025,90 +9771,29 @@ gen_entry_point_die (decl, context_die)
}
#endif
-/* Remember a type in the pending_types_list. */
-
-static void
-pend_type (type)
- register tree type;
-{
- if (pending_types == pending_types_allocated)
- {
- pending_types_allocated += PENDING_TYPES_INCREMENT;
- pending_types_list
- = (tree *) xrealloc (pending_types_list,
- sizeof (tree) * pending_types_allocated);
- }
-
- pending_types_list[pending_types++] = type;
-}
-
-/* Output any pending types (from the pending_types list) which we can output
- now (taking into account the scope that we are working on now).
-
- For each type output, remove the given type from the pending_types_list
- *before* we try to output it. */
-
-static void
-output_pending_types_for_scope (context_die)
- register dw_die_ref context_die;
-{
- register tree type;
-
- while (pending_types)
- {
- --pending_types;
- type = pending_types_list[pending_types];
- gen_type_die (type, context_die);
- if (!TREE_ASM_WRITTEN (type))
- abort ();
- }
-}
-
-/* Remember a type in the incomplete_types_list. */
-
-static void
-add_incomplete_type (type)
- tree type;
-{
- if (incomplete_types == incomplete_types_allocated)
- {
- incomplete_types_allocated += INCOMPLETE_TYPES_INCREMENT;
- incomplete_types_list
- = (tree *) xrealloc (incomplete_types_list,
- sizeof (tree) * incomplete_types_allocated);
- }
-
- incomplete_types_list[incomplete_types++] = type;
-}
-
/* Walk through the list of incomplete types again, trying once more to
emit full debugging info for them. */
static void
retry_incomplete_types ()
{
- register tree type;
+ int i;
- while (incomplete_types)
- {
- --incomplete_types;
- type = incomplete_types_list[incomplete_types];
- gen_type_die (type, comp_unit_die);
- }
+ for (i = VARRAY_ACTIVE_SIZE (incomplete_types) - 1; i >= 0; i--)
+ gen_type_die (VARRAY_TREE (incomplete_types, i), comp_unit_die);
}
/* Generate a DIE to represent an inlined instance of an enumeration type. */
static void
gen_inlined_enumeration_type_die (type, context_die)
- register tree type;
- register dw_die_ref context_die;
+ tree type;
+ dw_die_ref context_die;
{
- register dw_die_ref type_die = new_die (DW_TAG_enumeration_type,
- scope_die_for (type, context_die));
+ dw_die_ref type_die = new_die (DW_TAG_enumeration_type, context_die, type);
- if (!TREE_ASM_WRITTEN (type))
- abort ();
+ /* We do not check for TREE_ASM_WRITTEN (type) being set, as the type may
+ be incomplete and such types are not marked. */
add_abstract_origin_attribute (type_die, type);
}
@@ -8116,14 +9801,13 @@ gen_inlined_enumeration_type_die (type, context_die)
static void
gen_inlined_structure_type_die (type, context_die)
- register tree type;
- register dw_die_ref context_die;
+ tree type;
+ dw_die_ref context_die;
{
- register dw_die_ref type_die = new_die (DW_TAG_structure_type,
- scope_die_for (type, context_die));
+ dw_die_ref type_die = new_die (DW_TAG_structure_type, context_die, type);
- if (!TREE_ASM_WRITTEN (type))
- abort ();
+ /* We do not check for TREE_ASM_WRITTEN (type) being set, as the type may
+ be incomplete and such types are not marked. */
add_abstract_origin_attribute (type_die, type);
}
@@ -8131,14 +9815,13 @@ gen_inlined_structure_type_die (type, context_die)
static void
gen_inlined_union_type_die (type, context_die)
- register tree type;
- register dw_die_ref context_die;
+ tree type;
+ dw_die_ref context_die;
{
- register dw_die_ref type_die = new_die (DW_TAG_union_type,
- scope_die_for (type, context_die));
+ dw_die_ref type_die = new_die (DW_TAG_union_type, context_die, type);
- if (!TREE_ASM_WRITTEN (type))
- abort ();
+ /* We do not check for TREE_ASM_WRITTEN (type) being set, as the type may
+ be incomplete and such types are not marked. */
add_abstract_origin_attribute (type_die, type);
}
@@ -8149,15 +9832,15 @@ gen_inlined_union_type_die (type, context_die)
static void
gen_enumeration_type_die (type, context_die)
- register tree type;
- register dw_die_ref context_die;
+ tree type;
+ dw_die_ref context_die;
{
- register dw_die_ref type_die = lookup_type_die (type);
+ dw_die_ref type_die = lookup_type_die (type);
if (type_die == NULL)
{
type_die = new_die (DW_TAG_enumeration_type,
- scope_die_for (type, context_die));
+ scope_die_for (type, context_die), type);
equate_type_number_to_die (type, type_die);
add_name_attribute (type_die, type_tag (type));
}
@@ -8171,7 +9854,7 @@ gen_enumeration_type_die (type, context_die)
attribute or the DW_AT_element_list attribute. */
if (TYPE_SIZE (type))
{
- register tree link;
+ tree link;
TREE_ASM_WRITTEN (type) = 1;
add_byte_size_attribute (type_die, type);
@@ -8186,19 +9869,26 @@ gen_enumeration_type_die (type, context_die)
for (link = TYPE_FIELDS (type);
link != NULL; link = TREE_CHAIN (link))
{
- register dw_die_ref enum_die = new_die (DW_TAG_enumerator, type_die);
+ dw_die_ref enum_die = new_die (DW_TAG_enumerator, type_die, link);
add_name_attribute (enum_die,
IDENTIFIER_POINTER (TREE_PURPOSE (link)));
- add_AT_unsigned (enum_die, DW_AT_const_value,
- (unsigned) TREE_INT_CST_LOW (TREE_VALUE (link)));
+
+ if (host_integerp (TREE_VALUE (link), 0))
+ {
+ 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), 0));
+ }
}
}
else
add_AT_flag (type_die, DW_AT_declaration, 1);
}
-
/* Generate a DIE to represent either a real live formal parameter decl or to
represent just the type of some formal parameter position in some function
type.
@@ -8214,12 +9904,12 @@ gen_enumeration_type_die (type, context_die)
static dw_die_ref
gen_formal_parameter_die (node, context_die)
- register tree node;
- register dw_die_ref context_die;
+ tree node;
+ dw_die_ref context_die;
{
- register dw_die_ref parm_die
- = new_die (DW_TAG_formal_parameter, context_die);
- register tree origin;
+ dw_die_ref parm_die
+ = new_die (DW_TAG_formal_parameter, context_die, node);
+ tree origin;
switch (TREE_CODE_CLASS (TREE_CODE (node)))
{
@@ -8261,59 +9951,57 @@ gen_formal_parameter_die (node, context_die)
static void
gen_unspecified_parameters_die (decl_or_type, context_die)
- register tree decl_or_type;
- register dw_die_ref context_die;
+ tree decl_or_type;
+ dw_die_ref context_die;
{
- new_die (DW_TAG_unspecified_parameters, context_die);
+ new_die (DW_TAG_unspecified_parameters, context_die, decl_or_type);
}
/* Generate a list of nameless DW_TAG_formal_parameter DIEs (and perhaps a
DW_TAG_unspecified_parameters DIE) to represent the types of the formal
parameters as specified in some function type specification (except for
- those which appear as part of a function *definition*).
-
- Note we must be careful here to output all of the parameter DIEs before*
- we output any DIEs needed to represent the types of the formal parameters.
- This keeps svr4 SDB happy because it (incorrectly) thinks that the first
- non-parameter DIE it sees ends the formal parameter list. */
+ those which appear as part of a function *definition*). */
static void
gen_formal_types_die (function_or_method_type, context_die)
- register tree function_or_method_type;
- register dw_die_ref context_die;
+ tree function_or_method_type;
+ dw_die_ref context_die;
{
- register tree link;
- register tree formal_type = NULL;
- register tree first_parm_type = TYPE_ARG_TYPES (function_or_method_type);
+ tree link;
+ tree formal_type = NULL;
+ tree first_parm_type;
+ tree arg;
-#if 0
- /* In the case where we are generating a formal types list for a C++
- non-static member function type, skip over the first thing on the
- TYPE_ARG_TYPES list because it only represents the type of the hidden
- `this pointer'. The debugger should be able to figure out (without
- being explicitly told) that this non-static member function type takes a
- `this pointer' and should be able to figure what the type of that hidden
- parameter is from the DW_AT_member attribute of the parent
- DW_TAG_subroutine_type DIE. */
- if (TREE_CODE (function_or_method_type) == METHOD_TYPE)
- first_parm_type = TREE_CHAIN (first_parm_type);
-#endif
+ if (TREE_CODE (function_or_method_type) == FUNCTION_DECL)
+ {
+ arg = DECL_ARGUMENTS (function_or_method_type);
+ function_or_method_type = TREE_TYPE (function_or_method_type);
+ }
+ else
+ arg = NULL_TREE;
+
+ first_parm_type = TYPE_ARG_TYPES (function_or_method_type);
- /* Make our first pass over the list of formal parameter types and output a
+ /* Make our first pass over the list of formal parameter types and output a
DW_TAG_formal_parameter DIE for each one. */
- for (link = first_parm_type; link; link = TREE_CHAIN (link))
+ for (link = first_parm_type; link; )
{
- register dw_die_ref parm_die;
-
+ dw_die_ref parm_die;
+
formal_type = TREE_VALUE (link);
if (formal_type == void_type_node)
break;
/* Output a (nameless) DIE to represent the formal parameter itself. */
parm_die = gen_formal_parameter_die (formal_type, context_die);
- if (TREE_CODE (function_or_method_type) == METHOD_TYPE
- && link == first_parm_type)
+ if ((TREE_CODE (function_or_method_type) == METHOD_TYPE
+ && link == first_parm_type)
+ || (arg && DECL_ARTIFICIAL (arg)))
add_AT_flag (parm_die, DW_AT_artificial, 1);
+
+ link = TREE_CHAIN (link);
+ if (arg)
+ arg = TREE_CHAIN (arg);
}
/* If this function type has an ellipsis, add a
@@ -8321,70 +10009,147 @@ gen_formal_types_die (function_or_method_type, context_die)
if (formal_type != void_type_node)
gen_unspecified_parameters_die (function_or_method_type, context_die);
- /* Make our second (and final) pass over the list of formal parameter types
+ /* Make our second (and final) pass over the list of formal parameter types
and output DIEs to represent those types (as necessary). */
for (link = TYPE_ARG_TYPES (function_or_method_type);
- link;
+ link && TREE_VALUE (link);
link = TREE_CHAIN (link))
+ gen_type_die (TREE_VALUE (link), context_die);
+}
+
+/* We want to generate the DIE for TYPE so that we can generate the
+ die for MEMBER, which has been defined; we will need to refer back
+ to the member declaration nested within TYPE. If we're trying to
+ generate minimal debug info for TYPE, processing TYPE won't do the
+ trick; we need to attach the member declaration by hand. */
+
+static void
+gen_type_die_for_member (type, member, context_die)
+ tree type, member;
+ dw_die_ref context_die;
+{
+ gen_type_die (type, context_die);
+
+ /* If we're trying to avoid duplicate debug info, we may not have
+ emitted the member decl for this function. Emit it now. */
+ if (TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (type))
+ && ! lookup_decl_die (member))
{
- formal_type = TREE_VALUE (link);
- if (formal_type == void_type_node)
- break;
+ if (decl_ultimate_origin (member))
+ abort ();
+
+ push_decl_scope (type);
+ if (TREE_CODE (member) == FUNCTION_DECL)
+ gen_subprogram_die (member, lookup_type_die (type));
+ else
+ gen_variable_die (member, lookup_type_die (type));
- gen_type_die (formal_type, context_die);
+ pop_decl_scope ();
}
}
+/* Generate the DWARF2 info for the "abstract" instance of a function which we
+ may later generate inlined and/or out-of-line instances of. */
+
+static void
+dwarf2out_abstract_function (decl)
+ tree decl;
+{
+ dw_die_ref old_die;
+ tree save_fn;
+ tree context;
+ int was_abstract = DECL_ABSTRACT (decl);
+
+ /* Make sure we have the actual abstract inline, not a clone. */
+ decl = DECL_ORIGIN (decl);
+
+ old_die = lookup_decl_die (decl);
+ if (old_die && get_AT_unsigned (old_die, DW_AT_inline))
+ /* We've already generated the abstract instance. */
+ return;
+
+ /* Be sure we've emitted the in-class declaration DIE (if any) first, so
+ we don't get confused by DECL_ABSTRACT. */
+ if (debug_info_level > DINFO_LEVEL_TERSE)
+ {
+ context = decl_class_context (decl);
+ if (context)
+ gen_type_die_for_member
+ (context, decl, decl_function_context (decl) ? NULL : comp_unit_die);
+ }
+
+ /* Pretend we've just finished compiling this function. */
+ save_fn = current_function_decl;
+ current_function_decl = decl;
+
+ set_decl_abstract_flags (decl, 1);
+ dwarf2out_decl (decl);
+ if (! was_abstract)
+ set_decl_abstract_flags (decl, 0);
+
+ current_function_decl = save_fn;
+}
+
/* Generate a DIE to represent a declared function (either file-scope or
block-local). */
static void
gen_subprogram_die (decl, context_die)
- register tree decl;
- register dw_die_ref context_die;
+ tree decl;
+ dw_die_ref context_die;
{
char label_id[MAX_ARTIFICIAL_LABEL_BYTES];
- register tree origin = decl_ultimate_origin (decl);
- register dw_die_ref subr_die;
- register rtx fp_reg;
- register tree fn_arg_types;
- register tree outer_scope;
- register dw_die_ref old_die = lookup_decl_die (decl);
- register int declaration
- = (current_function_decl != decl
- || (context_die
- && (context_die->die_tag == DW_TAG_structure_type
- || context_die->die_tag == DW_TAG_union_type)));
+ tree origin = decl_ultimate_origin (decl);
+ dw_die_ref subr_die;
+ rtx fp_reg;
+ tree fn_arg_types;
+ tree outer_scope;
+ dw_die_ref old_die = lookup_decl_die (decl);
+ int declaration = (current_function_decl != decl
+ || class_scope_p (context_die));
- if (origin != NULL)
+ /* It is possible to have both DECL_ABSTRACT and DECLARATION be true if we
+ started to generate the abstract instance of an inline, decided to output
+ its containing class, and proceeded to emit the declaration of the inline
+ from the member list for the class. If so, DECLARATION takes priority;
+ we'll get back to the abstract instance when done with the class. */
+
+ /* The class-scope declaration DIE must be the primary DIE. */
+ if (origin && declaration && class_scope_p (context_die))
{
- subr_die = new_die (DW_TAG_subprogram, context_die);
- add_abstract_origin_attribute (subr_die, origin);
+ origin = NULL;
+ if (old_die)
+ abort ();
}
- else if (old_die && DECL_ABSTRACT (decl)
- && get_AT_unsigned (old_die, DW_AT_inline))
+
+ if (origin != NULL)
{
- /* This must be a redefinition of an extern inline function.
- We can just reuse the old die here. */
- subr_die = old_die;
+ if (declaration && ! local_scope_p (context_die))
+ abort ();
+
+ /* Fixup die_parent for the abstract instance of a nested
+ inline function. */
+ if (old_die && old_die->die_parent == NULL)
+ add_child_die (context_die, old_die);
- /* Clear out the inlined attribute and parm types. */
- remove_AT (subr_die, DW_AT_inline);
- remove_children (subr_die);
+ subr_die = new_die (DW_TAG_subprogram, context_die, decl);
+ add_abstract_origin_attribute (subr_die, origin);
}
else if (old_die)
{
- register unsigned file_index
- = lookup_filename (DECL_SOURCE_FILE (decl));
+ unsigned file_index = lookup_filename (DECL_SOURCE_FILE (decl));
- if (get_AT_flag (old_die, DW_AT_declaration) != 1)
+ if (!get_AT_flag (old_die, DW_AT_declaration)
+ /* We can have a normal definition following an inline one in the
+ case of redefinition of GNU C extern inlines.
+ It seems reasonable to use AT_specification in this case. */
+ && !get_AT_unsigned (old_die, DW_AT_inline))
{
/* ??? This can happen if there is a bug in the program, for
instance, if it has duplicate function definitions. Ideally,
we should detect this case and ignore it. For now, if we have
already reported an error, any error at all, then assume that
- we got here because of a input error, not a dwarf2 bug. */
- extern int errorcount;
+ we got here because of an input error, not a dwarf2 bug. */
if (errorcount)
return;
abort ();
@@ -8393,15 +10158,15 @@ gen_subprogram_die (decl, context_die)
/* If the definition comes from the same place as the declaration,
maybe use the old DIE. We always want the DIE for this function
that has the *_pc attributes to be under comp_unit_die so the
- debugger can find it. For inlines, that is the concrete instance,
- so we can use the old DIE here. For non-inline methods, we want a
- specification DIE at toplevel, so we need a new DIE. For local
- class methods, this does not apply. */
- if ((DECL_ABSTRACT (decl) || old_die->die_parent == comp_unit_die
- || context_die == NULL)
- && get_AT_unsigned (old_die, DW_AT_decl_file) == file_index
- && (get_AT_unsigned (old_die, DW_AT_decl_line)
- == DECL_SOURCE_LINE (decl)))
+ debugger can find it. We also need to do this for abstract
+ instances of inlines, since the spec requires the out-of-line copy
+ to have the same parent. For local class methods, this doesn't
+ apply; we just use the old DIE. */
+ if ((old_die->die_parent == comp_unit_die || context_die == NULL)
+ && (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)))))
{
subr_die = old_die;
@@ -8411,43 +10176,35 @@ gen_subprogram_die (decl, context_die)
}
else
{
- subr_die = new_die (DW_TAG_subprogram, context_die);
+ subr_die = new_die (DW_TAG_subprogram, context_die, decl);
add_AT_die_ref (subr_die, DW_AT_specification, old_die);
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)
- != DECL_SOURCE_LINE (decl))
+ != (unsigned) DECL_SOURCE_LINE (decl))
add_AT_unsigned
(subr_die, DW_AT_decl_line, DECL_SOURCE_LINE (decl));
}
}
else
{
- register dw_die_ref scope_die;
-
- if (DECL_CONTEXT (decl))
- scope_die = scope_die_for (decl, context_die);
- else
- /* Don't put block extern declarations under comp_unit_die. */
- scope_die = context_die;
+ subr_die = new_die (DW_TAG_subprogram, context_die, decl);
- subr_die = new_die (DW_TAG_subprogram, scope_die);
-
if (TREE_PUBLIC (decl))
add_AT_flag (subr_die, DW_AT_external, 1);
add_name_and_src_coords_attributes (subr_die, decl);
if (debug_info_level > DINFO_LEVEL_TERSE)
{
- register tree type = TREE_TYPE (decl);
-
- add_prototyped_attribute (subr_die, type);
- add_type_attribute (subr_die, TREE_TYPE (type), 0, 0, context_die);
+ add_prototyped_attribute (subr_die, TREE_TYPE (decl));
+ add_type_attribute (subr_die, TREE_TYPE (TREE_TYPE (decl)),
+ 0, 0, context_die);
}
add_pure_or_virtual_attribute (subr_die, decl);
if (DECL_ARTIFICIAL (decl))
add_AT_flag (subr_die, DW_AT_artificial, 1);
+
if (TREE_PROTECTED (decl))
add_AT_unsigned (subr_die, DW_AT_accessibility, DW_ACCESS_protected);
else if (TREE_PRIVATE (decl))
@@ -8456,39 +10213,40 @@ gen_subprogram_die (decl, context_die)
if (declaration)
{
- add_AT_flag (subr_die, DW_AT_declaration, 1);
-
- /* 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))
- equate_decl_number_to_die (decl, subr_die);
+ if (!old_die || !get_AT_unsigned (old_die, DW_AT_inline))
+ {
+ add_AT_flag (subr_die, DW_AT_declaration, 1);
+
+ /* 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))
+ equate_decl_number_to_die (decl, subr_die);
+ }
}
else if (DECL_ABSTRACT (decl))
{
- /* ??? Checking DECL_DEFER_OUTPUT is correct for static inline functions,
- but not for extern inline functions. We can't get this completely
- correct because information about whether the function was declared
- inline is not saved anywhere. */
- if (DECL_DEFER_OUTPUT (decl))
+ if (DECL_INLINE (decl) && !flag_no_inline)
{
- if (DECL_INLINE (decl))
+ /* ??? Checking DECL_DEFER_OUTPUT is correct for static
+ inline functions, but not for extern inline functions.
+ We can't get this completely correct because information
+ about whether the function was declared inline is not
+ saved anywhere. */
+ if (DECL_DEFER_OUTPUT (decl))
add_AT_unsigned (subr_die, DW_AT_inline, DW_INL_declared_inlined);
else
- add_AT_unsigned (subr_die, DW_AT_inline,
- DW_INL_declared_not_inlined);
+ add_AT_unsigned (subr_die, DW_AT_inline, DW_INL_inlined);
}
- else if (DECL_INLINE (decl))
- add_AT_unsigned (subr_die, DW_AT_inline, DW_INL_inlined);
else
- abort ();
+ add_AT_unsigned (subr_die, DW_AT_inline, DW_INL_declared_not_inlined);
equate_decl_number_to_die (decl, subr_die);
}
else if (!DECL_EXTERNAL (decl))
{
- if (origin == NULL_TREE)
+ if (!old_die || !get_AT_unsigned (old_die, DW_AT_inline))
equate_decl_number_to_die (decl, subr_die);
ASM_GENERATE_INTERNAL_LABEL (label_id, FUNC_BEGIN_LABEL,
@@ -8523,28 +10281,27 @@ gen_subprogram_die (decl, context_die)
}
/* Now output descriptions of the arguments for this function. This gets
- (unnecessarily?) complex because of the fact that the DECL_ARGUMENT list
+ (unnecessarily?) complex because of the fact that the DECL_ARGUMENT list
for a FUNCTION_DECL doesn't indicate cases where there was a trailing
`...' at the end of the formal parameter list. In order to find out if
there was a trailing ellipsis or not, we must instead look at the type
associated with the FUNCTION_DECL. This will be a node of type
FUNCTION_TYPE. If the chain of type nodes hanging off of this
- FUNCTION_TYPE node ends with a void_type_node then there should *not* be
+ FUNCTION_TYPE node ends with a void_type_node then there should *not* be
an ellipsis at the end. */
- push_decl_scope (decl);
/* In the case where we are describing a mere function declaration, all we
- need to do here (and all we *can* do here) is to describe the *types* of
+ need to do here (and all we *can* do here) is to describe the *types* of
its formal parameters. */
if (debug_info_level <= DINFO_LEVEL_TERSE)
;
else if (declaration)
- gen_formal_types_die (TREE_TYPE (decl), subr_die);
+ gen_formal_types_die (decl, subr_die);
else
{
/* Generate DIEs to represent all known formal parameters */
- register tree arg_decls = DECL_ARGUMENTS (decl);
- register tree parm;
+ tree arg_decls = DECL_ARGUMENTS (decl);
+ tree parm;
/* When generating DIEs, generate the unspecified_parameters DIE
instead if we come across the arg "__builtin_va_alist" */
@@ -8559,8 +10316,8 @@ gen_subprogram_die (decl, context_die)
gen_decl_die (parm, subr_die);
}
- /* Decide whether we need a unspecified_parameters DIE at the end.
- There are 2 more cases to do this for: 1) the ansi ... declaration -
+ /* Decide whether we need an unspecified_parameters DIE at the end.
+ There are 2 more cases to do this for: 1) the ansi ... declaration -
this is detectable when the end of the arg list is not a
void_type_node 2) an unprototyped function declaration (not a
definition). This just means that we have no info about the
@@ -8580,19 +10337,19 @@ gen_subprogram_die (decl, context_die)
(if it has one - it may be just a declaration). */
outer_scope = DECL_INITIAL (decl);
- /* Note that here, `outer_scope' is a pointer to the outermost BLOCK
- node created to represent a function. This outermost BLOCK actually
- represents the outermost binding contour for the function, i.e. the
- contour in which the function's formal parameters and labels get
- declared. Curiously, it appears that the front end doesn't actually
- put the PARM_DECL nodes for the current function onto the BLOCK_VARS
- list for this outer scope. (They are strung off of the DECL_ARGUMENTS
- list for the function instead.) The BLOCK_VARS list for the
- `outer_scope' does provide us with a list of the LABEL_DECL nodes for
- the function however, and we output DWARF info for those in
- decls_for_scope. Just within the `outer_scope' there will be a BLOCK
- node representing the function's outermost pair of curly braces, and
- any blocks used for the base and member initializers of a C++
+ /* OUTER_SCOPE is a pointer to the outermost BLOCK node created to represent
+ a function. This BLOCK actually represents the outermost binding contour
+ for the function, i.e. the contour in which the function's formal
+ parameters and labels get declared. Curiously, it appears that the front
+ end doesn't actually put the PARM_DECL nodes for the current function onto
+ the BLOCK_VARS list for this outer scope, but are strung off of the
+ DECL_ARGUMENTS list for the function instead.
+
+ The BLOCK_VARS list for the `outer_scope' does provide us with a list of
+ the LABEL_DECL nodes for the function however, and we output DWARF info
+ for those in decls_for_scope. Just within the `outer_scope' there will be
+ a BLOCK node representing the function's outermost pair of curly braces,
+ and any blocks used for the base and member initializers of a C++
constructor function. */
if (! declaration && TREE_CODE (outer_scope) != ERROR_MARK)
{
@@ -8611,49 +10368,47 @@ gen_subprogram_die (decl, context_die)
}
#endif
}
-
- pop_decl_scope ();
}
/* Generate a DIE to represent a declared data object. */
static void
gen_variable_die (decl, context_die)
- register tree decl;
- register dw_die_ref context_die;
+ tree decl;
+ dw_die_ref context_die;
{
- register tree origin = decl_ultimate_origin (decl);
- register dw_die_ref var_die = new_die (DW_TAG_variable, context_die);
+ tree origin = decl_ultimate_origin (decl);
+ dw_die_ref var_die = new_die (DW_TAG_variable, context_die, decl);
dw_die_ref old_die = lookup_decl_die (decl);
- int declaration
- = (DECL_EXTERNAL (decl)
- || current_function_decl != decl_function_context (decl)
- || context_die->die_tag == DW_TAG_structure_type
- || context_die->die_tag == DW_TAG_union_type);
+ int declaration = (DECL_EXTERNAL (decl)
+ || class_scope_p (context_die));
if (origin != NULL)
add_abstract_origin_attribute (var_die, origin);
+
/* Loop unrolling can create multiple blocks that refer to the same
- static variable, so we must test for the DW_AT_declaration flag. */
- /* ??? Loop unrolling/reorder_blocks should perhaps be rewritten to
+ static variable, so we must test for the DW_AT_declaration flag.
+
+ ??? Loop unrolling/reorder_blocks should perhaps be rewritten to
copy decls and set the DECL_ABSTRACT flag on them instead of
- sharing them. */
+ sharing them.
+
+ ??? Duplicated blocks have been rewritten to use .debug_ranges. */
else if (old_die && TREE_STATIC (decl)
&& get_AT_flag (old_die, DW_AT_declaration) == 1)
{
- /* ??? This is an instantiation of a C++ class level static. */
+ /* This is a definition of a C++ class level static. */
add_AT_die_ref (var_die, DW_AT_specification, old_die);
if (DECL_NAME (decl))
{
- register unsigned file_index
- = lookup_filename (DECL_SOURCE_FILE (decl));
+ unsigned file_index = lookup_filename (DECL_SOURCE_FILE (decl));
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)
- != DECL_SOURCE_LINE (decl))
+ != (unsigned) DECL_SOURCE_LINE (decl))
add_AT_unsigned (var_die, DW_AT_decl_line,
DECL_SOURCE_LINE (decl));
@@ -8662,8 +10417,7 @@ gen_variable_die (decl, context_die)
else
{
add_name_and_src_coords_attributes (var_die, decl);
- add_type_attribute (var_die, TREE_TYPE (decl),
- TREE_READONLY (decl),
+ add_type_attribute (var_die, TREE_TYPE (decl), TREE_READONLY (decl),
TREE_THIS_VOLATILE (decl), context_die);
if (TREE_PUBLIC (decl))
@@ -8674,37 +10428,36 @@ gen_variable_die (decl, context_die)
if (TREE_PROTECTED (decl))
add_AT_unsigned (var_die, DW_AT_accessibility, DW_ACCESS_protected);
-
else if (TREE_PRIVATE (decl))
add_AT_unsigned (var_die, DW_AT_accessibility, DW_ACCESS_private);
}
if (declaration)
add_AT_flag (var_die, DW_AT_declaration, 1);
-
- if ((declaration && decl_class_context (decl)) || DECL_ABSTRACT (decl))
+
+ if (class_scope_p (context_die) || DECL_ABSTRACT (decl))
equate_decl_number_to_die (decl, var_die);
if (! declaration && ! DECL_ABSTRACT (decl))
{
- equate_decl_number_to_die (decl, var_die);
add_location_or_const_value_attribute (var_die, decl);
add_pubname (decl, var_die);
}
+ else
+ tree_add_const_value_attribute (var_die, decl);
}
/* Generate a DIE to represent a label identifier. */
static void
gen_label_die (decl, context_die)
- register tree decl;
- register dw_die_ref context_die;
+ tree decl;
+ dw_die_ref context_die;
{
- register tree origin = decl_ultimate_origin (decl);
- register dw_die_ref lbl_die = new_die (DW_TAG_label, context_die);
- register rtx insn;
+ tree origin = decl_ultimate_origin (decl);
+ dw_die_ref lbl_die = new_die (DW_TAG_label, context_die, decl);
+ rtx insn;
char label[MAX_ARTIFICIAL_LABEL_BYTES];
- char label2[MAX_ARTIFICIAL_LABEL_BYTES];
if (origin != NULL)
add_abstract_origin_attribute (lbl_die, origin);
@@ -8724,17 +10477,15 @@ gen_label_die (decl, context_die)
|| ((GET_CODE (insn) == NOTE
&& NOTE_LINE_NUMBER (insn) == NOTE_INSN_DELETED_LABEL)))
{
- /* When optimization is enabled (via -O) some parts of the compiler
- (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which
+ /* When optimization is enabled (via -O) some parts of the compiler
+ (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which
represent source-level labels which were explicitly declared by
the user. This really shouldn't be happening though, so catch
it if it ever does happen. */
if (INSN_DELETED_P (insn))
abort ();
- sprintf (label2, INSN_LABEL_FMT, current_funcdef_number);
- ASM_GENERATE_INTERNAL_LABEL (label, label2,
- (unsigned) INSN_UID (insn));
+ ASM_GENERATE_INTERNAL_LABEL (label, "L", CODE_LABEL_NUMBER (insn));
add_AT_lbl_id (lbl_die, DW_AT_low_pc, label);
}
}
@@ -8744,51 +10495,70 @@ gen_label_die (decl, context_die)
static void
gen_lexical_block_die (stmt, context_die, depth)
- register tree stmt;
- register dw_die_ref context_die;
+ tree stmt;
+ dw_die_ref context_die;
int depth;
{
- register dw_die_ref stmt_die = new_die (DW_TAG_lexical_block, context_die);
+ dw_die_ref stmt_die = new_die (DW_TAG_lexical_block, context_die, stmt);
char label[MAX_ARTIFICIAL_LABEL_BYTES];
if (! BLOCK_ABSTRACT (stmt))
{
- ASM_GENERATE_INTERNAL_LABEL (label, BLOCK_BEGIN_LABEL,
- next_block_number);
- add_AT_lbl_id (stmt_die, DW_AT_low_pc, label);
- ASM_GENERATE_INTERNAL_LABEL (label, BLOCK_END_LABEL, next_block_number);
- add_AT_lbl_id (stmt_die, DW_AT_high_pc, label);
+ if (BLOCK_FRAGMENT_CHAIN (stmt))
+ {
+ tree chain;
+
+ add_AT_range_list (stmt_die, DW_AT_ranges, add_ranges (stmt));
+
+ chain = BLOCK_FRAGMENT_CHAIN (stmt);
+ do
+ {
+ add_ranges (chain);
+ chain = BLOCK_FRAGMENT_CHAIN (chain);
+ }
+ while (chain);
+ add_ranges (NULL);
+ }
+ else
+ {
+ ASM_GENERATE_INTERNAL_LABEL (label, BLOCK_BEGIN_LABEL,
+ BLOCK_NUMBER (stmt));
+ add_AT_lbl_id (stmt_die, DW_AT_low_pc, label);
+ ASM_GENERATE_INTERNAL_LABEL (label, BLOCK_END_LABEL,
+ BLOCK_NUMBER (stmt));
+ add_AT_lbl_id (stmt_die, DW_AT_high_pc, label);
+ }
}
- push_decl_scope (stmt);
decls_for_scope (stmt, stmt_die, depth);
- pop_decl_scope ();
}
/* Generate a DIE for an inlined subprogram. */
static void
gen_inlined_subroutine_die (stmt, context_die, depth)
- register tree stmt;
- register dw_die_ref context_die;
+ tree stmt;
+ dw_die_ref context_die;
int depth;
{
if (! BLOCK_ABSTRACT (stmt))
{
- register dw_die_ref subr_die
- = new_die (DW_TAG_inlined_subroutine, context_die);
- register tree decl = block_ultimate_origin (stmt);
+ dw_die_ref subr_die
+ = new_die (DW_TAG_inlined_subroutine, context_die, stmt);
+ tree decl = block_ultimate_origin (stmt);
char label[MAX_ARTIFICIAL_LABEL_BYTES];
+ /* Emit info for the abstract instance first, if we haven't yet. */
+ dwarf2out_abstract_function (decl);
+
add_abstract_origin_attribute (subr_die, decl);
ASM_GENERATE_INTERNAL_LABEL (label, BLOCK_BEGIN_LABEL,
- next_block_number);
+ BLOCK_NUMBER (stmt));
add_AT_lbl_id (subr_die, DW_AT_low_pc, label);
- ASM_GENERATE_INTERNAL_LABEL (label, BLOCK_END_LABEL, next_block_number);
+ ASM_GENERATE_INTERNAL_LABEL (label, BLOCK_END_LABEL,
+ BLOCK_NUMBER (stmt));
add_AT_lbl_id (subr_die, DW_AT_high_pc, label);
- push_decl_scope (decl);
decls_for_scope (stmt, subr_die, depth);
- pop_decl_scope ();
current_function_has_inlines = 1;
}
}
@@ -8797,17 +10567,16 @@ gen_inlined_subroutine_die (stmt, context_die, depth)
static void
gen_field_die (decl, context_die)
- register tree decl;
- register dw_die_ref context_die;
+ tree decl;
+ dw_die_ref context_die;
{
- register dw_die_ref decl_die = new_die (DW_TAG_member, context_die);
+ dw_die_ref decl_die = new_die (DW_TAG_member, context_die, decl);
add_name_and_src_coords_attributes (decl_die, decl);
add_type_attribute (decl_die, member_declared_type (decl),
TREE_READONLY (decl), TREE_THIS_VOLATILE (decl),
context_die);
- /* If this is a bit field... */
if (DECL_BIT_FIELD_TYPE (decl))
{
add_byte_size_attribute (decl_die, decl);
@@ -8823,7 +10592,6 @@ gen_field_die (decl, context_die)
if (TREE_PROTECTED (decl))
add_AT_unsigned (decl_die, DW_AT_accessibility, DW_ACCESS_protected);
-
else if (TREE_PRIVATE (decl))
add_AT_unsigned (decl_die, DW_AT_accessibility, DW_ACCESS_private);
}
@@ -8833,13 +10601,14 @@ gen_field_die (decl, context_die)
Use modified_type_die instead.
We keep this code here just in case these types of DIEs may be needed to
represent certain things in other languages (e.g. Pascal) someday. */
+
static void
gen_pointer_type_die (type, context_die)
- register tree type;
- register dw_die_ref context_die;
+ tree type;
+ dw_die_ref context_die;
{
- register dw_die_ref ptr_die
- = new_die (DW_TAG_pointer_type, scope_die_for (type, context_die));
+ dw_die_ref ptr_die
+ = new_die (DW_TAG_pointer_type, scope_die_for (type, context_die), type);
equate_type_number_to_die (type, ptr_die);
add_type_attribute (ptr_die, TREE_TYPE (type), 0, 0, context_die);
@@ -8850,13 +10619,14 @@ gen_pointer_type_die (type, context_die)
Use modified_type_die instead.
We keep this code here just in case these types of DIEs may be needed to
represent certain things in other languages (e.g. Pascal) someday. */
+
static void
gen_reference_type_die (type, context_die)
- register tree type;
- register dw_die_ref context_die;
+ tree type;
+ dw_die_ref context_die;
{
- register dw_die_ref ref_die
- = new_die (DW_TAG_reference_type, scope_die_for (type, context_die));
+ dw_die_ref ref_die
+ = new_die (DW_TAG_reference_type, scope_die_for (type, context_die), type);
equate_type_number_to_die (type, ref_die);
add_type_attribute (ref_die, TREE_TYPE (type), 0, 0, context_die);
@@ -8865,13 +10635,15 @@ gen_reference_type_die (type, context_die)
#endif
/* Generate a DIE for a pointer to a member type. */
+
static void
gen_ptr_to_mbr_type_die (type, context_die)
- register tree type;
- register dw_die_ref context_die;
+ tree type;
+ dw_die_ref context_die;
{
- register dw_die_ref ptr_die
- = new_die (DW_TAG_ptr_to_member_type, scope_die_for (type, context_die));
+ dw_die_ref ptr_die
+ = new_die (DW_TAG_ptr_to_member_type,
+ scope_die_for (type, context_die), type);
equate_type_number_to_die (type, ptr_die);
add_AT_die_ref (ptr_die, DW_AT_containing_type,
@@ -8881,18 +10653,21 @@ gen_ptr_to_mbr_type_die (type, context_die)
/* Generate the DIE for the compilation unit. */
-static void
-gen_compile_unit_die (main_input_filename)
- register char *main_input_filename;
+static dw_die_ref
+gen_compile_unit_die (filename)
+ const char *filename;
{
+ dw_die_ref die;
char producer[250];
- char *wd = getpwd ();
+ const char *wd = getpwd ();
+ const char *language_string = lang_hooks.name;
+ int language;
- comp_unit_die = new_die (DW_TAG_compile_unit, NULL);
- add_name_attribute (comp_unit_die, main_input_filename);
+ die = new_die (DW_TAG_compile_unit, NULL, NULL);
+ add_name_attribute (die, filename);
- if (wd != NULL)
- add_AT_string (comp_unit_die, DW_AT_comp_dir, wd);
+ if (wd != NULL && filename[0] != DIR_SEPARATOR)
+ add_AT_string (die, DW_AT_comp_dir, wd);
sprintf (producer, "%s %s", language_string, version_string);
@@ -8907,65 +10682,62 @@ gen_compile_unit_die (main_input_filename)
strcat (producer, " -g");
#endif
- add_AT_string (comp_unit_die, DW_AT_producer, producer);
+ add_AT_string (die, DW_AT_producer, producer);
if (strcmp (language_string, "GNU C++") == 0)
- add_AT_unsigned (comp_unit_die, DW_AT_language, DW_LANG_C_plus_plus);
-
+ language = DW_LANG_C_plus_plus;
else if (strcmp (language_string, "GNU Ada") == 0)
- add_AT_unsigned (comp_unit_die, DW_AT_language, DW_LANG_Ada83);
-
+ language = DW_LANG_Ada83;
else if (strcmp (language_string, "GNU F77") == 0)
- add_AT_unsigned (comp_unit_die, DW_AT_language, DW_LANG_Fortran77);
-
+ language = DW_LANG_Fortran77;
else if (strcmp (language_string, "GNU Pascal") == 0)
- add_AT_unsigned (comp_unit_die, DW_AT_language, DW_LANG_Pascal83);
-
+ language = DW_LANG_Pascal83;
+ else if (strcmp (language_string, "GNU Java") == 0)
+ language = DW_LANG_Java;
else if (flag_traditional)
- add_AT_unsigned (comp_unit_die, DW_AT_language, DW_LANG_C);
-
+ language = DW_LANG_C;
else
- add_AT_unsigned (comp_unit_die, DW_AT_language, DW_LANG_C89);
+ language = DW_LANG_C89;
-#if 0 /* unimplemented */
- if (debug_info_level >= DINFO_LEVEL_VERBOSE)
- add_AT_unsigned (comp_unit_die, DW_AT_macro_info, 0);
-#endif
+ add_AT_unsigned (die, DW_AT_language, language);
+ return die;
}
/* Generate a DIE for a string type. */
static void
gen_string_type_die (type, context_die)
- register tree type;
- register dw_die_ref context_die;
+ tree type;
+ dw_die_ref context_die;
{
- register dw_die_ref type_die
- = new_die (DW_TAG_string_type, scope_die_for (type, context_die));
+ dw_die_ref type_die
+ = new_die (DW_TAG_string_type, scope_die_for (type, context_die), type);
equate_type_number_to_die (type, type_die);
- /* Fudge the string length attribute for now. */
-
- /* TODO: add string length info.
- string_length_attribute (TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
- bound_representation (upper_bound, 0, 'u'); */
+ /* ??? Fudge the string length attribute for now.
+ TODO: add string length info. */
+#if 0
+ string_length_attribute (TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
+ bound_representation (upper_bound, 0, 'u');
+#endif
}
/* Generate the DIE for a base class. */
static void
gen_inheritance_die (binfo, context_die)
- register tree binfo;
- register dw_die_ref context_die;
+ tree binfo;
+ dw_die_ref context_die;
{
- dw_die_ref die = new_die (DW_TAG_inheritance, context_die);
+ dw_die_ref die = new_die (DW_TAG_inheritance, context_die, binfo);
add_type_attribute (die, BINFO_TYPE (binfo), 0, 0, context_die);
add_data_member_location_attribute (die, binfo);
if (TREE_VIA_VIRTUAL (binfo))
add_AT_unsigned (die, DW_AT_virtuality, DW_VIRTUALITY_virtual);
+
if (TREE_VIA_PUBLIC (binfo))
add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_public);
else if (TREE_VIA_PROTECTED (binfo))
@@ -8976,30 +10748,30 @@ gen_inheritance_die (binfo, context_die)
static void
gen_member_die (type, context_die)
- register tree type;
- register dw_die_ref context_die;
+ tree type;
+ dw_die_ref context_die;
{
- register tree member;
+ tree member;
+ dw_die_ref child;
/* If this is not an incomplete type, output descriptions of each of its
members. Note that as we output the DIEs necessary to represent the
members of this record or union type, we will also be trying to output
DIEs to represent the *types* of those members. However the `type'
- function (above) will specifically avoid generating type DIEs for member
- types *within* the list of member DIEs for this (containing) type execpt
+ function (above) will specifically avoid generating type DIEs for member
+ types *within* the list of member DIEs for this (containing) type except
for those types (of members) which are explicitly marked as also being
members of this (containing) type themselves. The g++ front- end can
- force any given type to be treated as a member of some other
- (containing) type by setting the TYPE_CONTEXT of the given (member) type
- to point to the TREE node representing the appropriate (containing)
- type. */
+ force any given type to be treated as a member of some other (containing)
+ type by setting the TYPE_CONTEXT of the given (member) type to point to
+ the TREE node representing the appropriate (containing) type. */
/* First output info about the base classes. */
if (TYPE_BINFO (type) && TYPE_BINFO_BASETYPES (type))
{
- register tree bases = TYPE_BINFO_BASETYPES (type);
- register int n_bases = TREE_VEC_LENGTH (bases);
- register int i;
+ tree bases = TYPE_BINFO_BASETYPES (type);
+ int n_bases = TREE_VEC_LENGTH (bases);
+ int i;
for (i = 0; i < n_bases; i++)
gen_inheritance_die (TREE_VEC_ELT (bases, i), context_die);
@@ -9007,25 +10779,51 @@ gen_member_die (type, context_die)
/* Now output info about the data members and type members. */
for (member = TYPE_FIELDS (type); member; member = TREE_CHAIN (member))
- gen_decl_die (member, context_die);
+ {
+ /* If we thought we were generating minimal debug info for TYPE
+ and then changed our minds, some of the member declarations
+ may have already been defined. Don't define them again, but
+ do put them in the right order. */
+
+ child = lookup_decl_die (member);
+ if (child)
+ splice_child_die (context_die, child);
+ else
+ gen_decl_die (member, context_die);
+ }
/* Now output info about the function members (if any). */
for (member = TYPE_METHODS (type); member; member = TREE_CHAIN (member))
- gen_decl_die (member, context_die);
+ {
+ /* Don't include clones in the member list. */
+ if (DECL_ABSTRACT_ORIGIN (member))
+ continue;
+
+ child = lookup_decl_die (member);
+ if (child)
+ splice_child_die (context_die, child);
+ else
+ gen_decl_die (member, context_die);
+ }
}
-/* Generate a DIE for a structure or union type. */
+/* Generate a DIE for a structure or union type. If TYPE_DECL_SUPPRESS_DEBUG
+ is set, we pretend that the type was never defined, so we only get the
+ member DIEs needed by later specification DIEs. */
static void
gen_struct_or_union_type_die (type, context_die)
- register tree type;
- register dw_die_ref context_die;
+ tree type;
+ dw_die_ref context_die;
{
- register dw_die_ref type_die = lookup_type_die (type);
- register dw_die_ref scope_die = 0;
- register int nested = 0;
+ dw_die_ref type_die = lookup_type_die (type);
+ dw_die_ref scope_die = 0;
+ int nested = 0;
+ int complete = (TYPE_SIZE (type)
+ && (! TYPE_STUB_DECL (type)
+ || ! TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (type))));
- if (type_die && ! TYPE_SIZE (type))
+ if (type_die && ! complete)
return;
if (TYPE_CONTEXT (type) != NULL_TREE
@@ -9037,31 +10835,25 @@ gen_struct_or_union_type_die (type, context_die)
if (! type_die || (nested && scope_die == comp_unit_die))
/* First occurrence of type or toplevel definition of nested class. */
{
- register dw_die_ref old_die = type_die;
+ dw_die_ref old_die = type_die;
type_die = new_die (TREE_CODE (type) == RECORD_TYPE
? DW_TAG_structure_type : DW_TAG_union_type,
- scope_die);
+ scope_die, type);
equate_type_number_to_die (type, type_die);
- add_name_attribute (type_die, type_tag (type));
if (old_die)
add_AT_die_ref (type_die, DW_AT_specification, old_die);
+ else
+ add_name_attribute (type_die, type_tag (type));
}
else
remove_AT (type_die, DW_AT_declaration);
- /* If we're not in the right context to be defining this type, defer to
- avoid tricky recursion. */
- if (TYPE_SIZE (type) && decl_scope_depth > 0 && scope_die == comp_unit_die)
- {
- add_AT_flag (type_die, DW_AT_declaration, 1);
- pend_type (type);
- }
/* If this type has been completed, then give it a byte_size attribute and
then give a list of members. */
- else if (TYPE_SIZE (type))
+ if (complete)
{
- /* Prevent infinite recursion in cases where the type of some member of
+ /* Prevent infinite recursion in cases where the type of some member of
this type is expressed in terms of this type itself. */
TREE_ASM_WRITTEN (type) = 1;
add_byte_size_attribute (type_die, type);
@@ -9091,9 +10883,10 @@ gen_struct_or_union_type_die (type, context_die)
{
add_AT_flag (type_die, DW_AT_declaration, 1);
- /* We can't do this for function-local types, and we don't need to. */
- if (TREE_PERMANENT (type))
- add_incomplete_type (type);
+ /* We don't need to do this for function-local types. */
+ if (TYPE_STUB_DECL (type)
+ && ! decl_function_context (TYPE_STUB_DECL (type)))
+ VARRAY_PUSH_TREE (incomplete_types, type);
}
}
@@ -9101,12 +10894,13 @@ gen_struct_or_union_type_die (type, context_die)
static void
gen_subroutine_type_die (type, context_die)
- register tree type;
- register dw_die_ref context_die;
+ tree type;
+ dw_die_ref context_die;
{
- register tree return_type = TREE_TYPE (type);
- register dw_die_ref subr_die
- = new_die (DW_TAG_subroutine_type, scope_die_for (type, context_die));
+ tree return_type = TREE_TYPE (type);
+ dw_die_ref subr_die
+ = new_die (DW_TAG_subroutine_type,
+ scope_die_for (type, context_die), type);
equate_type_number_to_die (type, subr_die);
add_prototyped_attribute (subr_die, type);
@@ -9118,31 +10912,37 @@ gen_subroutine_type_die (type, context_die)
static void
gen_typedef_die (decl, context_die)
- register tree decl;
- register dw_die_ref context_die;
+ tree decl;
+ dw_die_ref context_die;
{
- register dw_die_ref type_die;
- register tree origin;
+ dw_die_ref type_die;
+ tree origin;
if (TREE_ASM_WRITTEN (decl))
return;
- TREE_ASM_WRITTEN (decl) = 1;
- type_die = new_die (DW_TAG_typedef, scope_die_for (decl, context_die));
+ TREE_ASM_WRITTEN (decl) = 1;
+ type_die = new_die (DW_TAG_typedef, context_die, decl);
origin = decl_ultimate_origin (decl);
if (origin != NULL)
add_abstract_origin_attribute (type_die, origin);
else
{
- register tree type;
+ tree type;
+
add_name_and_src_coords_attributes (type_die, decl);
if (DECL_ORIGINAL_TYPE (decl))
{
type = DECL_ORIGINAL_TYPE (decl);
- equate_type_number_to_die (TREE_TYPE (decl), type_die);
+
+ if (type == TREE_TYPE (decl))
+ abort ();
+ else
+ equate_type_number_to_die (TREE_TYPE (decl), type_die);
}
else
type = TREE_TYPE (decl);
+
add_type_attribute (type_die, type, TREE_READONLY (decl),
TREE_THIS_VOLATILE (decl), context_die);
}
@@ -9155,9 +10955,11 @@ gen_typedef_die (decl, context_die)
static void
gen_type_die (type, context_die)
- register tree type;
- register dw_die_ref context_die;
+ tree type;
+ dw_die_ref context_die;
{
+ int need_pop;
+
if (type == NULL_TREE || type == error_mark_node)
return;
@@ -9171,7 +10973,7 @@ gen_type_die (type, context_die)
if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
&& DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
- {
+ {
TREE_ASM_WRITTEN (type) = 1;
gen_decl_die (TYPE_NAME (type), context_die);
return;
@@ -9197,7 +10999,7 @@ gen_type_die (type, context_die)
break;
case OFFSET_TYPE:
- /* This code is used for C++ pointer-to-data-member types.
+ /* This code is used for C++ pointer-to-data-member types.
Output a description of the relevant class type. */
gen_type_die (TYPE_OFFSET_BASETYPE (type), context_die);
@@ -9241,34 +11043,43 @@ gen_type_die (type, context_die)
gen_array_type_die (type, context_die);
break;
+ case VECTOR_TYPE:
+ gen_type_die (TYPE_DEBUG_REPRESENTATION_TYPE (type), context_die);
+ break;
+
case ENUMERAL_TYPE:
case RECORD_TYPE:
case UNION_TYPE:
case QUAL_UNION_TYPE:
- /* If this is a nested type whose containing class hasn't been
- written out yet, writing it out will cover this one, too. */
+ /* If this is a nested type whose containing class hasn't been written
+ out yet, writing it out will cover this one, too. This does not apply
+ to instantiations of member class templates; they need to be added to
+ the containing class as they are generated. FIXME: This hurts the
+ idea of combining type decls from multiple TUs, since we can't predict
+ what set of template instantiations we'll get. */
if (TYPE_CONTEXT (type)
&& AGGREGATE_TYPE_P (TYPE_CONTEXT (type))
&& ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type)))
{
gen_type_die (TYPE_CONTEXT (type), context_die);
- if (TREE_ASM_WRITTEN (TYPE_CONTEXT (type)))
+ if (TREE_ASM_WRITTEN (type))
return;
/* If that failed, attach ourselves to the stub. */
push_decl_scope (TYPE_CONTEXT (type));
context_die = lookup_type_die (TYPE_CONTEXT (type));
+ need_pop = 1;
}
+ else
+ need_pop = 0;
if (TREE_CODE (type) == ENUMERAL_TYPE)
gen_enumeration_type_die (type, context_die);
else
gen_struct_or_union_type_die (type, context_die);
- if (TYPE_CONTEXT (type)
- && AGGREGATE_TYPE_P (TYPE_CONTEXT (type))
- && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type)))
+ if (need_pop)
pop_decl_scope ();
/* Don't set TREE_ASM_WRITTEN on an incomplete struct; we want to fix
@@ -9300,8 +11111,8 @@ gen_type_die (type, context_die)
static void
gen_tagged_type_instantiation_die (type, context_die)
- register tree type;
- register dw_die_ref context_die;
+ tree type;
+ dw_die_ref context_die;
{
if (type == NULL_TREE || type == error_mark_node)
return;
@@ -9310,10 +11121,12 @@ gen_tagged_type_instantiation_die (type, context_die)
this type (i.e. without any const or volatile qualifiers) so make sure
that we have the main variant (i.e. the unqualified version) of this
type now. */
- if (type != type_main_variant (type)
- || !TREE_ASM_WRITTEN (type))
+ if (type != type_main_variant (type))
abort ();
+ /* Do not check TREE_ASM_WRITTEN (type) as it may not be set if this is
+ an instance of an unresolved type. */
+
switch (TREE_CODE (type))
{
case ERROR_MARK:
@@ -9342,20 +11155,33 @@ gen_tagged_type_instantiation_die (type, context_die)
static void
gen_block_die (stmt, context_die, depth)
- register tree stmt;
- register dw_die_ref context_die;
+ tree stmt;
+ dw_die_ref context_die;
int depth;
{
- register int must_output_die = 0;
- register tree origin;
- register tree decl;
- register enum tree_code origin_code;
+ int must_output_die = 0;
+ tree origin;
+ tree decl;
+ enum tree_code origin_code;
/* Ignore blocks never really used to make RTL. */
-
- if (stmt == NULL_TREE || !TREE_USED (stmt))
+ if (stmt == NULL_TREE || !TREE_USED (stmt)
+ || (!TREE_ASM_WRITTEN (stmt) && !BLOCK_ABSTRACT (stmt)))
return;
+ /* If the block is one fragment of a non-contiguous block, do not
+ process the variables, since they will have been done by the
+ origin block. Do process subblocks. */
+ if (BLOCK_FRAGMENT_ORIGIN (stmt))
+ {
+ tree sub;
+
+ for (sub = BLOCK_SUBBLOCKS (stmt); sub; sub = BLOCK_CHAIN (sub))
+ gen_block_die (sub, context_die, depth + 1);
+
+ return;
+ }
+
/* Determine the "ultimate origin" of this block. This block may be an
inlined instance of an inlined instance of inline function, so we have
to trace all of the way back through the origin chain to find out what
@@ -9373,13 +11199,12 @@ gen_block_die (stmt, context_die, depth)
else
{
/* In the case where the current block represents an inlining of the
- "body block" of an inline function, we must *NOT* output any DIE for
- this block because we have already output a DIE to represent the
- whole inlined function scope and the "body block" of any function
- doesn't really represent a different scope according to ANSI C
- rules. So we check here to make sure that this block does not
- represent a "body block inlining" before trying to set the
- `must_output_die' flag. */
+ "body block" of an inline function, we must *NOT* output any DIE for
+ this block because we have already output a DIE to represent the whole
+ inlined function scope and the "body block" of any function doesn't
+ really represent a different scope according to ANSI C rules. So we
+ check here to make sure that this block does not represent a "body
+ block inlining" before trying to set the MUST_OUTPUT_DIE flag. */
if (! is_body_block (origin ? origin : stmt))
{
/* Determine if this block directly contains any "significant"
@@ -9425,28 +11250,24 @@ gen_block_die (stmt, context_die, depth)
static void
decls_for_scope (stmt, context_die, depth)
- register tree stmt;
- register dw_die_ref context_die;
+ tree stmt;
+ dw_die_ref context_die;
int depth;
{
- register tree decl;
- register tree subblocks;
+ tree decl;
+ tree subblocks;
/* Ignore blocks never really used to make RTL. */
if (stmt == NULL_TREE || ! TREE_USED (stmt))
return;
- if (!BLOCK_ABSTRACT (stmt) && depth > 0)
- next_block_number++;
-
/* Output the DIEs to represent all of the data objects and typedefs
declared directly within this block but not within any nested
sub-blocks. Also, nested function and tag DIEs have been
generated with a parent of NULL; fix that up now. */
- for (decl = BLOCK_VARS (stmt);
- decl != NULL; decl = TREE_CHAIN (decl))
+ for (decl = BLOCK_VARS (stmt); decl != NULL; decl = TREE_CHAIN (decl))
{
- register dw_die_ref die;
+ dw_die_ref die;
if (TREE_CODE (decl) == FUNCTION_DECL)
die = lookup_decl_die (decl);
@@ -9473,7 +11294,7 @@ decls_for_scope (stmt, context_die, depth)
static inline int
is_redundant_typedef (decl)
- register tree decl;
+ tree decl;
{
if (TYPE_DECL_IS_STUB (decl))
return 1;
@@ -9493,31 +11314,21 @@ is_redundant_typedef (decl)
static void
gen_decl_die (decl, context_die)
- register tree decl;
- register dw_die_ref context_die;
+ tree decl;
+ dw_die_ref context_die;
{
- register tree origin;
+ tree origin;
- /* Make a note of the decl node we are going to be working on. We may need
- to give the user the source coordinates of where it appeared in case we
- notice (later on) that something about it looks screwy. */
- dwarf_last_decl = decl;
-
- if (TREE_CODE (decl) == ERROR_MARK)
- return;
-
- /* If this ..._DECL node is marked to be ignored, then ignore it. But don't
- ignore a function definition, since that would screw up our count of
- blocks, and that in turn will completely screw up the labels we will
- reference in subsequent DW_AT_low_pc and DW_AT_high_pc attributes (for
- subsequent blocks). */
- if (DECL_IGNORED_P (decl) && TREE_CODE (decl) != FUNCTION_DECL)
+ if (DECL_P (decl) && DECL_IGNORED_P (decl))
return;
switch (TREE_CODE (decl))
{
+ case ERROR_MARK:
+ break;
+
case CONST_DECL:
- /* The individual enumerators of an enum type get output when we output
+ /* The individual enumerators of an enum type get output when we output
the Dwarf representation of the relevant enum type itself. */
break;
@@ -9525,23 +11336,41 @@ gen_decl_die (decl, context_die)
/* Don't output any DIEs to represent mere function declarations,
unless they are class members or explicit block externs. */
if (DECL_INITIAL (decl) == NULL_TREE && DECL_CONTEXT (decl) == NULL_TREE
- && (current_function_decl == NULL_TREE || ! DECL_ARTIFICIAL (decl)))
+ && (current_function_decl == NULL_TREE || DECL_ARTIFICIAL (decl)))
break;
- if (debug_info_level > DINFO_LEVEL_TERSE)
+ /* If we're emitting a clone, emit info for the abstract instance. */
+ if (DECL_ORIGIN (decl) != decl)
+ dwarf2out_abstract_function (DECL_ABSTRACT_ORIGIN (decl));
+
+ /* If we're emitting an out-of-line copy of an inline function,
+ emit info for the abstract instance and set up to refer to it. */
+ else if (DECL_INLINE (decl) && ! DECL_ABSTRACT (decl)
+ && ! class_scope_p (context_die)
+ /* dwarf2out_abstract_function won't emit a die if this is just
+ a declaration. We must avoid setting DECL_ABSTRACT_ORIGIN in
+ that case, because that works only if we have a die. */
+ && DECL_INITIAL (decl) != NULL_TREE)
+ {
+ dwarf2out_abstract_function (decl);
+ set_decl_origin_self (decl);
+ }
+
+ /* Otherwise we're emitting the primary DIE for this decl. */
+ else if (debug_info_level > DINFO_LEVEL_TERSE)
{
/* Before we describe the FUNCTION_DECL itself, make sure that we
have described its return type. */
gen_type_die (TREE_TYPE (TREE_TYPE (decl)), context_die);
- /* And its containing type. */
- origin = decl_class_context (decl);
- if (origin != NULL_TREE)
- gen_type_die (origin, context_die);
-
/* And its virtual context. */
if (DECL_VINDEX (decl) != NULL_TREE)
gen_type_die (DECL_CONTEXT (decl), context_die);
+
+ /* And its containing type. */
+ origin = decl_class_context (decl);
+ if (origin != NULL_TREE)
+ gen_type_die_for_member (origin, decl, context_die);
}
/* Now output a DIE to represent the function itself. */
@@ -9554,14 +11383,13 @@ gen_decl_die (decl, context_die)
if (debug_info_level <= DINFO_LEVEL_TERSE)
break;
- /* In the special case of a TYPE_DECL node representing the
- declaration of some type tag, if the given TYPE_DECL is marked as
- having been instantiated from some other (original) TYPE_DECL node
- (e.g. one which was generated within the original definition of an
- inline function) we have to generate a special (abbreviated)
- DW_TAG_structure_type, DW_TAG_union_type, or DW_TAG_enumeration_type
- DIE here. */
- if (TYPE_DECL_IS_STUB (decl) && DECL_ABSTRACT_ORIGIN (decl) != NULL_TREE)
+ /* In the special case of a TYPE_DECL node representing the declaration
+ of some type tag, if the given TYPE_DECL is marked as having been
+ instantiated from some other (original) TYPE_DECL node (e.g. one which
+ was generated within the original definition of an inline function) we
+ have to generate a special (abbreviated) DW_TAG_structure_type,
+ DW_TAG_union_type, or DW_TAG_enumeration_type DIE here. */
+ if (TYPE_DECL_IS_STUB (decl) && decl_ultimate_origin (decl) != NULL_TREE)
{
gen_tagged_type_instantiation_die (TREE_TYPE (decl), context_die);
break;
@@ -9592,7 +11420,7 @@ gen_decl_die (decl, context_die)
/* And its containing type. */
origin = decl_class_context (decl);
if (origin != NULL_TREE)
- gen_type_die (origin, context_die);
+ gen_type_die_for_member (origin, decl, context_die);
/* Now output the DIE to represent the data object itself. This gets
complicated because of the possibility that the VAR_DECL really
@@ -9606,8 +11434,8 @@ gen_decl_die (decl, context_die)
break;
case FIELD_DECL:
- /* Ignore the nameless fields that are used to skip bits, but
- handle C++ anonymous unions. */
+ /* Ignore the nameless fields that are used to skip bits but handle C++
+ anonymous unions. */
if (DECL_NAME (decl) != NULL_TREE
|| TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE)
{
@@ -9621,72 +11449,110 @@ gen_decl_die (decl, context_die)
gen_formal_parameter_die (decl, context_die);
break;
+ case NAMESPACE_DECL:
+ /* Ignore for now. */
+ break;
+
default:
abort ();
}
}
+
+static void
+mark_limbo_die_list (ptr)
+ void *ptr ATTRIBUTE_UNUSED;
+{
+ limbo_die_node *node;
+ for (node = limbo_die_list; node ; node = node->next)
+ ggc_mark_tree (node->created_for);
+}
-/* Write the debugging output for DECL. */
+/* Add Ada "use" clause information for SGI Workshop debugger. */
void
-dwarf2out_decl (decl)
- register tree decl;
+dwarf2out_add_library_unit_info (filename, context_list)
+ const char *filename;
+ const char *context_list;
{
- register dw_die_ref context_die = comp_unit_die;
+ unsigned int file_index;
- if (TREE_CODE (decl) == ERROR_MARK)
- return;
-
- /* If this ..._DECL node is marked to be ignored, then ignore it. We gotta
- hope that the node in question doesn't represent a function definition.
- If it does, then totally ignoring it is bound to screw up our count of
- blocks, and that in turn will completely screw up the labels we will
- reference in subsequent DW_AT_low_pc and DW_AT_high_pc attributes (for
- subsequent blocks). (It's too bad that BLOCK nodes don't carry their
- own sequence numbers with them!) */
- if (DECL_IGNORED_P (decl))
- {
- if (TREE_CODE (decl) == FUNCTION_DECL
- && DECL_INITIAL (decl) != NULL)
- abort ();
+ if (filename != NULL)
+ {
+ dw_die_ref unit_die = new_die (DW_TAG_module, comp_unit_die, NULL);
+ tree context_list_decl
+ = build_decl (LABEL_DECL, get_identifier (context_list),
+ void_type_node);
- return;
+ TREE_PUBLIC (context_list_decl) = TRUE;
+ add_name_attribute (unit_die, context_list);
+ file_index = lookup_filename (filename);
+ add_AT_unsigned (unit_die, DW_AT_decl_file, file_index);
+ add_pubname (context_list_decl, unit_die);
}
+}
+
+/* Output debug information for global decl DECL. Called from toplev.c after
+ compilation proper has finished. */
+
+static void
+dwarf2out_global_decl (decl)
+ tree decl;
+{
+ /* Output DWARF2 information for file-scope tentative data object
+ declarations, file-scope (extern) function declarations (which had no
+ corresponding body) and file-scope tagged type declarations and
+ definitions which have not yet been forced out. */
+ if (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))
+ dwarf2out_decl (decl);
+}
+
+/* Write the debugging output for DECL. */
+
+void
+dwarf2out_decl (decl)
+ tree decl;
+{
+ dw_die_ref context_die = comp_unit_die;
switch (TREE_CODE (decl))
{
+ case ERROR_MARK:
+ return;
+
case FUNCTION_DECL:
- /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of a
+ /* 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_FUNCTION_CODE (decl))
+ 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
- that *are* referenced later on) but we aren't clairvoyant, so we have
- no idea which functions will be referenced in the future (i.e. later
+ that *are* referenced later on) but we aren't clairvoyant, so we have
+ no idea which functions will be referenced in the future (i.e. later
on within the current translation unit). So here we just ignore all
- file-scope function declarations which are not also definitions. If
+ file-scope function declarations which are not also definitions. If
and when the debugger needs to know something about these functions,
- it wil have to hunt around and find the DWARF information associated
- with the definition of the function. Note that we can't just check
- `DECL_EXTERNAL' to find out which FUNCTION_DECL nodes represent
- definitions and which ones represent mere declarations. We have to
- check `DECL_INITIAL' instead. That's because the C front-end
- supports some weird semantics for "extern inline" function
- definitions. These can get inlined within the current translation
- unit (an thus, we need to generate DWARF info for their abstract
- instances so that the DWARF info for the concrete inlined instances
- can have something to refer to) but the compiler never generates any
- out-of-lines instances of such things (despite the fact that they
- *are* definitions). The important point is that the C front-end
- marks these "extern inline" functions as DECL_EXTERNAL, but we need
- to generate DWARF for them anyway. Note that the C++ front-end also
- plays some similar games for inline function definitions appearing
- within include files which also contain
- `#pragma interface' pragmas. */
+ it will have to hunt around and find the DWARF information associated
+ with the definition of the function.
+
+ We can't just check DECL_EXTERNAL to find out which FUNCTION_DECL
+ nodes represent definitions and which ones represent mere
+ declarations. We have to check DECL_INITIAL instead. That's because
+ the C front-end supports some weird semantics for "extern inline"
+ function definitions. These can get inlined within the current
+ translation unit (an thus, we need to generate Dwarf info for their
+ abstract instances so that the Dwarf info for the concrete inlined
+ instances can have something to refer to) but the compiler never
+ generates any out-of-lines instances of such things (despite the fact
+ that they *are* definitions).
+
+ The important point is that the C front-end marks these "extern
+ inline" functions as DECL_EXTERNAL, but we need to generate DWARF for
+ them anyway. Note that the C++ front-end also plays some similar games
+ for inline function definitions appearing within include files which
+ also contain `#pragma interface' pragmas. */
if (DECL_INITIAL (decl) == NULL_TREE)
return;
@@ -9695,11 +11561,10 @@ dwarf2out_decl (decl)
we're a method, it will be ignored, since we already have a DIE. */
if (decl_function_context (decl))
context_die = NULL;
-
break;
case VAR_DECL:
- /* Ignore this VAR_DECL if it refers to a file-scope extern data object
+ /* Ignore this VAR_DECL if it refers to a file-scope extern data object
declaration and if the declaration was never even referenced from
within this entire compilation unit. We suppress these DIEs in
order to save space in the .debug section (by eliminating entries
@@ -9717,6 +11582,10 @@ dwarf2out_decl (decl)
break;
case TYPE_DECL:
+ /* Don't emit stubs for types unless they are needed by other DIEs. */
+ if (TYPE_DECL_SUPPRESS_DEBUG (decl))
+ return;
+
/* 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)
@@ -9725,7 +11594,8 @@ dwarf2out_decl (decl)
comparisons have. */
if ((get_AT_unsigned (comp_unit_die, DW_AT_language)
== DW_LANG_C_plus_plus)
- && TREE_CODE (TREE_TYPE (decl)) == BOOLEAN_TYPE)
+ && TREE_CODE (TREE_TYPE (decl)) == BOOLEAN_TYPE
+ && ! DECL_IGNORED_P (decl))
modified_type_die (TREE_TYPE (decl), 0, 0, NULL);
return;
@@ -9747,117 +11617,159 @@ dwarf2out_decl (decl)
}
gen_decl_die (decl, context_die);
- output_pending_types_for_scope (comp_unit_die);
}
/* Output a marker (i.e. a label) for the beginning of the generated code for
a lexical block. */
-void
-dwarf2out_begin_block (blocknum)
- register unsigned blocknum;
+static void
+dwarf2out_begin_block (line, blocknum)
+ unsigned int line ATTRIBUTE_UNUSED;
+ unsigned int blocknum;
{
function_section (current_function_decl);
- ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, BLOCK_BEGIN_LABEL, blocknum);
+ ASM_OUTPUT_DEBUG_LABEL (asm_out_file, BLOCK_BEGIN_LABEL, blocknum);
}
/* Output a marker (i.e. a label) for the end of the generated code for a
lexical block. */
-void
-dwarf2out_end_block (blocknum)
- register unsigned blocknum;
+static void
+dwarf2out_end_block (line, blocknum)
+ unsigned int line ATTRIBUTE_UNUSED;
+ unsigned int blocknum;
{
function_section (current_function_decl);
- ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, BLOCK_END_LABEL, blocknum);
+ ASM_OUTPUT_DEBUG_LABEL (asm_out_file, BLOCK_END_LABEL, blocknum);
}
-/* Output a marker (i.e. a label) at a point in the assembly code which
- corresponds to a given source level label. */
+/* Returns nonzero if it is appropriate not to emit any debugging
+ information for BLOCK, because it doesn't contain any instructions.
-void
-dwarf2out_label (insn)
- register rtx insn;
+ Don't allow this for blocks with nested functions or local classes
+ as we would end up with orphans, and in the presence of scheduling
+ we may end up calling them anyway. */
+
+static bool
+dwarf2out_ignore_block (block)
+ tree block;
{
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
+ tree decl;
- if (debug_info_level >= DINFO_LEVEL_NORMAL)
- {
- function_section (current_function_decl);
- sprintf (label, INSN_LABEL_FMT, current_funcdef_number);
- ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, label,
- (unsigned) INSN_UID (insn));
- }
+ for (decl = BLOCK_VARS (block); decl; decl = TREE_CHAIN (decl))
+ if (TREE_CODE (decl) == FUNCTION_DECL
+ || (TREE_CODE (decl) == TYPE_DECL && TYPE_DECL_IS_STUB (decl)))
+ return 0;
+
+ return 1;
}
-/* Lookup a filename (in the list of filenames that we know about here in
+/* Lookup FILE_NAME (in the list of filenames that we know about here in
dwarf2out.c) and return its "index". The index of each (known) filename is
- just a unique number which is associated with only that one filename.
- We need such numbers for the sake of generating labels
- (in the .debug_sfnames section) and references to those
- files numbers (in the .debug_srcinfo and.debug_macinfo sections).
- If the filename given as an argument is not found in our current list,
- add it to the list and assign it the next available unique index number.
- In order to speed up searches, we remember the index of the filename
- was looked up last. This handles the majority of all searches. */
+ just a unique number which is associated with only that one filename. We
+ need such numbers for the sake of generating labels (in the .debug_sfnames
+ section) and references to those files numbers (in the .debug_srcinfo
+ and.debug_macinfo sections). If the filename given as an argument is not
+ found in our current list, add it to the list and assign it the next
+ available unique index number. In order to speed up searches, we remember
+ the index of the filename was looked up last. This handles the majority of
+ all searches. */
static unsigned
lookup_filename (file_name)
- char *file_name;
+ const char *file_name;
{
- static unsigned last_file_lookup_index = 0;
- register unsigned i;
+ unsigned i;
- /* Check to see if the file name that was searched on the previous call
- matches this file name. If so, return the index. */
- if (last_file_lookup_index != 0)
- if (strcmp (file_name, file_table[last_file_lookup_index]) == 0)
- return last_file_lookup_index;
+ /* ??? Why isn't DECL_SOURCE_FILE left null instead. */
+ if (strcmp (file_name, "<internal>") == 0
+ || strcmp (file_name, "<built-in>") == 0)
+ return 0;
+
+ /* Check to see if the file name that was searched on the previous
+ call matches this file name. If so, return the index. */
+ if (file_table.last_lookup_index != 0)
+ if (0 == strcmp (file_name,
+ file_table.table[file_table.last_lookup_index]))
+ return file_table.last_lookup_index;
/* Didn't match the previous lookup, search the table */
- for (i = 1; i < file_table_in_use; ++i)
- if (strcmp (file_name, file_table[i]) == 0)
+ for (i = 1; i < file_table.in_use; i++)
+ if (strcmp (file_name, file_table.table[i]) == 0)
{
- last_file_lookup_index = i;
+ file_table.last_lookup_index = i;
return i;
}
- /* Prepare to add a new table entry by making sure there is enough space in
+ /* Prepare to add a new table entry by making sure there is enough space in
the table to do so. If not, expand the current table. */
- if (file_table_in_use == file_table_allocated)
+ if (i == file_table.allocated)
{
- file_table_allocated += FILE_TABLE_INCREMENT;
- file_table
- = (char **) xrealloc (file_table,
- file_table_allocated * sizeof (char *));
+ file_table.allocated = i + FILE_TABLE_INCREMENT;
+ file_table.table = (char **)
+ xrealloc (file_table.table, file_table.allocated * sizeof (char *));
}
/* Add the new entry to the end of the filename table. */
- file_table[file_table_in_use] = xstrdup (file_name);
- last_file_lookup_index = file_table_in_use++;
+ file_table.table[i] = xstrdup (file_name);
+ file_table.in_use = i + 1;
+ file_table.last_lookup_index = i;
+
+ if (DWARF2_ASM_LINE_DEBUG_INFO)
+ fprintf (asm_out_file, "\t.file %u \"%s\"\n", i, file_name);
- return last_file_lookup_index;
+ return i;
+}
+
+static void
+init_file_table ()
+{
+ /* Allocate the initial hunk of the file_table. */
+ file_table.table = (char **) xcalloc (FILE_TABLE_INCREMENT, sizeof (char *));
+ file_table.allocated = FILE_TABLE_INCREMENT;
+
+ /* Skip the first entry - file numbers begin at 1. */
+ file_table.in_use = 1;
+ file_table.last_lookup_index = 0;
}
/* 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. */
-void
-dwarf2out_line (filename, line)
- register char *filename;
- register unsigned line;
+static void
+dwarf2out_source_line (line, filename)
+ unsigned int line;
+ const char *filename;
{
if (debug_info_level >= DINFO_LEVEL_NORMAL)
{
function_section (current_function_decl);
- if (DECL_SECTION_NAME (current_function_decl))
+ /* If requested, emit something human-readable. */
+ if (flag_debug_asm)
+ fprintf (asm_out_file, "\t%s %s:%d\n", ASM_COMMENT_START,
+ filename, line);
+
+ if (DWARF2_ASM_LINE_DEBUG_INFO)
+ {
+ unsigned file_num = lookup_filename (filename);
+
+ /* Emit the .loc directive understood by GNU as. */
+ fprintf (asm_out_file, "\t.loc %d %d 0\n", file_num, line);
+
+ /* Indicate that line number info exists. */
+ line_info_table_in_use++;
+
+ /* Indicate that multiple line number tables exist. */
+ if (DECL_SECTION_NAME (current_function_decl))
+ separate_line_info_table_in_use++;
+ }
+ else if (DECL_SECTION_NAME (current_function_decl))
{
- register dw_separate_line_info_ref line_info;
+ dw_separate_line_info_ref line_info;
ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, SEPARATE_LINE_CODE_LABEL,
separate_line_info_table_in_use);
- fputc ('\n', asm_out_file);
/* expand the line info table if necessary */
if (separate_line_info_table_in_use
@@ -9880,11 +11792,10 @@ dwarf2out_line (filename, line)
}
else
{
- register dw_line_info_ref line_info;
+ dw_line_info_ref line_info;
ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, LINE_CODE_LABEL,
line_info_table_in_use);
- fputc ('\n', asm_out_file);
/* Expand the line info table if necessary. */
if (line_info_table_in_use == line_info_table_allocated)
@@ -9905,140 +11816,232 @@ dwarf2out_line (filename, line)
}
}
-/* Record the beginning of a new source file, for later output
- of the .debug_macinfo section. At present, unimplemented. */
+/* Record the beginning of a new source file. */
-void
-dwarf2out_start_source_file (filename)
- register char *filename ATTRIBUTE_UNUSED;
+static void
+dwarf2out_start_source_file (lineno, filename)
+ unsigned int lineno;
+ const char *filename;
{
+ if (flag_eliminate_dwarf2_dups)
+ {
+ /* Record the beginning of the file for break_out_includes. */
+ dw_die_ref bincl_die = new_die (DW_TAG_GNU_BINCL, comp_unit_die, NULL);
+ add_AT_string (bincl_die, DW_AT_name, filename);
+ }
+
+ if (debug_info_level >= DINFO_LEVEL_VERBOSE)
+ {
+ named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG);
+ dw2_asm_output_data (1, DW_MACINFO_start_file, "Start new file");
+ dw2_asm_output_data_uleb128 (lineno, "Included from line number %d",
+ lineno);
+ dw2_asm_output_data_uleb128 (lookup_filename (filename),
+ "Filename we just started");
+ }
}
-/* Record the end of a source file, for later output
- of the .debug_macinfo section. At present, unimplemented. */
+/* Record the end of a source file. */
-void
-dwarf2out_end_source_file ()
+static void
+dwarf2out_end_source_file (lineno)
+ unsigned int lineno ATTRIBUTE_UNUSED;
{
+ if (flag_eliminate_dwarf2_dups)
+ /* Record the end of the file for break_out_includes. */
+ new_die (DW_TAG_GNU_EINCL, comp_unit_die, NULL);
+
+ if (debug_info_level >= DINFO_LEVEL_VERBOSE)
+ {
+ named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG);
+ dw2_asm_output_data (1, DW_MACINFO_end_file, "End file");
+ }
}
-/* Called from check_newline in c-parse.y. The `buffer' parameter contains
+/* Called from debug_define in toplev.c. The `buffer' parameter contains
the tail part of the directive line, i.e. the part which is past the
initial whitespace, #, whitespace, directive-name, whitespace part. */
-void
+static void
dwarf2out_define (lineno, buffer)
- register unsigned lineno;
- register char *buffer;
+ unsigned lineno ATTRIBUTE_UNUSED;
+ const char *buffer ATTRIBUTE_UNUSED;
{
static int initialized = 0;
if (!initialized)
{
- dwarf2out_start_source_file (primary_filename);
+ dwarf2out_start_source_file (0, primary_filename);
initialized = 1;
}
+
+ if (debug_info_level >= DINFO_LEVEL_VERBOSE)
+ {
+ named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG);
+ dw2_asm_output_data (1, DW_MACINFO_define, "Define macro");
+ dw2_asm_output_data_uleb128 (lineno, "At line number %d", lineno);
+ dw2_asm_output_nstring (buffer, -1, "The macro");
+ }
}
-/* Called from check_newline in c-parse.y. The `buffer' parameter contains
+/* Called from debug_undef in toplev.c. The `buffer' parameter contains
the tail part of the directive line, i.e. the part which is past the
initial whitespace, #, whitespace, directive-name, whitespace part. */
-void
+static void
dwarf2out_undef (lineno, buffer)
- register unsigned lineno ATTRIBUTE_UNUSED;
- register char *buffer ATTRIBUTE_UNUSED;
+ unsigned lineno ATTRIBUTE_UNUSED;
+ const char *buffer ATTRIBUTE_UNUSED;
{
+ if (debug_info_level >= DINFO_LEVEL_VERBOSE)
+ {
+ named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG);
+ dw2_asm_output_data (1, DW_MACINFO_undef, "Undefine macro");
+ dw2_asm_output_data_uleb128 (lineno, "At line number %d", lineno);
+ dw2_asm_output_nstring (buffer, -1, "The macro");
+ }
}
/* Set up for Dwarf output at the start of compilation. */
-void
-dwarf2out_init (asm_out_file, main_input_filename)
- register FILE *asm_out_file;
- register char *main_input_filename;
+static void
+dwarf2out_init (main_input_filename)
+ const char *main_input_filename;
{
+ init_file_table ();
+
/* Remember the name of the primary input file. */
primary_filename = main_input_filename;
- /* Allocate the initial hunk of the file_table. */
- file_table = (char **) xmalloc (FILE_TABLE_INCREMENT * sizeof (char *));
- bzero ((char *) file_table, FILE_TABLE_INCREMENT * sizeof (char *));
- file_table_allocated = FILE_TABLE_INCREMENT;
-
- /* Skip the first entry - file numbers begin at 1. */
- file_table_in_use = 1;
+ /* Add it to the file table first, under the assumption that we'll
+ be emitting line number data for it first, which avoids having
+ to add an initial DW_LNS_set_file. */
+ lookup_filename (main_input_filename);
/* Allocate the initial hunk of the decl_die_table. */
decl_die_table
- = (dw_die_ref *) xmalloc (DECL_DIE_TABLE_INCREMENT * sizeof (dw_die_ref));
- bzero ((char *) decl_die_table,
- DECL_DIE_TABLE_INCREMENT * sizeof (dw_die_ref));
+ = (dw_die_ref *) xcalloc (DECL_DIE_TABLE_INCREMENT, sizeof (dw_die_ref));
decl_die_table_allocated = DECL_DIE_TABLE_INCREMENT;
decl_die_table_in_use = 0;
/* Allocate the initial hunk of the decl_scope_table. */
- decl_scope_table
- = (decl_scope_node *) xmalloc (DECL_SCOPE_TABLE_INCREMENT
- * sizeof (decl_scope_node));
- bzero ((char *) decl_scope_table,
- DECL_SCOPE_TABLE_INCREMENT * sizeof (decl_scope_node));
- decl_scope_table_allocated = DECL_SCOPE_TABLE_INCREMENT;
- decl_scope_depth = 0;
+ VARRAY_TREE_INIT (decl_scope_table, 256, "decl_scope_table");
+ ggc_add_tree_varray_root (&decl_scope_table, 1);
/* Allocate the initial hunk of the abbrev_die_table. */
abbrev_die_table
- = (dw_die_ref *) xmalloc (ABBREV_DIE_TABLE_INCREMENT
- * sizeof (dw_die_ref));
- bzero ((char *) abbrev_die_table,
- ABBREV_DIE_TABLE_INCREMENT * sizeof (dw_die_ref));
+ = (dw_die_ref *) xcalloc (ABBREV_DIE_TABLE_INCREMENT,
+ sizeof (dw_die_ref));
abbrev_die_table_allocated = ABBREV_DIE_TABLE_INCREMENT;
/* Zero-th entry is allocated, but unused */
abbrev_die_table_in_use = 1;
/* Allocate the initial hunk of the line_info_table. */
line_info_table
- = (dw_line_info_ref) xmalloc (LINE_INFO_TABLE_INCREMENT
- * sizeof (dw_line_info_entry));
- bzero ((char *) line_info_table,
- LINE_INFO_TABLE_INCREMENT * sizeof (dw_line_info_entry));
+ = (dw_line_info_ref) xcalloc (LINE_INFO_TABLE_INCREMENT,
+ sizeof (dw_line_info_entry));
line_info_table_allocated = LINE_INFO_TABLE_INCREMENT;
+
/* Zero-th entry is allocated, but unused */
line_info_table_in_use = 1;
- /* Generate the initial DIE for the .debug section. Note that the (string)
+ /* Generate the initial DIE for the .debug section. Note that the (string)
value given in the DW_AT_name attribute of the DW_TAG_compile_unit DIE
- will (typically) be a relative pathname and that this pathname should be
+ will (typically) be a relative pathname and that this pathname should be
taken as being relative to the directory from which the compiler was
invoked when the given (base) source file was compiled. */
- gen_compile_unit_die (main_input_filename);
+ comp_unit_die = gen_compile_unit_die (main_input_filename);
+
+ VARRAY_TREE_INIT (incomplete_types, 64, "incomplete_types");
+ ggc_add_tree_varray_root (&incomplete_types, 1);
+
+ VARRAY_RTX_INIT (used_rtx_varray, 32, "used_rtx_varray");
+ ggc_add_rtx_varray_root (&used_rtx_varray, 1);
+
+ ggc_add_root (&limbo_die_list, 1, 1, mark_limbo_die_list);
ASM_GENERATE_INTERNAL_LABEL (text_end_label, TEXT_END_LABEL, 0);
- ASM_GENERATE_INTERNAL_LABEL (abbrev_section_label, ABBREV_SECTION_LABEL, 0);
- ASM_GENERATE_INTERNAL_LABEL (text_section_label, TEXT_SECTION_LABEL, 0);
- ASM_GENERATE_INTERNAL_LABEL (debug_info_section_label,
+ ASM_GENERATE_INTERNAL_LABEL (abbrev_section_label,
+ DEBUG_ABBREV_SECTION_LABEL, 0);
+ if (DWARF2_GENERATE_TEXT_SECTION_LABEL)
+ ASM_GENERATE_INTERNAL_LABEL (text_section_label, TEXT_SECTION_LABEL, 0);
+ else
+ strcpy (text_section_label, stripattributes (TEXT_SECTION_NAME));
+
+ ASM_GENERATE_INTERNAL_LABEL (debug_info_section_label,
DEBUG_INFO_SECTION_LABEL, 0);
- ASM_GENERATE_INTERNAL_LABEL (debug_line_section_label,
+ ASM_GENERATE_INTERNAL_LABEL (debug_line_section_label,
DEBUG_LINE_SECTION_LABEL, 0);
-
- ASM_OUTPUT_SECTION (asm_out_file, ABBREV_SECTION);
+ ASM_GENERATE_INTERNAL_LABEL (ranges_section_label,
+ DEBUG_RANGES_SECTION_LABEL, 0);
+ named_section_flags (DEBUG_ABBREV_SECTION, SECTION_DEBUG);
ASM_OUTPUT_LABEL (asm_out_file, abbrev_section_label);
- ASM_OUTPUT_SECTION (asm_out_file, TEXT_SECTION);
- ASM_OUTPUT_LABEL (asm_out_file, text_section_label);
- ASM_OUTPUT_SECTION (asm_out_file, DEBUG_INFO_SECTION);
+ named_section_flags (DEBUG_INFO_SECTION, SECTION_DEBUG);
ASM_OUTPUT_LABEL (asm_out_file, debug_info_section_label);
- ASM_OUTPUT_SECTION (asm_out_file, DEBUG_LINE_SECTION);
+ named_section_flags (DEBUG_LINE_SECTION, SECTION_DEBUG);
ASM_OUTPUT_LABEL (asm_out_file, debug_line_section_label);
+
+ if (debug_info_level >= DINFO_LEVEL_VERBOSE)
+ {
+ named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG);
+ ASM_GENERATE_INTERNAL_LABEL (macinfo_section_label,
+ DEBUG_MACINFO_SECTION_LABEL, 0);
+ ASM_OUTPUT_LABEL (asm_out_file, macinfo_section_label);
+ }
+
+ if (DWARF2_GENERATE_TEXT_SECTION_LABEL)
+ {
+ text_section ();
+ ASM_OUTPUT_LABEL (asm_out_file, text_section_label);
+ }
+}
+
+/* Allocate a string in .debug_str hash table. */
+
+static hashnode
+indirect_string_alloc (tab)
+ hash_table *tab ATTRIBUTE_UNUSED;
+{
+ struct indirect_string_node *node;
+
+ node = xmalloc (sizeof (struct indirect_string_node));
+ node->refcount = 0;
+ node->form = 0;
+ node->label = NULL;
+
+ return (hashnode) node;
+}
+
+/* A helper function for dwarf2out_finish called through
+ ht_forall. Emit one queued .debug_str string. */
+
+static int
+output_indirect_string (pfile, h, v)
+ struct cpp_reader *pfile ATTRIBUTE_UNUSED;
+ hashnode h;
+ const PTR v ATTRIBUTE_UNUSED;
+{
+ struct indirect_string_node *node = (struct indirect_string_node *) h;
+
+ if (node->form == DW_FORM_strp)
+ {
+ named_section_flags (DEBUG_STR_SECTION, DEBUG_STR_SECTION_FLAGS);
+ ASM_OUTPUT_LABEL (asm_out_file, node->label);
+ assemble_string ((const char *) HT_STR (&node->id),
+ HT_LEN (&node->id) + 1);
+ }
+
+ return 1;
}
/* Output stuff that dwarf requires at the end of every file,
and generate the DWARF-2 debugging info. */
-void
-dwarf2out_finish ()
+static void
+dwarf2out_finish (input_filename)
+ const char *input_filename ATTRIBUTE_UNUSED;
{
limbo_die_node *node, *next_node;
- dw_die_ref die;
- dw_attr_ref a;
+ dw_die_ref die = 0;
/* Traverse the limbo die list, and add parent/child links. The only
dies without parents that should be here are concrete instances of
@@ -10052,91 +12055,161 @@ dwarf2out_finish ()
if (die->die_parent == NULL)
{
- a = get_AT (die, DW_AT_abstract_origin);
- if (a)
- add_child_die (a->dw_attr_val.v.val_die_ref->die_parent, die);
+ dw_die_ref origin = get_AT_ref (die, DW_AT_abstract_origin);
+ tree context;
+
+ if (origin)
+ 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);
+ else if (node->created_for
+ && ((DECL_P (node->created_for)
+ && (context = DECL_CONTEXT (node->created_for)))
+ || (TYPE_P (node->created_for)
+ && (context = TYPE_CONTEXT (node->created_for))))
+ && TREE_CODE (context) == FUNCTION_DECL)
+ {
+ /* In certain situations, the lexical block containing a
+ nested function can be optimized away, which results
+ in the nested function die being orphaned. Likewise
+ with the return type of that nested function. Force
+ this to be a child of the containing function. */
+ origin = lookup_decl_die (context);
+ if (! origin)
+ abort ();
+ add_child_die (origin, die);
+ }
else
abort ();
}
+
free (node);
}
+ limbo_die_list = NULL;
+
/* Walk through the list of incomplete types again, trying once more to
emit full debugging info for them. */
retry_incomplete_types ();
- /* Traverse the DIE tree and add sibling attributes to those DIE's
+ /* We need to reverse all the dies before break_out_includes, or
+ we'll see the end of an include file before the beginning. */
+ reverse_all_dies (comp_unit_die);
+
+ /* Generate separate CUs for each of the include files we've seen.
+ They will go into limbo_die_list. */
+ if (flag_eliminate_dwarf2_dups)
+ break_out_includes (comp_unit_die);
+
+ /* Traverse the DIE's and add add sibling attributes to those DIE's
that have children. */
add_sibling_attributes (comp_unit_die);
+ for (node = limbo_die_list; node; node = node->next)
+ add_sibling_attributes (node->die);
/* Output a terminator label for the .text section. */
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_SECTION (asm_out_file, TEXT_SECTION);
+ text_section ();
ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, TEXT_END_LABEL, 0);
-#if 0
- /* Output a terminator label for the .data section. */
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_SECTION (asm_out_file, DATA_SECTION);
- ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, DATA_END_LABEL, 0);
-
- /* Output a terminator label for the .bss section. */
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_SECTION (asm_out_file, BSS_SECTION);
- ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, BSS_END_LABEL, 0);
-#endif
-
- /* Output the source line correspondence table. */
- if (line_info_table_in_use > 1 || separate_line_info_table_in_use)
+ /* Output the source line correspondence table. We must do this
+ even if there is no line information. Otherwise, on an empty
+ translation unit, we will generate a present, but empty,
+ .debug_info section. IRIX 6.5 `nm' will then complain when
+ examining the file. */
+ if (! DWARF2_ASM_LINE_DEBUG_INFO)
{
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_SECTION (asm_out_file, DEBUG_LINE_SECTION);
+ named_section_flags (DEBUG_LINE_SECTION, SECTION_DEBUG);
output_line_info ();
+ }
- /* We can only use the low/high_pc attributes if all of the code
- was in .text. */
- if (separate_line_info_table_in_use == 0)
- {
- add_AT_lbl_id (comp_unit_die, DW_AT_low_pc, text_section_label);
- add_AT_lbl_id (comp_unit_die, DW_AT_high_pc, text_end_label);
- }
+ /* Output location list section if necessary. */
+ if (have_location_lists)
+ {
+ /* Output the location lists info. */
+ named_section_flags (DEBUG_LOC_SECTION, SECTION_DEBUG);
+ 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);
+ have_location_lists = 0;
+ }
- add_AT_lbl_offset (comp_unit_die, DW_AT_stmt_list,
- debug_line_section_label);
+ /* We can only use the low/high_pc attributes if all of the code was
+ in .text. */
+ if (separate_line_info_table_in_use == 0)
+ {
+ add_AT_lbl_id (comp_unit_die, DW_AT_low_pc, text_section_label);
+ add_AT_lbl_id (comp_unit_die, DW_AT_high_pc, text_end_label);
}
- /* Output the abbreviation table. */
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_SECTION (asm_out_file, ABBREV_SECTION);
- build_abbrev_table (comp_unit_die);
- output_abbrev_section ();
+ /* If it wasn't, we need to give .debug_loc and .debug_ranges an appropriate
+ "base address". Use zero so that these addresses become absolute. */
+ else if (have_location_lists || ranges_table_in_use)
+ add_AT_addr (comp_unit_die, DW_AT_entry_pc, const0_rtx);
- /* Initialize the beginning DIE offset - and calculate sizes/offsets. */
- next_die_offset = DWARF_COMPILE_UNIT_HEADER_SIZE;
- calc_die_sizes (comp_unit_die);
+ if (debug_info_level >= DINFO_LEVEL_NORMAL)
+ add_AT_lbl_offset (comp_unit_die, DW_AT_stmt_list,
+ debug_line_section_label);
- /* Output debugging information. */
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_SECTION (asm_out_file, DEBUG_INFO_SECTION);
- output_compilation_unit_header ();
- output_die (comp_unit_die);
+ if (debug_info_level >= DINFO_LEVEL_VERBOSE)
+ add_AT_lbl_offset (comp_unit_die, DW_AT_macro_info, macinfo_section_label);
+
+ /* Output all of the compilation units. We put the main one last so that
+ the offsets are available to output_pubnames. */
+ for (node = limbo_die_list; node; node = node->next)
+ output_comp_unit (node->die);
+ output_comp_unit (comp_unit_die);
+
+ /* Output the abbreviation table. */
+ named_section_flags (DEBUG_ABBREV_SECTION, SECTION_DEBUG);
+ output_abbrev_section ();
+
+ /* Output public names table if necessary. */
if (pubname_table_in_use)
{
- /* Output public names table. */
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_SECTION (asm_out_file, PUBNAMES_SECTION);
+ named_section_flags (DEBUG_PUBNAMES_SECTION, SECTION_DEBUG);
output_pubnames ();
}
+ /* Output the address range information. We only put functions in the arange
+ table, so don't write it out if we don't have any. */
if (fde_table_in_use)
{
- /* Output the address range information. */
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_SECTION (asm_out_file, ARANGES_SECTION);
+ named_section_flags (DEBUG_ARANGES_SECTION, SECTION_DEBUG);
output_aranges ();
}
+
+ /* Output ranges section if necessary. */
+ if (ranges_table_in_use)
+ {
+ named_section_flags (DEBUG_RANGES_SECTION, SECTION_DEBUG);
+ ASM_OUTPUT_LABEL (asm_out_file, ranges_section_label);
+ output_ranges ();
+ }
+
+ /* Have to end the primary source file. */
+ if (debug_info_level >= DINFO_LEVEL_VERBOSE)
+ {
+ named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG);
+ dw2_asm_output_data (1, DW_MACINFO_end_file, "End file");
+ }
+
+ /* If we emitted any DW_FORM_strp form attribute, output the string
+ table too. */
+ if (debug_str_hash)
+ ht_forall (debug_str_hash, output_indirect_string, NULL);
}
-#endif /* DWARF2_DEBUGGING_INFO */
+#endif /* DWARF2_DEBUGGING_INFO || DWARF2_UNWIND_INFO */
OpenPOWER on IntegriCloud