sdbout.c (current_file): New global.

* sdbout.c (current_file): New global.
	(PUT_SDB_SRC_FILE): New PUT_SDB_FOO macro.
	(sdbout_init): Initialize current_file ifdef MIPS_DEBUGGING_INFO.
	(sdbout_{start_new,resume_previous}_source_file): New functions.
	* toplev.c (debug_{start,end}_source_file): Call them if SDB_DEBUG.
	* mips/mips.h (PUT_SDB_SRC_FILE): Define.

From-SVN: r13179
This commit is contained in:
Doug Evans 1996-11-15 22:37:40 +00:00
parent 6619df077d
commit cc694a8150
3 changed files with 83 additions and 0 deletions

View File

@ -1061,6 +1061,12 @@ do { \
#define PUT_SDB_EPILOGUE_END(NAME)
#define PUT_SDB_SRC_FILE(FILENAME) \
do { \
extern FILE *asm_out_text_file; \
output_file_directive (asm_out_text_file, (FILENAME)); \
} while (0)
#define SDB_GENERATE_FAKE(BUFFER, NUMBER) \
sprintf ((BUFFER), ".%dfake", (NUMBER));

View File

@ -288,6 +288,38 @@ do { fprintf (asm_out_file, "\t.def\t"); \
/* 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
/* Perform linker optimization of merging header file definitions together
for targets with MIPS_DEBUGGING_INFO defined. This won't work without a
post 960826 version of GAS. Nothing breaks with earlier versions of GAS,
the optimization just won't be done. The native assembler already has the
necessary support. */
#ifdef MIPS_DEBUGGING_INFO
#ifndef PUT_SDB_SRC_FILE
#define PUT_SDB_SRC_FILE(FILENAME) \
output_file_directive (asm_out_file, (FILENAME))
#endif
/* ECOFF linkers have an optimization that does the same kind of thing as
N_BINCL/E_INCL in stabs: eliminate duplicate debug information in the
executable. To achieve this, GCC must output a .file for each file
name change. */
/* This is a stack of input files. */
struct sdb_file
{
struct sdb_file *next;
char *name;
};
/* This is the top of the stack. */
static struct sdb_file *current_file;
#endif /* MIPS_DEBUGGING_INFO */
/* Set up for SDB output at the start of compilation. */
@ -297,6 +329,12 @@ sdbout_init (asm_file, input_file_name, syms)
char *input_file_name;
tree syms;
{
#ifdef MIPS_DEBUGGING_INFO
current_file = (struct sdb_file *) xmalloc (sizeof *current_file);
current_file->next = NULL;
current_file->name = input_file_name;
#endif
#ifdef RMS_QUICK_HACK_1
tree t;
for (t = syms; t; t = TREE_CHAIN (t))
@ -1556,4 +1594,35 @@ sdbout_label (insn)
PUT_SDB_ENDEF;
}
/* Change to reading from a new source file. */
void
sdbout_start_new_source_file (filename)
char *filename;
{
#ifdef MIPS_DEBUGGING_INFO
struct sdb_file *n = (struct sdb_file *) xmalloc (sizeof *n);
n->next = current_file;
n->name = filename;
current_file = n;
PUT_SDB_SRC_FILE (filename);
#endif
}
/* Revert to reading a previous source file. */
void
sdbout_resume_previous_source_file ()
{
#ifdef MIPS_DEBUGGING_INFO
struct sdb_file *next;
next = current_file->next;
free (current_file);
current_file = next;
PUT_SDB_SRC_FILE (current_file->name);
#endif
}
#endif /* SDB_DEBUGGING_INFO */

View File

@ -4323,6 +4323,10 @@ debug_start_source_file (filename)
&& write_symbols == DWARF2_DEBUG)
dwarf2out_start_source_file (filename);
#endif /* DWARF2_DEBUGGING_INFO */
#ifdef SDB_DEBUGGING_INFO
if (write_symbols == SDB_DEBUG)
sdbout_start_new_source_file (filename);
#endif
}
/* Record the resumption of a source file. LINENO is the line number in
@ -4346,6 +4350,10 @@ debug_end_source_file (lineno)
&& write_symbols == DWARF2_DEBUG)
dwarf2out_end_source_file ();
#endif /* DWARF2_DEBUGGING_INFO */
#ifdef SDB_DEBUGGING_INFO
if (write_symbols == SDB_DEBUG)
sdbout_resume_previous_source_file ();
#endif
}
/* Called from check_newline in c-parse.y. The `buffer' parameter contains