aboutsummaryrefslogtreecommitdiff
path: root/gcc/final.c
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2003-06-26 20:04:40 -0700
committerDevang Patel <dpatel@gcc.gnu.org>2003-06-26 20:04:40 -0700
commit6a08f7b337df863c8835f0fc66fd65d72c3824c8 (patch)
treed83a8d6ed732288799e53eadf75a909cdffd8111 /gcc/final.c
parent6ba701c8e99bcf81604a3bf9f69544434edd239e (diff)
downloadgcc-6a08f7b337df863c8835f0fc66fd65d72c3824c8.zip
gcc-6a08f7b337df863c8835f0fc66fd65d72c3824c8.tar.gz
gcc-6a08f7b337df863c8835f0fc66fd65d72c3824c8.tar.bz2
final.c (debug_flush_symbol_queue): New function.
* final.c (debug_flush_symbol_queue): New function. (debug_queue_symbol): New function. (debug_free_queue): New function. (debug_nesting): New variable. (symbol_queue): New variable. (symbol_queue_index): Same. (symbol_queue_size): Same. * debug.h (debug_flush_symbol_queue): New. (debug_queue_symbol): New. (debug_free_queue): New. (debug_nesting): New. (symbol_queue_index): New. * dbxout.c (DBXOUT_DECR_NESTING): New macro. (DBXOUT_DECR_NESTING_AND_RETURN): New macro. (dbxout_init): Delay symbol output. (dbxout_global_decl): Save, set and reset TREE_USED bit around dbxout_symbol() call. (dbxout_begin_function): Same. (dbxout_finish): Free symbol queue. (dbxout_type): Put appropriate symbols in queue. (dbxout_symbol): Put info for symbol's type in queue. Decrement/Increment nesting counts flush symbol queue appropriately. (dbxout_parms): Increment dbxout nesting. (dbxout_reg_parms): Same. * flags.h (flag_debug_only_used_symbols): New. * toplev.c (flag_debug_only_used_symbols): New variable. (lang_independent_options): Add entries for new option -feliminate-unused-debug-symbols. * common.opt: Add entry for -feliminate-unused-debug-symbols. * opts.c (common_handle_options): Same. * config/rs6000/darwin.h (CC1_SPEC): Interpret -gused as -feliminate-unused-debug-symbols. * doc/invoke.texi (Debugging Options): Document -feliminate-unused-debug-symbols. From-SVN: r68556
Diffstat (limited to 'gcc/final.c')
-rw-r--r--gcc/final.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/gcc/final.c b/gcc/final.c
index 6015cd0..b7a04f5 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -81,6 +81,10 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "dwarf2out.h"
#endif
+#ifdef DBX_DEBUGGING_INFO
+#include "dbxout.h"
+#endif
+
/* If we aren't using cc0, CC_STATUS_INIT shouldn't exist. So define a
null default for it to save conditionalization later. */
#ifndef CC_STATUS_INIT
@@ -3847,3 +3851,85 @@ leaf_renumber_regs_insn (in_rtx)
}
}
#endif
+
+
+/* When -gused is used, emit debug info for only used symbols. But in
+ addition to the standard intercepted debug_hooks there are some direct
+ calls into this file, i.e., dbxout_symbol, dbxout_parms, and dbxout_reg_params.
+ Those routines may also be called from a higher level intercepted routine. So
+ to prevent recording data for an inner call to one of these for an intercept,
+ we maintain a intercept nesting counter (debug_nesting). We only save the
+ intercepted arguments if the nesting is 1. */
+int debug_nesting = 0;
+
+static tree *symbol_queue;
+int symbol_queue_index = 0;
+static int symbol_queue_size = 0;
+
+/* Generate the symbols for any queued up type symbols we encountered
+ while generating the type info for some originally used symbol.
+ This might generate additional entries in the queue. Only when
+ the nesting depth goes to 0 is this routine called. */
+
+void
+debug_flush_symbol_queue ()
+{
+ int i;
+
+ /* Make sure that additionally queued items are not flushed
+ prematurely. */
+
+ ++debug_nesting;
+
+ for (i = 0; i < symbol_queue_index; ++i)
+ {
+ /* If we pushed queued symbols then such symbols are must be
+ output no matter what anyone else says. Specifically,
+ we need to make sure dbxout_symbol() thinks the symbol was
+ used and also we need to override TYPE_DECL_SUPPRESS_DEBUG
+ which may be set for outside reasons. */
+ int saved_tree_used = TREE_USED (symbol_queue[i]);
+ int saved_suppress_debug = TYPE_DECL_SUPPRESS_DEBUG (symbol_queue[i]);
+ TREE_USED (symbol_queue[i]) = 1;
+ TYPE_DECL_SUPPRESS_DEBUG (symbol_queue[i]) = 0;
+
+#ifdef DBX_DEBUGGING_INFO
+ dbxout_symbol (symbol_queue[i], 0);
+#endif
+
+ TREE_USED (symbol_queue[i]) = saved_tree_used;
+ TYPE_DECL_SUPPRESS_DEBUG (symbol_queue[i]) = saved_suppress_debug;
+ }
+
+ symbol_queue_index = 0;
+ --debug_nesting;
+}
+
+/* Queue a type symbol needed as part of the definition of a decl
+ symbol. These symbols are generated when debug_flush_symbol_queue()
+ is called. */
+
+void
+debug_queue_symbol (tree decl)
+{
+ if (symbol_queue_index >= symbol_queue_size)
+ {
+ symbol_queue_size += 10;
+ symbol_queue = (tree *) xrealloc (symbol_queue,
+ symbol_queue_size * sizeof (tree));
+ }
+
+ symbol_queue[symbol_queue_index++] = decl;
+}
+
+/* Free symbol queue */
+void
+debug_free_queue ()
+{
+ if (symbol_queue)
+ {
+ free (symbol_queue);
+ symbol_queue = NULL;
+ symbol_queue_size = 0;
+ }
+}