home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 7
/
FreshFishVol7.bin
/
bbs
/
gnu
/
gcc-2.3.3-src.lha
/
GNU
/
src
/
amiga
/
gcc-2.3.3
/
sdbout.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-02-06
|
41KB
|
1,450 lines
/* Output sdb-format symbol table information from GNU compiler.
Copyright (C) 1988, 1992 Free Software Foundation, Inc.
This file is part of GNU CC.
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.
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.
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* mike@tredysvr.Tredydev.Unisys.COM says:
I modified the struct.c example and have a nm of a .o resulting from the
AT&T C compiler. From the example below I would conclude the following:
1. All .defs from structures are emitted as scanned. The example below
clearly shows the symbol table entries for BoxRec2 are after the first
function.
2. All functions and their locals (including statics) are emitted as scanned.
3. All nested unnamed union and structure .defs must be emitted before
the structure in which they are nested. The AT&T assembler is a
one pass beast as far as symbolics are concerned.
4. All structure .defs are emitted before the typedefs that refer to them.
5. All top level static and external variable definitions are moved to the
end of file with all top level statics occurring first before externs.
6. All undefined references are at the end of the file.
*/
#include "config.h"
#ifdef SDB_DEBUGGING_INFO
#include "tree.h"
#include "rtl.h"
#include <stdio.h>
#include "regs.h"
#include "flags.h"
#include "insn-config.h"
#include "reload.h"
/* Mips systems use the SDB functions to dump out symbols, but
do not supply usable syms.h include files. */
#if defined(USG) && !defined(MIPS) && !defined (hpux)
#include <syms.h>
/* Use T_INT if we don't have T_VOID. */
#ifndef T_VOID
#define T_VOID T_INT
#endif
#else /* not USG, or MIPS */
#include "gsyms.h"
#endif /* not USG, or MIPS */
/* #include <storclass.h> used to be this instead of syms.h. */
/* 1 if PARM is passed to this function in memory. */
#define PARM_PASSED_IN_MEMORY(PARM) \
(GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
/* A C expression for the integer offset value of an automatic variable
(C_AUTO) having address X (an RTX). */
#ifndef DEBUGGER_AUTO_OFFSET
#define DEBUGGER_AUTO_OFFSET(X) \
(GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
#endif
/* A C expression for the integer offset value of an argument (C_ARG)
having address X (an RTX). The nominal offset is OFFSET. */
#ifndef DEBUGGER_ARG_OFFSET
#define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
#endif
/* Line number of beginning of current function, minus one.
Negative means not in a function or not using sdb. */
int sdb_begin_function_line = -1;
/* Counter to generate unique "names" for nameless struct members. */
static int unnamed_struct_number = 0;
extern FILE *asm_out_file;
extern tree current_function_decl;
void sdbout_init ();
void sdbout_symbol ();
void sdbout_types();
static void sdbout_typedefs ();
static void sdbout_syms ();
static void sdbout_one_type ();
static void sdbout_queue_anonymous_type ();
static void sdbout_dequeue_anonymous_types ();
static int plain_type_1 ();
/* Define the default sizes for various types. */
#ifndef CHAR_TYPE_SIZE
#define CHAR_TYPE_SIZE BITS_PER_UNIT
#endif
#ifndef SHORT_TYPE_SIZE
#define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2))
#endif
#ifndef INT_TYPE_SIZE
#define INT_TYPE_SIZE BITS_PER_WORD
#endif
#ifndef LONG_TYPE_SIZE
#define LONG_TYPE_SIZE BITS_PER_WORD
#endif
#ifndef LONG_LONG_TYPE_SIZE
#define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
#endif
#ifndef FLOAT_TYPE_SIZE
#define FLOAT_TYPE_SIZE BITS_PER_WORD
#endif
#ifndef DOUBLE_TYPE_SIZE
#define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
#endif
#ifndef LONG_DOUBLE_TYPE_SIZE
#define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
#endif
/* Random macros describing parts of SDB data. */
/* Put something here if lines get too long */
#define CONTIN
/* Default value of delimiter is ";". */
#ifndef SDB_DELIM
#define SDB_DELIM ";"
#endif
/* Maximum number of dimensions the assembler will allow. */
#ifndef SDB_MAX_DIM
#define SDB_MAX_DIM 4
#endif
#ifndef PUT_SDB_SCL
#define PUT_SDB_SCL(a) fprintf(asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM)
#endif
#ifndef PUT_SDB_INT_VAL
#define PUT_SDB_INT_VAL(a) fprintf (asm_out_file, "\t.val\t%d%s", (a), SDB_DELIM)
#endif
#ifndef PUT_SDB_VAL
#define PUT_SDB_VAL(a) \
( fputs ("\t.val\t", asm_out_file), \
output_addr_const (asm_out_file, (a)), \
fprintf (asm_out_file, SDB_DELIM))
#endif
#ifndef PUT_SDB_DEF
#define PUT_SDB_DEF(a) \
do { fprintf (asm_out_file, "\t.def\t"); \
ASM_OUTPUT_LABELREF (asm_out_file, a); \
fprintf (asm_out_file, SDB_DELIM); } while (0)
#endif
#ifndef PUT_SDB_PLAIN_DEF
#define PUT_SDB_PLAIN_DEF(a) fprintf(asm_out_file,"\t.def\t.%s%s",a, SDB_DELIM)
#endif
#ifndef PUT_SDB_ENDEF
#define PUT_SDB_ENDEF fputs("\t.endef\n", asm_out_file)
#endif
#ifndef PUT_SDB_TYPE
#define PUT_SDB_TYPE(a) fprintf(asm_out_file, "\t.type\t0%o%s", a, SDB_DELIM)
#endif
#ifndef PUT_SDB_SIZE
#define PUT_SDB_SIZE(a) fprintf(asm_out_file, "\t.size\t%d%s", a, SDB_DELIM)
#endif
#ifndef PUT_SDB_START_DIM
#define PUT_SDB_START_DIM fprintf(asm_out_file, "\t.dim\t")
#endif
#ifndef PUT_SDB_NEXT_DIM
#define PUT_SDB_NEXT_DIM(a) fprintf(asm_out_file, "%d,", a)
#endif
#ifndef PUT_SDB_LAST_DIM
#define PUT_SDB_LAST_DIM(a) fprintf(asm_out_file, "%d%s", a, SDB_DELIM)
#endif
#ifndef PUT_SDB_TAG
#define PUT_SDB_TAG(a) \
do { fprintf (asm_out_file, "\t.tag\t"); \
ASM_OUTPUT_LABELREF (asm_out_file, a); \
fprintf (asm_out_file, SDB_DELIM); } while (0)
#endif
#ifndef PUT_SDB_BLOCK_START
#define PUT_SDB_BLOCK_START(LINE) \
fprintf (asm_out_file, \
"\t.def\t.bb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
#endif
#ifndef PUT_SDB_BLOCK_END
#define PUT_SDB_BLOCK_END(LINE) \
fprintf (asm_out_file, \
"\t.def\t.eb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
#endif
#ifndef PUT_SDB_FUNCTION_START
#define PUT_SDB_FUNCTION_START(LINE) \
fprintf (asm_out_file, \
"\t.def\t.bf%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
#endif
#ifndef PUT_SDB_FUNCTION_END
#define PUT_SDB_FUNCTION_END(LINE) \
fprintf (asm_out_file, \
"\t.def\t.ef%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
#endif
#ifndef PUT_SDB_EPILOGUE_END
#define PUT_SDB_EPILOGUE_END(NAME) \
do { fprintf (asm_out_file, "\t.def\t"); \
ASM_OUTPUT_LABELREF (asm_out_file, NAME); \
fprintf (asm_out_file, \
"%s\t.val\t.%s\t.scl\t-1%s\t.endef\n", \
SDB_DELIM, SDB_DELIM, SDB_DELIM); } while (0)
#endif
#ifndef SDB_GENERATE_FAKE
#define SDB_GENERATE_FAKE(BUFFER, NUMBER) \
sprintf ((BUFFER), ".%dfake", (NUMBER));
#endif
/* Return the sdb tag identifier string for TYPE
if TYPE has already been defined; otherwise return a null pointer. */
#define KNOWN_TYPE_TAG(type) (char *)(TYPE_SYMTAB_ADDRESS (type))
/* Set the sdb tag identifier string for TYPE to NAME. */
#define SET_KNOWN_TYPE_TAG(TYPE, NAME) \
(TYPE_SYMTAB_ADDRESS (TYPE) = (int)(NAME))
/* Return the name (a string) of the struct, union or enum tag
described by the TREE_LIST node LINK. This is 0 for an anonymous one. */
#define TAG_NAME(link) \
(((link) && TREE_PURPOSE ((link)) \
&& IDENTIFIER_POINTER (TREE_PURPOSE ((link)))) \
? IDENTIFIER_POINTER (TREE_PURPOSE ((link))) : (char *) 0)
/* Ensure we don't output a negative line number. */
#define MAKE_LINE_SAFE(line) \
if (line <= sdb_begin_function_line) line = sdb_begin_function_line + 1
/* Set up for