aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorJim Blandy <jimb@codesourcery.com>2002-10-09 04:43:49 +0000
committerJim Blandy <jimb@codesourcery.com>2002-10-09 04:43:49 +0000
commit57349743d5a73b60ce32e5aa38ad3ebc0b361e8a (patch)
tree0f3d6393d013c242a2abfbd2af9fd8d61d727e8b /gdb
parentd14a0ab1e169100fd54654c2e16607d0659cda14 (diff)
downloadgdb-57349743d5a73b60ce32e5aa38ad3ebc0b361e8a.zip
gdb-57349743d5a73b60ce32e5aa38ad3ebc0b361e8a.tar.gz
gdb-57349743d5a73b60ce32e5aa38ad3ebc0b361e8a.tar.bz2
2002-10-08 Petr Sorfa <petrs@caldera.com>
Revised and re-submitted by John Wolfe <jlw@caldera.com> Move the Dwarf 2 abbrev table to a per-compilation-unit structure, so we can work on more than one compilation unit at a time. This helps prepare GDB to handle inter-CU die references. * dwarf2read.c (ABBREV_HASH_SIZE): moved definition forward in the code to be defined before struct comp_unit_head. (comp_unit_head): Added new members - offset, cu_head, begin_die, next and dwarf2_abbrevs. (dwarf2_abbrevs): Removed single static var; now member of struct comp_unit_head. dwarf2_build_psymtabs_hard): Complete new struct comp_unit_head members. (psymtab_to_symtab_1): Changed to work with the new struct comp_unit_head. (dwarf2_read_abbrevs): Now accepts a cu_header parameter and constructs the dwarf2_abbrevs[] inside the cu_header. (dwarf2_empty_abbrev_table): Now expects a ptr to a dwarf2_abbrev table to clean up. (dwarf2_lookup_abbrev): Now accepts a cu_header parameter and handling of dwarf2_abbrevs inside the cu_header. (read_partial_die): Now supports the call to the new dwarf2_lookup_abbrev. (read_full_die): Now supports the call to the new dwarf2_lookup_abbrev.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog28
-rw-r--r--gdb/dwarf2read.c85
2 files changed, 86 insertions, 27 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a7f4219..dc2a6a4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,31 @@
+2002-10-08 Petr Sorfa <petrs@caldera.com>
+
+ Revised and re-submitted by John Wolfe <jlw@caldera.com>
+
+ Move the Dwarf 2 abbrev table to a per-compilation-unit structure,
+ so we can work on more than one compilation unit at a time. This
+ helps prepare GDB to handle inter-CU die references.
+ * dwarf2read.c (ABBREV_HASH_SIZE): moved definition forward in
+ the code to be defined before struct comp_unit_head.
+ (comp_unit_head): Added new members - offset, cu_head,
+ begin_die, next and dwarf2_abbrevs.
+ (dwarf2_abbrevs): Removed single static var; now member of
+ struct comp_unit_head.
+ dwarf2_build_psymtabs_hard): Complete new struct comp_unit_head
+ members.
+ (psymtab_to_symtab_1): Changed to work with the new
+ struct comp_unit_head.
+ (dwarf2_read_abbrevs): Now accepts a cu_header parameter and
+ constructs the dwarf2_abbrevs[] inside the cu_header.
+ (dwarf2_empty_abbrev_table): Now expects a ptr to a
+ dwarf2_abbrev table to clean up.
+ (dwarf2_lookup_abbrev): Now accepts a cu_header parameter and
+ handling of dwarf2_abbrevs inside the cu_header.
+ (read_partial_die): Now supports the call to the new
+ dwarf2_lookup_abbrev.
+ (read_full_die): Now supports the call to the new
+ dwarf2_lookup_abbrev.
+
2002-10-06 Christopher Faylor <cgf@redhat.com>
* Makefile.in (install-gdbtk): Add missing continuation backslash to
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index b62b028..8edbd86 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -162,6 +162,11 @@ unsigned int dwarf_eh_frame_size;
/* local data types */
+/* We hold several abbreviation tables in memory at the same time. */
+#ifndef ABBREV_HASH_SIZE
+#define ABBREV_HASH_SIZE 121
+#endif
+
/* The data in a compilation unit header, after target2host
translation, looks like this. */
struct comp_unit_head
@@ -174,6 +179,29 @@ struct comp_unit_head
unsigned int offset_size; /* size of file offsets; either 4 or 8 */
unsigned int initial_length_size; /* size of the length field; either
4 or 12 */
+
+ /* Offset to the first byte of this compilation unit header in the
+ * .debug_info section, for resolving relative reference dies. */
+
+ unsigned int offset;
+
+ /* Pointer to this compilation unit header in the .debug_info
+ * section */
+
+ char *cu_head_ptr;
+
+ /* Pointer to the first die of this compilatio unit. This will
+ * be the first byte following the compilation unit header. */
+
+ char *first_die_ptr;
+
+ /* Pointer to the next compilation unit header in the program. */
+
+ struct comp_unit_head *next;
+
+ /* DWARF abbreviation table associated with this compilation unit */
+
+ struct abbrev_info *dwarf2_abbrevs[ABBREV_HASH_SIZE];
};
/* The line number information for a compilation unit (found in the
@@ -312,17 +340,10 @@ struct dwarf_block
char *data;
};
-/* We only hold one compilation unit's abbrevs in
- memory at any one time. */
-#ifndef ABBREV_HASH_SIZE
-#define ABBREV_HASH_SIZE 121
-#endif
#ifndef ATTR_ALLOC_CHUNK
#define ATTR_ALLOC_CHUNK 4
#endif
-static struct abbrev_info *dwarf2_abbrevs[ABBREV_HASH_SIZE];
-
/* A hash table of die offsets for following references. */
#ifndef REF_HASH_SIZE
#define REF_HASH_SIZE 1021
@@ -686,11 +707,12 @@ static void psymtab_to_symtab_1 (struct partial_symtab *);
char *dwarf2_read_section (struct objfile *, file_ptr, unsigned int);
-static void dwarf2_read_abbrevs (bfd *, unsigned int);
+static void dwarf2_read_abbrevs (bfd *abfd, struct comp_unit_head *cu_header);
static void dwarf2_empty_abbrev_table (PTR);
-static struct abbrev_info *dwarf2_lookup_abbrev (unsigned int);
+static struct abbrev_info *dwarf2_lookup_abbrev (unsigned int,
+ const struct comp_unit_head *cu_header);
static char *read_partial_die (struct partial_die_info *,
bfd *, char *,
@@ -1211,9 +1233,14 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
(long) (beg_of_comp_unit - dwarf_info_buffer));
return;
}
+ /* Complete the cu_header */
+ cu_header.offset = beg_of_comp_unit - dwarf_info_buffer;
+ cu_header.first_die_ptr = info_ptr;
+ cu_header.cu_head_ptr = beg_of_comp_unit;
+
/* Read the abbrevs for this compilation unit into a table */
- dwarf2_read_abbrevs (abfd, cu_header.abbrev_offset);
- make_cleanup (dwarf2_empty_abbrev_table, NULL);
+ dwarf2_read_abbrevs (abfd, &cu_header);
+ make_cleanup (dwarf2_empty_abbrev_table, cu_header.dwarf2_abbrevs);
/* Read the compilation unit die */
info_ptr = read_partial_die (&comp_unit_die, abfd, info_ptr,
@@ -1560,8 +1587,8 @@ psymtab_to_symtab_1 (struct partial_symtab *pst)
info_ptr = read_comp_unit_head (&cu_header, info_ptr, abfd);
/* Read the abbrevs for this compilation unit */
- dwarf2_read_abbrevs (abfd, cu_header.abbrev_offset);
- make_cleanup (dwarf2_empty_abbrev_table, NULL);
+ dwarf2_read_abbrevs (abfd, &cu_header);
+ make_cleanup (dwarf2_empty_abbrev_table, cu_header.dwarf2_abbrevs);
dies = read_comp_unit (info_ptr, abfd, &cu_header);
@@ -3345,17 +3372,18 @@ dwarf2_read_section (struct objfile *objfile, file_ptr offset,
in a hash table. */
static void
-dwarf2_read_abbrevs (bfd *abfd, unsigned int offset)
+dwarf2_read_abbrevs (bfd *abfd, struct comp_unit_head *cu_header)
{
char *abbrev_ptr;
struct abbrev_info *cur_abbrev;
unsigned int abbrev_number, bytes_read, abbrev_name;
unsigned int abbrev_form, hash_number;
- /* empty the table */
- dwarf2_empty_abbrev_table (NULL);
+ /* Initialize dwarf2 abbrevs */
+ memset (cu_header->dwarf2_abbrevs, 0,
+ ABBREV_HASH_SIZE*sizeof (struct abbrev_info *));
- abbrev_ptr = dwarf_abbrev_buffer + offset;
+ abbrev_ptr = dwarf_abbrev_buffer + cu_header->abbrev_offset;
abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
abbrev_ptr += bytes_read;
@@ -3394,8 +3422,8 @@ dwarf2_read_abbrevs (bfd *abfd, unsigned int offset)
}
hash_number = abbrev_number % ABBREV_HASH_SIZE;
- cur_abbrev->next = dwarf2_abbrevs[hash_number];
- dwarf2_abbrevs[hash_number] = cur_abbrev;
+ cur_abbrev->next = cu_header->dwarf2_abbrevs[hash_number];
+ cu_header->dwarf2_abbrevs[hash_number] = cur_abbrev;
/* Get next abbreviation.
Under Irix6 the abbreviations for a compilation unit are not
@@ -3409,7 +3437,7 @@ dwarf2_read_abbrevs (bfd *abfd, unsigned int offset)
break;
abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
abbrev_ptr += bytes_read;
- if (dwarf2_lookup_abbrev (abbrev_number) != NULL)
+ if (dwarf2_lookup_abbrev (abbrev_number, cu_header) != NULL)
break;
}
}
@@ -3418,15 +3446,18 @@ dwarf2_read_abbrevs (bfd *abfd, unsigned int offset)
/* ARGSUSED */
static void
-dwarf2_empty_abbrev_table (PTR ignore)
+dwarf2_empty_abbrev_table (PTR ptr_to_abbrevs_table)
{
int i;
struct abbrev_info *abbrev, *next;
+ struct abbrev_info **abbrevs;
+
+ abbrevs = (struct abbrev_info **)ptr_to_abbrevs_table;
for (i = 0; i < ABBREV_HASH_SIZE; ++i)
{
next = NULL;
- abbrev = dwarf2_abbrevs[i];
+ abbrev = abbrevs[i];
while (abbrev)
{
next = abbrev->next;
@@ -3434,20 +3465,20 @@ dwarf2_empty_abbrev_table (PTR ignore)
xfree (abbrev);
abbrev = next;
}
- dwarf2_abbrevs[i] = NULL;
+ abbrevs[i] = NULL;
}
}
/* Lookup an abbrev_info structure in the abbrev hash table. */
static struct abbrev_info *
-dwarf2_lookup_abbrev (unsigned int number)
+dwarf2_lookup_abbrev (unsigned int number, const struct comp_unit_head *cu_header)
{
unsigned int hash_number;
struct abbrev_info *abbrev;
hash_number = number % ABBREV_HASH_SIZE;
- abbrev = dwarf2_abbrevs[hash_number];
+ abbrev = cu_header->dwarf2_abbrevs[hash_number];
while (abbrev)
{
@@ -3479,7 +3510,7 @@ read_partial_die (struct partial_die_info *part_die, bfd *abfd,
if (!abbrev_number)
return info_ptr;
- abbrev = dwarf2_lookup_abbrev (abbrev_number);
+ abbrev = dwarf2_lookup_abbrev (abbrev_number, cu_header);
if (!abbrev)
{
error ("Dwarf Error: Could not find abbrev number %d.", abbrev_number);
@@ -3623,7 +3654,7 @@ read_full_die (struct die_info **diep, bfd *abfd, char *info_ptr,
return info_ptr;
}
- abbrev = dwarf2_lookup_abbrev (abbrev_number);
+ abbrev = dwarf2_lookup_abbrev (abbrev_number, cu_header);
if (!abbrev)
{
error ("Dwarf Error: could not find abbrev number %d.", abbrev_number);