#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "tree.h"
#include "rtl.h"
#include "flags.h"
#include "regs.h"
#include "insn-config.h"
#include "reload.h"
#include "output.h"
#include "dbxout.h"
#include "toplev.h"
#include "tm_p.h"
#include "ggc.h"
#include "debug.h"
#include "function.h"
#include "target.h"
#include "langhooks.h"
#include "obstack.h"
#include "expr.h"
#ifdef XCOFF_DEBUGGING_INFO
#include "xcoffout.h"
#endif
#define DBXOUT_DECR_NESTING \
if (--debug_nesting == 0 && symbol_queue_index > 0) \
{ emit_pending_bincls_if_required (); debug_flush_symbol_queue (); }
#define DBXOUT_DECR_NESTING_AND_RETURN(x) \
do {--debug_nesting; return (x);} while (0)
#ifndef ASM_STABS_OP
# ifdef XCOFF_DEBUGGING_INFO
# define ASM_STABS_OP "\t.stabx\t"
# else
# define ASM_STABS_OP "\t.stabs\t"
# endif
#endif
#ifndef ASM_STABN_OP
#define ASM_STABN_OP "\t.stabn\t"
#endif
#ifndef ASM_STABD_OP
#define ASM_STABD_OP "\t.stabd\t"
#endif
#ifndef DBX_TYPE_DECL_STABS_CODE
#define DBX_TYPE_DECL_STABS_CODE N_LSYM
#endif
#ifndef DBX_STATIC_CONST_VAR_CODE
#define DBX_STATIC_CONST_VAR_CODE N_FUN
#endif
#ifndef DBX_REGPARM_STABS_CODE
#define DBX_REGPARM_STABS_CODE N_RSYM
#endif
#ifndef DBX_REGPARM_STABS_LETTER
#define DBX_REGPARM_STABS_LETTER 'P'
#endif
#ifndef NO_DBX_FUNCTION_END
#define NO_DBX_FUNCTION_END 0
#endif
#ifndef NO_DBX_BNSYM_ENSYM
#define NO_DBX_BNSYM_ENSYM 0
#endif
#ifndef NO_DBX_MAIN_SOURCE_DIRECTORY
#define NO_DBX_MAIN_SOURCE_DIRECTORY 0
#endif
#ifndef DBX_BLOCKS_FUNCTION_RELATIVE
#define DBX_BLOCKS_FUNCTION_RELATIVE 0
#endif
#ifndef DBX_LINES_FUNCTION_RELATIVE
#define DBX_LINES_FUNCTION_RELATIVE 0
#endif
#ifndef DBX_CONTIN_LENGTH
#define DBX_CONTIN_LENGTH 80
#endif
#ifndef DBX_CONTIN_CHAR
#define DBX_CONTIN_CHAR '\\'
#endif
enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED, TYPE_QUEUED};
struct typeinfo GTY(())
{
enum typestatus status;
int file_number;
int type_number;
int q_type_number;
};
static GTY ((length ("typevec_len"))) struct typeinfo *typevec;
static GTY(()) int typevec_len;
static GTY(()) int next_type_number;
struct qualified_typeinfo GTY(())
{
int pointer_type;
int function_type;
int reference_type;
int const_type;
int volatile_type;
};
static GTY ((length ("q_typevec_len"))) struct qualified_typeinfo *q_typevec;
static GTY(()) int q_typevec_len;
static GTY(()) int next_q_type_number;
static int dbxout_next_q_type_number (void);
static GTY(()) tree preinit_symbols;
static GTY(()) tree anon_place_holder;
enum binclstatus {BINCL_NOT_REQUIRED, BINCL_PENDING, BINCL_PROCESSED};
struct dbx_file
{
struct dbx_file *next;
int file_number;
int next_type_number;
enum binclstatus bincl_status;
const char *pending_bincl_name;
struct dbx_file *prev;
};
#if (defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)) \
&& defined (DBX_USE_BINCL)
static struct dbx_file *current_file;
#endif
static FILE *dbx_out_file;
static GTY(()) int next_file_number;
static GTY(()) int scope_labelno;
static GTY(()) int dbxout_source_line_counter;
static GTY(()) int source_label_number = 1;
static GTY(()) const char *lastfile;
static GTY(()) int lastfile_is_base;
#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
#ifdef DBX_USE_BINCL
static int pending_bincls = 0;
#endif
static const char *base_input_file;
#ifdef DEBUG_SYMS_TEXT
#define FORCE_TEXT switch_to_section (current_function_section ())
#else
#define FORCE_TEXT
#endif
#include "gstab.h"
#define STAB_CODE_TYPE enum __stab_debug_code
#define PARM_PASSED_IN_MEMORY(PARM) \
(MEM_P (DECL_INCOMING_RTL (PARM)))
#ifndef DEBUGGER_AUTO_OFFSET
#define DEBUGGER_AUTO_OFFSET(X) \
(GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
#endif
#ifndef DEBUGGER_ARG_OFFSET
#define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
#endif
static struct obstack stabstr_ob;
static size_t stabstr_last_contin_point;
#ifdef DBX_USE_BINCL
static void emit_bincl_stab (const char *c);
static void emit_pending_bincls (void);
#endif
static inline void emit_pending_bincls_if_required (void);
static void dbxout_init (const char *);
static void dbxout_finish (const char *);
static void dbxout_start_source_file (unsigned, const char *);
static void dbxout_end_source_file (unsigned);
static void dbxout_typedefs (tree);
static void dbxout_type_index (tree);
static void dbxout_args (tree);
static void dbxout_type_fields (tree);
static void dbxout_type_method_1 (tree);
static void dbxout_type_methods (tree);
static void dbxout_range_type (tree);
static bool dbxout_type (tree, int);
static bool dbxout_partial_type (tree, tree);
static void dbxout_complete_type (tree, tree);
static void dbxout_type_xref (tree);
static void dbxout_pointer_type (tree);
static void dbxout_void_type (tree);
static void dbxout_integer_type (tree);
static void dbxout_real_type (tree);
static void dbxout_boolean_type (tree);
static void dbxout_complex_type (tree);
static void dbxout_function_type (tree);
static void dbxout_reference_type (tree);
static int dbxout_reusable_type (tree);
static void dbxout_note_q_type (tree);
static void dbxout_next_type_number (tree);
#ifdef DBX_NO_XREFS
static bool dbxout_cross_ref_type_p (tree);
#endif
static void dbxout_type_with_name (tree);
static void dbxout_queue_type (tree);
static void dbxout_free_type_queue (void);
static bool print_int_cst_bounds_in_octal_p (tree);
static void dbxout_type_name (tree);
static void dbxout_class_name_qualifiers (tree);
static int dbxout_symbol_location (tree, tree, const char *, rtx);
static void dbxout_symbol_name (tree, const char *, int);
static void dbxout_block (tree, int, tree);
static void dbxout_global_decl (tree);
static void dbxout_type_decl (tree, int);
static void dbxout_handle_pch (unsigned);
#if defined (DBX_DEBUGGING_INFO)
static void dbxout_source_line (unsigned int, const char *);
static void dbxout_begin_prologue (unsigned int, const char *);
static void dbxout_source_file (const char *);
static void dbxout_function_end (tree);
static void dbxout_begin_function (tree);
static void dbxout_begin_block (unsigned, unsigned);
static void dbxout_end_block (unsigned, unsigned);
static void dbxout_function_decl (tree);
const struct gcc_debug_hooks dbx_debug_hooks =
{
dbxout_init,
dbxout_finish,
debug_nothing_int_charstar,
debug_nothing_int_charstar,
dbxout_start_source_file,
dbxout_end_source_file,
dbxout_begin_block,
dbxout_end_block,
debug_true_tree,
dbxout_source_line,
dbxout_begin_prologue,
debug_nothing_int_charstar,
debug_nothing_int_charstar,
#ifdef DBX_FUNCTION_FIRST
dbxout_begin_function,
#else
debug_nothing_tree,
#endif
debug_nothing_int,
dbxout_function_decl,
dbxout_global_decl,
dbxout_type_decl,
debug_nothing_tree_tree,
debug_nothing_tree,
debug_nothing_tree,
debug_nothing_rtx,
dbxout_handle_pch,
debug_nothing_rtx,
debug_nothing_od_msg_loc,
debug_nothing_void,
0
};
#endif
#if defined (XCOFF_DEBUGGING_INFO)
const struct gcc_debug_hooks xcoff_debug_hooks =
{
dbxout_init,
dbxout_finish,
debug_nothing_int_charstar,
debug_nothing_int_charstar,
dbxout_start_source_file,
dbxout_end_source_file,
xcoffout_begin_block,
xcoffout_end_block,
debug_true_tree,
xcoffout_source_line,
xcoffout_begin_prologue,
debug_nothing_int_charstar,
xcoffout_end_epilogue,
debug_nothing_tree,
xcoffout_end_function,
debug_nothing_tree,
dbxout_global_decl,
dbxout_type_decl,
debug_nothing_tree_tree,
debug_nothing_tree,
debug_nothing_tree,
debug_nothing_rtx,
dbxout_handle_pch,
debug_nothing_rtx,
debug_nothing_od_msg_loc,
debug_nothing_void,
0
};
#endif
#define NUMBER_FMT_LOOP(P, NUM, BASE) \
do \
{ \
int digit = NUM % BASE; \
NUM /= BASE; \
*--P = digit + '0'; \
} \
while (NUM > 0)
void
dbxout_int (int num)
{
char buf[64];
char *p = buf + sizeof buf;
unsigned int unum;
if (num == 0)
{
putc ('0', dbx_out_file);
return;
}
if (num < 0)
{
putc ('-', dbx_out_file);
unum = -num;
}
else
unum = num;
NUMBER_FMT_LOOP (p, unum, 10);
while (p < buf + sizeof buf)
{
putc (*p, dbx_out_file);
p++;
}
}
void
dbxout_stab_value_zero (void)
{
fputs ("0\n", dbx_out_file);
}
void
dbxout_stab_value_label (const char *label)
{
assemble_name (dbx_out_file, label);
putc ('\n', dbx_out_file);
}
void
dbxout_stab_value_label_diff (const char *label, const char *base)
{
assemble_name (dbx_out_file, label);
putc ('-', dbx_out_file);
assemble_name (dbx_out_file, base);
putc ('\n', dbx_out_file);
}
void
dbxout_stab_value_internal_label (const char *stem, int *counterp)
{
char label[100];
int counter = counterp ? (*counterp)++ : 0;
ASM_GENERATE_INTERNAL_LABEL (label, stem, counter);
dbxout_stab_value_label (label);
targetm.asm_out.internal_label (dbx_out_file, stem, counter);
}
void
dbxout_stab_value_internal_label_diff (const char *stem, int *counterp,
const char *base)
{
char label[100];
int counter = counterp ? (*counterp)++ : 0;
ASM_GENERATE_INTERNAL_LABEL (label, stem, counter);
dbxout_stab_value_label_diff (label, base);
targetm.asm_out.internal_label (dbx_out_file, stem, counter);
}
void
dbxout_stabd (int stype, int sdesc)
{
fputs (ASM_STABD_OP, dbx_out_file);
dbxout_int (stype);
fputs (",0,", dbx_out_file);
dbxout_int (sdesc);
putc ('\n', dbx_out_file);
}
void
dbxout_begin_stabn (int stype)
{
fputs (ASM_STABN_OP, dbx_out_file);
dbxout_int (stype);
fputs (",0,0,", dbx_out_file);
}
void
dbxout_begin_stabn_sline (int lineno)
{
fputs (ASM_STABN_OP, dbx_out_file);
dbxout_int (N_SLINE);
fputs (",0,", dbx_out_file);
dbxout_int (lineno);
putc (',', dbx_out_file);
}
void
dbxout_begin_empty_stabs (int stype)
{
fputs (ASM_STABS_OP, dbx_out_file);
fputs ("\"\",", dbx_out_file);
dbxout_int (stype);
fputs (",0,0,", dbx_out_file);
}
void
dbxout_begin_simple_stabs (const char *str, int stype)
{
fputs (ASM_STABS_OP, dbx_out_file);
output_quoted_string (dbx_out_file, str);
putc (',', dbx_out_file);
dbxout_int (stype);
fputs (",0,0,", dbx_out_file);
}
void
dbxout_begin_simple_stabs_desc (const char *str, int stype, int sdesc)
{
fputs (ASM_STABS_OP, dbx_out_file);
output_quoted_string (dbx_out_file, str);
putc (',', dbx_out_file);
dbxout_int (stype);
fputs (",0,", dbx_out_file);
dbxout_int (sdesc);
putc (',', dbx_out_file);
}
static void
dbxout_begin_complex_stabs (void)
{
emit_pending_bincls_if_required ();
FORCE_TEXT;
fputs (ASM_STABS_OP, dbx_out_file);
putc ('"', dbx_out_file);
gcc_assert (stabstr_last_contin_point == 0);
}
static void
dbxout_begin_complex_stabs_noforcetext (void)
{
fputs (ASM_STABS_OP, dbx_out_file);
putc ('"', dbx_out_file);
gcc_assert (stabstr_last_contin_point == 0);
}
#define stabstr_C(chr) obstack_1grow (&stabstr_ob, chr)
#define stabstr_S(str) obstack_grow (&stabstr_ob, str, strlen(str))
static void
stabstr_I (tree id)
{
if ((strcmp (lang_hooks.name, "GNU C++") == 0
|| strcmp (lang_hooks.name, "GNU Objective-C++") == 0)
&& IDENTIFIER_LENGTH (id) > 2
&& strncmp ("$_", IDENTIFIER_POINTER (id), 2) == 0)
obstack_grow (&stabstr_ob, "$_", 2);
else
obstack_grow (&stabstr_ob, IDENTIFIER_POINTER (id), IDENTIFIER_LENGTH (id));
}
static void
stabstr_D (HOST_WIDE_INT num)
{
char buf[64];
char *p = buf + sizeof buf;
unsigned int unum;
if (num == 0)
{
stabstr_C ('0');
return;
}
if (num < 0)
{
stabstr_C ('-');
unum = -num;
}
else
unum = num;
NUMBER_FMT_LOOP (p, unum, 10);
obstack_grow (&stabstr_ob, p, (buf + sizeof buf) - p);
}
static void
stabstr_U (unsigned HOST_WIDE_INT num)
{
char buf[64];
char *p = buf + sizeof buf;
if (num == 0)
{
stabstr_C ('0');
return;
}
NUMBER_FMT_LOOP (p, num, 10);
obstack_grow (&stabstr_ob, p, (buf + sizeof buf) - p);
}
static void
stabstr_O (tree cst)
{
unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (cst);
unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (cst);
char buf[128];
char *p = buf + sizeof buf;
{
const unsigned int width = TYPE_PRECISION (TREE_TYPE (cst));
if (width == HOST_BITS_PER_WIDE_INT * 2)
;
else if (width > HOST_BITS_PER_WIDE_INT)
high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1);
else if (width == HOST_BITS_PER_WIDE_INT)
high = 0;
else
high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1);
}
stabstr_C ('0');
if (high == 0 && low == 0)
return;
if (high == 0)
NUMBER_FMT_LOOP (p, low, 8);
else
{
const int n_digits = HOST_BITS_PER_WIDE_INT / 3;
int i;
for (i = 1; i <= n_digits; i++)
{
unsigned int digit = low % 8;
low /= 8;
*--p = '0' + digit;
}
if (HOST_BITS_PER_WIDE_INT % 3 != 0)
{
const int n_leftover_bits = HOST_BITS_PER_WIDE_INT % 3;
const int n_bits_from_high = 3 - n_leftover_bits;
const unsigned HOST_WIDE_INT
low_mask = (((unsigned HOST_WIDE_INT)1) << n_leftover_bits) - 1;
const unsigned HOST_WIDE_INT
high_mask = (((unsigned HOST_WIDE_INT)1) << n_bits_from_high) - 1;
unsigned int digit;
gcc_assert (!(low & ~low_mask));
digit = (low | ((high & high_mask) << n_leftover_bits));
high >>= n_bits_from_high;
*--p = '0' + digit;
}
if (high)
NUMBER_FMT_LOOP (p, high, 8);
}
obstack_grow (&stabstr_ob, p, (buf + sizeof buf) - p);
}
static inline void
stabstr_continue (void)
{
if (DBX_CONTIN_LENGTH > 0
&& obstack_object_size (&stabstr_ob) - stabstr_last_contin_point
> DBX_CONTIN_LENGTH)
{
if (DBX_CONTIN_CHAR == '\\')
obstack_1grow (&stabstr_ob, '\\');
obstack_1grow (&stabstr_ob, DBX_CONTIN_CHAR);
obstack_1grow (&stabstr_ob, '\0');
stabstr_last_contin_point = obstack_object_size (&stabstr_ob);
}
}
#define CONTIN stabstr_continue ()
#ifndef DBX_FINISH_STABS
#define DBX_FINISH_STABS(SYM, CODE, LINE, ADDR, LABEL, NUMBER) \
do { \
int line_ = use_gnu_debug_info_extensions ? LINE : 0; \
\
dbxout_int (CODE); \
fputs (",0,", dbx_out_file); \
dbxout_int (line_); \
putc (',', dbx_out_file); \
if (ADDR) \
output_addr_const (dbx_out_file, ADDR); \
else if (LABEL) \
assemble_name (dbx_out_file, LABEL); \
else \
dbxout_int (NUMBER); \
putc ('\n', dbx_out_file); \
\
} while (0)
#endif
static void
dbxout_finish_complex_stabs (tree sym, STAB_CODE_TYPE code,
rtx addr, const char *label, int number)
{
int line ATTRIBUTE_UNUSED;
char *str;
size_t len;
line = sym ? DECL_SOURCE_LINE (sym) : 0;
if (DBX_CONTIN_LENGTH > 0)
{
char *chunk;
size_t chunklen;
obstack_1grow (&stabstr_ob, '\0');
len = obstack_object_size (&stabstr_ob);
chunk = str = XOBFINISH (&stabstr_ob, char *);
for (;;)
{
chunklen = strlen (chunk);
fwrite (chunk, 1, chunklen, dbx_out_file);
fputs ("\",", dbx_out_file);
chunk += chunklen + 1;
len -= chunklen + 1;
DBX_FINISH_STABS (sym, code, len == 0 ? line : 0,
addr, label, number);
if (len == 0)
break;
fputs (ASM_STABS_OP, dbx_out_file);
putc ('"', dbx_out_file);
}
stabstr_last_contin_point = 0;
}
else
{
obstack_grow (&stabstr_ob, "\",", 2);
len = obstack_object_size (&stabstr_ob);
str = XOBFINISH (&stabstr_ob, char *);
fwrite (str, 1, len, dbx_out_file);
DBX_FINISH_STABS (sym, code, line, addr, label, number);
}
obstack_free (&stabstr_ob, str);
}
#if defined (DBX_DEBUGGING_INFO)
static void
dbxout_function_end (tree decl)
{
char lscope_label_name[100];
dbxout_flush_type_queue ();
switch_to_section (function_section (current_function_decl));
ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", scope_labelno);
targetm.asm_out.internal_label (dbx_out_file, "Lscope", scope_labelno);
if (!use_gnu_debug_info_extensions
|| NO_DBX_FUNCTION_END
|| !targetm.have_named_sections
|| DECL_IGNORED_P (decl))
return;
if (flag_reorder_blocks_and_partition)
{
dbxout_begin_empty_stabs (N_FUN);
dbxout_stab_value_label_diff (cfun->hot_section_end_label,
cfun->hot_section_label);
dbxout_begin_empty_stabs (N_FUN);
dbxout_stab_value_label_diff (cfun->cold_section_end_label,
cfun->cold_section_label);
}
else
{
char begin_label[20];
ASM_GENERATE_INTERNAL_LABEL (begin_label, "LFBB", scope_labelno);
dbxout_begin_empty_stabs (N_FUN);
dbxout_stab_value_label_diff (lscope_label_name, begin_label);
}
if (!NO_DBX_BNSYM_ENSYM)
{
dbxout_flush_type_queue ();
dbxout_stabd (N_ENSYM, 0);
}
}
#endif
static unsigned int ATTRIBUTE_UNUSED
get_lang_number (void)
{
const char *language_string = lang_hooks.name;
if (strcmp (language_string, "GNU C") == 0)
return N_SO_C;
else if (strcmp (language_string, "GNU C++") == 0)
return N_SO_CC;
else if (strcmp (language_string, "GNU F77") == 0)
return N_SO_FORTRAN;
else if (strcmp (language_string, "GNU F95") == 0)
return N_SO_FORTRAN90;
else if (strcmp (language_string, "GNU Pascal") == 0)
return N_SO_PASCAL;
else if (strcmp (language_string, "GNU Objective-C") == 0)
return N_SO_OBJC;
else if (strcmp (language_string, "GNU Objective-C++") == 0)
return N_SO_OBJCPLUS;
else
return 0;
}
static void
dbxout_init (const char *input_file_name)
{
char ltext_label_name[100];
bool used_ltext_label_name = false;
tree syms = lang_hooks.decls.getdecls ();
typevec_len = 100;
typevec = ggc_calloc (typevec_len, sizeof typevec[0]);
q_typevec_len = 100;
q_typevec = ggc_calloc (q_typevec_len, sizeof q_typevec[0]);
if (flag_save_repository
&& flag_pch_file
&& !flag_debug_only_used_symbols
&& asm_file_name
&& strcmp (asm_file_name, "-"))
{
dbx_out_file = fopen (asm_file_name, "w+b");
if (dbx_out_file == 0)
fatal_error ("can%'t open %s for writing: %m", asm_file_name);
}
else
dbx_out_file = asm_out_file;
obstack_specify_allocation (&stabstr_ob, 0, 1, xmalloc, free);
ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);
if (use_gnu_debug_info_extensions && !NO_DBX_MAIN_SOURCE_DIRECTORY)
{
static const char *cwd;
if (!cwd)
{
cwd = get_src_pwd ();
if (cwd[0] == '\0')
cwd = "/";
else if (!IS_DIR_SEPARATOR (cwd[strlen (cwd) - 1]))
cwd = concat (cwd, "/", NULL);
}
#ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (dbx_out_file, cwd);
#else
dbxout_begin_simple_stabs_desc (cwd, N_SO, get_lang_number ());
dbxout_stab_value_label (ltext_label_name);
used_ltext_label_name = true;
#endif
}
#ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
DBX_OUTPUT_MAIN_SOURCE_FILENAME (dbx_out_file, input_file_name);
#else
dbxout_begin_simple_stabs_desc (input_file_name, N_SO, get_lang_number ());
dbxout_stab_value_label (ltext_label_name);
used_ltext_label_name = true;
#endif
if (used_ltext_label_name)
{
switch_to_section (text_section);
targetm.asm_out.internal_label (dbx_out_file, "Ltext", 0);
}
dbxout_begin_empty_stabs (N_OSO);
dbxout_stab_value_zero ();
#ifndef NO_DBX_GCC_MARKER
dbxout_begin_simple_stabs ("gcc2_compiled.", N_OPT);
dbxout_stab_value_zero ();
#endif
base_input_file = lastfile = input_file_name;
next_type_number = 1;
#ifdef DBX_USE_BINCL
current_file = XNEW (struct dbx_file);
current_file->next = NULL;
current_file->file_number = 0;
current_file->next_type_number = 1;
next_file_number = 1;
current_file->prev = NULL;
current_file->bincl_status = BINCL_NOT_REQUIRED;
current_file->pending_bincl_name = NULL;
#endif
#ifndef DBX_ONLY_USED_SYMBOLS
dbxout_symbol (TYPE_NAME (integer_type_node), 0);
dbxout_symbol (TYPE_NAME (char_type_node), 0);
#endif
dbxout_typedefs (syms);
if (preinit_symbols)
{
tree t;
for (t = nreverse (preinit_symbols); t; t = TREE_CHAIN (t))
dbxout_symbol (TREE_VALUE (t), 0);
preinit_symbols = 0;
}
dbxout_queue_type (void_type_node);
dbxout_flush_type_queue ();
anon_place_holder = get_identifier ("__anon__");
}
static void
dbxout_typedefs (tree syms)
{
for (; syms != NULL_TREE; syms = TREE_CHAIN (syms))
{
if (TREE_CODE (syms) == TYPE_DECL)
{
tree type = TREE_TYPE (syms);
if (TYPE_NAME (type)
&& TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
&& COMPLETE_OR_VOID_TYPE_P (type)
&& ! TREE_ASM_WRITTEN (TYPE_NAME (type)))
dbxout_symbol (TYPE_NAME (type), 0);
}
}
}
#ifdef DBX_USE_BINCL
static void
emit_bincl_stab (const char *name)
{
static unsigned int dbx_checksum;
dbxout_begin_simple_stabs (name, N_BINCL);
if (flag_save_repository
&& flag_pch_file
&& !flag_debug_only_used_symbols)
{
dbx_checksum = crc32_string (42, name);
fprintf (asm_out_file, "%s", ASM_STABS_OP);
output_quoted_string (asm_out_file, name);
fprintf (asm_out_file, ",%d,0,0,%d\n", N_EXCL, dbx_checksum);
fprintf (dbx_out_file, "%d\n", dbx_checksum);
}
else
dbxout_stab_value_zero ();
}
static inline void
emit_pending_bincls_if_required (void)
{
if (pending_bincls)
emit_pending_bincls ();
}
static void
emit_pending_bincls (void)
{
struct dbx_file *f = current_file;
while (f->bincl_status == BINCL_PENDING)
f = f->next;
f = f->prev;
while (f)
{
if (f->bincl_status == BINCL_PENDING)
{
emit_bincl_stab (f->pending_bincl_name);
f->file_number = next_file_number++;
f->bincl_status = BINCL_PROCESSED;
}
if (f == current_file)
break;
f = f->prev;
}
pending_bincls = 0;
}
#else
static inline void
emit_pending_bincls_if_required (void) {}
#endif
static void
dbxout_start_source_file (unsigned int line ATTRIBUTE_UNUSED,
const char *filename ATTRIBUTE_UNUSED)
{
#ifdef DBX_USE_BINCL
struct dbx_file *n = XNEW (struct dbx_file);
dbxout_flush_type_queue ();
n->next = current_file;
n->next_type_number = 1;
n->file_number = 0;
n->prev = NULL;
if (current_file)
current_file->prev = n;
n->bincl_status = BINCL_PENDING;
n->pending_bincl_name = filename;
pending_bincls = 1;
current_file = n;
#endif
}
static void
dbxout_end_source_file (unsigned int line ATTRIBUTE_UNUSED)
{
dbxout_flush_type_queue ();
#ifdef DBX_USE_BINCL
if (!current_file)
return;
if (current_file->bincl_status == BINCL_PROCESSED)
{
dbxout_begin_stabn (N_EINCL);
dbxout_stab_value_zero ();
}
current_file->bincl_status = BINCL_NOT_REQUIRED;
current_file = current_file->next;
if (current_file == 0)
pending_bincls = 0;
#endif
}
static void
dbxout_handle_pch (unsigned at_end)
{
if (! at_end)
{
dbxout_start_source_file (0, lastfile);
lastfile = NULL;
}
else
{
dbxout_end_source_file (0);
lastfile_is_base = lastfile == NULL;
}
}
#if defined (DBX_DEBUGGING_INFO)
static void
dbxout_source_file (const char *filename)
{
if (lastfile == 0 && lastfile_is_base)
{
lastfile = base_input_file;
lastfile_is_base = 0;
}
if (filename && (lastfile == 0 || strcmp (filename, lastfile)))
{
if (current_function_decl == NULL_TREE)
switch_to_section (text_section);
dbxout_begin_simple_stabs (filename, N_SOL);
dbxout_stab_value_internal_label ("Ltext", &source_label_number);
lastfile = filename;
}
}
static void
dbxout_begin_prologue (unsigned int lineno, const char *filename)
{
if (use_gnu_debug_info_extensions
&& !NO_DBX_FUNCTION_END
&& !NO_DBX_BNSYM_ENSYM)
dbxout_stabd (N_BNSYM, 0);
scope_labelno++;
dbxout_source_line (lineno, filename);
emit_pending_bincls_if_required ();
targetm.asm_out.internal_label (asm_out_file, "LFBB", scope_labelno);
}
static void
dbxout_source_line (unsigned int lineno, const char *filename)
{
dbxout_source_file (filename);
#ifdef DBX_OUTPUT_SOURCE_LINE
DBX_OUTPUT_SOURCE_LINE (dbx_out_file, lineno, dbxout_source_line_counter);
#else
if (DBX_LINES_FUNCTION_RELATIVE)
{
char begin_label[20];
dbxout_begin_stabn_sline (lineno);
ASM_GENERATE_INTERNAL_LABEL (begin_label, "LFBB", scope_labelno);
dbxout_stab_value_internal_label_diff ("LM", &dbxout_source_line_counter,
begin_label);
}
else
dbxout_stabd (N_SLINE, lineno);
#endif
}
static void
dbxout_begin_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n)
{
emit_pending_bincls_if_required ();
targetm.asm_out.internal_label (dbx_out_file, "LBB", n);
}
static void
dbxout_end_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n)
{
emit_pending_bincls_if_required ();
targetm.asm_out.internal_label (dbx_out_file, "LBE", n);
}
static void
dbxout_function_decl (tree decl)
{
emit_pending_bincls_if_required ();
#ifndef DBX_FUNCTION_FIRST
dbxout_begin_function (decl);
#endif
dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
dbxout_function_end (decl);
}
#endif
static void
dbxout_global_decl (tree decl)
{
if (TREE_CODE (decl) == VAR_DECL && !DECL_EXTERNAL (decl))
{
int saved_tree_used = TREE_USED (decl);
TREE_USED (decl) = 1;
dbxout_symbol (decl, 0);
TREE_USED (decl) = saved_tree_used;
}
}
static void
dbxout_type_decl (tree decl, int local)
{
dbxout_symbol (decl, local);
}
static void
dbxout_finish (const char *filename ATTRIBUTE_UNUSED)
{
dbxout_free_type_queue ();
#ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
DBX_OUTPUT_MAIN_SOURCE_FILE_END (dbx_out_file, filename);
#elif defined DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END
{
switch_to_section (text_section);
dbxout_begin_empty_stabs (N_SO);
dbxout_stab_value_internal_label ("Letext", 0);
}
#endif
debug_free_queue ();
if (flag_save_repository
&& flag_pch_file && !flag_debug_only_used_symbols)
{
if (ferror (dbx_out_file) != 0)
fatal_error ("error writing to %s: %m", asm_file_name);
if (fclose (dbx_out_file) != 0)
fatal_error ("error closing %s: %m", asm_file_name);
}
}
static void
dbxout_note_q_type (tree type)
{
tree ttype = TREE_TYPE (type);
int t_number = TYPE_SYMTAB_ADDRESS (type);
int tt_number = TYPE_SYMTAB_ADDRESS (ttype);
int q_number = typevec[t_number].q_type_number;
if (TYPE_QUALS (type))
return;
if (q_number == 0)
q_number = dbxout_next_q_type_number ();
switch (TREE_CODE (type))
{
case FUNCTION_TYPE:
if (q_typevec[q_number].function_type == 0)
{
q_typevec[q_number].function_type = t_number;
typevec[tt_number].q_type_number = q_number;
}
break;
case POINTER_TYPE:
if (q_typevec[q_number].pointer_type == 0)
{
q_typevec[q_number].pointer_type = t_number;
typevec[tt_number].q_type_number = q_number;
}
break;
case REFERENCE_TYPE:
if (q_typevec[q_number].reference_type == 0)
{
q_typevec[q_number].reference_type = t_number;
typevec[tt_number].q_type_number = q_number;
}
break;
default:
gcc_unreachable ();
break;
}
}
static int
dbxout_reusable_type (tree type)
{
tree t;
int q_no = 0;
if (TYPE_QUALS (type))
return 0;
t = TREE_TYPE (type);
if (t && TYPE_SYMTAB_ADDRESS (t) == 0)
return 0;
switch (TREE_CODE (type))
{
case FUNCTION_TYPE:
q_no = typevec[TYPE_SYMTAB_ADDRESS (t)].q_type_number;
if (q_no && q_typevec[q_no].function_type)
return q_typevec[q_no].function_type;
break;
case POINTER_TYPE:
q_no = typevec[TYPE_SYMTAB_ADDRESS (t)].q_type_number;
if (q_no && q_typevec[q_no].pointer_type)
return q_typevec[q_no].pointer_type;
break;
case REFERENCE_TYPE:
q_no = typevec[TYPE_SYMTAB_ADDRESS (t)].q_type_number;
if (q_no && q_typevec[q_no].reference_type)
return q_typevec[q_no].reference_type;
break;
default:
break;
}
return 0;
}
static void
dbxout_type_index (tree type)
{
struct typeinfo *t = NULL;
if (TYPE_SYMTAB_ADDRESS (type) == 0)
{
int r = dbxout_reusable_type (type);
if (r)
TYPE_SYMTAB_ADDRESS (type) = r;
dbxout_next_type_number (type);
}
#ifndef DBX_USE_BINCL
stabstr_D (TYPE_SYMTAB_ADDRESS (type));
#else
t = &typevec[TYPE_SYMTAB_ADDRESS (type)];
stabstr_C ('(');
stabstr_D (t->file_number);
stabstr_C (',');
stabstr_D (t->type_number);
stabstr_C (')');
#endif
}
#define DECL_ACCESSIBILITY_CHAR(DECL) \
(TREE_PRIVATE (DECL) ? '0' : TREE_PROTECTED (DECL) ? '1' : '2')
static void
dbxout_type_fields (tree type)
{
tree tem;
for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
{
if (tem == error_mark_node || TREE_TYPE (tem) == error_mark_node)
return;
if (TREE_CODE (tem) == TYPE_DECL
|| DECL_IGNORED_P (tem)
|| (TREE_CODE (tem) == FIELD_DECL
&& (! host_integerp (bit_position (tem), 0)
|| ! DECL_SIZE (tem)
|| ! host_integerp (DECL_SIZE (tem), 1))))
continue;
else if (TREE_CODE (tem) != CONST_DECL)
{
if (tem != TYPE_FIELDS (type))
CONTIN;
else if (TREE_CODE (TREE_TYPE (tem)) == RECORD_TYPE
&& !strncmp (lang_hooks.name, "GNU Objective-C", 15))
{
extern tree objc_is_class_name (tree);
if (objc_is_class_name (TYPE_NAME (type))
&& objc_is_class_name (TYPE_NAME (TREE_TYPE (tem))))
{
dbxout_type_fields (TREE_TYPE (tem));
continue;
}
}
if (DECL_NAME (tem))
stabstr_I (DECL_NAME (tem));
stabstr_C (':');
if (use_gnu_debug_info_extensions
&& (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
|| TREE_CODE (tem) != FIELD_DECL))
{
stabstr_C ('/');
stabstr_C (DECL_ACCESSIBILITY_CHAR (tem));
}
dbxout_type ((TREE_CODE (tem) == FIELD_DECL
&& DECL_BIT_FIELD_TYPE (tem))
? DECL_BIT_FIELD_TYPE (tem) : TREE_TYPE (tem), 0);
if (TREE_CODE (tem) == VAR_DECL)
{
if (TREE_STATIC (tem) && use_gnu_debug_info_extensions)
{
tree name = DECL_ASSEMBLER_NAME (tem);
stabstr_C (':');
stabstr_I (name);
stabstr_C (';');
}
else
stabstr_S (",0,0;");
}
else
{
stabstr_C (',');
stabstr_D (int_bit_position (tem));
stabstr_C (',');
stabstr_D (tree_low_cst (DECL_SIZE (tem), 1));
stabstr_C (';');
}
}
}
}
static void
dbxout_type_method_1 (tree decl)
{
char c1 = 'A', c2;
if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
c2 = '?';
else
{
tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)));
if (TYPE_READONLY (TREE_TYPE (firstarg)))
c1 += 1;
if (TYPE_VOLATILE (TREE_TYPE (firstarg)))
c1 += 2;
if (DECL_VINDEX (decl))
c2 = '*';
else
c2 = '.';
}
stabstr_C (':');
stabstr_I (DECL_ASSEMBLER_NAME (decl));
stabstr_C (';');
stabstr_C (DECL_ACCESSIBILITY_CHAR (decl));
stabstr_C (c1);
stabstr_C (c2);
if (DECL_VINDEX (decl) && host_integerp (DECL_VINDEX (decl), 0))
{
stabstr_D (tree_low_cst (DECL_VINDEX (decl), 0));
stabstr_C (';');
dbxout_type (DECL_CONTEXT (decl), 0);
stabstr_C (';');
}
}
static void
dbxout_type_methods (tree type)
{
tree methods = TYPE_METHODS (type);
tree fndecl;
tree last;
if (methods == NULL_TREE)
return;
if (TREE_CODE (methods) != TREE_VEC)
fndecl = methods;
else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
fndecl = TREE_VEC_ELT (methods, 0);
else
fndecl = TREE_VEC_ELT (methods, 1);
while (fndecl)
{
int need_prefix = 1;
for (last = NULL_TREE;
fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last));
fndecl = TREE_CHAIN (fndecl))
{
if (TREE_CODE (fndecl) != FUNCTION_DECL)
continue;
CONTIN;
last = fndecl;
if (DECL_IGNORED_P (fndecl) || DECL_ABSTRACT (fndecl))
continue;
if (need_prefix)
{
stabstr_I (DECL_NAME (fndecl));
stabstr_S ("::");
need_prefix = 0;
}
dbxout_type (TREE_TYPE (fndecl), 0);
dbxout_type_method_1 (fndecl);
}
if (!need_prefix)
stabstr_C (';');
}
}
static void
dbxout_range_type (tree type)
{
stabstr_C ('r');
if (TREE_TYPE (type))
dbxout_type (TREE_TYPE (type), 0);
else if (TREE_CODE (type) != INTEGER_TYPE)
dbxout_type (type, 0);
else
{
if (TYPE_SYMTAB_ADDRESS (type) != 0)
dbxout_type_index (type);
else
dbxout_type_index (integer_type_node);
}
stabstr_C (';');
if (TYPE_MIN_VALUE (type) != 0
&& host_integerp (TYPE_MIN_VALUE (type), 0))
{
if (print_int_cst_bounds_in_octal_p (type))
stabstr_O (TYPE_MIN_VALUE (type));
else
stabstr_D (tree_low_cst (TYPE_MIN_VALUE (type), 0));
}
else
stabstr_C ('0');
stabstr_C (';');
if (TYPE_MAX_VALUE (type) != 0
&& host_integerp (TYPE_MAX_VALUE (type), 0))
{
if (print_int_cst_bounds_in_octal_p (type))
stabstr_O (TYPE_MAX_VALUE (type));
else
stabstr_D (tree_low_cst (TYPE_MAX_VALUE (type), 0));
stabstr_C (';');
}
else
stabstr_S ("-1;");
}
static bool
dbxout_type (tree type, int flag)
{
tree main_variant;
bool vector_type = false;
if (type == error_mark_node)
type = integer_type_node;
if (TREE_CODE (type) == VECTOR_TYPE)
{
type = TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type)));
vector_type = true;
}
if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
&& DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
main_variant = TREE_TYPE (TYPE_NAME (type));
else
main_variant = TYPE_MAIN_VARIANT (type);
if (!use_gnu_debug_info_extensions)
type = main_variant;
if (TYPE_NAME (type)
&& TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
&& TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type))
&& flag == 1)
flag = 0;
if (flag == 1 || flag == 2)
dbxout_complete_type (type, main_variant);
else if ( flag == 0)
return dbxout_partial_type (type, main_variant);
else
gcc_unreachable ();
return false;
}
static bool
dbxout_partial_type (tree type, tree main_variant)
{
bool result = false;
dbxout_type_index (type);
#ifdef DBX_TYPE_DEFINED
if (DBX_TYPE_DEFINED (type))
return result;
#endif
switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status)
{
case TYPE_UNSEEN:
break;
case TYPE_XREF:
case TYPE_DEFINED:
case TYPE_QUEUED:
return result;
break;
}
#ifdef DBX_NO_XREFS
if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
|| TREE_CODE (type) == QUAL_UNION_TYPE
|| TREE_CODE (type) == ENUMERAL_TYPE)
&& ! use_gnu_debug_info_extensions)
if (dbxout_cross_ref_type_p (type))
{
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
result = true;
return result;
}
#endif
if (TYPE_READONLY (type) > TYPE_READONLY (main_variant))
{
dbxout_queue_type (type);
return result;
}
if (TYPE_VOLATILE (type) > TYPE_VOLATILE (main_variant))
{
dbxout_queue_type (type);
return result;
}
if (flag_debug_only_used_symbols
&& TYPE_NAME (type)
&& TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
{
tree tree_type = TREE_TYPE (TYPE_NAME (type));
tree orig_type = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
if (tree_type)
{
switch (TREE_CODE (tree_type))
{
case ENUMERAL_TYPE:
case RECORD_TYPE:
case UNION_TYPE:
case QUAL_UNION_TYPE:
dbxout_next_type_number (tree_type);
typevec[TYPE_SYMTAB_ADDRESS (tree_type)].status = TYPE_XREF;
dbxout_type_xref (tree_type);
result = true;
if (orig_type
&& TYPE_STUB_DECL (orig_type)
&& ! DECL_IGNORED_P (TYPE_STUB_DECL (orig_type)))
debug_queue_symbol (TYPE_STUB_DECL (orig_type));
break;
default:
break;
}
}
if (orig_type)
dbxout_queue_type (orig_type);
dbxout_queue_type (type);
return result;
}
switch (TREE_CODE (type))
{
case VOID_TYPE:
case LANG_TYPE:
case BLOCK_POINTER_TYPE:
dbxout_void_type (type);
break;
case RECORD_TYPE:
case UNION_TYPE:
case QUAL_UNION_TYPE:
case ENUMERAL_TYPE:
if (TYPE_STUB_DECL (type)
&& DECL_P (TYPE_STUB_DECL (type))
&& ! DECL_IGNORED_P (TYPE_STUB_DECL (type)))
debug_queue_symbol (TYPE_STUB_DECL (type));
if (main_variant != TYPE_MAIN_VARIANT (type))
{
tree orig_type = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
if (flag_debug_only_used_symbols)
{
if (TYPE_STUB_DECL (orig_type)
&& !DECL_IGNORED_P (TYPE_STUB_DECL (orig_type)))
debug_queue_symbol (TYPE_STUB_DECL (orig_type));
}
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
dbxout_type_xref (orig_type);
dbxout_queue_type (orig_type);
return result;
}
dbxout_queue_type (type);
break;
case INTEGER_TYPE:
dbxout_integer_type (type);
break;
case REAL_TYPE:
dbxout_real_type (type);
break;
case BOOLEAN_TYPE:
dbxout_boolean_type (type);
break;
case COMPLEX_TYPE:
dbxout_complex_type (type);
break;
case VECTOR_TYPE:
case ARRAY_TYPE:
case OFFSET_TYPE:
dbxout_queue_type (type);
break;
case POINTER_TYPE:
case REFERENCE_TYPE:
case FUNCTION_TYPE:
dbxout_note_q_type (type);
dbxout_queue_type (type);
break;
case METHOD_TYPE:
stabstr_C ('=');
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
if (use_gnu_debug_info_extensions)
{
stabstr_C ('#');
dbxout_type (TYPE_METHOD_BASETYPE (type), 1);
stabstr_C (',');
dbxout_type (TREE_TYPE (type), 0);
dbxout_args (TYPE_ARG_TYPES (type));
stabstr_C (';');
}
else
dbxout_type (TREE_TYPE (type), 1);
break;
default:
gcc_unreachable ();
}
return result;
}
static void
dbxout_complete_type (tree type, tree main_variant)
{
tree tem;
bool vector_type = false;
dbxout_type_index (type);
#ifdef DBX_TYPE_DEFINED
if (DBX_TYPE_DEFINED (type))
return;
#endif
switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status)
{
case TYPE_UNSEEN:
case TYPE_QUEUED:
break;
case TYPE_XREF:
if (!COMPLETE_TYPE_P (type)
|| ! host_integerp (TYPE_SIZE (type), 1))
return;
break;
case TYPE_DEFINED:
return;
}
#ifdef DBX_NO_XREFS
if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
|| TREE_CODE (type) == QUAL_UNION_TYPE
|| TREE_CODE (type) == ENUMERAL_TYPE)
&& ! use_gnu_debug_info_extensions)
if (dbxout_cross_ref_type_p (type))
{
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
return;
}
#endif
if (TYPE_READONLY (type) > TYPE_READONLY (main_variant))
{
tree ttype;
stabstr_C ('=');
stabstr_C ('k');
ttype = build_type_variant (type, 0, TYPE_VOLATILE (type));
dbxout_next_type_number (ttype);
dbxout_type_index (ttype);
dbxout_queue_type (ttype);
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
return;
}
if (TYPE_VOLATILE (type) > TYPE_VOLATILE (main_variant))
{
tree ttype;
stabstr_C ('=');
if (strncmp (lang_hooks.name, "GNU Objective-C", 15)
|| !lookup_attribute ("objc_volatilized", TYPE_ATTRIBUTES (type)))
stabstr_C ('B');
ttype = build_type_variant (type, 0, TYPE_READONLY (type));
dbxout_next_type_number (ttype);
dbxout_type_index (ttype);
dbxout_queue_type (ttype);
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
return;
}
if (TYPE_NAME (type)
&& TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
&& DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
{
tree orig_type = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
stabstr_C ('=');
dbxout_type_index (orig_type);
dbxout_queue_type (orig_type);
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
return;
}
switch (TREE_CODE (type))
{
case VOID_TYPE:
case LANG_TYPE:
case BLOCK_POINTER_TYPE:
dbxout_void_type (type);
break;
case POINTER_TYPE:
dbxout_pointer_type (type);
break;
case RECORD_TYPE:
case UNION_TYPE:
case QUAL_UNION_TYPE:
{
tree binfo = TYPE_BINFO (type);
if (TYPE_STUB_DECL (type)
&& DECL_P (TYPE_STUB_DECL (type))
&& ! DECL_IGNORED_P (TYPE_STUB_DECL (type))
&& flag_debug_only_used_symbols)
debug_queue_symbol (TYPE_STUB_DECL (type));
if (!COMPLETE_TYPE_P (type)
|| ! host_integerp (TYPE_SIZE (type), 1))
{
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
if (use_gnu_debug_info_extensions)
dbxout_type_xref (type);
return;
}
stabstr_C ('=');
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
stabstr_C ((TREE_CODE (type) == RECORD_TYPE) ? 's' : 'u');
stabstr_D (int_size_in_bytes (type));
if (TREE_CODE (type) == RECORD_TYPE
&& !strncmp (lang_hooks.name, "GNU Objective-C", 15))
{
extern tree objc_is_class_name (tree);
if (objc_is_class_name (TYPE_NAME (type)))
binfo = NULL_TREE;
}
if (binfo)
{
int i;
tree child;
VEC (tree,gc) *accesses = BINFO_BASE_ACCESSES (binfo);
if (use_gnu_debug_info_extensions)
{
if (BINFO_N_BASE_BINFOS (binfo))
{
stabstr_C ('!');
stabstr_U (BINFO_N_BASE_BINFOS (binfo));
stabstr_C (',');
}
}
for (i = 0; BINFO_BASE_ITERATE (binfo, i, child); i++)
{
tree access = (accesses ? VEC_index (tree, accesses, i)
: access_public_node);
if (use_gnu_debug_info_extensions)
{
stabstr_C (BINFO_VIRTUAL_P (child) ? '1' : '0');
stabstr_C (access == access_public_node ? '2' :
access == access_protected_node
? '1' :'0');
if (BINFO_VIRTUAL_P (child)
&& (strcmp (lang_hooks.name, "GNU C++") == 0
|| strcmp (lang_hooks.name, "GNU Objective-C++") == 0))
stabstr_D
(tree_low_cst (BINFO_VPTR_FIELD (child), 0)
* BITS_PER_UNIT);
else
stabstr_D (tree_low_cst (BINFO_OFFSET (child), 0)
* BITS_PER_UNIT);
stabstr_C (',');
if (!dbxout_type (BINFO_TYPE (child), 0))
dbxout_type_xref (BINFO_TYPE (child));
stabstr_C (';');
}
else
{
dbxout_type_name (BINFO_TYPE (child));
stabstr_C (':');
dbxout_type (BINFO_TYPE (child), 0);
stabstr_C (',');
stabstr_D (tree_low_cst (BINFO_OFFSET (child), 0)
* BITS_PER_UNIT);
stabstr_C (',');
stabstr_D
(tree_low_cst (TYPE_SIZE (BINFO_TYPE (child)), 0)
* BITS_PER_UNIT);
stabstr_C (';');
}
}
}
dbxout_type_fields (type);
if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
{
dbxout_type_methods (type);
}
stabstr_C (';');
if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
&& TYPE_VFIELD (type))
{
stabstr_S ("~%");
dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0);
stabstr_C (';');
}
}
break;
case ENUMERAL_TYPE:
if (TYPE_STUB_DECL (type)
&& DECL_P (TYPE_STUB_DECL (type))
&& ! DECL_IGNORED_P (TYPE_STUB_DECL (type))
&& flag_debug_only_used_symbols)
debug_queue_symbol (TYPE_STUB_DECL (type));
if (!COMPLETE_TYPE_P (type)
|| ! host_integerp (TYPE_SIZE (type), 1))
{
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
if (use_gnu_debug_info_extensions)
dbxout_type_xref (type);
return;
}
if (main_variant != TYPE_MAIN_VARIANT (type))
{
tree orig_type = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
if (flag_debug_only_used_symbols)
{
if (TYPE_STUB_DECL (orig_type)
&& !DECL_IGNORED_P (TYPE_STUB_DECL (orig_type)))
debug_queue_symbol (TYPE_STUB_DECL (orig_type));
}
stabstr_C ('=');
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
dbxout_type_index (orig_type);
dbxout_queue_type (orig_type);
return;
}
stabstr_C ('=');
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
if (use_gnu_debug_info_extensions
&& TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
{
stabstr_S ("@s");
stabstr_D (TYPE_PRECISION (type));
stabstr_C (';');
}
stabstr_C ('e');
for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
{
stabstr_I (TREE_PURPOSE (tem));
stabstr_C (':');
if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0)
stabstr_D (TREE_INT_CST_LOW (TREE_VALUE (tem)));
else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1
&& (HOST_WIDE_INT) TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0)
stabstr_D (TREE_INT_CST_LOW (TREE_VALUE (tem)));
else
stabstr_O (TREE_VALUE (tem));
stabstr_C (',');
if (TREE_CHAIN (tem) != 0)
CONTIN;
}
stabstr_C (';');
break;
case INTEGER_TYPE:
dbxout_integer_type (type);
break;
case REAL_TYPE:
dbxout_real_type (type);
break;
case BOOLEAN_TYPE:
dbxout_boolean_type (type);
break;
case COMPLEX_TYPE:
dbxout_complex_type (type);
break;
case FUNCTION_TYPE:
dbxout_function_type (type);
break;
case REFERENCE_TYPE:
dbxout_reference_type (type);
break;
case VECTOR_TYPE:
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
type = TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type)));
vector_type = true;
case ARRAY_TYPE:
stabstr_C ('=');
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
if (TYPE_PACKED (type) && use_gnu_debug_info_extensions)
{
stabstr_S ("@s");
stabstr_D (BITS_PER_UNIT * int_size_in_bytes (type));
stabstr_S (";@S;S");
dbxout_type (TYPE_DOMAIN (type), 0);
}
if (use_gnu_debug_info_extensions && vector_type)
stabstr_S ("@V;");
if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions)
{
stabstr_S ("@S;");
}
tem = TYPE_DOMAIN (type);
if (tem == NULL)
{
stabstr_S ("ar");
dbxout_type_index (integer_type_node);
stabstr_S (";0;-1;");
}
else
{
stabstr_C ('a');
dbxout_range_type (tem);
}
dbxout_type_index (TREE_TYPE (type));
dbxout_queue_type (TREE_TYPE (type));
break;
case METHOD_TYPE:
stabstr_C ('=');
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
if (use_gnu_debug_info_extensions)
{
stabstr_C ('#');
dbxout_type (TYPE_METHOD_BASETYPE (type), 1);
stabstr_C (',');
dbxout_type (TREE_TYPE (type), 1);
dbxout_args (TYPE_ARG_TYPES (type));
stabstr_C (';');
}
else
dbxout_type (TREE_TYPE (type), 1);
break;
case OFFSET_TYPE:
stabstr_C ('=');
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
if (use_gnu_debug_info_extensions)
{
stabstr_C ('@');
dbxout_type (TYPE_OFFSET_BASETYPE (type), 0);
stabstr_C (',');
dbxout_type (TREE_TYPE (type), 0);
}
else
dbxout_type (integer_type_node, 0);
break;
default:
gcc_unreachable ();
}
}
static void
dbxout_type_xref (tree type)
{
static int anonymous_type_number = 0;
stabstr_C ('=');
switch (TREE_CODE (type))
{
case RECORD_TYPE:
stabstr_S ("xs");
break;
case UNION_TYPE:
case QUAL_UNION_TYPE:
stabstr_S ("xu");
break;
case ENUMERAL_TYPE:
stabstr_S ("xe");
break;
default:
gcc_unreachable ();
}
if (TYPE_NAME (type) != 0
&& (TREE_CODE (TYPE_NAME (type)) != TYPE_DECL
|| DECL_NAME (TYPE_NAME (type)) != 0))
dbxout_type_name (type);
else
{
stabstr_S ("$$");
stabstr_D (anonymous_type_number++);
}
stabstr_C (':');
return;
}
static void
dbxout_pointer_type (tree type)
{
tree ttype;
stabstr_C ('=');
stabstr_C ('*');
ttype = TREE_TYPE (type);
dbxout_type_index (ttype);
dbxout_queue_type (ttype);
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
return;
}
static void
dbxout_void_type (tree type)
{
stabstr_C ('=');
dbxout_type_index (type);
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
}
static void
dbxout_integer_type (tree type)
{
stabstr_C ('=');
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
if (type == char_type_node && ! TYPE_UNSIGNED (type))
{
stabstr_C ('r');
dbxout_type_index (type);
stabstr_S (";0;127;");
}
else if (TREE_TYPE (type) != 0
&& TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE)
{
if (use_gnu_debug_info_extensions
&& TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
{
stabstr_S ("@s");
stabstr_D (TYPE_PRECISION (type));
stabstr_C (';');
}
dbxout_range_type (type);
}
else
{
if (use_gnu_debug_info_extensions
&& TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
{
stabstr_S ("@s");
stabstr_D (TYPE_PRECISION (type));
stabstr_C (';');
}
if (print_int_cst_bounds_in_octal_p (type))
{
stabstr_C ('r');
if (TREE_TYPE (type) != 0)
dbxout_type_index (TREE_TYPE (type));
else
dbxout_type_index (type);
stabstr_C (';');
stabstr_O (TYPE_MIN_VALUE (type));
stabstr_C (';');
stabstr_O (TYPE_MAX_VALUE (type));
stabstr_C (';');
}
else
dbxout_range_type (type);
}
return;
}
static void
dbxout_real_type (tree type)
{
stabstr_C ('=');
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
stabstr_C ('r');
dbxout_type_index (integer_type_node);
stabstr_C (';');
stabstr_D (int_size_in_bytes (type));
stabstr_S (";0;");
return;
}
static void
dbxout_boolean_type (tree type)
{
stabstr_C ('=');
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
if (use_gnu_debug_info_extensions)
{
stabstr_S ("@s");
stabstr_D (BITS_PER_UNIT * int_size_in_bytes (type));
stabstr_S (";-16;");
}
else
stabstr_S ("eFalse:0,True:1,;");
return;
}
static void
dbxout_complex_type (tree type)
{
stabstr_C ('=');
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
{
stabstr_S ("R3;");
stabstr_D (2 * int_size_in_bytes (TREE_TYPE (type)));
stabstr_S (";0;");
}
else
{
stabstr_C ('s');
stabstr_D (int_size_in_bytes (type));
stabstr_S ("real:");
dbxout_type (TREE_TYPE (type), 0);
stabstr_S (",0,");
stabstr_D (TYPE_PRECISION (TREE_TYPE (type)));
stabstr_S (";imag:");
dbxout_type (TREE_TYPE (type), 0);
stabstr_C (',');
stabstr_D (TYPE_PRECISION (TREE_TYPE (type)));
stabstr_C (',');
stabstr_D (TYPE_PRECISION (TREE_TYPE (type)));
stabstr_S (";;");
}
}
static void
dbxout_function_type (tree type)
{
tree ttype;
stabstr_C ('=');
stabstr_C ('f');
ttype = TREE_TYPE (type);
dbxout_type_index (ttype);
dbxout_queue_type (ttype);
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
return;
}
static void
dbxout_reference_type (tree type)
{
tree ttype;
stabstr_C ('=');
if (use_gnu_debug_info_extensions)
{
stabstr_C ('&');
}
else
stabstr_C ('*');
ttype = TREE_TYPE (type);
dbxout_type_index (ttype);
dbxout_queue_type (ttype);
return;
}
static void
dbxout_next_type_number (tree type)
{
if (TYPE_SYMTAB_ADDRESS (type) != 0)
return;
TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
if (next_type_number == typevec_len)
{
typevec
= ggc_realloc (typevec, (typevec_len * 2 * sizeof typevec[0]));
memset (typevec + typevec_len, 0, typevec_len * sizeof typevec[0]);
typevec_len *= 2;
}
#ifdef DBX_USE_BINCL
emit_pending_bincls_if_required ();
typevec[TYPE_SYMTAB_ADDRESS (type)].file_number
= current_file->file_number;
typevec[TYPE_SYMTAB_ADDRESS (type)].type_number
= current_file->next_type_number++;
#endif
}
static int
dbxout_next_q_type_number (void)
{
next_q_type_number++;
if (next_q_type_number == q_typevec_len)
{
q_typevec
= ggc_realloc (q_typevec, (q_typevec_len * 2 * sizeof q_typevec[0]));
memset (q_typevec + q_typevec_len, 0, q_typevec_len * sizeof q_typevec[0]);
q_typevec_len *= 2;
}
return next_q_type_number;
}
static bool
print_int_cst_bounds_in_octal_p (tree type)
{
if (use_gnu_debug_info_extensions
&& TYPE_MIN_VALUE (type) != 0
&& TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST
&& TYPE_MAX_VALUE (type) != 0
&& TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST
&& (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node)
|| ((TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
&& TYPE_UNSIGNED (type))
|| TYPE_PRECISION (type) > HOST_BITS_PER_WIDE_INT
|| (TYPE_PRECISION (type) == HOST_BITS_PER_WIDE_INT
&& TYPE_UNSIGNED (type))))
return TRUE;
else
return FALSE;
}
static void
dbxout_type_name (tree type)
{
tree t = TYPE_NAME (type);
gcc_assert (t);
switch (TREE_CODE (t))
{
case IDENTIFIER_NODE:
break;
case TYPE_DECL:
t = DECL_NAME (t);
break;
default:
gcc_unreachable ();
}
stabstr_I (t);
}
static void
dbxout_class_name_qualifiers (tree decl)
{
tree context = decl_type_context (decl);
if (context != NULL_TREE
&& TREE_CODE(context) == RECORD_TYPE
&& TYPE_NAME (context) != 0
&& (TREE_CODE (TYPE_NAME (context)) == IDENTIFIER_NODE
|| (DECL_NAME (TYPE_NAME (context)) != 0)))
{
tree name = TYPE_NAME (context);
if (TREE_CODE (name) == TYPE_DECL)
{
dbxout_class_name_qualifiers (name);
name = DECL_NAME (name);
}
stabstr_I (name);
stabstr_S ("::");
}
}
static rtx
dbxout_expand_expr (tree expr)
{
switch (TREE_CODE (expr))
{
case VAR_DECL:
case PARM_DECL:
if (DECL_HAS_VALUE_EXPR_P (expr))
return dbxout_expand_expr (DECL_VALUE_EXPR (expr));
case CONST_DECL:
case RESULT_DECL:
return DECL_RTL_IF_SET (expr);
case INTEGER_CST:
return expand_expr (expr, NULL_RTX, VOIDmode, EXPAND_INITIALIZER);
case COMPONENT_REF:
case ARRAY_REF:
case ARRAY_RANGE_REF:
case BIT_FIELD_REF:
{
enum machine_mode mode;
HOST_WIDE_INT bitsize, bitpos;
tree offset, tem;
int volatilep = 0, unsignedp = 0;
rtx x;
tem = get_inner_reference (expr, &bitsize, &bitpos, &offset,
&mode, &unsignedp, &volatilep, true);
x = dbxout_expand_expr (tem);
if (x == NULL || !MEM_P (x))
return NULL;
if (offset != NULL)
{
if (!host_integerp (offset, 0))
return NULL;
x = adjust_address_nv (x, mode, tree_low_cst (offset, 0));
}
if (bitpos != 0)
x = adjust_address_nv (x, mode, bitpos / BITS_PER_UNIT);
return x;
}
default:
return NULL;
}
}
static int
output_used_types_helper (void **slot, void *data)
{
tree type = *slot;
VEC(tree, heap) **types_p = data;
if ((TREE_CODE (type) == RECORD_TYPE
|| TREE_CODE (type) == UNION_TYPE
|| TREE_CODE (type) == QUAL_UNION_TYPE
|| TREE_CODE (type) == ENUMERAL_TYPE)
&& TYPE_STUB_DECL (type)
&& DECL_P (TYPE_STUB_DECL (type))
&& ! DECL_IGNORED_P (TYPE_STUB_DECL (type)))
VEC_quick_push (tree, *types_p, TYPE_STUB_DECL (type));
else if (TYPE_NAME (type)
&& TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
VEC_quick_push (tree, *types_p, TYPE_NAME (type));
return 1;
}
static int
output_types_sort (const void *pa, const void *pb)
{
const tree lhs = *((const tree *)pa);
const tree rhs = *((const tree *)pb);
if (TYPE_P (lhs))
{
if (TYPE_P (rhs))
return TYPE_UID (lhs) - TYPE_UID (rhs);
else
return 1;
}
else
{
if (TYPE_P (rhs))
return -1;
else
return DECL_UID (lhs) - DECL_UID (rhs);
}
}
static void
output_used_types (void)
{
if (cfun && cfun->used_types_hash)
{
VEC(tree, heap) *types;
int i;
tree type;
types = VEC_alloc (tree, heap, htab_elements (cfun->used_types_hash));
htab_traverse (cfun->used_types_hash, output_used_types_helper, &types);
qsort (VEC_address (tree, types), VEC_length (tree, types),
sizeof (tree), output_types_sort);
for (i = 0; VEC_iterate (tree, types, i, type); i++)
debug_queue_symbol (type);
VEC_free (tree, heap, types);
}
}
int
dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED)
{
tree type = TREE_TYPE (decl);
tree context = NULL_TREE;
int result = 0;
rtx decl_rtl;
++debug_nesting;
if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL)
|| DECL_IGNORED_P (decl))
DBXOUT_DECR_NESTING_AND_RETURN (0);
if (flag_debug_only_used_symbols
&& (!TREE_USED (decl)
&& (TREE_CODE (decl) != VAR_DECL || !DECL_INITIAL (decl))))
DBXOUT_DECR_NESTING_AND_RETURN (0);
if (!typevec)
{
preinit_symbols = tree_cons (0, decl, preinit_symbols);
DBXOUT_DECR_NESTING_AND_RETURN (0);
}
if (flag_debug_only_used_symbols)
{
tree t;
t = type;
while (POINTER_TYPE_P (t))
t = TREE_TYPE (t);
if (TREE_CODE (t) == RECORD_TYPE
|| TREE_CODE (t) == UNION_TYPE
|| TREE_CODE (t) == QUAL_UNION_TYPE
|| TREE_CODE (t) == ENUMERAL_TYPE)
{
if (TYPE_STUB_DECL (t)
&& TYPE_STUB_DECL (t) != decl
&& DECL_P (TYPE_STUB_DECL (t))
&& ! DECL_IGNORED_P (TYPE_STUB_DECL (t)))
{
debug_queue_symbol (TYPE_STUB_DECL (t));
if (TYPE_NAME (t)
&& TYPE_NAME (t) != TYPE_STUB_DECL (t)
&& TYPE_NAME (t) != decl
&& DECL_P (TYPE_NAME (t)))
debug_queue_symbol (TYPE_NAME (t));
}
}
else if (TYPE_NAME (t)
&& TYPE_NAME (t) != decl
&& DECL_P (TYPE_NAME (t)))
debug_queue_symbol (TYPE_NAME (t));
}
emit_pending_bincls_if_required ();
switch (TREE_CODE (decl))
{
case CONST_DECL:
break;
case FUNCTION_DECL:
decl_rtl = DECL_RTL_IF_SET (decl);
if (!decl_rtl)
DBXOUT_DECR_NESTING_AND_RETURN (0);
if (DECL_EXTERNAL (decl))
break;
context = decl_function_context (decl);
if (context == current_function_decl)
break;
if (context && DECL_FROM_INLINE (decl))
break;
if (!MEM_P (decl_rtl)
|| GET_CODE (XEXP (decl_rtl, 0)) != SYMBOL_REF)
break;
if (flag_debug_only_used_symbols)
output_used_types ();
dbxout_begin_complex_stabs ();
stabstr_I (DECL_ASSEMBLER_NAME (decl));
stabstr_S (TREE_PUBLIC (decl) ? ":F" : ":f");
result = 1;
if (TREE_TYPE (type))
dbxout_type (TREE_TYPE (type), 0);
else
dbxout_type (void_type_node, 0);
if (context != 0)
{
stabstr_C (',');
stabstr_I (DECL_ASSEMBLER_NAME (decl));
stabstr_C (',');
stabstr_I (DECL_NAME (context));
}
dbxout_finish_complex_stabs (decl, N_FUN, XEXP (decl_rtl, 0), 0, 0);
break;
case TYPE_DECL:
if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl))
DBXOUT_DECR_NESTING_AND_RETURN (0);
#ifdef DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER
{
int fundamental_type_number =
DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER (decl);
if (fundamental_type_number != 0)
{
TREE_ASM_WRITTEN (decl) = 1;
TYPE_SYMTAB_ADDRESS (TREE_TYPE (decl)) = fundamental_type_number;
DBXOUT_DECR_NESTING_AND_RETURN (0);
}
}
#endif
FORCE_TEXT;
result = 1;
{
int tag_needed = 1;
int did_output = 0;
if (DECL_NAME (decl)
#ifdef DBX_ONLY_USED_SYMBOLS
&& (COMPLETE_TYPE_P (type) || TREE_CODE (type) == VOID_TYPE)
#endif
)
{
tag_needed = 0;
if ((TREE_CODE (type) == RECORD_TYPE
|| TREE_CODE (type) == UNION_TYPE
|| TREE_CODE (type) == QUAL_UNION_TYPE)
&& TYPE_NAME (type) == decl
&& !use_gnu_debug_info_extensions
&& !TREE_ASM_WRITTEN (TYPE_NAME (type))
&& DECL_ARTIFICIAL (decl)
&& COMPLETE_TYPE_P (type)
&& host_integerp (TYPE_SIZE (type), 1))
{
tree name = TYPE_NAME (type);
if (TREE_CODE (name) == TYPE_DECL)
name = DECL_NAME (name);
dbxout_begin_complex_stabs ();
stabstr_I (name);
stabstr_S (":T");
dbxout_type (type, 1);
dbxout_finish_complex_stabs (0, DBX_TYPE_DECL_STABS_CODE,
0, 0, 0);
}
dbxout_begin_complex_stabs ();
if (use_gnu_debug_info_extensions)
dbxout_class_name_qualifiers (decl);
if (DECL_NAME (decl) == anon_place_holder)
DECL_NAME (decl) = NULL_TREE;
else
stabstr_I (DECL_NAME (decl));
stabstr_C (':');
if ((TREE_CODE (type) == RECORD_TYPE
|| TREE_CODE (type) == UNION_TYPE
|| TREE_CODE (type) == QUAL_UNION_TYPE)
&& TYPE_NAME (type) == decl
&& DECL_ARTIFICIAL (decl))
{
if (use_gnu_debug_info_extensions)
{
stabstr_C ('T');
TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
}
}
stabstr_C ('t');
dbxout_type (type, 1);
dbxout_finish_complex_stabs (decl, DBX_TYPE_DECL_STABS_CODE,
0, 0, 0);
did_output = 1;
}
if (tag_needed && TYPE_NAME (type) != 0
&& (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
|| (DECL_NAME (TYPE_NAME (type)) != 0))
&& COMPLETE_TYPE_P (type)
&& !TREE_ASM_WRITTEN (TYPE_NAME (type))
&& (TYPE_SYMTAB_ADDRESS (type) == 0
|| typevec[TYPE_SYMTAB_ADDRESS (type)].status != TYPE_DEFINED))
{
tree name = TYPE_NAME (type);
if (TREE_CODE (name) == TYPE_DECL)
name = DECL_NAME (name);
dbxout_begin_complex_stabs ();
stabstr_I (name);
stabstr_S (":T");
dbxout_type (type, 1);
dbxout_finish_complex_stabs (0, DBX_TYPE_DECL_STABS_CODE, 0, 0, 0);
did_output = 1;
}
if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE)
{
dbxout_begin_complex_stabs ();
stabstr_S (" :T");
dbxout_type (type, 1);
dbxout_finish_complex_stabs (0, DBX_TYPE_DECL_STABS_CODE, 0, 0, 0);
}
if (did_output)
TREE_ASM_WRITTEN (decl) = 1;
break;
}
case PARM_DECL:
gcc_unreachable ();
case RESULT_DECL:
case VAR_DECL:
if (DECL_EXTERNAL (decl))
break;
if (TREE_STATIC (decl) && TREE_READONLY (decl)
&& DECL_INITIAL (decl) != 0
&& host_integerp (DECL_INITIAL (decl), 0)
&& ! TREE_ASM_WRITTEN (decl)
&& (DECL_CONTEXT (decl) == NULL_TREE
|| TREE_CODE (DECL_CONTEXT (decl)) == BLOCK
|| TREE_CODE (DECL_CONTEXT (decl)) == NAMESPACE_DECL)
&& TREE_PUBLIC (decl) == 0)
{
if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
|| TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
{
HOST_WIDE_INT ival = TREE_INT_CST_LOW (DECL_INITIAL (decl));
dbxout_begin_complex_stabs ();
dbxout_symbol_name (decl, NULL, 'c');
stabstr_S ("=i");
stabstr_D (ival);
dbxout_finish_complex_stabs (0, N_LSYM, 0, 0, 0);
DBXOUT_DECR_NESTING;
return 1;
}
else
break;
}
decl_rtl = dbxout_expand_expr (decl);
if (!decl_rtl)
DBXOUT_DECR_NESTING_AND_RETURN (0);
decl_rtl = eliminate_regs (decl_rtl, 0, NULL_RTX);
#ifdef LEAF_REG_REMAP
if (current_function_uses_only_leaf_regs)
leaf_renumber_regs_insn (decl_rtl);
#endif
result = dbxout_symbol_location (decl, type, 0, decl_rtl);
break;
default:
break;
}
DBXOUT_DECR_NESTING;
return result;
}
static int
dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home)
{
int letter = 0;
STAB_CODE_TYPE code;
rtx addr = 0;
int number = 0;
int regno = -1;
if (GET_CODE (home) == SUBREG)
{
rtx value = home;
while (GET_CODE (value) == SUBREG)
value = SUBREG_REG (value);
if (REG_P (value))
{
if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
return 0;
}
home = alter_subreg (&home);
}
if (REG_P (home))
{
regno = REGNO (home);
if (regno >= FIRST_PSEUDO_REGISTER)
return 0;
}
if (MEM_P (home) && GET_CODE (XEXP (home, 0)) == SYMBOL_REF)
{
if (TREE_PUBLIC (decl))
{
letter = 'G';
code = N_GSYM;
}
else
{
addr = XEXP (home, 0);
letter = decl_function_context (decl) ? 'V' : 'S';
if (GET_CODE (addr) == SYMBOL_REF
&& CONSTANT_POOL_ADDRESS_P (addr))
{
bool marked;
rtx tmp = get_pool_constant_mark (addr, &marked);
if (GET_CODE (tmp) == SYMBOL_REF)
{
addr = tmp;
if (CONSTANT_POOL_ADDRESS_P (addr))
get_pool_constant_mark (addr, &marked);
else
marked = true;
}
else if (GET_CODE (tmp) == LABEL_REF)
{
addr = tmp;
marked = true;
}
if (!marked)
return 0;
}
if (DECL_INITIAL (decl) == 0
|| (!strcmp (lang_hooks.name, "GNU C++")
&& DECL_INITIAL (decl) == error_mark_node))
code = N_LCSYM;
else if (DECL_IN_TEXT_SECTION (decl))
code = DBX_STATIC_CONST_VAR_CODE;
else
{
#ifdef DBX_STATIC_STAB_DATA_SECTION
switch_to_section (data_section);
#endif
code = N_STSYM;
}
}
}
else if (regno >= 0)
{
letter = 'r';
code = N_RSYM;
number = DBX_REGISTER_NUMBER (regno);
}
else if (MEM_P (home)
&& (MEM_P (XEXP (home, 0))
|| (REG_P (XEXP (home, 0))
&& REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM
&& REGNO (XEXP (home, 0)) != STACK_POINTER_REGNUM
#if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
&& REGNO (XEXP (home, 0)) != ARG_POINTER_REGNUM
#endif
)))
{
if (REG_P (XEXP (home, 0)))
{
letter = 'r';
code = N_RSYM;
if (REGNO (XEXP (home, 0)) >= FIRST_PSEUDO_REGISTER)
return 0;
number = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0)));
}
else
{
code = N_LSYM;
number = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0));
}
type = make_node (POINTER_TYPE);
TREE_TYPE (type) = TREE_TYPE (decl);
}
else if (MEM_P (home)
&& REG_P (XEXP (home, 0)))
{
code = N_LSYM;
number = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
}
else if (MEM_P (home)
&& GET_CODE (XEXP (home, 0)) == PLUS
&& GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT)
{
code = N_LSYM;
number = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
}
else if (MEM_P (home)
&& GET_CODE (XEXP (home, 0)) == CONST)
{
code = N_LCSYM;
letter = 'V';
addr = XEXP (XEXP (home, 0), 0);
}
else if (GET_CODE (home) == CONCAT)
{
tree subtype;
if (TREE_CODE (type) != COMPLEX_TYPE)
return 0;
subtype = TREE_TYPE (type);
if (WORDS_BIG_ENDIAN)
dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0));
else
dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0));
if (WORDS_BIG_ENDIAN)
dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1));
else
dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1));
return 1;
}
else
return 0;
emit_pending_bincls_if_required ();
FORCE_TEXT;
#ifdef DBX_STATIC_BLOCK_START
DBX_STATIC_BLOCK_START (dbx_out_file, code);
#endif
dbxout_begin_complex_stabs_noforcetext ();
dbxout_symbol_name (decl, suffix, letter);
dbxout_type (type, 0);
dbxout_finish_complex_stabs (decl, code, addr, 0, number);
#ifdef DBX_STATIC_BLOCK_END
DBX_STATIC_BLOCK_END (dbx_out_file, code);
#endif
return 1;
}
static void
dbxout_symbol_name (tree decl, const char *suffix, int letter)
{
tree name;
if (DECL_CONTEXT (decl)
&& (TYPE_P (DECL_CONTEXT (decl))
|| TREE_CODE (DECL_CONTEXT (decl)) == NAMESPACE_DECL))
name = DECL_ASSEMBLER_NAME (decl);
else
name = DECL_NAME (decl);
if (name)
stabstr_I (name);
else
stabstr_S ("(anon)");
if (suffix)
stabstr_S (suffix);
stabstr_C (':');
if (letter)
stabstr_C (letter);
}
int
dbxout_syms (tree syms)
{
int result = 0;
while (syms)
{
result += dbxout_symbol (syms, 1);
syms = TREE_CHAIN (syms);
}
return result;
}
void
dbxout_parms (tree parms)
{
++debug_nesting;
emit_pending_bincls_if_required ();
for (; parms; parms = TREE_CHAIN (parms))
if (DECL_NAME (parms)
&& TREE_TYPE (parms) != error_mark_node
&& DECL_RTL_SET_P (parms)
&& DECL_INCOMING_RTL (parms))
{
tree eff_type;
char letter;
STAB_CODE_TYPE code;
int number;
DECL_INCOMING_RTL (parms)
= eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
SET_DECL_RTL (parms, eliminate_regs (DECL_RTL (parms), 0, NULL_RTX));
#ifdef LEAF_REG_REMAP
if (current_function_uses_only_leaf_regs)
{
leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
leaf_renumber_regs_insn (DECL_RTL (parms));
}
#endif
if (PARM_PASSED_IN_MEMORY (parms))
{
rtx inrtl = XEXP (DECL_INCOMING_RTL (parms), 0);
if (GET_CODE (inrtl) == PLUS
&& GET_CODE (XEXP (inrtl, 1)) == CONST_INT)
number = INTVAL (XEXP (inrtl, 1));
else
number = 0;
code = N_PSYM;
number = DEBUGGER_ARG_OFFSET (number, inrtl);
letter = 'p';
eff_type = DECL_ARG_TYPE (parms);
}
else if (REG_P (DECL_RTL (parms)))
{
rtx best_rtl;
code = DBX_REGPARM_STABS_CODE;
letter = DBX_REGPARM_STABS_LETTER;
eff_type = TREE_TYPE (parms);
if (REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
best_rtl = DECL_RTL (parms);
else
best_rtl = DECL_INCOMING_RTL (parms);
number = DBX_REGISTER_NUMBER (REGNO (best_rtl));
}
else if (MEM_P (DECL_RTL (parms))
&& REG_P (XEXP (DECL_RTL (parms), 0))
&& REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM
&& REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM
#if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
&& REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM
#endif
)
{
code = DBX_REGPARM_STABS_CODE;
letter = (use_gnu_debug_info_extensions
? 'a' : DBX_REGPARM_STABS_LETTER);
eff_type = TREE_TYPE (parms);
if (REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER)
number = REGNO (XEXP (DECL_RTL (parms), 0));
else
number = REGNO (DECL_INCOMING_RTL (parms));
}
else if (MEM_P (DECL_RTL (parms))
&& MEM_P (XEXP (DECL_RTL (parms), 0)))
{
code = N_PSYM;
letter = 'v';
eff_type = TREE_TYPE (parms);
if (!REG_P (XEXP (XEXP (DECL_RTL (parms), 0), 0)))
number = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms), 0), 0), 1));
else
number = 0;
number = DEBUGGER_ARG_OFFSET (number,
XEXP (XEXP (DECL_RTL (parms), 0), 0));
}
else if (MEM_P (DECL_RTL (parms))
&& XEXP (DECL_RTL (parms), 0) != const0_rtx
&& ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
{
code = N_PSYM;
letter = 'p';
eff_type = TREE_TYPE (parms);
if (!REG_P (XEXP (DECL_RTL (parms), 0)))
number = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
else
number = 0;
number = DEBUGGER_ARG_OFFSET (number,
XEXP (DECL_RTL (parms), 0));
if (BYTES_BIG_ENDIAN
&& TYPE_MODE (TREE_TYPE (parms)) != GET_MODE (DECL_RTL (parms))
&& GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms))) < UNITS_PER_WORD)
number += (GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))
- GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms))));
}
else
continue;
dbxout_begin_complex_stabs ();
if (DECL_NAME (parms))
{
stabstr_I (DECL_NAME (parms));
stabstr_C (':');
}
else
stabstr_S ("(anon):");
stabstr_C (letter);
dbxout_type (eff_type, 0);
dbxout_finish_complex_stabs (parms, code, 0, 0, number);
}
DBXOUT_DECR_NESTING;
}
void
dbxout_reg_parms (tree parms)
{
++debug_nesting;
for (; parms; parms = TREE_CHAIN (parms))
if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms))
{
if (REG_P (DECL_RTL (parms))
&& REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
dbxout_symbol_location (parms, TREE_TYPE (parms),
0, DECL_RTL (parms));
else if (GET_CODE (DECL_RTL (parms)) == CONCAT)
dbxout_symbol_location (parms, TREE_TYPE (parms),
0, DECL_RTL (parms));
else if (MEM_P (DECL_RTL (parms))
&& ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
dbxout_symbol_location (parms, TREE_TYPE (parms),
0, DECL_RTL (parms));
}
DBXOUT_DECR_NESTING;
}
static void
dbxout_args (tree args)
{
while (args)
{
stabstr_C (',');
dbxout_type (TREE_VALUE (args), 0);
args = TREE_CHAIN (args);
}
}
static void
dbx_output_lbrac (const char *label,
const char *begin_label ATTRIBUTE_UNUSED)
{
dbxout_begin_stabn (N_LBRAC);
if (DBX_BLOCKS_FUNCTION_RELATIVE)
dbxout_stab_value_label_diff (label, begin_label);
else
dbxout_stab_value_label (label);
}
static void
dbx_output_rbrac (const char *label,
const char *begin_label ATTRIBUTE_UNUSED)
{
dbxout_begin_stabn (N_RBRAC);
if (DBX_BLOCKS_FUNCTION_RELATIVE)
dbxout_stab_value_label_diff (label, begin_label);
else
dbxout_stab_value_label (label);
}
static void
dbxout_block (tree block, int depth, tree args)
{
char begin_label[20];
ASM_GENERATE_INTERNAL_LABEL (begin_label, "LFBB", scope_labelno);
while (block)
{
if (TREE_USED (block) && TREE_ASM_WRITTEN (block))
{
int did_output;
int blocknum = BLOCK_NUMBER (block);
did_output = 0;
if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
did_output = dbxout_syms (BLOCK_VARS (block));
if (args)
dbxout_reg_parms (args);
if (did_output)
{
char buf[20];
const char *scope_start;
if (depth == 0)
scope_start = begin_label;
else
{
ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
scope_start = buf;
}
if (BLOCK_HANDLER_BLOCK (block))
{
tree decl = BLOCK_VARS (block);
while (decl)
{
dbxout_begin_complex_stabs ();
stabstr_I (DECL_NAME (decl));
stabstr_S (":C1");
dbxout_finish_complex_stabs (0, N_CATCH, 0,
scope_start, 0);
decl = TREE_CHAIN (decl);
}
}
dbx_output_lbrac (scope_start, begin_label);
}
dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
if (did_output)
{
char buf[100];
if (depth == 0)
ASM_GENERATE_INTERNAL_LABEL (buf, "Lscope", scope_labelno);
else
ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
dbx_output_rbrac (buf, begin_label);
}
}
block = BLOCK_CHAIN (block);
}
}
#ifdef DBX_NO_XREFS
static bool
dbxout_cross_ref_type_p (tree type)
{
return ((TYPE_NAME (type) != 0
&& ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
&& DECL_IGNORED_P (TYPE_NAME (type))))
|| !COMPLETE_TYPE_P (type)
|| ! host_integerp (TYPE_SIZE (type), 1));
}
#endif
static void
dbxout_type_with_name (tree type)
{
if (TYPE_SYMTAB_ADDRESS (type) != 0
&& typevec[TYPE_SYMTAB_ADDRESS (type)].status == TYPE_DEFINED)
return;
dbxout_begin_complex_stabs ();
if (!TYPE_VOLATILE (type)
&& !TYPE_READONLY (type)
&& TYPE_NAME (type)
&& TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
&& DECL_NAME (TYPE_NAME (type))
&& COMPLETE_TYPE_P (type))
{
stabstr_I (DECL_NAME (TYPE_NAME (type)));
stabstr_C (':');
stabstr_C ('t');
}
else if ((TREE_CODE (type) == RECORD_TYPE
|| TREE_CODE (type) == UNION_TYPE
|| TREE_CODE (type) == QUAL_UNION_TYPE
|| TREE_CODE (type) == ENUMERAL_TYPE)
&& COMPLETE_TYPE_P (type)
&& !TYPE_QUALS (type))
{
if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) != TYPE_DECL)
stabstr_I (TYPE_NAME (type));
else if (TYPE_NAME (type)
&& DECL_NAME (TYPE_NAME (type)))
stabstr_I (DECL_NAME (TYPE_NAME (type)));
stabstr_C (':');
stabstr_C ('T');
}
else
{
stabstr_C (':');
stabstr_C ('t');
}
dbxout_type (type, 2);
dbxout_finish_complex_stabs (0, N_LSYM, 0, 0, 0);
}
static GTY ((length ("type_queue_index"))) tree *type_queue;
static GTY (()) int type_queue_index = 0;
static GTY (()) int type_queue_size = 0;
void
dbxout_flush_type_queue (void)
{
int i;
for (i = 0; i < type_queue_index; ++i)
{
tree type = type_queue[i];
dbxout_type_with_name (type);
}
type_queue_index = 0;
}
static void
dbxout_queue_type (tree type)
{
dbxout_next_type_number (type);
if (typevec[TYPE_SYMTAB_ADDRESS (type)].status == TYPE_QUEUED
|| typevec[TYPE_SYMTAB_ADDRESS (type)].status == TYPE_DEFINED)
return;
typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_QUEUED;
if (type_queue_index >= type_queue_size)
{
type_queue_size += 10;
type_queue = ggc_realloc (type_queue,
type_queue_size * sizeof (tree));
}
type_queue[type_queue_index++] = type;
}
static void
dbxout_free_type_queue (void)
{
dbxout_flush_type_queue ();
if (type_queue)
{
ggc_free (type_queue);
type_queue = NULL;
type_queue_size = 0;
}
}
#if defined (DBX_DEBUGGING_INFO)
static void
dbxout_begin_function (tree decl)
{
int saved_tree_used1;
if (DECL_IGNORED_P (decl))
return;
saved_tree_used1 = TREE_USED (decl);
TREE_USED (decl) = 1;
if (DECL_NAME (DECL_RESULT (decl)) != 0)
{
int saved_tree_used2 = TREE_USED (DECL_RESULT (decl));
TREE_USED (DECL_RESULT (decl)) = 1;
dbxout_symbol (decl, 0);
TREE_USED (DECL_RESULT (decl)) = saved_tree_used2;
}
else
dbxout_symbol (decl, 0);
TREE_USED (decl) = saved_tree_used1;
dbxout_parms (DECL_ARGUMENTS (decl));
if (DECL_NAME (DECL_RESULT (decl)) != 0)
dbxout_symbol (DECL_RESULT (decl), 1);
}
#endif
#endif
#include "gt-dbxout.h"