⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dwarfout.c

📁 GUN开源阻止下的编译器GCC
💻 C
📖 第 1 页 / 共 5 页
字号:
/* Output Dwarf format symbol table information from the GNU C compiler.   Copyright (C) 1992, 1993, 1995 Free Software Foundation, Inc.   Written by Ron Guilmette (rfg@netcom.com) for   Network Computing Devices, August, September, October, November 1990.   Generously contributed by NCD to the Free Software Foundation.This file is part of GNU CC.GNU CC is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe 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 ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU CC; see the file COPYING.  If not, write tothe Free Software Foundation, 59 Temple Place - Suite 330,Boston, MA 02111-1307, USA.  */#include "config.h"#ifdef DWARF_DEBUGGING_INFO#include <stdio.h>#include "dwarf.h"#include "tree.h"#include "flags.h"#include "rtl.h"#include "hard-reg-set.h"#include "insn-config.h"#include "reload.h"#include "output.h"#include "defaults.h"#ifndef DWARF_VERSION#define DWARF_VERSION 1#endif/* #define NDEBUG 1 */#include "assert.h"#if defined(DWARF_TIMESTAMPS)#if defined(POSIX)#include <time.h>#else /* !defined(POSIX) */#include <sys/types.h>#if defined(__STDC__)extern time_t time (time_t *);#else /* !defined(__STDC__) */extern time_t time ();#endif /* !defined(__STDC__) */#endif /* !defined(POSIX) */#endif /* defined(DWARF_TIMESTAMPS) */extern char *getpwd ();extern char *index ();extern char *rindex ();/* IMPORTANT NOTE: Please see the file README.DWARF for important details   regarding the GNU implementation of Dwarf.  *//* NOTE: In the comments in this file, many references are made to   so called "Debugging Information Entries".  For the sake of brevity,   this term is abbreviated to `DIE' throughout the remainder of this   file.  *//* Note that the implementation of C++ support herein is (as yet) unfinished.   If you want to try to complete it, more power to you.  */#if defined(__GNUC__) && (NDEBUG == 1)#define inline static inline#else#define inline static#endif/* How to start an assembler comment.  */#ifndef ASM_COMMENT_START#define ASM_COMMENT_START ";#"#endif/* How to print out a register name.  */#ifndef PRINT_REG#define PRINT_REG(RTX, CODE, FILE) \  fprintf ((FILE), "%s", reg_names[REGNO (RTX)])#endif/* Define a macro which returns non-zero for any tagged type which is   used (directly or indirectly) in the specification of either some   function's return type or some formal parameter of some function.   We use this macro when we are operating in "terse" mode to help us   know what tagged types have to be represented in Dwarf (even in   terse mode) and which ones don't.   A flag bit with this meaning really should be a part of the normal   GCC ..._TYPE nodes, but at the moment, there is no such bit defined   for these nodes.  For now, we have to just fake it.  It it safe for   us to simply return zero for all complete tagged types (which will   get forced out anyway if they were used in the specification of some   formal or return type) and non-zero for all incomplete tagged types.*/#define TYPE_USED_FOR_FUNCTION(tagged_type) (TYPE_SIZE (tagged_type) == 0)extern int flag_traditional;extern char *version_string;extern char *language_string;/* 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 SHORT_TYPE_SIZE#define SHORT_TYPE_SIZE (BITS_PER_UNIT * 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 WCHAR_TYPE_SIZE#define WCHAR_TYPE_SIZE INT_TYPE_SIZE#endif#ifndef WCHAR_UNSIGNED#define WCHAR_UNSIGNED 0#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/* Structure to keep track of source filenames.  */struct filename_entry {  unsigned	number;  char *	name;};typedef struct filename_entry filename_entry;/* Pointer to an array of elements, each one having the structure above. */static filename_entry *filename_table;/* Total number of entries in the table (i.e. array) pointed to by   `filename_table'.  This is the *total* and includes both used and   unused slots.  */static unsigned ft_entries_allocated;/* Number of entries in the filename_table which are actually in use.  */static unsigned ft_entries;/* Size (in elements) of increments by which we may expand the filename   table.  Actually, a single hunk of space of this size should be enough   for most typical programs.	 */#define FT_ENTRIES_INCREMENT 64/* Local pointer to the name of the main input file.  Initialized in   dwarfout_init.  */static char *primary_filename;/* Pointer to the most recent filename for which we produced some line info.  */static char *last_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 with   assembler labels ..Bn and ..Bn.e, where n is the block number.   The labels themselves are generated in final.c, which assigns   numbers to the blocks in the same way.  */static unsigned next_block_number = 2;/* Counter to generate unique names for DIEs. */static unsigned next_unused_dienum = 1;/* Number of the DIE which is currently being generated.  */static unsigned current_dienum;/* Number to use for the special "pubname" label on the next DIE which   represents a function or data object defined in this compilation   unit which has "extern" linkage.  */static next_pubname_number = 0;#define NEXT_DIE_NUM pending_sibling_stack[pending_siblings-1]/* Pointer to a dynamically allocated list of pre-reserved and still   pending sibling DIE numbers.	 Note that this list will grow as needed.  */static unsigned *pending_sibling_stack;/* Counter to keep track of the number of pre-reserved and still pending   sibling DIE numbers.	 */static unsigned pending_siblings;/* The currently allocated size of the above list (expressed in number of   list elements).  */static unsigned pending_siblings_allocated;/* Size (in elements) of increments by which we may expand the pending   sibling stack.  Actually, a single hunk of space of this size should   be enough for most typical programs.	 */#define PENDING_SIBLINGS_INCREMENT 64/* Non-zero if we are performing our file-scope finalization pass and if   we should force out Dwarf descriptions of any and all file-scope   tagged types which are still incomplete types.  */static int finalizing = 0;/* 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.  */static tree *pending_types_list;/* Number of elements currently allocated for the pending_types_list.  */static unsigned pending_types_allocated;/* 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 pending   types list.  Actually, a single hunk of space of this size should   be enough for most typical programs.	 */#define PENDING_TYPES_INCREMENT 64/* Pointer to an artificial RECORD_TYPE which we create in dwarfout_init.   This is used in a hack to help us get the DIEs describing types of   formal parameters to come *after* all of the DIEs describing the formal   parameters themselves.  That's necessary in order to be compatible   with what the brain-damaged svr4 SDB debugger requires.  */static tree fake_containing_scope;/* The number of the current function definition that we are generating   debugging information for.  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 labels for various things   contained within various function definitions.  */static unsigned current_funcdef_number = 1;/* 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;/* Forward declarations for functions defined in this file.  */static void output_type ();static void type_attribute ();static void output_decls_for_scope ();static void output_decl ();static unsigned lookup_filename ();/* Definitions of defaults for assembler-dependent names of various   pseudo-ops and section names.   Theses may be overridden in your tm.h file (if necessary) for your   particular assembler.  The default values provided here correspond to   what is expected by "standard" AT&T System V.4 assemblers.  */#ifndef FILE_ASM_OP#define FILE_ASM_OP		".file"#endif#ifndef VERSION_ASM_OP#define VERSION_ASM_OP		".version"#endif#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 ASM_BYTE_OP#define ASM_BYTE_OP		".byte"#endif#ifndef SET_ASM_OP#define SET_ASM_OP		".set"#endif/* Pseudo-ops for pushing the current section onto the section stack (and   simultaneously changing to a new section) and for poping back to the   section we were in immediately before this one.  Note that most svr4   assemblers only maintain a one level stack... you can push all the   sections you want, but you can only pop out one level.  (The sparc   svr4 assembler is an exception to this general rule.)  That's   OK because we only use at most one level of the section stack herein.  */#ifndef PUSHSECTION_ASM_OP#define PUSHSECTION_ASM_OP	".section"#endif#ifndef POPSECTION_ASM_OP#define POPSECTION_ASM_OP	".previous"#endif/* The default format used by the ASM_OUTPUT_PUSH_SECTION macro (see below)   to print the PUSHSECTION_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 PUSHSECTION_FORMAT#define PUSHSECTION_FORMAT	"\t%s\t%s\n"#endif#ifndef DEBUG_SECTION#define DEBUG_SECTION		".debug"#endif#ifndef LINE_SECTION#define LINE_SECTION		".line"#endif#ifndef SFNAMES_SECTION#define SFNAMES_SECTION		".debug_sfnames"#endif#ifndef SRCINFO_SECTION#define SRCINFO_SECTION		".debug_srcinfo"#endif#ifndef MACINFO_SECTION#define MACINFO_SECTION		".debug_macinfo"#endif#ifndef PUBNAMES_SECTION#define PUBNAMES_SECTION	".debug_pubnames"#endif#ifndef ARANGES_SECTION#define ARANGES_SECTION		".debug_aranges"#endif#ifndef TEXT_SECTION#define TEXT_SECTION		".text"#endif#ifndef DATA_SECTION#define DATA_SECTION		".data"#endif#ifndef DATA1_SECTION#define DATA1_SECTION		".data1"#endif#ifndef RODATA_SECTION#define RODATA_SECTION		".rodata"#endif#ifndef RODATA1_SECTION#define RODATA1_SECTION		".rodata1"#endif#ifndef BSS_SECTION#define BSS_SECTION		".bss"#endif/* Definitions of defaults for formats and names of various special   (artificial) labels which may be generated within this file (when   the -g options is used and DWARF_DEBUGGING_INFO is in effect.   If necessary, these may be overridden from within your tm.h file,   but typically, you should never need to override these.   These labels have been hacked (temporarily) so that they all begin with   a `.L' sequence so as to appease the stock sparc/svr4 assembler and the

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -