* as.c (debug_type): Init to DEBUG_UNSPECIFIED.

* as.h (debug_type): Clarify documentation of the meaning
	of this variable.
	* dwarf2dbg.c (DWARF2_LINE_MIN_INSN_LENGTH): Default to 1.
	(print_stats): Fix parenthesis problem.
	(now_subseg_size): New.
	(dwarf2_finish): Use it.  If DEBUG_DWARF2, emit bits for .debug_info.
	(dwarf2_directive_file): Don't set debug_type.
	(dwarf2_where): Honor DEBUG_DWARF2 first.
	(dwarf2_emit_insn): Renamed from dwarf2_generate_asm_lineno;
	do nothing if not emitting dwarf2 debug info, or no work.
	* dwarf2dbg.h (dwarf2_emit_insn): Update.
	* ecoff.c (add_file): Turn on DEBUG_ECOFF only if DEBUG_UNSPECIFIED.
	(ecoff_new_file): Likewise.
	* read.c (generate_lineno_debug): Kill ecoff hackery.  Update
	commentary wrt dwarf2.

	* config/tc-alpha.c (alpha_adjust_symtab_relocs): Add
	ATTRIBUTE_UNUSED as needed.
	(emit_insn): Call dwarf2_emit_insn.
	(s_alpha_file): New.
	(s_alpha_loc): New.
	(s_alpha_coff_wrapper): Don't handle them.
	(md_pseudo_table): Update for .file and .loc.
	* config/tc-alpha.h (DWARF2_LINE_MIN_INSN_LENGTH): New.

	* config/tc-arm.c (output_inst): Update for dwarf2_emit_insn;
	don't protect with debug_type.
	* config/tc-hppa.c (md_assemble): Likewise.
	* config/tc-m68hc11.c (m68hc11_new_insn): Likewise.
	* config/tc-mn10300.c (md_assemble): Likewise.
	* config/tc-sh.c (md_assemble): Likewise.
	* config/tc-v850.c (md_assemble): Likewise.

	* config/tc-arm.c (arm_end_of_source): Remove.
	* config/tc-hppa.c (pa_end_of_source): Remove.
	* config/tc-m68hc11.c (m68hc11_end_of_source): Remove.
	* config/tc-mn10300.c (mn10300_finalize): Remove.
	* config/tc-sh.c (sh_finalize): Remove.
	* config/tc-v850.c (sh_finalize): Remove.

	* config/tc-arm.h (md_end): Remove.
	* config/tc-hppa.h (md_end): Remove.
	(DWARF2_LINE_MIN_INSN_LENGTH): New.
	* config/tc-m68hc11.h (md_end): Remove.
	* config/tc-mn10300.h (md_end): Remove.
	* config/tc-sh.h (md_end): Remove.
	* config/tc-v850.h (md_end): Remove.

	* config/tc-ia64.c (emit_one_bundle): Don't protect
	dwarf2 bits with debug_type.
	(md_assemble): Likewise.
	(ia64_end_of_source): Don't call dwarf2_finish.
This commit is contained in:
Richard Henderson 2000-11-17 08:47:52 +00:00
parent 512d22f487
commit 4dc7ead9fd
22 changed files with 210 additions and 168 deletions

View File

@ -1,3 +1,59 @@
2000-11-17 Richard Henderson <rth@redhat.com>
* as.c (debug_type): Init to DEBUG_UNSPECIFIED.
* as.h (debug_type): Clarify documentation of the meaning
of this variable.
* dwarf2dbg.c (DWARF2_LINE_MIN_INSN_LENGTH): Default to 1.
(print_stats): Fix parenthesis problem.
(now_subseg_size): New.
(dwarf2_finish): Use it. If DEBUG_DWARF2, emit bits for .debug_info.
(dwarf2_directive_file): Don't set debug_type.
(dwarf2_where): Honor DEBUG_DWARF2 first.
(dwarf2_emit_insn): Renamed from dwarf2_generate_asm_lineno;
do nothing if not emitting dwarf2 debug info, or no work.
* dwarf2dbg.h (dwarf2_emit_insn): Update.
* ecoff.c (add_file): Turn on DEBUG_ECOFF only if DEBUG_UNSPECIFIED.
(ecoff_new_file): Likewise.
* read.c (generate_lineno_debug): Kill ecoff hackery. Update
commentary wrt dwarf2.
* config/tc-alpha.c (alpha_adjust_symtab_relocs): Add
ATTRIBUTE_UNUSED as needed.
(emit_insn): Call dwarf2_emit_insn.
(s_alpha_file): New.
(s_alpha_loc): New.
(s_alpha_coff_wrapper): Don't handle them.
(md_pseudo_table): Update for .file and .loc.
* config/tc-alpha.h (DWARF2_LINE_MIN_INSN_LENGTH): New.
* config/tc-arm.c (output_inst): Update for dwarf2_emit_insn;
don't protect with debug_type.
* config/tc-hppa.c (md_assemble): Likewise.
* config/tc-m68hc11.c (m68hc11_new_insn): Likewise.
* config/tc-mn10300.c (md_assemble): Likewise.
* config/tc-sh.c (md_assemble): Likewise.
* config/tc-v850.c (md_assemble): Likewise.
* config/tc-arm.c (arm_end_of_source): Remove.
* config/tc-hppa.c (pa_end_of_source): Remove.
* config/tc-m68hc11.c (m68hc11_end_of_source): Remove.
* config/tc-mn10300.c (mn10300_finalize): Remove.
* config/tc-sh.c (sh_finalize): Remove.
* config/tc-v850.c (sh_finalize): Remove.
* config/tc-arm.h (md_end): Remove.
* config/tc-hppa.h (md_end): Remove.
(DWARF2_LINE_MIN_INSN_LENGTH): New.
* config/tc-m68hc11.h (md_end): Remove.
* config/tc-mn10300.h (md_end): Remove.
* config/tc-sh.h (md_end): Remove.
* config/tc-v850.h (md_end): Remove.
* config/tc-ia64.c (emit_one_bundle): Don't protect
dwarf2 bits with debug_type.
(md_assemble): Likewise.
(ia64_end_of_source): Don't call dwarf2_finish.
2000-11-16 Jim Wilson <wilson@redhat.com> 2000-11-16 Jim Wilson <wilson@redhat.com>
* config/tc-ia64.c (errata_nop_necessary_p): Abort if general regno * config/tc-ia64.c (errata_nop_necessary_p): Abort if general regno

View File

@ -68,7 +68,7 @@ static char *listing_filename = NULL;
/* Type of debugging to generate. */ /* Type of debugging to generate. */
enum debug_info_type debug_type = DEBUG_NONE; enum debug_info_type debug_type = DEBUG_UNSPECIFIED;
/* Maximum level of macro nesting. */ /* Maximum level of macro nesting. */
int max_macro_nest = 100; int max_macro_nest = 100;

View File

