summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog17
-rw-r--r--gdb/coffread.c2
-rw-r--r--gdb/dwarf2read.c85
-rw-r--r--gdb/elfread.c4
-rw-r--r--gdb/machoread.c4
-rw-r--r--gdb/symfile.h37
6 files changed, 109 insertions, 40 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 81cdddcfe13..17dae915984 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,20 @@
+2011-05-26 Tristan Gingold <gingold@adacore.com>
+
+ * symfile.h (struct dwarf2_section_names): New type.
+ (struct dwarf2_debug_sections): New type.
+ (dwarf2_has_info): Add parameter.
+ * dwarf2read.c (dwarf2_elf_names): New variable.
+ (INFO_SECTION, ABBREV_SECTION, LINE_SECTION, LOC_SECTION)
+ (MACINFO_SECTION, STR_SECTION, RANGES_SECTION, TYPES_SECTION)
+ (FRAME_SECTION, EH_FRAME_SECTION, GDB_INDEX_SECTION): Remove.
+ (dwarf2_has_info): Add names parameter. Pass names
+ to dwarf2_locate_sections.
+ (section_is_p): Rewrite using the names parameter.
+ (dwarf2_locate_sections): Use section names from the names parameter.
+ * coffread.c (coff_symfile_read): Adjust call to dwarf2_has_info.
+ * elfread.c (read_psyms): Ditto.
+ * machoread.c (macho_symfile_read): Ditto.
+
2011-05-25 Andreas Schwab <schwab@redhat.com>
PR gdb/8677
diff --git a/gdb/coffread.c b/gdb/coffread.c
index b11dd7387c1..16fd58f1b2b 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -637,7 +637,7 @@ coff_symfile_read (struct objfile *objfile, int symfile_flags)
info->stabsects,
info->stabstrsect->filepos, stabstrsize);
}
- if (dwarf2_has_info (objfile))
+ if (dwarf2_has_info (objfile, NULL))
{
/* DWARF2 sections. */
dwarf2_build_psymtabs (objfile);
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 2f4d1ae1b7e..01a94675ea9 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -243,22 +243,24 @@ struct dwarf2_per_objfile
static struct dwarf2_per_objfile *dwarf2_per_objfile;
-/* names of the debugging sections */
+/* Default names of the debugging sections. */
/* Note that if the debugging section has been compressed, it might
have a name like .zdebug_info. */
-#define INFO_SECTION "debug_info"
-#define ABBREV_SECTION "debug_abbrev"
-#define LINE_SECTION "debug_line"
-#define LOC_SECTION "debug_loc"
-#define MACINFO_SECTION "debug_macinfo"
-#define STR_SECTION "debug_str"
-#define RANGES_SECTION "debug_ranges"
-#define TYPES_SECTION "debug_types"
-#define FRAME_SECTION "debug_frame"
-#define EH_FRAME_SECTION "eh_frame"
-#define GDB_INDEX_SECTION "gdb_index"
+static const struct dwarf2_debug_sections dwarf2_elf_names = {
+ { ".debug_info", ".zdebug_info" },
+ { ".debug_abbrev", ".zdebug_abbrev" },
+ { ".debug_line", ".zdebug_line" },
+ { ".debug_loc", ".zdebug_loc" },
+ { ".debug_macinfo", ".zdebug_macinfo" },
+ { ".debug_str", ".zdebug_str" },
+ { ".debug_ranges", ".zdebug_ranges" },
+ { ".debug_types", ".zdebug_types" },
+ { ".debug_frame", ".zdebug_frame" },
+ { ".eh_frame", NULL },
+ { ".gdb_index", ".zgdb_index" }
+};
/* local data types */
@@ -1335,10 +1337,13 @@ static const char *dwarf2_physname (char *name, struct die_info *die,
struct dwarf2_cu *cu);
/* Try to locate the sections we need for DWARF 2 debugging
- information and return true if we have enough to do something. */
+ information and return true if we have enough to do something.
+ NAMES points to the dwarf2 section names, or is NULL if the standard
+ ELF names are used. */
int
-dwarf2_has_info (struct objfile *objfile)
+dwarf2_has_info (struct objfile *objfile,
+ const struct dwarf2_debug_sections *names)
{
dwarf2_per_objfile = objfile_data (objfile, dwarf2_objfile_data_key);
if (!dwarf2_per_objfile)
@@ -1351,23 +1356,28 @@ dwarf2_has_info (struct objfile *objfile)
set_objfile_data (objfile, dwarf2_objfile_data_key, data);
dwarf2_per_objfile = data;
- bfd_map_over_sections (objfile->obfd, dwarf2_locate_sections, NULL);
+ bfd_map_over_sections (objfile->obfd, dwarf2_locate_sections,
+ (void *) names);
dwarf2_per_objfile->objfile = objfile;
}
return (dwarf2_per_objfile->info.asection != NULL
&& dwarf2_per_objfile->abbrev.asection != NULL);
}
-/* When loading sections, we can either look for ".<name>", or for
- * ".z<name>", which indicates a compressed section. */
+/* When loading sections, we look either for uncompressed section or for
+ compressed section names. */
static int
-section_is_p (const char *section_name, const char *name)
+section_is_p (const char *section_name,
+ const struct dwarf2_section_names *names)
{
- return (section_name[0] == '.'
- && (strcmp (section_name + 1, name) == 0
- || (section_name[1] == 'z'
- && strcmp (section_name + 2, name) == 0)));
+ if (names->normal != NULL
+ && strcmp (section_name, names->normal) == 0)
+ return 1;
+ if (names->compressed != NULL
+ && strcmp (section_name, names->compressed) == 0)
+ return 1;
+ return 0;
}
/* This function is mapped across the sections and remembers the
@@ -1375,44 +1385,51 @@ section_is_p (const char *section_name, const char *name)
in. */
static void
-dwarf2_locate_sections (bfd *abfd, asection *sectp, void *ignore_ptr)
+dwarf2_locate_sections (bfd *abfd, asection *sectp, void *vnames)
{
- if (section_is_p (sectp->name, INFO_SECTION))
+ const struct dwarf2_debug_sections *names;
+
+ if (vnames == NULL)
+ names = &dwarf2_elf_names;
+ else
+ names = (const struct dwarf2_debug_sections *) vnames;
+
+ if (section_is_p (sectp->name, &names->info))
{
dwarf2_per_objfile->info.asection = sectp;
dwarf2_per_objfile->info.size = bfd_get_section_size (sectp);
}
- else if (section_is_p (sectp->name, ABBREV_SECTION))
+ else if (section_is_p (sectp->name, &names->abbrev))
{
dwarf2_per_objfile->abbrev.asection = sectp;
dwarf2_per_objfile->abbrev.size = bfd_get_section_size (sectp);
}
- else if (section_is_p (sectp->name, LINE_SECTION))
+ else if (section_is_p (sectp->name, &names->line))
{
dwarf2_per_objfile->line.asection = sectp;
dwarf2_per_objfile->line.size = bfd_get_section_size (sectp);
}
- else if (section_is_p (sectp->name, LOC_SECTION))
+ else if (section_is_p (sectp->name, &names->loc))
{
dwarf2_per_objfile->loc.asection = sectp;
dwarf2_per_objfile->loc.size = bfd_get_section_size (sectp);
}
- else if (section_is_p (sectp->name, MACINFO_SECTION))
+ else if (section_is_p (sectp->name, &names->macinfo))
{
dwarf2_per_objfile->macinfo.asection = sectp;
dwarf2_per_objfile->macinfo.size = bfd_get_section_size (sectp);
}
- else if (section_is_p (sectp->name, STR_SECTION))
+ else if (section_is_p (sectp->name, &names->str))
{
dwarf2_per_objfile->str.asection = sectp;
dwarf2_per_objfile->str.size = bfd_get_section_size (sectp);
}
- else if (section_is_p (sectp->name, FRAME_SECTION))
+ else if (section_is_p (sectp->name, &names->frame))
{
dwarf2_per_objfile->frame.asection = sectp;
dwarf2_per_objfile->frame.size = bfd_get_section_size (sectp);
}
- else if (section_is_p (sectp->name, EH_FRAME_SECTION))
+ else if (section_is_p (sectp->name, &names->eh_frame))
{
flagword aflag = bfd_get_section_flags (ignore_abfd, sectp);
@@ -1422,17 +1439,17 @@ dwarf2_locate_sections (bfd *abfd, asection *sectp, void *ignore_ptr)
dwarf2_per_objfile->eh_frame.size = bfd_get_section_size (sectp);
}
}
- else if (section_is_p (sectp->name, RANGES_SECTION))
+ else if (section_is_p (sectp->name, &names->ranges))
{
dwarf2_per_objfile->ranges.asection = sectp;
dwarf2_per_objfile->ranges.size = bfd_get_section_size (sectp);
}
- else if (section_is_p (sectp->name, TYPES_SECTION))
+ else if (section_is_p (sectp->name, &names->types))
{
dwarf2_per_objfile->types.asection = sectp;
dwarf2_per_objfile->types.size = bfd_get_section_size (sectp);
}
- else if (section_is_p (sectp->name, GDB_INDEX_SECTION))
+ else if (section_is_p (sectp->name, &names->gdb_index))
{
dwarf2_per_objfile->gdb_index.asection = sectp;
dwarf2_per_objfile->gdb_index.size = bfd_get_section_size (sectp);
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 6c6a7aff75d..825df0f1da6 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1391,7 +1391,7 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags)
bfd_section_size (abfd, str_sect));
}
- if (dwarf2_has_info (objfile))
+ if (dwarf2_has_info (objfile, NULL))
{
/* elf_sym_fns_gdb_index cannot handle simultaneous non-DWARF debug
information present in OBJFILE. If there is such debug info present
@@ -1437,7 +1437,7 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags)
static void
read_psyms (struct objfile *objfile)
{
- if (dwarf2_has_info (objfile))
+ if (dwarf2_has_info (objfile, NULL))
dwarf2_build_psymtabs (objfile);
}
diff --git a/gdb/machoread.c b/gdb/machoread.c
index 28cb958c83c..1cfa21ef102 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -660,7 +660,7 @@ macho_symfile_read (struct objfile *objfile, int symfile_flags)
/* Try to read .eh_frame / .debug_frame. */
/* First, locate these sections. We ignore the result status
as it only checks for debug info. */
- dwarf2_has_info (objfile);
+ dwarf2_has_info (objfile, NULL);
dwarf2_build_frame_info (objfile);
/* Check for DSYM file. */
@@ -702,7 +702,7 @@ macho_symfile_read (struct objfile *objfile, int symfile_flags)
}
}
- if (dwarf2_has_info (objfile))
+ if (dwarf2_has_info (objfile, NULL))
{
/* DWARF 2 sections */
dwarf2_build_psymtabs (objfile);
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 2b80ffd8dc4..9c0bb752951 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -553,7 +553,42 @@ extern struct cleanup *increment_reading_symtab (void);
/* From dwarf2read.c */
-extern int dwarf2_has_info (struct objfile *);
+/* Names for a dwarf2 debugging section. The field NORMAL is the normal
+ section name (usually from the DWARF standard), while the field COMPRESSED
+ is the name of compressed sections. If your object file format doesn't
+ support compressed sections, the field COMPRESSED can be NULL. Likewise,
+ the debugging section is not supported, the field NORMAL can be NULL too.
+ It doesn't make sense to have a NULL NORMAL field but a non-NULL COMPRESSED
+ field. */
+
+struct dwarf2_section_names {
+ const char *normal;
+ const char *compressed;
+};
+
+/* List of names for dward2 debugging sections. Also most object file formats
+ use the standardized (ie ELF) names, some (eg XCOFF) have customized names
+ due to restrictions.
+ The table for the standard names is defined in dwarf2read.c. Please
+ update all instances of dwarf2_debug_sections if you add a field to this
+ structure. It is always safe to use { NULL, NULL } in this case. */
+
+struct dwarf2_debug_sections {
+ struct dwarf2_section_names info;
+ struct dwarf2_section_names abbrev;
+ struct dwarf2_section_names line;
+ struct dwarf2_section_names loc;
+ struct dwarf2_section_names macinfo;
+ struct dwarf2_section_names str;
+ struct dwarf2_section_names ranges;
+ struct dwarf2_section_names types;
+ struct dwarf2_section_names frame;
+ struct dwarf2_section_names eh_frame;
+ struct dwarf2_section_names gdb_index;
+};
+
+extern int dwarf2_has_info (struct objfile *,
+ const struct dwarf2_debug_sections *);
/* Dwarf2 sections that can be accessed by dwarf2_get_section_info. */
enum dwarf2_section_enum {