aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoffrey Keating <geoffk@apple.com>2003-04-05 07:01:51 +0000
committerGeoffrey Keating <geoffk@gcc.gnu.org>2003-04-05 07:01:51 +0000
commit33b49800795a066270c5a4712db7cdc0875941e5 (patch)
tree3da09cdc35a115a5b68c8b9d716e7e83e9721d11
parent41a73c4c6ce2c30e81a35d594c9baf8719daf503 (diff)
downloadgcc-33b49800795a066270c5a4712db7cdc0875941e5.zip
gcc-33b49800795a066270c5a4712db7cdc0875941e5.tar.gz
gcc-33b49800795a066270c5a4712db7cdc0875941e5.tar.bz2
dbxout.c (scope_labelno): Add GTY.
2003-04-04 Geoffrey Keating <geoffk@apple.com> * dbxout.c (scope_labelno): Add GTY. (have_used_extensions): Add GTY. (source_label_number): Add GTY. (lastfile): Add GTY. (lastfile_is_base): New. (base_input_file): New. (dbxout_handle_pch): New. (dbx_debug_hooks): Add handle_pch. (xcoff_debug_hooks): Likewise. (dbxout_function_end): Remove scope_labelno. (dbxout_init): Set base_input_file. (dbxout_handle_pch): New. (dbxout_source_file): Honour lastfile_is_base. * dwarfout.c (dwarf_debug_hooks): Add dummy handle_pch. * sdbout.c (sdb_debug_hooks): Add dummy handle_pch. * vmsdbgout.c (vmsdbg_debug_hooks): Add dummy handle_pch. * dwarf2out.c (dwarf2_debug_hooks): Add dummy handle_pch. * debug.c (do_nothing_debug_hooks): Add dummy handle_pch. * debug.h (struct gcc_debug_hooks): Add handle_pch. * c-pch.c (pch_init): Don't call start_source_file, but do call handle_pch. (c_common_write_pch): Call handle_pch. (c_common_read_pch): Don't call start_source_file, or end_source_file. Index: gcc/testsuite/ChangeLog 2003-04-04 Geoffrey Keating <geoffk@apple.com> * gcc.dg/pch/static-3.c: New. * gcc.dg/pch/static-3.hs: New. * gcc.dg/pch/pch.exp: Test with -O0 -g too. From-SVN: r65266
-rw-r--r--gcc/ChangeLog27
-rw-r--r--gcc/c-pch.c17
-rw-r--r--gcc/dbxout.c80
-rw-r--r--gcc/debug.c3
-rw-r--r--gcc/debug.h4
-rw-r--r--gcc/dwarf2out.c3
-rw-r--r--gcc/dwarfout.c3
-rw-r--r--gcc/sdbout.c3
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/pch/pch.exp7
-rw-r--r--gcc/testsuite/gcc.dg/pch/static-3.c8
-rw-r--r--gcc/testsuite/gcc.dg/pch/static-3.hs7
-rw-r--r--gcc/vmsdbgout.c3
13 files changed, 134 insertions, 37 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6dba145..8802ff6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,30 @@
+2003-04-04 Geoffrey Keating <geoffk@apple.com>
+
+ * dbxout.c (scope_labelno): Add GTY.
+ (have_used_extensions): Add GTY.
+ (source_label_number): Add GTY.
+ (lastfile): Add GTY.
+ (lastfile_is_base): New.
+ (base_input_file): New.
+ (dbxout_handle_pch): New.
+ (dbx_debug_hooks): Add handle_pch.
+ (xcoff_debug_hooks): Likewise.
+ (dbxout_function_end): Remove scope_labelno.
+ (dbxout_init): Set base_input_file.
+ (dbxout_handle_pch): New.
+ (dbxout_source_file): Honour lastfile_is_base.
+ * dwarfout.c (dwarf_debug_hooks): Add dummy handle_pch.
+ * sdbout.c (sdb_debug_hooks): Add dummy handle_pch.
+ * vmsdbgout.c (vmsdbg_debug_hooks): Add dummy handle_pch.
+ * dwarf2out.c (dwarf2_debug_hooks): Add dummy handle_pch.
+ * debug.c (do_nothing_debug_hooks): Add dummy handle_pch.
+ * debug.h (struct gcc_debug_hooks): Add handle_pch.
+ * c-pch.c (pch_init): Don't call start_source_file, but do call
+ handle_pch.
+ (c_common_write_pch): Call handle_pch.
+ (c_common_read_pch): Don't call start_source_file,
+ or end_source_file.
+
Fri Apr 4 17:43:52 2003 Olivier Hainque <hainque@act-europe.fr>
* emit-rtl.c (get_mem_attrs): Adjust alignment tests determining
diff --git a/gcc/c-pch.c b/gcc/c-pch.c
index 821eddb..27a299f 100644
--- a/gcc/c-pch.c
+++ b/gcc/c-pch.c
@@ -68,10 +68,6 @@ pch_init ()
if (pch_file)
{
- /* We're precompiling a header file, so when it's actually used,
- it'll be at least one level deep. */
- (*debug_hooks->start_source_file) (lineno, input_filename);
-
f = fopen (pch_file, "w+b");
if (f == NULL)
fatal_io_error ("can't open %s", pch_file);
@@ -88,6 +84,9 @@ pch_init ()
asm_file_startpos = ftell (asm_out_file);
+ /* Let the debugging format deal with the PCHness. */
+ (*debug_hooks->handle_pch) (0);
+
cpp_save_state (parse_in, f);
}
}
@@ -100,6 +99,8 @@ c_common_write_pch ()
long written;
struct c_pch_header h;
+ (*debug_hooks->handle_pch) (1);
+
cpp_write_pch_deps (parse_in, pch_outfile);
asm_file_end = ftell (asm_out_file);
@@ -195,7 +196,7 @@ c_common_read_pch (pfile, name, fd, orig_name)
cpp_reader *pfile;
const char *name;
int fd;
- const char *orig_name;
+ const char *orig_name ATTRIBUTE_UNUSED;
{
FILE *f;
struct c_pch_header h;
@@ -203,10 +204,6 @@ c_common_read_pch (pfile, name, fd, orig_name)
unsigned long written;
struct save_macro_data *smd;
- /* Before we wrote the file, we started a source file, so we have to start
- one here to match. */
- (*debug_hooks->start_source_file) (lineno, orig_name);
-
f = fdopen (fd, "rb");
if (f == NULL)
{
@@ -243,6 +240,4 @@ c_common_read_pch (pfile, name, fd, orig_name)
return;
fclose (f);
-
- (*debug_hooks->end_source_file) (lineno);
}
diff --git a/gcc/dbxout.c b/gcc/dbxout.c
index 58208ff..3f5ace0 100644
--- a/gcc/dbxout.c
+++ b/gcc/dbxout.c
@@ -189,32 +189,41 @@ static GTY(()) struct dbx_file *current_file;
static GTY(()) int next_file_number;
-/* Typical USG systems don't have stab.h, and they also have
- no use for DBX-format debugging info. */
-
-#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
-
-/* Last source file name mentioned in a NOTE insn. */
-
-static const char *lastfile;
+/* A counter for dbxout_function_end. */
-/* Current working directory. */
-
-static const char *cwd;
+static GTY(()) int scope_labelno;
/* Nonzero if we have actually used any of the GDB extensions
to the debugging format. The idea is that we use them for the
first time only if there's a strong reason, but once we have done that,
we use them whenever convenient. */
-static int have_used_extensions = 0;
+static GTY(()) int have_used_extensions = 0;
/* Number for the next N_SOL filename stabs label. The number 0 is reserved
for the N_SO filename stabs label. */
-#if defined (DBX_DEBUGGING_INFO) && !defined (DBX_OUTPUT_SOURCE_FILENAME)
-static int source_label_number = 1;
-#endif
+static GTY(()) int source_label_number = 1;
+
+/* Last source file name mentioned in a NOTE insn. */
+
+static GTY(()) const char *lastfile;
+
+/* Used by PCH machinery to detect if 'lastfile' should be reset to
+ base_input_file. */
+static GTY(()) int lastfile_is_base;
+
+/* Typical USG systems don't have stab.h, and they also have
+ no use for DBX-format debugging info. */
+
+#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
+
+/* The original input file name. */
+static const char *base_input_file;
+
+/* Current working directory. */
+
+static const char *cwd;
#ifdef DEBUG_SYMS_TEXT
#define FORCE_TEXT function_section (current_function_decl);
@@ -323,6 +332,7 @@ static void dbxout_begin_function PARAMS ((tree));
static void dbxout_begin_block PARAMS ((unsigned, unsigned));
static void dbxout_end_block PARAMS ((unsigned, unsigned));
static void dbxout_function_decl PARAMS ((tree));
+static void dbxout_handle_pch PARAMS ((unsigned));
const struct gcc_debug_hooks dbx_debug_hooks =
{
@@ -349,7 +359,8 @@ const struct gcc_debug_hooks dbx_debug_hooks =
dbxout_global_decl, /* global_decl */
debug_nothing_tree, /* deferred_inline_function */
debug_nothing_tree, /* outlining_inline_function */
- debug_nothing_rtx /* label */
+ debug_nothing_rtx, /* label */
+ dbxout_handle_pch /* handle_pch */
};
#endif /* DBX_DEBUGGING_INFO */
@@ -375,7 +386,8 @@ const struct gcc_debug_hooks xcoff_debug_hooks =
dbxout_global_decl, /* global_decl */
debug_nothing_tree, /* deferred_inline_function */
debug_nothing_tree, /* outlining_inline_function */
- debug_nothing_rtx /* label */
+ debug_nothing_rtx, /* label */
+ dbxout_handle_pch /* handle_pch */
};
#endif /* XCOFF_DEBUGGING_INFO */
@@ -383,7 +395,6 @@ const struct gcc_debug_hooks xcoff_debug_hooks =
static void
dbxout_function_end ()
{
- static int scope_labelno = 0;
char lscope_label_name[100];
/* Convert Ltext into the appropriate format for local labels in case
the system doesn't insert underscores in front of user generated
@@ -473,7 +484,7 @@ dbxout_init (input_file_name)
ASM_STABS_OP, STABS_GCC_MARKER, N_OPT);
#endif
- lastfile = input_file_name;
+ base_input_file = lastfile = input_file_name;
next_type_number = 1;
@@ -559,6 +570,31 @@ dbxout_end_source_file (line)
#endif
}
+/* Handle a few odd cases that occur when trying to make PCH files work. */
+
+static void
+dbxout_handle_pch (unsigned at_end)
+{
+ if (! at_end)
+ {
+ /* When using the PCH, this file will be included, so we need to output
+ a BINCL. */
+ dbxout_start_source_file (0, lastfile);
+
+ /* The base file when using the PCH won't be the same as
+ the base file when it's being generated. */
+ lastfile = NULL;
+ }
+ else
+ {
+ /* ... and an EINCL. */
+ dbxout_end_source_file (0);
+
+ /* Deal with cases where 'lastfile' was never actually changed. */
+ lastfile_is_base = lastfile == NULL;
+ }
+}
+
#if defined (DBX_DEBUGGING_INFO)
/* Output debugging info to FILE to switch to sourcefile FILENAME. */
@@ -567,6 +603,12 @@ dbxout_source_file (file, filename)
FILE *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)))
{
#ifdef DBX_OUTPUT_SOURCE_FILENAME
diff --git a/gcc/debug.c b/gcc/debug.c
index 6a9c392..ca17373 100644
--- a/gcc/debug.c
+++ b/gcc/debug.c
@@ -43,7 +43,8 @@ const struct gcc_debug_hooks do_nothing_debug_hooks =
debug_nothing_tree, /* global_decl */
debug_nothing_tree, /* deferred_inline_function */
debug_nothing_tree, /* outlining_inline_function */
- debug_nothing_rtx /* label */
+ debug_nothing_rtx, /* label */
+ debug_nothing_int /* handle_pch */
};
/* This file contains implementations of each debug hook that do
diff --git a/gcc/debug.h b/gcc/debug.h
index 11c996f..2793e30 100644
--- a/gcc/debug.h
+++ b/gcc/debug.h
@@ -101,6 +101,10 @@ struct gcc_debug_hooks
/* Called from final_scan_insn for any CODE_LABEL insn whose
LABEL_NAME is non-null. */
void (* label) PARAMS ((rtx));
+
+ /* Called after the start and before the end of writing a PCH file.
+ The parameter is 0 if after the start, 1 if before the end. */
+ void (* handle_pch) PARAMS ((unsigned int));
};
extern const struct gcc_debug_hooks *debug_hooks;
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index dcc7d6e..8a9b9fd 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -3282,7 +3282,8 @@ const struct gcc_debug_hooks dwarf2_debug_hooks =
emitting the abstract description of inline functions until
something tries to reference them. */
dwarf2out_abstract_function, /* outlining_inline_function */
- debug_nothing_rtx /* label */
+ debug_nothing_rtx, /* label */
+ debug_nothing_int /* handle_pch */
};
#endif
diff --git a/gcc/dwarfout.c b/gcc/dwarfout.c
index 8f456f7..b6d150f 100644
--- a/gcc/dwarfout.c
+++ b/gcc/dwarfout.c
@@ -1294,7 +1294,8 @@ const struct gcc_debug_hooks dwarf_debug_hooks =
dwarfout_global_decl,
dwarfout_deferred_inline_function,
debug_nothing_tree, /* outlining_inline_function */
- debug_nothing_rtx /* label */
+ debug_nothing_rtx, /* label */
+ debug_nothing_int /* handle_pch */
};
/************************ general utility functions **************************/
diff --git a/gcc/sdbout.c b/gcc/sdbout.c
index 30565b3..aaba360 100644
--- a/gcc/sdbout.c
+++ b/gcc/sdbout.c
@@ -333,7 +333,8 @@ const struct gcc_debug_hooks sdb_debug_hooks =
sdbout_global_decl, /* global_decl */
debug_nothing_tree, /* deferred_inline_function */
debug_nothing_tree, /* outlining_inline_function */
- sdbout_label
+ sdbout_label, /* label */
+ debug_nothing_int /* handle_pch */
};
#if 0
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1d5fdd7..24f4489 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2003-04-04 Geoffrey Keating <geoffk@apple.com>
+
+ * gcc.dg/pch/static-3.c: New.
+ * gcc.dg/pch/static-3.hs: New.
+ * gcc.dg/pch/pch.exp: Test with -O0 -g too.
+
2003-04-04 Richard Henderson <rth@redhat.com>
* g++.dg/eh/forced1.C: Use _Unwind_SjLj_ForcedUnwind as appropriate.
diff --git a/gcc/testsuite/gcc.dg/pch/pch.exp b/gcc/testsuite/gcc.dg/pch/pch.exp
index 7a5aaca..543d614 100644
--- a/gcc/testsuite/gcc.dg/pch/pch.exp
+++ b/gcc/testsuite/gcc.dg/pch/pch.exp
@@ -41,8 +41,11 @@ foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
catch { file delete "$bname.s-gch" }
# We don't try to use the loop-optimizing options, since they are highly
- # unlikely to make any difference to PCH.
- foreach flags $torture_without_loops {
+ # unlikely to make any difference to PCH. However, we do want to
+ # add -O0 -g, since users who want PCH usually want debugging and quick
+ # compiles.
+ set pch_torture [concat [list {-O0 -g}] $torture_without_loops]
+ foreach flags $pch_torture {
verbose "Testing $nshort, $flags" 1
# For the header files, the default is to precompile.
diff --git a/gcc/testsuite/gcc.dg/pch/static-3.c b/gcc/testsuite/gcc.dg/pch/static-3.c
new file mode 100644
index 0000000..eae0ab0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pch/static-3.c
@@ -0,0 +1,8 @@
+#include "static-3.h"
+int bar(int *a)
+{
+ int i, tot;
+ for (i = tot = 0; i < 100; i++)
+ tot += a[i];
+ return tot;
+}
diff --git a/gcc/testsuite/gcc.dg/pch/static-3.hs b/gcc/testsuite/gcc.dg/pch/static-3.hs
new file mode 100644
index 0000000..b881945
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pch/static-3.hs
@@ -0,0 +1,7 @@
+static int foo(int *a)
+{
+ int i, tot;
+ for (i = tot = 0; i < 100; i++)
+ tot += a[i];
+ return tot;
+}
diff --git a/gcc/vmsdbgout.c b/gcc/vmsdbgout.c
index ae3fa17..7824698 100644
--- a/gcc/vmsdbgout.c
+++ b/gcc/vmsdbgout.c
@@ -189,7 +189,8 @@ const struct gcc_debug_hooks vmsdbg_debug_hooks
vmsdbgout_global_decl,
debug_nothing_tree, /* deferred_inline_function */
vmsdbgout_abstract_function,
- debug_nothing_rtx /* label */
+ debug_nothing_rtx, /* label */
+ debug_nothing_int /* handle_pch */
};
/* Definitions of defaults for assembler-dependent names of various