X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gas%2Fdwarf2dbg.c;h=3336453a4eeffabbd37fec150f362751c474d4b2;hb=1f1799d5ad9c8f2af8bebf4df515507c87659a9c;hp=69d4731c9cb346313a33de00cf0b777e03b77f5e;hpb=b7d6ed970a277da806f01110c032f0e19eab2368;p=deliverable%2Fbinutils-gdb.git diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c index 69d4731c9c..3336453a4e 100644 --- a/gas/dwarf2dbg.c +++ b/gas/dwarf2dbg.c @@ -1,5 +1,5 @@ /* dwarf2dbg.c - DWARF2 debug support - Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Contributed by David Mosberger-Tang This file is part of GAS, the GNU Assembler. @@ -49,11 +49,7 @@ #endif #ifndef DWARF2_ADDR_SIZE -# define DWARF2_ADDR_SIZE(bfd) (bfd_arch_bits_per_address (bfd) / 8); -#endif - -#ifndef TC_DWARF2_EMIT_OFFSET -# define TC_DWARF2_EMIT_OFFSET generic_dwarf2_emit_offset +# define DWARF2_ADDR_SIZE(bfd) (bfd_arch_bits_per_address (bfd) / 8) #endif #ifdef BFD_ASSEMBLER @@ -160,37 +156,38 @@ static struct dwarf2_line_info current; /* The size of an address on the target. */ static unsigned int sizeof_address; -static void generic_dwarf2_emit_offset PARAMS((symbolS *, unsigned int)); -static struct line_subseg *get_line_subseg PARAMS ((segT, subsegT)); -static unsigned int get_filenum PARAMS ((const char *, unsigned int)); -static struct frag *first_frag_for_seg PARAMS ((segT)); -static struct frag *last_frag_for_seg PARAMS ((segT)); -static void out_byte PARAMS ((int)); -static void out_opcode PARAMS ((int)); -static void out_two PARAMS ((int)); -static void out_four PARAMS ((int)); -static void out_abbrev PARAMS ((int, int)); -static void out_uleb128 PARAMS ((addressT)); -static offsetT get_frag_fix PARAMS ((fragS *)); -static void out_set_addr PARAMS ((segT, fragS *, addressT)); -static int size_inc_line_addr PARAMS ((int, addressT)); -static void emit_inc_line_addr PARAMS ((int, addressT, char *, int)); -static void out_inc_line_addr PARAMS ((int, addressT)); -static void relax_inc_line_addr PARAMS ((int, segT, fragS *, addressT, - fragS *, addressT)); -static void process_entries PARAMS ((segT, struct line_entry *)); -static void out_file_list PARAMS ((void)); -static void out_debug_line PARAMS ((segT)); -static void out_debug_aranges PARAMS ((segT, segT)); -static void out_debug_abbrev PARAMS ((segT)); -static void out_debug_info PARAMS ((segT, segT, segT)); +static struct line_subseg *get_line_subseg (segT, subsegT); +static unsigned int get_filenum (const char *, unsigned int); +static struct frag *first_frag_for_seg (segT); +static struct frag *last_frag_for_seg (segT); +static void out_byte (int); +static void out_opcode (int); +static void out_two (int); +static void out_four (int); +static void out_abbrev (int, int); +static void out_uleb128 (addressT); +static offsetT get_frag_fix (fragS *); +static void out_set_addr (segT, fragS *, addressT); +static int size_inc_line_addr (int, addressT); +static void emit_inc_line_addr (int, addressT, char *, int); +static void out_inc_line_addr (int, addressT); +static void relax_inc_line_addr (int, segT, fragS *, addressT, + fragS *, addressT); +static void process_entries (segT, struct line_entry *); +static void out_file_list (void); +static void out_debug_line (segT); +static void out_debug_aranges (segT, segT); +static void out_debug_abbrev (segT); +static void out_debug_info (segT, segT, segT); +#ifndef TC_DWARF2_EMIT_OFFSET +# define TC_DWARF2_EMIT_OFFSET generic_dwarf2_emit_offset +static void generic_dwarf2_emit_offset (symbolS *, unsigned int); + /* Create an offset to .dwarf2_*. */ static void -generic_dwarf2_emit_offset (symbol, size) - symbolS *symbol; - unsigned int size; +generic_dwarf2_emit_offset (symbolS *symbol, unsigned int size) { expressionS expr; @@ -199,13 +196,12 @@ generic_dwarf2_emit_offset (symbol, size) expr.X_add_number = 0; emit_expr (&expr, size); } +#endif /* Find or create an entry for SEG+SUBSEG in ALL_SEGS. */ static struct line_subseg * -get_line_subseg (seg, subseg) - segT seg; - subsegT subseg; +get_line_subseg (segT seg, subsegT subseg) { static segT last_seg; static subsegT last_subseg; @@ -251,12 +247,10 @@ get_line_subseg (seg, subseg) return ss; } -/* Record an entry for LOC ocurring at OFS within the current fragment. */ +/* Record an entry for LOC occurring at OFS within the current fragment. */ void -dwarf2_gen_line_info (ofs, loc) - addressT ofs; - struct dwarf2_line_info *loc; +dwarf2_gen_line_info (addressT ofs, struct dwarf2_line_info *loc) { struct line_subseg *ss; struct line_entry *e; @@ -290,8 +284,7 @@ dwarf2_gen_line_info (ofs, loc) } void -dwarf2_where (line) - struct dwarf2_line_info *line; +dwarf2_where (struct dwarf2_line_info *line) { if (debug_type == DEBUG_DWARF2) { @@ -311,8 +304,7 @@ dwarf2_where (line) for, emit a line statement appropriately. */ void -dwarf2_emit_insn (size) - int size; +dwarf2_emit_insn (int size) { struct dwarf2_line_info loc; @@ -343,9 +335,7 @@ dwarf2_emit_insn (size) empty one. */ static unsigned int -get_filenum (filename, num) - const char *filename; - unsigned int num; +get_filenum (const char *filename, unsigned int num) { static unsigned int last_used, last_used_dir_len; const char *file; @@ -382,7 +372,7 @@ get_filenum (filename, num) { --dir_len; for (dir = 1; dir < dirs_in_use; ++dir) - if (memcmp (filename, dirs[dir], dir_len) == 0 + if (strncmp (filename, dirs[dir], dir_len) == 0 && dirs[dir][dir_len] == '\0') break; @@ -444,8 +434,7 @@ get_filenum (filename, num) If an entry is added to the file table, return a pointer to the filename. */ char * -dwarf2_directive_file (dummy) - int dummy ATTRIBUTE_UNUSED; +dwarf2_directive_file (int dummy ATTRIBUTE_UNUSED) { offsetT num; char *filename; @@ -481,8 +470,7 @@ dwarf2_directive_file (dummy) } void -dwarf2_directive_loc (dummy) - int dummy ATTRIBUTE_UNUSED; +dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED) { offsetT filenum, line, column; @@ -534,8 +522,7 @@ dwarf2_directive_loc (dummy) } static struct frag * -first_frag_for_seg (seg) - segT seg; +first_frag_for_seg (segT seg) { frchainS *f, *first = NULL; @@ -548,8 +535,7 @@ first_frag_for_seg (seg) } static struct frag * -last_frag_for_seg (seg) - segT seg; +last_frag_for_seg (segT seg) { frchainS *f, *last = NULL; @@ -564,8 +550,7 @@ last_frag_for_seg (seg) /* Emit a single byte into the current segment. */ static inline void -out_byte (byte) - int byte; +out_byte (int byte) { FRAG_APPEND_1_CHAR (byte); } @@ -573,8 +558,7 @@ out_byte (byte) /* Emit a statement program opcode into the current segment. */ static inline void -out_opcode (opc) - int opc; +out_opcode (int opc) { out_byte (opc); } @@ -582,8 +566,7 @@ out_opcode (opc) /* Emit a two-byte word into the current segment. */ static inline void -out_two (data) - int data; +out_two (int data) { md_number_to_chars (frag_more (2), data, 2); } @@ -591,8 +574,7 @@ out_two (data) /* Emit a four byte word into the current segment. */ static inline void -out_four (data) - int data; +out_four (int data) { md_number_to_chars (frag_more (4), data, 4); } @@ -600,8 +582,7 @@ out_four (data) /* Emit an unsigned "little-endian base 128" number. */ static void -out_uleb128 (value) - addressT value; +out_uleb128 (addressT value) { output_leb128 (frag_more (sizeof_leb128 (value, 0)), value, 0); } @@ -609,8 +590,7 @@ out_uleb128 (value) /* Emit a tuple for .debug_abbrev. */ static inline void -out_abbrev (name, form) - int name, form; +out_abbrev (int name, int form) { out_uleb128 (name); out_uleb128 (form); @@ -619,8 +599,7 @@ out_abbrev (name, form) /* Get the size of a fragment. */ static offsetT -get_frag_fix (frag) - fragS *frag; +get_frag_fix (fragS *frag) { frchainS *fr; @@ -632,11 +611,7 @@ get_frag_fix (frag) on some subsegment chain. */ for (fr = frchain_root; fr; fr = fr->frch_next) if (fr->frch_last == frag) - { - long align_mask = -1 << get_recorded_alignment (fr->frch_seg); - return (((char *) obstack_next_free (&fr->frch_obstack) - - frag->fr_literal) + ~align_mask) & align_mask; - } + return (char *) obstack_next_free (&fr->frch_obstack) - frag->fr_literal; abort (); } @@ -644,10 +619,7 @@ get_frag_fix (frag) /* Set an absolute address (may result in a relocation entry). */ static void -out_set_addr (seg, frag, ofs) - segT seg; - fragS *frag; - addressT ofs; +out_set_addr (segT seg, fragS *frag, addressT ofs) { expressionS expr; symbolS *sym; @@ -665,11 +637,10 @@ out_set_addr (seg, frag, ofs) } #if DWARF2_LINE_MIN_INSN_LENGTH > 1 -static void scale_addr_delta PARAMS ((addressT *)); +static void scale_addr_delta (addressT *); static void -scale_addr_delta (addr_delta) - addressT *addr_delta; +scale_addr_delta (addressT *addr_delta) { static int printed_this = 0; if (*addr_delta % DWARF2_LINE_MIN_INSN_LENGTH != 0) @@ -692,9 +663,7 @@ scale_addr_delta (addr_delta) exactly the expected number of bytes. */ static int -size_inc_line_addr (line_delta, addr_delta) - int line_delta; - addressT addr_delta; +size_inc_line_addr (int line_delta, addressT addr_delta) { unsigned int tmp, opcode; int len = 0; @@ -753,11 +722,7 @@ size_inc_line_addr (line_delta, addr_delta) } static void -emit_inc_line_addr (line_delta, addr_delta, p, len) - int line_delta; - addressT addr_delta; - char *p; - int len; +emit_inc_line_addr (int line_delta, addressT addr_delta, char *p, int len) { unsigned int tmp, opcode; int need_copy = 0; @@ -848,9 +813,7 @@ emit_inc_line_addr (line_delta, addr_delta, p, len) /* Handy routine to combine calls to the above two routines. */ static void -out_inc_line_addr (line_delta, addr_delta) - int line_delta; - addressT addr_delta; +out_inc_line_addr (int line_delta, addressT addr_delta) { int len = size_inc_line_addr (line_delta, addr_delta); emit_inc_line_addr (line_delta, addr_delta, frag_more (len), len); @@ -860,11 +823,9 @@ out_inc_line_addr (line_delta, addr_delta) increments between fragments of the target segment. */ static void -relax_inc_line_addr (line_delta, seg, to_frag, to_ofs, from_frag, from_ofs) - int line_delta; - segT seg; - fragS *to_frag, *from_frag; - addressT to_ofs, from_ofs; +relax_inc_line_addr (int line_delta, segT seg, + fragS *to_frag, addressT to_ofs, + fragS *from_frag, addressT from_ofs) { symbolS *to_sym, *from_sym; expressionS expr; @@ -891,8 +852,7 @@ relax_inc_line_addr (line_delta, seg, to_frag, to_ofs, from_frag, from_ofs) the relaxation loop. We set fr_subtype to the expected length. */ int -dwarf2dbg_estimate_size_before_relax (frag) - fragS *frag; +dwarf2dbg_estimate_size_before_relax (fragS *frag) { offsetT addr_delta; int size; @@ -910,8 +870,7 @@ dwarf2dbg_estimate_size_before_relax (frag) of the frag. This returns the change in frag length. */ int -dwarf2dbg_relax_frag (frag) - fragS *frag; +dwarf2dbg_relax_frag (fragS *frag) { int old_size, new_size; @@ -926,8 +885,7 @@ dwarf2dbg_relax_frag (frag) fr_subtype will be the desired length of the frag. */ void -dwarf2dbg_convert_frag (frag) - fragS *frag; +dwarf2dbg_convert_frag (fragS *frag) { offsetT addr_diff; @@ -951,9 +909,7 @@ dwarf2dbg_convert_frag (frag) beginning at E, for segment SEG. */ static void -process_entries (seg, e) - segT seg; - struct line_entry *e; +process_entries (segT seg, struct line_entry *e) { unsigned filenum = 1; unsigned line = 1; @@ -1045,7 +1001,7 @@ process_entries (seg, e) /* Emit the directory and file tables for .debug_line. */ static void -out_file_list () +out_file_list (void) { size_t size; char *cp; @@ -1087,8 +1043,7 @@ out_file_list () /* Emit the collected .debug_line data. */ static void -out_debug_line (line_seg) - segT line_seg; +out_debug_line (segT line_seg) { expressionS expr; symbolS *line_start; @@ -1176,9 +1131,7 @@ out_debug_line (line_seg) /* Emit data for .debug_aranges. */ static void -out_debug_aranges (aranges_seg, info_seg) - segT aranges_seg; - segT info_seg; +out_debug_aranges (segT aranges_seg, segT info_seg) { unsigned int addr_size = sizeof_address; addressT size, skip; @@ -1254,8 +1207,7 @@ out_debug_aranges (aranges_seg, info_seg) sync with out_debug_info below. */ static void -out_debug_abbrev (abbrev_seg) - segT abbrev_seg; +out_debug_abbrev (segT abbrev_seg) { subseg_set (abbrev_seg, 0); @@ -1281,10 +1233,7 @@ out_debug_abbrev (abbrev_seg) /* Emit a description of this compilation unit for .debug_info. */ static void -out_debug_info (info_seg, abbrev_seg, line_seg) - segT info_seg; - segT abbrev_seg; - segT line_seg; +out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg) { char producer[128]; char *comp_dir; @@ -1401,7 +1350,7 @@ out_debug_info (info_seg, abbrev_seg, line_seg) } void -dwarf2_finish () +dwarf2_finish (void) { segT line_seg; struct line_seg *s;