*** ../../gcc.gused/gcc/dbxout.c Thu Jun 19 18:22:07 2003 --- dbxout.c Fri Jun 20 10:26:37 2003 *************** Software Foundation, 59 Temple Place - S *** 93,98 **** --- 93,103 ---- #include "xcoffout.h" #endif + enum binclstatus {BINCL_NOT_REQUIRED, BINCL_PENDING, BINCL_PROCESSED}; + static void emit_bincl_stab PARAMS ((const char *)); + static void emit_pending_bincls PARAMS ((void)); + static inline void emit_pending_bincls_if_required PARAMS ((void)); + /* When -gused is used, emit debug info for only used symbols. But in addition to the standard intercepted debug_hooks there are some direct *************** struct dbx_file GTY(()) *** 207,214 **** --- 212,225 ---- struct dbx_file *next; int file_number; int next_type_number; + enum binclstatus bincl_status; /* Keep track of lazy bincl */ + const char *pending_bincl_name; /* Name of bincl */ + struct dbx_file *prev; /* Chain to traverse all pending bincls */ }; + /* If zero then there is no pending BINCL */ + static int pending_bincls = 0; + /* This is the top of the stack. */ static GTY(()) struct dbx_file *current_file; *************** dbxout_init (input_file_name) *** 523,528 **** --- 534,542 ---- current_file->file_number = 0; current_file->next_type_number = 1; next_file_number = 1; + current_file->prev = NULL; + current_file->bincl_status = BINCL_NOT_REQUIRED; + current_file->pending_bincl_name = NULL; #endif /* Make sure that types `int' and `char' have numbers 1 and 2. *************** dbxout_typedefs (syms) *** 564,569 **** --- 578,637 ---- } } + /* Emit BINCL stab using given name. */ + static void + emit_bincl_stab (name) + const char *name; + { + fprintf (asmfile, "%s", ASM_STABS_OP); + output_quoted_string (asmfile, name); + fprintf (asmfile, ",%d,0,0,0\n", N_BINCL); + } + + /* If there are pending bincls then it is time to emit all of them. */ + + static inline void + emit_pending_bincls_if_required () + { + #ifdef DBX_USE_BINCL + if (pending_bincls) + emit_pending_bincls (); + #endif + } + + /* Emit all pending bincls. */ + + static void + emit_pending_bincls () + { + struct dbx_file *f = current_file; + + /* Find first pending bincl */ + while (f->bincl_status == BINCL_PENDING) + f = f->next; + + /* Now emit all bincls */ + f = f->prev; + + while (f) + { + if (f->bincl_status == BINCL_PENDING) + { + emit_bincl_stab (f->pending_bincl_name); + + /* Update file number and status */ + f->file_number = next_file_number++; + f->bincl_status = BINCL_PROCESSED; + } + if (f == current_file) + break; + f = f->prev; + } + + /* All pending bincls have been emitted. */ + pending_bincls = 0; + } + /* Change to reading from a new source file. Generate a N_BINCL stab. */ static void *************** dbxout_start_source_file (line, filename *** 575,586 **** struct dbx_file *n = (struct dbx_file *) ggc_alloc (sizeof *n); n->next = current_file; - n->file_number = next_file_number++; n->next_type_number = 1; current_file = n; - fprintf (asmfile, "%s", ASM_STABS_OP); - output_quoted_string (asmfile, filename); - fprintf (asmfile, ",%d,0,0,0\n", N_BINCL); #endif } --- 643,657 ---- struct dbx_file *n = (struct dbx_file *) ggc_alloc (sizeof *n); n->next = current_file; n->next_type_number = 1; + /* Do not assign file number now. Delay it until we actually emit BINCL. */ + n->file_number = 0; + n->prev = NULL; + current_file->prev = n; + n->bincl_status = BINCL_PENDING; + n->pending_bincl_name = filename; + pending_bincls = 1; current_file = n; #endif } *************** dbxout_end_source_file (line) *** 591,597 **** unsigned int line ATTRIBUTE_UNUSED; { #ifdef DBX_USE_BINCL ! fprintf (asmfile, "%s%d,0,0,0\n", ASM_STABN_OP, N_EINCL); current_file = current_file->next; #endif } --- 662,671 ---- unsigned int line ATTRIBUTE_UNUSED; { #ifdef DBX_USE_BINCL ! /* Emit EINCL stab only if BINCL is not pending. */ ! if (current_file->bincl_status == BINCL_PROCESSED) ! fprintf (asmfile, "%s%d,0,0,0\n", ASM_STABN_OP, N_EINCL); ! current_file->bincl_status = BINCL_NOT_REQUIRED; current_file = current_file->next; #endif } *************** dbxout_begin_block (line, n) *** 685,690 **** --- 759,765 ---- unsigned int line ATTRIBUTE_UNUSED; unsigned int n; { + emit_pending_bincls_if_required (); (*targetm.asm_out.internal_label) (asmfile, "LBB", n); } *************** dbxout_end_block (line, n) *** 695,700 **** --- 770,776 ---- unsigned int line ATTRIBUTE_UNUSED; unsigned int n; { + emit_pending_bincls_if_required (); (*targetm.asm_out.internal_label) (asmfile, "LBE", n); } *************** static void *** 708,713 **** --- 784,790 ---- dbxout_function_decl (decl) tree decl; { + emit_pending_bincls_if_required (); #ifndef DBX_FUNCTION_FIRST dbxout_begin_function (decl); #endif *************** dbxout_type_index (type) *** 842,847 **** --- 919,925 ---- static void dbxout_continue () { + emit_pending_bincls_if_required (); #ifdef DBX_CONTIN_CHAR fprintf (asmfile, "%c", DBX_CONTIN_CHAR); #else *************** dbxout_flush_symbol_queue () *** 1176,1181 **** --- 1254,1261 ---- { int i; + emit_pending_bincls_if_required (); + /* Make sure that additionally queued items are not flushed prematurely. */ *************** dbxout_class_name_qualifiers (decl) *** 2094,2099 **** --- 2174,2181 ---- { tree name = TYPE_NAME (context); + emit_pending_bincls_if_required (); + if (TREE_CODE (name) == TYPE_DECL) { dbxout_class_name_qualifiers (name); *************** dbxout_symbol (decl, local) *** 2188,2193 **** --- 2270,2277 ---- dbxout_queue_symbol (TYPE_NAME (t)); } + emit_pending_bincls_if_required (); + dbxout_prepare_symbol (decl); /* The output will always start with the symbol name, *************** dbxout_symbol_location (decl, type, suff *** 2468,2473 **** --- 2552,2559 ---- int letter = 0; int regno = -1; + emit_pending_bincls_if_required (); + /* Don't mention a variable at all if it was completely optimized into nothingness. *************** dbxout_parms (parms) *** 2787,2792 **** --- 2873,2880 ---- tree parms; { ++dbxout_nesting; + + emit_pending_bincls_if_required (); for (; parms; parms = TREE_CHAIN (parms)) if (DECL_NAME (parms) && TREE_TYPE (parms) != error_mark_node)