@ -454,8 +454,13 @@ COMMON int linkrelax;
/* TRUE if we should produce a listing. */ /* TRUE if we should produce a listing. */
extern int listing; extern int listing;
/* Type of debugging information we should generate. We currently /* Type of debugging information we should generate. We currently support
support stabs, ECOFF, and DWARF2. */ stabs, ECOFF, and DWARF2.
NOTE! This means debug information about the assembly source code itself
and _not_ about possible debug information from a high-level language.
This is especially relevant to DWARF2, since the compiler may emit line
number directives that the assembler resolves. */
enum debug_info_type { enum debug_info_type {
DEBUG_UNSPECIFIED, DEBUG_UNSPECIFIED,

View File

@ -58,6 +58,7 @@
#ifdef OBJ_ELF #ifdef OBJ_ELF
#include "elf/alpha.h" #include "elf/alpha.h"
#include "dwarf2dbg.h"
#endif #endif
#include <ctype.h> #include <ctype.h>
@ -245,6 +246,8 @@ static void s_alpha_end PARAMS ((int));
static void s_alpha_mask PARAMS ((int)); static void s_alpha_mask PARAMS ((int));
static void s_alpha_frame PARAMS ((int)); static void s_alpha_frame PARAMS ((int));
static void s_alpha_prologue PARAMS ((int)); static void s_alpha_prologue PARAMS ((int));
static void s_alpha_file PARAMS ((int));
static void s_alpha_loc PARAMS ((int));
static void s_alpha_coff_wrapper PARAMS ((int)); static void s_alpha_coff_wrapper PARAMS ((int));
#endif #endif
#ifdef OBJ_EVAX #ifdef OBJ_EVAX
@ -393,8 +396,8 @@ static offsetT alpha_lit4_literal;
static offsetT alpha_lit8_literal; static offsetT alpha_lit8_literal;
#endif #endif
/* The active .ent symbol. */
#ifdef OBJ_ELF #ifdef OBJ_ELF
/* The active .ent symbol. */
static symbolS *alpha_cur_ent_sym; static symbolS *alpha_cur_ent_sym;
#endif #endif
@ -1671,9 +1674,9 @@ alpha_adjust_symtab ()
static void static void
alpha_adjust_symtab_relocs (abfd, sec, ptr) alpha_adjust_symtab_relocs (abfd, sec, ptr)
bfd *abfd; bfd *abfd ATTRIBUTE_UNUSED;
asection *sec; asection *sec;
PTR ptr; PTR ptr ATTRIBUTE_UNUSED;
{ {
segment_info_type *seginfo = seg_info (sec); segment_info_type *seginfo = seg_info (sec);
fixS **prevP; fixS **prevP;
@ -2466,6 +2469,10 @@ emit_insn (insn)
f = frag_more (4); f = frag_more (4);
md_number_to_chars (f, insn->insn, 4); md_number_to_chars (f, insn->insn, 4);
#ifdef OBJ_ELF
dwarf2_emit_insn (4);
#endif
/* Apply the fixups in order */ /* Apply the fixups in order */
for (i = 0; i < insn->nfixups; ++i) for (i = 0; i < insn->nfixups; ++i)
{ {
@ -3287,8 +3294,8 @@ emit_lda (tok, ntok, opname)
|| tok[2].X_op != O_pregister || tok[2].X_op != O_pregister
|| !is_ir_num(tok[2].X_add_number)) || !is_ir_num(tok[2].X_add_number))
{ {
as_bad (_("bad instruction format for lda !%s!%d"), r->name, as_bad (_("bad instruction format for lda !%s!%ld"), r->name,
reloc->X_add_number); (long) reloc->X_add_number);
reloc = (const expressionS *)0; reloc = (const expressionS *)0;
ntok--; ntok--;
@ -4571,6 +4578,26 @@ s_alpha_prologue (ignore)
} }
} }
static void
s_alpha_file (ignore)
int ignore ATTRIBUTE_UNUSED;
{
if (ECOFF_DEBUGGING)
ecoff_directive_file (0);
else
dwarf2_directive_file (0);
}
static void
s_alpha_loc (ignore)
int ignore ATTRIBUTE_UNUSED;
{
if (ECOFF_DEBUGGING)
ecoff_directive_loc (0);
else
dwarf2_directive_loc (0);
}
static void static void
s_alpha_coff_wrapper (which) s_alpha_coff_wrapper (which)
int which; int which;
@ -4581,11 +4608,9 @@ s_alpha_coff_wrapper (which)
ecoff_directive_def, ecoff_directive_def,
ecoff_directive_dim, ecoff_directive_dim,
ecoff_directive_endef, ecoff_directive_endef,
ecoff_directive_file,
ecoff_directive_scl, ecoff_directive_scl,
ecoff_directive_tag, ecoff_directive_tag,
ecoff_directive_val, ecoff_directive_val,
ecoff_directive_loc,
}; };
assert (which >= 0 && which < (int)(sizeof(fns)/sizeof(*fns))); assert (which >= 0 && which < (int)(sizeof(fns)/sizeof(*fns)));
@ -5447,17 +5472,17 @@ const pseudo_typeS md_pseudo_table[] =
{"fmask", s_alpha_mask, 1}, {"fmask", s_alpha_mask, 1},
{"frame", s_alpha_frame, 0}, {"frame", s_alpha_frame, 0},
{"prologue", s_alpha_prologue, 0}, {"prologue", s_alpha_prologue, 0},
{"file", s_alpha_file, 5},
{"loc", s_alpha_loc, 9},
/* COFF debugging related pseudos. */ /* COFF debugging related pseudos. */
{"begin", s_alpha_coff_wrapper, 0}, {"begin", s_alpha_coff_wrapper, 0},
{"bend", s_alpha_coff_wrapper, 1}, {"bend", s_alpha_coff_wrapper, 1},
{"def", s_alpha_coff_wrapper, 2}, {"def", s_alpha_coff_wrapper, 2},
{"dim", s_alpha_coff_wrapper, 3}, {"dim", s_alpha_coff_wrapper, 3},
{"endef", s_alpha_coff_wrapper, 4}, {"endef", s_alpha_coff_wrapper, 4},
{"file", s_alpha_coff_wrapper, 5}, {"scl", s_alpha_coff_wrapper, 5},
{"scl", s_alpha_coff_wrapper, 6}, {"tag", s_alpha_coff_wrapper, 6},
{"tag", s_alpha_coff_wrapper, 7}, {"val", s_alpha_coff_wrapper, 7},
{"val", s_alpha_coff_wrapper, 8},
{"loc", s_alpha_coff_wrapper, 9},
#else #else
{"prologue", s_ignore, 0}, {"prologue", s_ignore, 0},
#endif #endif

