aboutsummaryrefslogtreecommitdiff
path: root/gas/dwarf2dbg.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2009-09-11 15:27:38 +0000
committerNick Clifton <nickc@redhat.com>2009-09-11 15:27:38 +0000
commit1e9cc1c27b927dc95dfaec390eb492d29bbc7a0b (patch)
tree53a3c5ddeb73ec0cf10bb3c6e02d1a4b35a727a7 /gas/dwarf2dbg.c
parente23bb3fc8406336ae8bbfe860ef06d4685ba96eb (diff)
downloadgdb-1e9cc1c27b927dc95dfaec390eb492d29bbc7a0b.zip
gdb-1e9cc1c27b927dc95dfaec390eb492d29bbc7a0b.tar.gz
gdb-1e9cc1c27b927dc95dfaec390eb492d29bbc7a0b.tar.bz2
* po/bfd.pot: Updated by the Translation project.
* po/binutils.pot: Updated by the Translation project. * po/gold.pot: Updated by the Translation project. * po/gold.pot: Updated by the Translation project. * po/gprof.pot: Updated by the Translation project. * po/sv.po: Updated Swedish translation. * po/ld.pot: Updated by the Translation project. * po/fi.po: Updated Finnish translation. * po/ld.pot: Updated by the Translation project. * po/fi.po: Updated Finnish translation. Updated sources to compile cleanly with -Wc++-compat: * basic_blocks.c: Add casts. * cg_dfn.c: Add cast. * corefile.c: Add casts. * gmon_io.c: Add casts. * hist.c: Add cast. * source.c: Add cast. * sym_ids.c (struct match): Moved to top level. Updated soruces in ld/* to compile cleanly with -Wc++-compat: * ld.h (enum endian_enum,enum symbolic_enum,enum dynamic_list_enum): Move to top level. * ldcref.c: Add casts. * ldctor.c: Add casts. * ldexp.c * ldexp.h (enum node_tree_enum,enum phase_enum): Move to top level. * ldlang.c: Add casts. (lang_insert_orphan): Use enum name instead of integer. * ldlang.h (enum statement_enum): Move to top level. * ldmain.c: Add casts. * ldwrite.c: Add casts. * lexsup.c: Add casts. (enum control_enum): Move to top level. * mri.c: Add casts. (mri_draw_tree): Use enum name instead of integer. Updated sources to compile cleanly with -Wc++-compat: * basic_blocks.c: Add casts. * cg_dfn.c: Add cast. * corefile.c: Add casts. * gmon_io.c: Add casts. * hist.c: Add cast. * source.c: Add cast. * sym_ids.c (struct match): Moved to top level. * as.c (main): Call dwarf2_init. * config/obj-elf.c (struct group_list): New field. (build_group_lists): Use hash lookup. (free_section_idx): New function. (elf_frob_file): Adjust. * dwarf2dbg.c (all_segs_hash, last_seg_ptr): New variables. (get_line_subseg): Adjust. (dwarf2_init): New function. * dwarf2dbg.h (dwarf2_init): New declaration.
Diffstat (limited to 'gas/dwarf2dbg.c')
-rw-r--r--gas/dwarf2dbg.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index 4d03659..42d7267 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -168,6 +168,10 @@ struct line_seg {
/* Collects data for all line table entries during assembly. */
static struct line_seg *all_segs;
+/* Hash used to quickly lookup a segment by name, avoiding the need to search
+ through the all_segs list. */
+static struct hash_control *all_segs_hash;
+static struct line_seg **last_seg_ptr;
struct file_entry {
const char *filename;
@@ -230,23 +234,25 @@ get_line_subseg (segT seg, subsegT subseg)
static subsegT last_subseg;
static struct line_subseg *last_line_subseg;
- struct line_seg **ps, *s;
+ struct line_seg *s;
struct line_subseg **pss, *ss;
if (seg == last_seg && subseg == last_subseg)
return last_line_subseg;
- for (ps = &all_segs; (s = *ps) != NULL; ps = &s->next)
- if (s->seg == seg)
- goto found_seg;
-
- s = (struct line_seg *) xmalloc (sizeof (*s));
- s->next = NULL;
- s->seg = seg;
- s->head = NULL;
- *ps = s;
+ s = (struct line_seg *) hash_find (all_segs_hash, seg->name);
+ if (s == NULL)
+ {
+ s = (struct line_seg *) xmalloc (sizeof (*s));
+ s->next = NULL;
+ s->seg = seg;
+ s->head = NULL;
+ *last_seg_ptr = s;
+ last_seg_ptr = &s->next;
+ hash_insert (all_segs_hash, seg->name, s);
+ }
+ gas_assert (seg == s->seg);
- found_seg:
for (pss = &s->head; (ss = *pss) != NULL ; pss = &ss->next)
{
if (ss->subseg == subseg)
@@ -467,7 +473,7 @@ get_filenum (const char *filename, unsigned int num)
xrealloc (dirs, (dir + 32) * sizeof (const char *));
}
- dirs[dir] = xmalloc (dir_len + 1);
+ dirs[dir] = (char *) xmalloc (dir_len + 1);
memcpy (dirs[dir], filename, dir_len);
dirs[dir][dir_len] = '\0';
dirs_in_use = dir + 1;
@@ -1702,6 +1708,14 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg)
symbol_set_value_now (info_end);
}
+void
+dwarf2_init (void)
+{
+ all_segs_hash = hash_new ();
+ last_seg_ptr = &all_segs;
+}
+
+
/* Finish the dwarf2 debug sections. We emit .debug.line if there
were any .file/.loc directives, or --gdwarf2 was given, or if the
file has a non-empty .debug_info section. If we emit .debug_line,