summaryrefslogtreecommitdiff
path: root/contrib/gcc/dbxout.c
diff options
context:
space:
mode:
authorAlexander Kabaev <kan@FreeBSD.org>2005-06-03 03:50:42 +0000
committerAlexander Kabaev <kan@FreeBSD.org>2005-06-03 03:50:42 +0000
commit31a119f3ede3e46847ca7849e70407c96e04d1f3 (patch)
tree56d842dca34faa3e40f969e13617dfdbb051d690 /contrib/gcc/dbxout.c
parent2554b2d12b64808f2da1a31320628c91ab16164a (diff)
downloadsrc-test2-31a119f3ede3e46847ca7849e70407c96e04d1f3.tar.gz
src-test2-31a119f3ede3e46847ca7849e70407c96e04d1f3.zip
Notes
Diffstat (limited to 'contrib/gcc/dbxout.c')
-rw-r--r--contrib/gcc/dbxout.c182
1 files changed, 111 insertions, 71 deletions
diff --git a/contrib/gcc/dbxout.c b/contrib/gcc/dbxout.c
index 5a3c1354b950..b12ea5cbf329 100644
--- a/contrib/gcc/dbxout.c
+++ b/contrib/gcc/dbxout.c
@@ -434,6 +434,9 @@ static void
dbxout_function_end (void)
{
char lscope_label_name[100];
+
+ /* The Lscope label must be emitted even if we aren't doing anything
+ else; dbxout_block needs it. */
/* Convert Ltext into the appropriate format for local labels in case
the system doesn't insert underscores in front of user generated
labels. */
@@ -441,6 +444,16 @@ dbxout_function_end (void)
(*targetm.asm_out.internal_label) (asmfile, "Lscope", scope_labelno);
scope_labelno++;
+ /* The N_FUN tag at the end of the function is a GNU extension,
+ which may be undesirable, and is unnecessary if we do not have
+ named sections. */
+ if (!use_gnu_debug_info_extensions
+#if defined(NO_DBX_FUNCTION_END)
+ || NO_DBX_FUNCTION_END
+#endif
+ || !targetm.have_named_sections)
+ return;
+
/* By convention, GCC will mark the end of a function with an N_FUN
symbol and an empty string. */
#ifdef DBX_OUTPUT_NFUN
@@ -774,12 +787,7 @@ dbxout_function_decl (tree decl)
#ifdef DBX_OUTPUT_FUNCTION_END
DBX_OUTPUT_FUNCTION_END (asmfile, decl);
#endif
- if (use_gnu_debug_info_extensions
-#if defined(NO_DBX_FUNCTION_END)
- && ! NO_DBX_FUNCTION_END
-#endif
- && targetm.have_named_sections)
- dbxout_function_end ();
+ dbxout_function_end ();
}
#endif /* DBX_DEBUGGING_INFO */
@@ -2439,6 +2447,37 @@ dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home)
letter = decl_function_context (decl) ? 'V' : 'S';
+ /* Some ports can transform a symbol ref into a label ref,
+ because the symbol ref is too far away and has to be
+ dumped into a constant pool. Alternatively, the symbol
+ in the constant pool might be referenced by a different
+ symbol. */
+ if (GET_CODE (current_sym_addr) == SYMBOL_REF
+ && CONSTANT_POOL_ADDRESS_P (current_sym_addr))
+ {
+ bool marked;
+ rtx tmp = get_pool_constant_mark (current_sym_addr, &marked);
+
+ if (GET_CODE (tmp) == SYMBOL_REF)
+ {
+ current_sym_addr = tmp;
+ if (CONSTANT_POOL_ADDRESS_P (current_sym_addr))
+ get_pool_constant_mark (current_sym_addr, &marked);
+ else
+ marked = true;
+ }
+ else if (GET_CODE (tmp) == LABEL_REF)
+ {
+ current_sym_addr = tmp;
+ marked = true;
+ }
+
+ /* If all references to the constant pool were optimized
+ out, we just ignore the symbol. */
+ if (!marked)
+ return 0;
+ }
+
/* This should be the same condition as in assemble_variable, but
we don't have access to dont_output_data here. So, instead,
we rely on the fact that error_mark_node initializers always
@@ -2453,37 +2492,6 @@ dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home)
current_sym_code = DBX_STATIC_CONST_VAR_CODE;
else
{
- /* Some ports can transform a symbol ref into a label ref,
- because the symbol ref is too far away and has to be
- dumped into a constant pool. Alternatively, the symbol
- in the constant pool might be referenced by a different
- symbol. */
- if (GET_CODE (current_sym_addr) == SYMBOL_REF
- && CONSTANT_POOL_ADDRESS_P (current_sym_addr))
- {
- bool marked;
- rtx tmp = get_pool_constant_mark (current_sym_addr, &marked);
-
- if (GET_CODE (tmp) == SYMBOL_REF)
- {
- current_sym_addr = tmp;
- if (CONSTANT_POOL_ADDRESS_P (current_sym_addr))
- get_pool_constant_mark (current_sym_addr, &marked);
- else
- marked = true;
- }
- else if (GET_CODE (tmp) == LABEL_REF)
- {
- current_sym_addr = tmp;
- marked = true;
- }
-
- /* If all references to the constant pool were optimized
- out, we just ignore the symbol. */
- if (!marked)
- return 0;
- }
-
/* Ultrix `as' seems to need this. */
#ifdef DBX_STATIC_STAB_DATA_SECTION
data_section ();
@@ -3037,6 +3045,46 @@ dbxout_args (tree args)
}
}
+/* Subroutine of dbxout_block. Emit an N_LBRAC stab referencing LABEL.
+ BEGIN_LABEL is the name of the beginning of the function, which may
+ be required. */
+static void
+dbx_output_lbrac (const char *label,
+ const char *begin_label ATTRIBUTE_UNUSED)
+{
+#ifdef DBX_OUTPUT_LBRAC
+ DBX_OUTPUT_LBRAC (asmfile, label);
+#else
+ fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_LBRAC);
+ assemble_name (asmfile, label);
+#if DBX_BLOCKS_FUNCTION_RELATIVE
+ putc ('-', asmfile);
+ assemble_name (asmfile, begin_label);
+#endif
+ fprintf (asmfile, "\n");
+#endif
+}
+
+/* Subroutine of dbxout_block. Emit an N_RBRAC stab referencing LABEL.
+ BEGIN_LABEL is the name of the beginning of the function, which may
+ be required. */
+static void
+dbx_output_rbrac (const char *label,
+ const char *begin_label ATTRIBUTE_UNUSED)
+{
+#ifdef DBX_OUTPUT_RBRAC
+ DBX_OUTPUT_RBRAC (asmfile, label);
+#else
+ fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_RBRAC);
+ assemble_name (asmfile, label);
+#if DBX_BLOCKS_FUNCTION_RELATIVE
+ putc ('-', asmfile);
+ assemble_name (asmfile, begin_label);
+#endif
+ fprintf (asmfile, "\n");
+#endif
+}
+
/* Output everything about a symbol block (a BLOCK node
that represents a scope level),
including recursive output of contained blocks.
@@ -3057,15 +3105,11 @@ dbxout_args (tree args)
static void
dbxout_block (tree block, int depth, tree args)
{
- int blocknum = -1;
-
-#if DBX_BLOCKS_FUNCTION_RELATIVE
const char *begin_label;
if (current_function_func_begin_label != NULL_TREE)
begin_label = IDENTIFIER_POINTER (current_function_func_begin_label);
else
begin_label = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);
-#endif
while (block)
{
@@ -3073,6 +3117,7 @@ dbxout_block (tree block, int depth, tree args)
if (TREE_USED (block) && TREE_ASM_WRITTEN (block))
{
int did_output;
+ int blocknum = BLOCK_NUMBER (block);
/* In dbx format, the syms of a block come before the N_LBRAC.
If nothing is output, we don't need the N_LBRAC, either. */
@@ -3086,11 +3131,20 @@ dbxout_block (tree block, int depth, tree args)
the block. Use the block's tree-walk order to generate
the assembler symbols LBBn and LBEn
that final will define around the code in this block. */
- if (depth > 0 && did_output)
+ if (did_output)
{
char buf[20];
- blocknum = BLOCK_NUMBER (block);
- ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
+ const char *scope_start;
+
+ if (depth == 0)
+ /* The outermost block doesn't get LBB labels; use
+ the function symbol. */
+ scope_start = begin_label;
+ else
+ {
+ ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
+ scope_start = buf;
+ }
if (BLOCK_HANDLER_BLOCK (block))
{
@@ -3100,44 +3154,30 @@ dbxout_block (tree block, int depth, tree args)
{
fprintf (asmfile, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP,
IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
- assemble_name (asmfile, buf);
+ assemble_name (asmfile, scope_start);
fprintf (asmfile, "\n");
decl = TREE_CHAIN (decl);
}
}
-
-#ifdef DBX_OUTPUT_LBRAC
- DBX_OUTPUT_LBRAC (asmfile, buf);
-#else
- fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_LBRAC);
- assemble_name (asmfile, buf);
-#if DBX_BLOCKS_FUNCTION_RELATIVE
- putc ('-', asmfile);
- assemble_name (asmfile, begin_label);
-#endif
- fprintf (asmfile, "\n");
-#endif
+ dbx_output_lbrac (scope_start, begin_label);
}
/* Output the subblocks. */
dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
/* Refer to the marker for the end of the block. */
- if (depth > 0 && did_output)
+ if (did_output)
{
- char buf[20];
- ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
-#ifdef DBX_OUTPUT_RBRAC
- DBX_OUTPUT_RBRAC (asmfile, buf);
-#else
- fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_RBRAC);
- assemble_name (asmfile, buf);
-#if DBX_BLOCKS_FUNCTION_RELATIVE
- putc ('-', asmfile);
- assemble_name (asmfile, begin_label);
-#endif
- fprintf (asmfile, "\n");
-#endif
+ char buf[100];
+ if (depth == 0)
+ /* The outermost block doesn't get LBE labels;
+ use the "scope" label which will be emitted
+ by dbxout_function_end. */
+ ASM_GENERATE_INTERNAL_LABEL (buf, "Lscope", scope_labelno);
+ else
+ ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
+
+ dbx_output_rbrac (buf, begin_label);
}
}
block = BLOCK_CHAIN (block);