View File

@ -146,3 +146,5 @@ do { \
(long)fixP->tc_fix_data.next_lituse); \ (long)fixP->tc_fix_data.next_lituse); \
} while (0) } while (0)
#endif #endif
#define DWARF2_LINE_MIN_INSN_LENGTH 4

View File

@ -6374,11 +6374,10 @@ output_inst PARAMS ((void))
fix_new_arm (frag_now, to - frag_now->fr_literal, fix_new_arm (frag_now, to - frag_now->fr_literal,
inst.size, & inst.reloc.exp, inst.reloc.pc_rel, inst.size, & inst.reloc.exp, inst.reloc.pc_rel,
inst.reloc.type); inst.reloc.type);
#ifdef OBJ_ELF #ifdef OBJ_ELF
if (debug_type == DEBUG_DWARF2) dwarf2_emit_insn (inst.size);
dwarf2_generate_asm_lineno (inst.size);
#endif #endif
return;
} }
void void
@ -7505,13 +7504,4 @@ s_arm_elf_cons (nbytes)
demand_empty_rest_of_line (); demand_empty_rest_of_line ();
} }
/* Stuff to do after assembling all of the source file. */
void
arm_end_of_source ()
{
if (debug_type == DEBUG_DWARF2)
dwarf2_finish ();
}
#endif /* OBJ_ELF */ #endif /* OBJ_ELF */

View File

@ -212,8 +212,5 @@ void armelf_frob_symbol PARAMS ((symbolS *, int *));
#endif #endif
#ifdef OBJ_ELF #ifdef OBJ_ELF
#define md_end() arm_end_of_source ()
extern void arm_end_of_source PARAMS ((void));
#define DWARF2_LINE_MIN_INSN_LENGTH 2 #define DWARF2_LINE_MIN_INSN_LENGTH 2
#endif #endif

View File

@ -1491,8 +1491,7 @@ md_assemble (str)
the_insn.format, the_insn.arg_reloc, NULL); the_insn.format, the_insn.arg_reloc, NULL);
#ifdef OBJ_ELF #ifdef OBJ_ELF
if (debug_type == DEBUG_DWARF2) dwarf2_emit_insn (4);
dwarf2_generate_asm_lineno (4);
#endif #endif
} }
@ -8540,13 +8539,6 @@ elf_hppa_final_processing ()
} }
} }
void
pa_end_of_source ()
{
if (debug_type == DEBUG_DWARF2)
dwarf2_finish ();
}
static void static void
pa_vtable_entry (ignore) pa_vtable_entry (ignore)
int ignore ATTRIBUTE_UNUSED; int ignore ATTRIBUTE_UNUSED;

View File

@ -173,8 +173,7 @@ int hppa_fix_adjustable PARAMS((struct fix *));
#define elf_tc_final_processing elf_hppa_final_processing #define elf_tc_final_processing elf_hppa_final_processing
void elf_hppa_final_processing PARAMS ((void)); void elf_hppa_final_processing PARAMS ((void));
#define md_end() pa_end_of_source () #define DWARF2_LINE_MIN_INSN_LENGTH 4
void pa_end_of_source PARAMS ((void));
#endif /* OBJ_ELF */ #endif /* OBJ_ELF */
#define md_operand(x) #define md_operand(x)

View File

@ -5649,7 +5649,6 @@ emit_one_bundle ()
continue; /* try next slot */ continue; /* try next slot */
} }
if (debug_type == DEBUG_DWARF2)
{ {
bfd_vma addr; bfd_vma addr;
@ -6197,9 +6196,6 @@ ia64_end_of_source ()
bfd_set_private_flags (stdoutput, md.flags); bfd_set_private_flags (stdoutput, md.flags);
if (debug_type == DEBUG_DWARF2)
dwarf2_finish ();
md.mem_offset.hint = 0; md.mem_offset.hint = 0;
} }
@ -9088,8 +9084,7 @@ md_assemble (str)
CURR_SLOT.qp_regno = qp_regno; CURR_SLOT.qp_regno = qp_regno;
CURR_SLOT.idesc = idesc; CURR_SLOT.idesc = idesc;
as_where (&CURR_SLOT.src_file, &CURR_SLOT.src_line); as_where (&CURR_SLOT.src_file, &CURR_SLOT.src_line);
if (debug_type == DEBUG_DWARF2) dwarf2_where (&CURR_SLOT.debug_line);
dwarf2_where (&CURR_SLOT.debug_line);
/* Add unwind entry, if there is one. */ /* Add unwind entry, if there is one. */
if (unwind.current_entry) if (unwind.current_entry)

View File

@ -1371,9 +1371,7 @@ m68hc11_new_insn (size)
f = frag_more (size); f = frag_more (size);
/* Emit line number information in dwarf2 debug sections. */ dwarf2_emit_insn (size);
if (debug_type == DEBUG_DWARF2)
dwarf2_generate_asm_lineno (size);
return f; return f;
} }
@ -2769,38 +2767,3 @@ m68hc11_cleanup ()
{ {
return 1; return 1;
} }
void
m68hc11_end_of_source ()
{
segT saved_seg;
subsegT saved_subseg;
segT debug_info;
char *p;
long total_size = 0;
if (debug_type != DEBUG_DWARF2)
return;
dwarf2_finish ();
saved_seg = now_seg;
saved_subseg = now_subseg;
debug_info = subseg_new (".debug_info", 0);
bfd_set_section_flags (stdoutput, debug_info, SEC_READONLY);
subseg_set (debug_info, 0);
p = frag_more (10);
total_size = 12;
# define STUFF(val,size) md_number_to_chars (p, val, size); p += size;
STUFF (total_size, 4); /* Length of compilation unit. */
STUFF (2, 2); /* Dwarf version */
STUFF (0, 4);
STUFF (2, 1); /* Pointer size */
STUFF (1, 1); /* Compile unit */
STUFF (0, 4);
now_subseg = saved_subseg;
now_seg = saved_seg;
}

View File

@ -79,9 +79,6 @@ extern void m68hc11_init_after_args PARAMS ((void));
extern int m68hc11_parse_long_option PARAMS ((char *)); extern int m68hc11_parse_long_option PARAMS ((char *));
#define md_parse_long_option m68hc11_parse_long_option #define md_parse_long_option m68hc11_parse_long_option
extern void m68hc11_end_of_source PARAMS ((void));
#define md_end() m68hc11_end_of_source ()
#define DWARF2_LINE_MIN_INSN_LENGTH 1 #define DWARF2_LINE_MIN_INSN_LENGTH 1
/* We don't need to handle .word strangely. */ /* We don't need to handle .word strangely. */

View File

@ -1789,8 +1789,7 @@ keep_going:
} }
} }
if (debug_type == DEBUG_DWARF2) dwarf2_emit_insn (real_size);
dwarf2_generate_asm_lineno (real_size);
} }
/* If while processing a fixup, a reloc really needs to be created /* If while processing a fixup, a reloc really needs to be created
@ -2135,10 +2134,3 @@ set_arch_mach (mach)
current_machine = mach; current_machine = mach;
} }
void
mn10300_finalize ()
{
if (debug_type == DEBUG_DWARF2)
dwarf2_finish ();
}

View File

@ -62,7 +62,4 @@ extern boolean mn10300_fix_adjustable PARAMS ((struct fix *));
extern const struct relax_type md_relax_table[]; extern const struct relax_type md_relax_table[];
#define TC_GENERIC_RELAX_TABLE md_relax_table #define TC_GENERIC_RELAX_TABLE md_relax_table
#define md_end() mn10300_finalize ()
void mn10300_finalize PARAMS ((void));
#define DWARF2_LINE_MIN_INSN_LENGTH 1 #define DWARF2_LINE_MIN_INSN_LENGTH 1

View File

@ -1929,8 +1929,7 @@ md_assemble (str)
} }
} }
if (debug_type == DEBUG_DWARF2) dwarf2_emit_insn (size);
dwarf2_generate_asm_lineno (size);
} }
/* This routine is called each time a label definition is seen. It /* This routine is called each time a label definition is seen. It
@ -3324,10 +3323,3 @@ tc_gen_reloc (section, fixp)
} }
#endif /* BFD_ASSEMBLER */ #endif /* BFD_ASSEMBLER */
void
sh_finalize ()
{
if (debug_type == DEBUG_DWARF2)
dwarf2_finish ();
}

View File

@ -206,6 +206,3 @@ extern void sh_elf_final_processing PARAMS ((void));
&& ! S_IS_COMMON ((FIX)->fx_addsy)))) && ! S_IS_COMMON ((FIX)->fx_addsy))))
#endif /* OBJ_ELF */ #endif /* OBJ_ELF */
#define md_end() sh_finalize ()
void sh_finalize PARAMS ((void));

View File

@ -2275,8 +2275,7 @@ md_assemble (str)
input_line_pointer = saved_input_line_pointer; input_line_pointer = saved_input_line_pointer;
if (debug_type == DEBUG_DWARF2) dwarf2_emit_insn (total_insn_size);
dwarf2_generate_asm_lineno (total_insn_size);
} }
/* If while processing a fixup, a reloc really needs to be created /* If while processing a fixup, a reloc really needs to be created
@ -2534,10 +2533,3 @@ v850_force_relocation (fixP)
return 0; return 0;
} }
void
v850_finalize ()
{
if (debug_type == DEBUG_DWARF2)
dwarf2_finish ();
}

View File

@ -90,7 +90,4 @@ extern const struct relax_type md_relax_table[];
#define MD_PCREL_FROM_SECTION(fixP,section) v850_pcrel_from_section (fixP, section) #define MD_PCREL_FROM_SECTION(fixP,section) v850_pcrel_from_section (fixP, section)
extern long v850_pcrel_from_section (); extern long v850_pcrel_from_section ();
#define md_end() v850_finalize ()
extern void v850_finalize PARAMS ((void));
#define DWARF2_LINE_MIN_INSN_LENGTH 2 #define DWARF2_LINE_MIN_INSN_LENGTH 2

View File

@ -63,7 +63,7 @@
#ifndef DWARF2_LINE_MIN_INSN_LENGTH #ifndef DWARF2_LINE_MIN_INSN_LENGTH
/* Define the architecture-dependent minimum instruction length (in /* Define the architecture-dependent minimum instruction length (in
bytes). This value should be rather too small than too big. */ bytes). This value should be rather too small than too big. */
# define DWARF2_LINE_MIN_INSN_LENGTH 4 # define DWARF2_LINE_MIN_INSN_LENGTH 1
#endif #endif
/* Flag that indicates the initial value of the is_stmt_start flag. /* Flag that indicates the initial value of the is_stmt_start flag.
@ -178,6 +178,7 @@ static int get_filenum PARAMS ((int, char *));
static void gen_dir_list PARAMS ((void)); static void gen_dir_list PARAMS ((void));
static void gen_file_list PARAMS ((void)); static void gen_file_list PARAMS ((void));
static void print_stats PARAMS ((unsigned long)); static void print_stats PARAMS ((unsigned long));
static addressT now_subseg_size PARAMS ((void));
#define out_byte(byte) FRAG_APPEND_1_CHAR(byte) #define out_byte(byte) FRAG_APPEND_1_CHAR(byte)
#define out_opcode(opc) (out_byte ((opc)), ++ls.opcode_hist[(opc) & 0xff]) #define out_opcode(opc) (out_byte ((opc)), ++ls.opcode_hist[(opc) & 0xff])
@ -643,13 +644,29 @@ print_stats (total_size)
j = SPECIAL_LINE (i); j = SPECIAL_LINE (i);
if (j == DWARF2_LINE_BASE) if (j == DWARF2_LINE_BASE)
fprintf (stderr, "\n%4u: ", fprintf (stderr, "\n%4u: ",
((unsigned int) (unsigned int) (DWARF2_LINE_MIN_INSN_LENGTH
DWARF2_LINE_MIN_INSN_LENGTH * SPECIAL_ADDR (i))); * SPECIAL_ADDR (i)));
fprintf (stderr, " %2u", ls.opcode_hist[i]); fprintf (stderr, " %2u", ls.opcode_hist[i]);
} }
fprintf (stderr, "\n"); fprintf (stderr, "\n");
} }
/* Compute the size of the current subsegment, taking all fragments
into account. Note that we don't generate variant frags, so the
fixed portion is all we need to consider. */
static addressT
now_subseg_size ()
{
struct frag *f;
addressT size = 0;
for (f = frchain_now->frch_root; f ; f = f->fr_next)
size += f->fr_fix;
return size + frag_now_fix_octets ();
}
void void
dwarf2_finish () dwarf2_finish ()
{ {
@ -667,23 +684,29 @@ dwarf2_finish ()
if (!ls.sm.empty_sequence) if (!ls.sm.empty_sequence)
out_end_sequence (); out_end_sequence ();
total_size = body_size = frag_now_fix (); subseg_set (ls.line_seg, DL_BODY);
total_size = body_size = now_subseg_size ();
/* Now generate the directory and file lists. */ /* Now generate the directory and file lists. */
subseg_set (ls.line_seg, DL_FILES); subseg_set (ls.line_seg, DL_FILES);
gen_dir_list (); gen_dir_list ();
gen_file_list (); gen_file_list ();
total_size += frag_now_fix (); total_size += now_subseg_size ();
/* And now the header ("statement program prolog", in DWARF2 lingo...). */ /* And now the header ("statement program prolog", in DWARF2 lingo...). */
subseg_set (ls.line_seg, DL_PROLOG); subseg_set (ls.line_seg, DL_PROLOG);
cp = frag_more (15 + DWARF2_LINE_OPCODE_BASE - 1); cp = frag_more (15 + DWARF2_LINE_OPCODE_BASE - 1);
total_size += frag_now_fix (); total_size += now_subseg_size ();
prolog_size = total_size - body_size - 10; prolog_size = total_size - body_size - 10;
# define STUFF(val,size) md_number_to_chars (cp, val, size); cp += size; #define STUFF(val,size) \
do { \
md_number_to_chars (cp, val, size); \
cp += size; \
} while (0)
STUFF (total_size - 4, 4); /* length */ STUFF (total_size - 4, 4); /* length */
STUFF (2, 2); /* version */ STUFF (2, 2); /* version */
STUFF (prolog_size, 4); /* prologue_length */ STUFF (prolog_size, 4); /* prologue_length */
@ -704,6 +727,47 @@ dwarf2_finish ()
STUFF (0, 1); /* DW_LNS_const_add_pc */ STUFF (0, 1); /* DW_LNS_const_add_pc */
STUFF (1, 1); /* DW_LNS_fixed_advance_pc */ STUFF (1, 1); /* DW_LNS_fixed_advance_pc */
#undef STUFF
/* If this is assembler generated line info, add a .debug_info
section as well. */
if (debug_type == DEBUG_DWARF2)
{
segT info_seg = subseg_new (".debug_info", 0);
segT abbrev_seg = subseg_new (".debug_abbrev", 0);
char *len;
#ifdef BFD_ASSEMBLER
bfd_set_section_flags (stdoutput, info_seg, SEC_READONLY);
bfd_set_section_flags (stdoutput, abbrev_seg, SEC_READONLY);
#endif
subseg_set (info_seg, 0);
len = frag_more (4);
#define STUFF(val, size) \
do { \
cp = frag_more (size); \
md_number_to_chars (cp, (val), (size)); \
} while(0)
STUFF (2, 2); /* Dwarf version */
STUFF (0, 4); /* Offset into (final!) .debug_abbrev. */
/* Pointer size. */
#ifdef BFD_ASSEMBLER
STUFF (bfd_arch_bits_per_address (stdoutput) / 8, 1);
#else
STUFF (4, 1);
#endif
/* FIXME: Add a DW_TAG_compile_unit DIE. The line info cannot
even be seen without it. */
/* Set size of debug_info. */
md_number_to_chars (len, now_subseg_size () - 4, 4);
}
subseg_set (saved_seg, saved_subseg); subseg_set (saved_seg, saved_subseg);
if (flag_debug) if (flag_debug)
@ -726,11 +790,6 @@ dwarf2_directive_file (dummy)
ls.any_dwarf2_directives = 1; ls.any_dwarf2_directives = 1;
if (debug_type == DEBUG_NONE)
/* Automatically turn on DWARF2 debug info unless something else
has been selected. */
debug_type = DEBUG_DWARF2;
ls.current.filenum = get_absolute_expression (); ls.current.filenum = get_absolute_expression ();
ls.current.filename = demand_copy_C_string (&len); ls.current.filename = demand_copy_C_string (&len);
@ -762,33 +821,42 @@ void
dwarf2_where (line) dwarf2_where (line)
struct dwarf2_line_info *line; struct dwarf2_line_info *line;
{ {
if (ls.any_dwarf2_directives) if (debug_type == DEBUG_DWARF2)
*line = ls.current;
else
{ {
as_where (&line->filename, &line->line); as_where (&line->filename, &line->line);
line->filenum = 0; line->filenum = 0;
line->column = 0; line->column = 0;
line->flags = DWARF2_FLAG_BEGIN_STMT; line->flags = DWARF2_FLAG_BEGIN_STMT;
} }
else
*line = ls.current;
} }
/* Generate a DWARF2 line statement for an /* Called for each machine instruction, or relatively atomic group of
instruction of SIZE bytes in length. */ machine instructions (ie built-in macro). The instruction or group
is SIZE bytes in length. If dwarf2 line number generation is called
for, emit a line statement appropriately. */
void void
dwarf2_generate_asm_lineno (size) dwarf2_emit_insn (size)
int size; int size;
{ {
addressT addr; addressT addr;
static struct dwarf2_line_info debug_line; struct dwarf2_line_info debug_line;
if (debug_type != DEBUG_DWARF2 && ! ls.any_dwarf2_directives)
return;
/* Reset any_dwarf2_directives so that we won't waste time
determining that no information has changed between insns. */
ls.any_dwarf2_directives = 0;
/* First update the notion of the current source line. */ /* First update the notion of the current source line. */
dwarf2_where (&debug_line); dwarf2_where (&debug_line);
/* We want the offset of the start of this /* We want the offset of the start of this
instruction within the the current frag. */ instruction within the the current frag. */
addr = frag_now->fr_address + frag_now_fix () - size; addr = frag_now_fix () - size;
/* And record the information. */ /* And record the information. */
dwarf2_gen_line_info (addr, &debug_line); dwarf2_gen_line_info (addr, &debug_line);

View File

@ -65,6 +65,6 @@ extern void dwarf2_gen_line_info PARAMS ((addressT addr,
.debug_line section. */ .debug_line section. */
extern void dwarf2_finish PARAMS ((void)); extern void dwarf2_finish PARAMS ((void));
extern void dwarf2_generate_asm_lineno PARAMS ((int)); extern void dwarf2_emit_insn PARAMS ((int));
#endif /* AS_DWARF2DBG_H */ #endif /* AS_DWARF2DBG_H */

View File

@ -2216,9 +2216,11 @@ add_file (file_name, indx, fake)
this if we see a .file directive with a string, since that this if we see a .file directive with a string, since that
implies that some sort of debugging information is being implies that some sort of debugging information is being
provided. */ provided. */
if (! symbol_table_frozen && debug_type == DEBUG_NONE) if (! symbol_table_frozen && debug_type == DEBUG_UNSPECIFIED)
debug_type = DEBUG_ECOFF; debug_type = DEBUG_ECOFF;
} }
else
debug_type = DEBUG_NONE;
#ifndef NO_LISTING #ifndef NO_LISTING
if (listing) if (listing)
@ -2335,7 +2337,7 @@ ecoff_new_file (name)
/* This is a hand coded assembler file, so automatically turn on /* This is a hand coded assembler file, so automatically turn on
debugging information. */ debugging information. */
if (debug_type == DEBUG_NONE) if (debug_type == DEBUG_UNSPECIFIED)
debug_type = DEBUG_ECOFF; debug_type = DEBUG_ECOFF;
} }

View File

@ -4982,22 +4982,11 @@ generate_file_debug ()
void void
generate_lineno_debug () generate_lineno_debug ()
{ {
#ifdef ECOFF_DEBUGGING
/* ECOFF assemblers automatically generate debugging information.
FIXME: This should probably be handled elsewhere. */
if (debug_type == DEBUG_UNSPECIFIED)
{
if (ECOFF_DEBUGGING && ecoff_no_current_file ())
debug_type = DEBUG_ECOFF;
else
debug_type = DEBUG_NONE;
}
#endif
switch (debug_type) switch (debug_type)
{ {
case DEBUG_UNSPECIFIED: case DEBUG_UNSPECIFIED:
case DEBUG_NONE: case DEBUG_NONE:
case DEBUG_DWARF:
break; break;
case DEBUG_STABS: case DEBUG_STABS:
stabs_generate_asm_lineno (); stabs_generate_asm_lineno ();
@ -5005,16 +4994,11 @@ generate_lineno_debug ()
case DEBUG_ECOFF: case DEBUG_ECOFF:
ecoff_generate_asm_lineno (); ecoff_generate_asm_lineno ();
break; break;
case DEBUG_DWARF:
case DEBUG_DWARF2: case DEBUG_DWARF2:
/* This cannot safely be done in a generic manner. A single /* ??? We could here indicate to dwarf2dbg.c that something
binary instruction word may span mutliple lines of assembler has changed. However, since there is additional backend
source and may occupy a variable number of bytes. Instead, support that is required (calling dwarf2_emit_insn), we
if a port wishes to support DWARF2 line number generation by let dwarf2dbg.c call as_where on its own. */
the assembler, it should add a call to dwarf2_generate_asm_lineno
inside md_assemble() at whatever point is appropriate. Note,
such a port should also define md_end and make sure that
dwarf2_finish is called, to emit the accumulated line information. */
break; break;
} }
} }