* [rfa/dwarf] Use objfile_data mechanism for per-objfile data
@ 2004-04-01 17:16 Daniel Jacobowitz
2004-04-01 20:58 ` Jim Blandy
0 siblings, 1 reply; 11+ messages in thread
From: Daniel Jacobowitz @ 2004-04-01 17:16 UTC (permalink / raw)
To: gdb-patches; +Cc: jimb, ezannoni
Right now we keep a lot of crud in the per-psymtab data that is really
per-objfile. I'm going to be adding additional per-objfile data, and I need
it to be per-objfile rather than duplicated, so I took a moment to clean
this up. This gathers about twenty static variables in dwarf2read.c that
were saved/restored from the per-psymtab data, and replaces them with
pointers into a single per-objfile structure. It doesn't eliminate use of a
global variable to access the per-objfile structure, but that's an easy
cleanup after this patch has been applied.
Tested on i686-pc-linux-gnu. OK?
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
2004-04-01 Daniel Jacobowitz <drow@mvista.com>
* dwarf2read.c (dwarf2_per_objfile_data): New.
(struct dwarf2_per_objfile_data): New.
(dwarf2_per_objfile): New.
(dwarf_info_size, dwarf_abbrev_size, dwarf_line_size)
(dwarf_pubnames_size, dwarf_aranges_size, dwarf_loc_size)
(dwarf_macinfo_size, dwarf_str_size, dwarf_ranges_size)
(dwarf_frame_size, dwarf_eh_frame_size, dwarf_info_buffer)
(dwarf_abbrev_buffer, dwarf_line_buffer, dwarf_str_buffer)
(dwarf_macinfo_buffer, dwarf_ranges_buffer, dwarf_loc_buffer):
Replace with macros.
(struct dwarf2_pinfo): Remove per-objfile members. Update comments.
(DWARF_ABBREV_SIZE, DWARF_LINE_SIZE)
(DWARF_LOC_SIZE, DWARF_MACINFO_SIZE, DWARF_STR_SIZE)
(DWARF_RANGES_SIZE, DWARF_INFO_BUFFER)
(DWARF_ABBREV_BUFFER, DWARF_LINE_BUFFER, DWARF_STR_BUFFER)
(DWARF_MACINFO_BUFFER, DWARF_RANGES_BUFFER, DWARF_LOC_BUFFER):
Remove macros.
(dwarf2_has_info): Take an objfile argument. Allocate per-objfile
data.
(dwarf2_build_psymtabs_hard): Remove use of removed macros.
(psymtab_to_symtab_1): Restore per-objfile data pointer. Remove use
of removed macros.
(_initialize_dwarf2_read): New function.
* symfile.h (dwarf2_has_info): Update prototype.
* coffread.c (coff_symfile_read): Update call to dwarf2_has_info.
* elfread.c (elf_symfile_read): Likewise.
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.141
diff -u -p -r1.141 dwarf2read.c
--- dwarf2read.c 16 Mar 2004 22:43:15 -0000 1.141
+++ dwarf2read.c 1 Apr 2004 17:09:38 -0000
@@ -140,19 +140,54 @@ typedef struct statement_prologue
}
_STATEMENT_PROLOGUE;
-/* offsets and sizes of debugging sections */
+static const struct objfile_data *dwarf2_per_objfile_data;
-static unsigned int dwarf_info_size;
-static unsigned int dwarf_abbrev_size;
-static unsigned int dwarf_line_size;
-static unsigned int dwarf_pubnames_size;
-static unsigned int dwarf_aranges_size;
-static unsigned int dwarf_loc_size;
-static unsigned int dwarf_macinfo_size;
-static unsigned int dwarf_str_size;
-static unsigned int dwarf_ranges_size;
-unsigned int dwarf_frame_size;
-unsigned int dwarf_eh_frame_size;
+struct dwarf2_per_objfile_data
+{
+ /* Sizes of debugging sections. */
+ unsigned int dwarf_info_size;
+ unsigned int dwarf_abbrev_size;
+ unsigned int dwarf_line_size;
+ unsigned int dwarf_pubnames_size;
+ unsigned int dwarf_aranges_size;
+ unsigned int dwarf_loc_size;
+ unsigned int dwarf_macinfo_size;
+ unsigned int dwarf_str_size;
+ unsigned int dwarf_ranges_size;
+ unsigned int dwarf_frame_size;
+ unsigned int dwarf_eh_frame_size;
+
+ /* Loaded data from the sections. */
+ char *dwarf_info_buffer;
+ char *dwarf_abbrev_buffer;
+ char *dwarf_line_buffer;
+ char *dwarf_str_buffer;
+ char *dwarf_macinfo_buffer;
+ char *dwarf_ranges_buffer;
+ char *dwarf_loc_buffer;
+};
+
+#define dwarf_info_size dwarf2_per_objfile->dwarf_info_size
+#define dwarf_abbrev_size dwarf2_per_objfile->dwarf_abbrev_size
+#define dwarf_line_size dwarf2_per_objfile->dwarf_line_size
+#define dwarf_pubnames_size dwarf2_per_objfile->dwarf_pubnames_size
+#define dwarf_aranges_size dwarf2_per_objfile->dwarf_aranges_size
+#define dwarf_loc_size dwarf2_per_objfile->dwarf_loc_size
+#define dwarf_macinfo_size dwarf2_per_objfile->dwarf_macinfo_size
+#define dwarf_str_size dwarf2_per_objfile->dwarf_str_size
+#define dwarf_ranges_size dwarf2_per_objfile->dwarf_ranges_size
+#define dwarf_frame_size dwarf2_per_objfile->dwarf_frame_size
+#define dwarf_eh_frame_size dwarf2_per_objfile->dwarf_eh_frame_size
+
+#define dwarf_info_buffer dwarf2_per_objfile->dwarf_info_buffer
+#define dwarf_abbrev_buffer dwarf2_per_objfile->dwarf_abbrev_buffer
+#define dwarf_line_buffer dwarf2_per_objfile->dwarf_line_buffer
+#define dwarf_loc_buffer dwarf2_per_objfile->dwarf_loc_buffer
+#define dwarf_macinfo_buffer dwarf2_per_objfile->dwarf_macinfo_buffer
+#define dwarf_str_buffer dwarf2_per_objfile->dwarf_str_buffer
+#define dwarf_ranges_buffer dwarf2_per_objfile->dwarf_ranges_buffer
+
+static struct dwarf2_per_objfile_data *dwarf2_per_objfile;
static asection *dwarf_info_section;
static asection *dwarf_abbrev_section;
@@ -436,15 +471,6 @@ static struct obstack dwarf2_tmp_obstack
#define DW_FIELD_ALLOC_CHUNK 4
#endif
-/* Actually data from the sections. */
-static char *dwarf_info_buffer;
-static char *dwarf_abbrev_buffer;
-static char *dwarf_line_buffer;
-static char *dwarf_str_buffer;
-static char *dwarf_macinfo_buffer;
-static char *dwarf_ranges_buffer;
-static char *dwarf_loc_buffer;
-
/* A zeroed version of a partial die for initialization purposes. */
static struct partial_die_info zeroed_partial_die;
@@ -458,87 +484,17 @@ static int isreg; /* Object lives in re
the register number. */
/* We put a pointer to this structure in the read_symtab_private field
- of the psymtab.
-
- Most of the information in this structure is related to an entire
- object file and could be passed via the sym_private field of the
- objfile. It is possible to have both dwarf2 and some other form
- of debug symbols in one object file. */
+ of the psymtab. */
struct dwarf2_pinfo
{
- /* Pointer to start of dwarf info buffer for the objfile. */
-
- char *dwarf_info_buffer;
-
/* Offset in dwarf_info_buffer for this compilation unit. */
unsigned long dwarf_info_offset;
-
- /* Pointer to start of dwarf abbreviation buffer for the objfile. */
-
- char *dwarf_abbrev_buffer;
-
- /* Size of dwarf abbreviation section for the objfile. */
-
- unsigned int dwarf_abbrev_size;
-
- /* Pointer to start of dwarf line buffer for the objfile. */
-
- char *dwarf_line_buffer;
-
- /* Size of dwarf_line_buffer, in bytes. */
-
- unsigned int dwarf_line_size;
-
- /* Pointer to start of dwarf string buffer for the objfile. */
-
- char *dwarf_str_buffer;
-
- /* Size of dwarf string section for the objfile. */
-
- unsigned int dwarf_str_size;
-
- /* Pointer to start of dwarf macro buffer for the objfile. */
-
- char *dwarf_macinfo_buffer;
-
- /* Size of dwarf macinfo section for the objfile. */
-
- unsigned int dwarf_macinfo_size;
-
- /* Pointer to start of dwarf ranges buffer for the objfile. */
-
- char *dwarf_ranges_buffer;
-
- /* Size of dwarf ranges buffer for the objfile. */
-
- unsigned int dwarf_ranges_size;
-
- /* Pointer to start of dwarf locations buffer for the objfile. */
-
- char *dwarf_loc_buffer;
-
- /* Size of dwarf locations buffer for the objfile. */
-
- unsigned int dwarf_loc_size;
};
#define PST_PRIVATE(p) ((struct dwarf2_pinfo *)(p)->read_symtab_private)
-#define DWARF_INFO_BUFFER(p) (PST_PRIVATE(p)->dwarf_info_buffer)
#define DWARF_INFO_OFFSET(p) (PST_PRIVATE(p)->dwarf_info_offset)
-#define DWARF_ABBREV_BUFFER(p) (PST_PRIVATE(p)->dwarf_abbrev_buffer)
-#define DWARF_ABBREV_SIZE(p) (PST_PRIVATE(p)->dwarf_abbrev_size)
-#define DWARF_LINE_BUFFER(p) (PST_PRIVATE(p)->dwarf_line_buffer)
-#define DWARF_LINE_SIZE(p) (PST_PRIVATE(p)->dwarf_line_size)
-#define DWARF_STR_BUFFER(p) (PST_PRIVATE(p)->dwarf_str_buffer)
-#define DWARF_STR_SIZE(p) (PST_PRIVATE(p)->dwarf_str_size)
-#define DWARF_MACINFO_BUFFER(p) (PST_PRIVATE(p)->dwarf_macinfo_buffer)
-#define DWARF_MACINFO_SIZE(p) (PST_PRIVATE(p)->dwarf_macinfo_size)
-#define DWARF_RANGES_BUFFER(p) (PST_PRIVATE(p)->dwarf_ranges_buffer)
-#define DWARF_RANGES_SIZE(p) (PST_PRIVATE(p)->dwarf_ranges_size)
-#define DWARF_LOC_BUFFER(p) (PST_PRIVATE(p)->dwarf_loc_buffer)
-#define DWARF_LOC_SIZE(p) (PST_PRIVATE(p)->dwarf_loc_size)
/* FIXME: We might want to set this from BFD via bfd_arch_bits_per_byte,
but this would require a corresponding change in unpack_field_as_long
@@ -948,8 +904,16 @@ static char *skip_one_die (char *info_pt
information and return true if we have enough to do something. */
int
-dwarf2_has_info (bfd *abfd)
+dwarf2_has_info (struct objfile *objfile)
{
+ struct dwarf2_per_objfile_data *data;
+
+ /* Initialize per-objfile state. */
+ data = obstack_alloc (&objfile->objfile_obstack, sizeof (*data));
+ memset (data, 0, sizeof (*data));
+ set_objfile_data (objfile, dwarf2_per_objfile_data, data);
+ dwarf2_per_objfile = data;
+
dwarf_info_section = 0;
dwarf_abbrev_section = 0;
dwarf_line_section = 0;
@@ -960,7 +924,7 @@ dwarf2_has_info (bfd *abfd)
dwarf_ranges_section = 0;
dwarf_loc_section = 0;
- bfd_map_over_sections (abfd, dwarf2_locate_sections, NULL);
+ bfd_map_over_sections (objfile->obfd, dwarf2_locate_sections, NULL);
return (dwarf_info_section != NULL && dwarf_abbrev_section != NULL);
}
@@ -1037,7 +1001,6 @@ dwarf2_locate_sections (bfd *ignore_abfd
void
dwarf2_build_psymtabs (struct objfile *objfile, int mainline)
{
-
/* We definitely need the .debug_info and .debug_abbrev sections */
dwarf_info_buffer = dwarf2_read_section (objfile, dwarf_info_section);
@@ -1278,20 +1241,7 @@ dwarf2_build_psymtabs_hard (struct objfi
pst->read_symtab_private = (char *)
obstack_alloc (&objfile->objfile_obstack, sizeof (struct dwarf2_pinfo));
- DWARF_INFO_BUFFER (pst) = dwarf_info_buffer;
DWARF_INFO_OFFSET (pst) = beg_of_comp_unit - dwarf_info_buffer;
- DWARF_ABBREV_BUFFER (pst) = dwarf_abbrev_buffer;
- DWARF_ABBREV_SIZE (pst) = dwarf_abbrev_size;
- DWARF_LINE_BUFFER (pst) = dwarf_line_buffer;
- DWARF_LINE_SIZE (pst) = dwarf_line_size;
- DWARF_STR_BUFFER (pst) = dwarf_str_buffer;
- DWARF_STR_SIZE (pst) = dwarf_str_size;
- DWARF_MACINFO_BUFFER (pst) = dwarf_macinfo_buffer;
- DWARF_MACINFO_SIZE (pst) = dwarf_macinfo_size;
- DWARF_RANGES_BUFFER (pst) = dwarf_ranges_buffer;
- DWARF_RANGES_SIZE (pst) = dwarf_ranges_size;
- DWARF_LOC_BUFFER (pst) = dwarf_loc_buffer;
- DWARF_LOC_SIZE (pst) = dwarf_loc_size;
baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
/* Store the function that reads in the rest of the symbol table */
@@ -1985,21 +1935,11 @@ psymtab_to_symtab_1 (struct partial_symt
struct attribute *attr;
CORE_ADDR baseaddr;
+ dwarf2_per_objfile = objfile_data (pst->objfile, dwarf2_per_objfile_data);
+
/* Set local variables from the partial symbol table info. */
offset = DWARF_INFO_OFFSET (pst);
- dwarf_info_buffer = DWARF_INFO_BUFFER (pst);
- dwarf_abbrev_buffer = DWARF_ABBREV_BUFFER (pst);
- dwarf_abbrev_size = DWARF_ABBREV_SIZE (pst);
- dwarf_line_buffer = DWARF_LINE_BUFFER (pst);
- dwarf_line_size = DWARF_LINE_SIZE (pst);
- dwarf_str_buffer = DWARF_STR_BUFFER (pst);
- dwarf_str_size = DWARF_STR_SIZE (pst);
- dwarf_macinfo_buffer = DWARF_MACINFO_BUFFER (pst);
- dwarf_macinfo_size = DWARF_MACINFO_SIZE (pst);
- dwarf_ranges_buffer = DWARF_RANGES_BUFFER (pst);
- dwarf_ranges_size = DWARF_RANGES_SIZE (pst);
- dwarf_loc_buffer = DWARF_LOC_BUFFER (pst);
- dwarf_loc_size = DWARF_LOC_SIZE (pst);
+
info_ptr = dwarf_info_buffer + offset;
baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
@@ -8244,4 +8184,12 @@ dwarf2_symbol_mark_computed (struct attr
SYMBOL_OPS (sym) = &dwarf2_locexpr_funcs;
SYMBOL_LOCATION_BATON (sym) = baton;
}
+}
+
+void _initialize_dwarf2_read (void);
+
+void
+_initialize_dwarf2_read (void)
+{
+ dwarf2_per_objfile_data = register_objfile_data ();
}
Index: symfile.h
===================================================================
RCS file: /cvs/src/src/gdb/symfile.h,v
retrieving revision 1.27
diff -u -p -r1.27 symfile.h
--- symfile.h 14 Feb 2004 15:46:33 -0000 1.27
+++ symfile.h 1 Apr 2004 17:09:39 -0000
@@ -315,7 +315,7 @@ extern void dwarf_build_psymtabs (struct
/* From dwarf2read.c */
-extern int dwarf2_has_info (bfd *abfd);
+extern int dwarf2_has_info (struct objfile *);
extern void dwarf2_build_psymtabs (struct objfile *, int);
extern void dwarf2_build_frame_info (struct objfile *);
Index: coffread.c
===================================================================
RCS file: /cvs/src/src/gdb/coffread.c,v
retrieving revision 1.53
diff -u -p -r1.53 coffread.c
--- coffread.c 27 Feb 2004 17:46:11 -0000 1.53
+++ coffread.c 1 Apr 2004 17:09:42 -0000
@@ -634,7 +634,7 @@ coff_symfile_read (struct objfile *objfi
info->stabsects,
info->stabstrsect->filepos, stabstrsize);
}
- if (dwarf2_has_info (abfd))
+ if (dwarf2_has_info (objfile))
{
/* DWARF2 sections. */
dwarf2_build_psymtabs (objfile, mainline);
Index: elfread.c
===================================================================
RCS file: /cvs/src/src/gdb/elfread.c,v
retrieving revision 1.42
diff -u -p -r1.42 elfread.c
--- elfread.c 7 Feb 2004 23:13:47 -0000 1.42
+++ elfread.c 1 Apr 2004 17:09:43 -0000
@@ -575,7 +575,7 @@ elf_symfile_read (struct objfile *objfil
str_sect->filepos,
bfd_section_size (abfd, str_sect));
}
- if (dwarf2_has_info (abfd))
+ if (dwarf2_has_info (objfile))
{
/* DWARF 2 sections */
dwarf2_build_psymtabs (objfile, mainline);
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [rfa/dwarf] Use objfile_data mechanism for per-objfile data 2004-04-01 17:16 [rfa/dwarf] Use objfile_data mechanism for per-objfile data Daniel Jacobowitz @ 2004-04-01 20:58 ` Jim Blandy 2004-04-01 21:06 ` Daniel Jacobowitz 0 siblings, 1 reply; 11+ messages in thread From: Jim Blandy @ 2004-04-01 20:58 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: gdb-patches, ezannoni Wonderful! So it turns out 'struct dwarf2_pinfo' has only one real member, huh? :) I have to say, 'dwarf2_per_objfile_data', 'struct dwarf2_per_objfile_data', and 'dwarf2_per_objfile' are not my favorite cluster of names. It took me a few passes to get it straight. (Yes, I should have gotten more sleep, but I suspect there are others who work under the same conditions...) How about: - 'dwarf2_objfile_data_key' for the 'struct objfile_data', and - 'struct dwarf2_objfile' and 'dwarf2_objfile' for the actual per-objfile datatype and the global pointer to the current instance? (Is that any better? I think suffixes like "_data" really only belong on things whose type is unspecified at the point where the name appears, like 'void *' pointers, or objects related to them. I mean, everything is "data"; if you're going to give something a generic-sounding name, that should be because you're emphasizing the genericness of it.) The lower-case implicit-parameter macros bug me. But I assume they're going away soon, and upper-casing them would make the patch huge, right? ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [rfa/dwarf] Use objfile_data mechanism for per-objfile data 2004-04-01 20:58 ` Jim Blandy @ 2004-04-01 21:06 ` Daniel Jacobowitz 2004-04-01 21:58 ` Jim Blandy 0 siblings, 1 reply; 11+ messages in thread From: Daniel Jacobowitz @ 2004-04-01 21:06 UTC (permalink / raw) To: Jim Blandy; +Cc: gdb-patches, ezannoni On Thu, Apr 01, 2004 at 03:57:16PM -0500, Jim Blandy wrote: > > Wonderful! So it turns out 'struct dwarf2_pinfo' has only one real > member, huh? :) On my branch it has two - I added a per-psymtab hash table in some cases. > I have to say, 'dwarf2_per_objfile_data', 'struct > dwarf2_per_objfile_data', and 'dwarf2_per_objfile' are not my favorite > cluster of names. It took me a few passes to get it straight. (Yes, > I should have gotten more sleep, but I suspect there are others who > work under the same conditions...) > > How about: > - 'dwarf2_objfile_data_key' for the 'struct objfile_data', and > - 'struct dwarf2_objfile' and 'dwarf2_objfile' for the actual > per-objfile datatype and the global pointer to the current instance? > > (Is that any better? I think suffixes like "_data" really only belong > on things whose type is unspecified at the point where the name > appears, like 'void *' pointers, or objects related to them. I mean, > everything is "data"; if you're going to give something a > generic-sounding name, that should be because you're emphasizing the > genericness of it.) I don't think that's any better. "dwarf2_objfile" implies that it's a kind of objfile. But I'm willing to use your names :) > The lower-case implicit-parameter macros bug me. But I assume they're > going away soon, and upper-casing them would make the patch huge, > right? I didn't have a particular plan in either direction. Doing either would be an easy follow-on. Replacing them with their expansions would be noisy indentation-wise, but otherwise trivial - that may be best. -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [rfa/dwarf] Use objfile_data mechanism for per-objfile data 2004-04-01 21:06 ` Daniel Jacobowitz @ 2004-04-01 21:58 ` Jim Blandy 2004-04-01 22:01 ` Daniel Jacobowitz 0 siblings, 1 reply; 11+ messages in thread From: Jim Blandy @ 2004-04-01 21:58 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: gdb-patches, ezannoni Daniel Jacobowitz <drow@false.org> writes: > > How about: > > - 'dwarf2_objfile_data_key' for the 'struct objfile_data', and > > - 'struct dwarf2_objfile' and 'dwarf2_objfile' for the actual > > per-objfile datatype and the global pointer to the current instance? > > > > (Is that any better? I think suffixes like "_data" really only belong > > on things whose type is unspecified at the point where the name > > appears, like 'void *' pointers, or objects related to them. I mean, > > everything is "data"; if you're going to give something a > > generic-sounding name, that should be because you're emphasizing the > > genericness of it.) > > I don't think that's any better. "dwarf2_objfile" implies that it's a > kind of objfile. But I'm willing to use your names :) No, no: "We striev for kwalitie." Okay, well, how about 'struct dwarf2_per_objfile' and dwarf2_per_objfile'? That's pretty close to your original names. > > The lower-case implicit-parameter macros bug me. But I assume they're > > going away soon, and upper-casing them would make the patch huge, > > right? > > I didn't have a particular plan in either direction. Doing either > would be an easy follow-on. Replacing them with their expansions would > be noisy indentation-wise, but otherwise trivial - that may be best. I'd be happier with replacing them with their expansions. We could drop the 'dwarf_' prefixes on the member names, too. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [rfa/dwarf] Use objfile_data mechanism for per-objfile data 2004-04-01 21:58 ` Jim Blandy @ 2004-04-01 22:01 ` Daniel Jacobowitz 2004-04-01 22:41 ` Jim Blandy 0 siblings, 1 reply; 11+ messages in thread From: Daniel Jacobowitz @ 2004-04-01 22:01 UTC (permalink / raw) To: Jim Blandy; +Cc: gdb-patches, ezannoni On Thu, Apr 01, 2004 at 04:57:11PM -0500, Jim Blandy wrote: > > Daniel Jacobowitz <drow@false.org> writes: > > > How about: > > > - 'dwarf2_objfile_data_key' for the 'struct objfile_data', and > > > - 'struct dwarf2_objfile' and 'dwarf2_objfile' for the actual > > > per-objfile datatype and the global pointer to the current instance? > > > > > > (Is that any better? I think suffixes like "_data" really only belong > > > on things whose type is unspecified at the point where the name > > > appears, like 'void *' pointers, or objects related to them. I mean, > > > everything is "data"; if you're going to give something a > > > generic-sounding name, that should be because you're emphasizing the > > > genericness of it.) > > > > I don't think that's any better. "dwarf2_objfile" implies that it's a > > kind of objfile. But I'm willing to use your names :) > > No, no: "We striev for kwalitie." > > Okay, well, how about 'struct dwarf2_per_objfile' and > dwarf2_per_objfile'? That's pretty close to your original names. - 'dwarf2_objfile_data_key' for the 'struct objfile_data', and - 'struct dwarf2_per_objfile' for the struct - 'dwarf2_per_objfile' for the global Sound good? > > > The lower-case implicit-parameter macros bug me. But I assume they're > > > going away soon, and upper-casing them would make the patch huge, > > > right? > > > > I didn't have a particular plan in either direction. Doing either > > would be an easy follow-on. Replacing them with their expansions would > > be noisy indentation-wise, but otherwise trivial - that may be best. > > I'd be happier with replacing them with their expansions. We could > drop the 'dwarf_' prefixes on the member names, too. OK. Mind if I do this later, i.e. in a few weeks? I'm polishing the rest of the intercu patches for submission now. If you have a strong preference I can do it now instead. -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [rfa/dwarf] Use objfile_data mechanism for per-objfile data 2004-04-01 22:01 ` Daniel Jacobowitz @ 2004-04-01 22:41 ` Jim Blandy 2004-04-02 3:08 ` Daniel Jacobowitz 0 siblings, 1 reply; 11+ messages in thread From: Jim Blandy @ 2004-04-01 22:41 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: gdb-patches, ezannoni Daniel Jacobowitz <drow@false.org> writes: > - 'dwarf2_objfile_data_key' for the 'struct objfile_data', and > - 'struct dwarf2_per_objfile' for the struct > - 'dwarf2_per_objfile' for the global > > Sound good? Okay. > > > > The lower-case implicit-parameter macros bug me. But I assume they're > > > > going away soon, and upper-casing them would make the patch huge, > > > > right? > > > > > > I didn't have a particular plan in either direction. Doing either > > > would be an easy follow-on. Replacing them with their expansions would > > > be noisy indentation-wise, but otherwise trivial - that may be best. > > > > I'd be happier with replacing them with their expansions. We could > > drop the 'dwarf_' prefixes on the member names, too. > > OK. Mind if I do this later, i.e. in a few weeks? I'm polishing the > rest of the intercu patches for submission now. > > If you have a strong preference I can do it now instead. If they sit there for very long, I will have neglected my duties. But you've been working steadily on this for quite a while, so short of some disaster for you, I'm confident it'll get done. So if it would produce interference with your other patches, leave it for later. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [rfa/dwarf] Use objfile_data mechanism for per-objfile data 2004-04-01 22:41 ` Jim Blandy @ 2004-04-02 3:08 ` Daniel Jacobowitz 2004-04-02 3:47 ` Jim Blandy 2004-04-02 19:08 ` Andrew Cagney 0 siblings, 2 replies; 11+ messages in thread From: Daniel Jacobowitz @ 2004-04-02 3:08 UTC (permalink / raw) To: Jim Blandy; +Cc: gdb-patches, ezannoni On Thu, Apr 01, 2004 at 05:40:01PM -0500, Jim Blandy wrote: > If they sit there for very long, I will have neglected my duties. But > you've been working steadily on this for quite a while, so short of > some disaster for you, I'm confident it'll get done. So if it would > produce interference with your other patches, leave it for later. May as well get it right the first time, since I will need to merge this to the branch anyway for the renamed variables. This better? I got the most blatantly overlong lines, but not all of them; I'll add re-indenting this file thoroughly to my list of things to do when I'm done churning it. I also intend to move a lot of functions around for more logical grouping. -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer 2004-04-01 Daniel Jacobowitz <drow@mvista.com> * dwarf2read.c (dwarf2_objfile_data_key): New. (struct dwarf2_per_objfile, dwarf2_per_objfile): New. (dwarf_info_size, dwarf_abbrev_size, dwarf_line_size) (dwarf_pubnames_size, dwarf_aranges_size, dwarf_loc_size) (dwarf_macinfo_size, dwarf_str_size, dwarf_ranges_size) (dwarf_frame_size, dwarf_eh_frame_size, dwarf_info_buffer) (dwarf_abbrev_buffer, dwarf_line_buffer, dwarf_str_buffer) (dwarf_macinfo_buffer, dwarf_ranges_buffer, dwarf_loc_buffer): Remove variables. (struct dwarf2_pinfo): Remove per-objfile members. Update comments. (DWARF_ABBREV_SIZE, DWARF_LINE_SIZE) (DWARF_LOC_SIZE, DWARF_MACINFO_SIZE, DWARF_STR_SIZE) (DWARF_RANGES_SIZE, DWARF_INFO_BUFFER) (DWARF_ABBREV_BUFFER, DWARF_LINE_BUFFER, DWARF_STR_BUFFER) (DWARF_MACINFO_BUFFER, DWARF_RANGES_BUFFER, DWARF_LOC_BUFFER): Remove macros. (dwarf2_has_info): Take an objfile argument. Allocate per-objfile data. (dwarf2_locate_sections, dwarf2_build_psymtabs) (dwarf2_build_psymtabs_easy, dwarf2_build_psymtabs_hard) (skip_one_die, dwarf2_get_pc_bounds, dwarf2_read_abbrevs) (read_partial_die, read_full_die, read_indirect_string) (dwarf_decode_line_header, dwarf_decode_macros) (dwarf2_symbol_mark_computed): Remove use of removed macros. Update uses of removed variables. (psymtab_to_symtab_1): Restore per-objfile data pointer. Remove use of removed macros. (_initialize_dwarf2_read): New function. * symfile.h (dwarf2_has_info): Update prototype. * coffread.c (coff_symfile_read): Update call to dwarf2_has_info. * elfread.c (elf_symfile_read): Likewise. Index: dwarf2read.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2read.c,v retrieving revision 1.141 diff -u -p -r1.141 dwarf2read.c --- dwarf2read.c 16 Mar 2004 22:43:15 -0000 1.141 +++ dwarf2read.c 2 Apr 2004 03:00:36 -0000 @@ -140,19 +140,34 @@ typedef struct statement_prologue } _STATEMENT_PROLOGUE; -/* offsets and sizes of debugging sections */ +static const struct objfile_data *dwarf2_objfile_data_key; -static unsigned int dwarf_info_size; -static unsigned int dwarf_abbrev_size; -static unsigned int dwarf_line_size; -static unsigned int dwarf_pubnames_size; -static unsigned int dwarf_aranges_size; -static unsigned int dwarf_loc_size; -static unsigned int dwarf_macinfo_size; -static unsigned int dwarf_str_size; -static unsigned int dwarf_ranges_size; -unsigned int dwarf_frame_size; -unsigned int dwarf_eh_frame_size; +struct dwarf2_per_objfile +{ + /* Sizes of debugging sections. */ + unsigned int info_size; + unsigned int abbrev_size; + unsigned int line_size; + unsigned int pubnames_size; + unsigned int aranges_size; + unsigned int loc_size; + unsigned int macinfo_size; + unsigned int str_size; + unsigned int ranges_size; + unsigned int frame_size; + unsigned int eh_frame_size; + + /* Loaded data from the sections. */ + char *info_buffer; + char *abbrev_buffer; + char *line_buffer; + char *str_buffer; + char *macinfo_buffer; + char *ranges_buffer; + char *loc_buffer; +}; + +static struct dwarf2_per_objfile *dwarf2_per_objfile; static asection *dwarf_info_section; static asection *dwarf_abbrev_section; @@ -315,7 +330,7 @@ struct line_header } *file_names; /* The start and end of the statement program following this - header. These point into dwarf_line_buffer. */ + header. These point into dwarf2_per_objfile->line_buffer. */ char *statement_program_start, *statement_program_end; }; @@ -436,15 +451,6 @@ static struct obstack dwarf2_tmp_obstack #define DW_FIELD_ALLOC_CHUNK 4 #endif -/* Actually data from the sections. */ -static char *dwarf_info_buffer; -static char *dwarf_abbrev_buffer; -static char *dwarf_line_buffer; -static char *dwarf_str_buffer; -static char *dwarf_macinfo_buffer; -static char *dwarf_ranges_buffer; -static char *dwarf_loc_buffer; - /* A zeroed version of a partial die for initialization purposes. */ static struct partial_die_info zeroed_partial_die; @@ -458,87 +464,17 @@ static int isreg; /* Object lives in re the register number. */ /* We put a pointer to this structure in the read_symtab_private field - of the psymtab. - - Most of the information in this structure is related to an entire - object file and could be passed via the sym_private field of the - objfile. It is possible to have both dwarf2 and some other form - of debug symbols in one object file. */ + of the psymtab. */ struct dwarf2_pinfo { - /* Pointer to start of dwarf info buffer for the objfile. */ - - char *dwarf_info_buffer; - - /* Offset in dwarf_info_buffer for this compilation unit. */ + /* Offset in .debug_info for this compilation unit. */ unsigned long dwarf_info_offset; - - /* Pointer to start of dwarf abbreviation buffer for the objfile. */ - - char *dwarf_abbrev_buffer; - - /* Size of dwarf abbreviation section for the objfile. */ - - unsigned int dwarf_abbrev_size; - - /* Pointer to start of dwarf line buffer for the objfile. */ - - char *dwarf_line_buffer; - - /* Size of dwarf_line_buffer, in bytes. */ - - unsigned int dwarf_line_size; - - /* Pointer to start of dwarf string buffer for the objfile. */ - - char *dwarf_str_buffer; - - /* Size of dwarf string section for the objfile. */ - - unsigned int dwarf_str_size; - - /* Pointer to start of dwarf macro buffer for the objfile. */ - - char *dwarf_macinfo_buffer; - - /* Size of dwarf macinfo section for the objfile. */ - - unsigned int dwarf_macinfo_size; - - /* Pointer to start of dwarf ranges buffer for the objfile. */ - - char *dwarf_ranges_buffer; - - /* Size of dwarf ranges buffer for the objfile. */ - - unsigned int dwarf_ranges_size; - - /* Pointer to start of dwarf locations buffer for the objfile. */ - - char *dwarf_loc_buffer; - - /* Size of dwarf locations buffer for the objfile. */ - - unsigned int dwarf_loc_size; }; #define PST_PRIVATE(p) ((struct dwarf2_pinfo *)(p)->read_symtab_private) -#define DWARF_INFO_BUFFER(p) (PST_PRIVATE(p)->dwarf_info_buffer) #define DWARF_INFO_OFFSET(p) (PST_PRIVATE(p)->dwarf_info_offset) -#define DWARF_ABBREV_BUFFER(p) (PST_PRIVATE(p)->dwarf_abbrev_buffer) -#define DWARF_ABBREV_SIZE(p) (PST_PRIVATE(p)->dwarf_abbrev_size) -#define DWARF_LINE_BUFFER(p) (PST_PRIVATE(p)->dwarf_line_buffer) -#define DWARF_LINE_SIZE(p) (PST_PRIVATE(p)->dwarf_line_size) -#define DWARF_STR_BUFFER(p) (PST_PRIVATE(p)->dwarf_str_buffer) -#define DWARF_STR_SIZE(p) (PST_PRIVATE(p)->dwarf_str_size) -#define DWARF_MACINFO_BUFFER(p) (PST_PRIVATE(p)->dwarf_macinfo_buffer) -#define DWARF_MACINFO_SIZE(p) (PST_PRIVATE(p)->dwarf_macinfo_size) -#define DWARF_RANGES_BUFFER(p) (PST_PRIVATE(p)->dwarf_ranges_buffer) -#define DWARF_RANGES_SIZE(p) (PST_PRIVATE(p)->dwarf_ranges_size) -#define DWARF_LOC_BUFFER(p) (PST_PRIVATE(p)->dwarf_loc_buffer) -#define DWARF_LOC_SIZE(p) (PST_PRIVATE(p)->dwarf_loc_size) /* FIXME: We might want to set this from BFD via bfd_arch_bits_per_byte, but this would require a corresponding change in unpack_field_as_long @@ -948,8 +884,16 @@ static char *skip_one_die (char *info_pt information and return true if we have enough to do something. */ int -dwarf2_has_info (bfd *abfd) +dwarf2_has_info (struct objfile *objfile) { + struct dwarf2_per_objfile *data; + + /* Initialize per-objfile state. */ + data = obstack_alloc (&objfile->objfile_obstack, sizeof (*data)); + memset (data, 0, sizeof (*data)); + set_objfile_data (objfile, dwarf2_objfile_data_key, data); + dwarf2_per_objfile = data; + dwarf_info_section = 0; dwarf_abbrev_section = 0; dwarf_line_section = 0; @@ -960,7 +904,7 @@ dwarf2_has_info (bfd *abfd) dwarf_ranges_section = 0; dwarf_loc_section = 0; - bfd_map_over_sections (abfd, dwarf2_locate_sections, NULL); + bfd_map_over_sections (objfile->obfd, dwarf2_locate_sections, NULL); return (dwarf_info_section != NULL && dwarf_abbrev_section != NULL); } @@ -973,47 +917,47 @@ dwarf2_locate_sections (bfd *ignore_abfd { if (strcmp (sectp->name, INFO_SECTION) == 0) { - dwarf_info_size = bfd_get_section_size_before_reloc (sectp); + dwarf2_per_objfile->info_size = bfd_get_section_size_before_reloc (sectp); dwarf_info_section = sectp; } else if (strcmp (sectp->name, ABBREV_SECTION) == 0) { - dwarf_abbrev_size = bfd_get_section_size_before_reloc (sectp); + dwarf2_per_objfile->abbrev_size = bfd_get_section_size_before_reloc (sectp); dwarf_abbrev_section = sectp; } else if (strcmp (sectp->name, LINE_SECTION) == 0) { - dwarf_line_size = bfd_get_section_size_before_reloc (sectp); + dwarf2_per_objfile->line_size = bfd_get_section_size_before_reloc (sectp); dwarf_line_section = sectp; } else if (strcmp (sectp->name, PUBNAMES_SECTION) == 0) { - dwarf_pubnames_size = bfd_get_section_size_before_reloc (sectp); + dwarf2_per_objfile->pubnames_size = bfd_get_section_size_before_reloc (sectp); dwarf_pubnames_section = sectp; } else if (strcmp (sectp->name, ARANGES_SECTION) == 0) { - dwarf_aranges_size = bfd_get_section_size_before_reloc (sectp); + dwarf2_per_objfile->aranges_size = bfd_get_section_size_before_reloc (sectp); dwarf_aranges_section = sectp; } else if (strcmp (sectp->name, LOC_SECTION) == 0) { - dwarf_loc_size = bfd_get_section_size_before_reloc (sectp); + dwarf2_per_objfile->loc_size = bfd_get_section_size_before_reloc (sectp); dwarf_loc_section = sectp; } else if (strcmp (sectp->name, MACINFO_SECTION) == 0) { - dwarf_macinfo_size = bfd_get_section_size_before_reloc (sectp); + dwarf2_per_objfile->macinfo_size = bfd_get_section_size_before_reloc (sectp); dwarf_macinfo_section = sectp; } else if (strcmp (sectp->name, STR_SECTION) == 0) { - dwarf_str_size = bfd_get_section_size_before_reloc (sectp); + dwarf2_per_objfile->str_size = bfd_get_section_size_before_reloc (sectp); dwarf_str_section = sectp; } else if (strcmp (sectp->name, FRAME_SECTION) == 0) { - dwarf_frame_size = bfd_get_section_size_before_reloc (sectp); + dwarf2_per_objfile->frame_size = bfd_get_section_size_before_reloc (sectp); dwarf_frame_section = sectp; } else if (strcmp (sectp->name, EH_FRAME_SECTION) == 0) @@ -1021,13 +965,13 @@ dwarf2_locate_sections (bfd *ignore_abfd flagword aflag = bfd_get_section_flags (ignore_abfd, sectp); if (aflag & SEC_HAS_CONTENTS) { - dwarf_eh_frame_size = bfd_get_section_size_before_reloc (sectp); + dwarf2_per_objfile->eh_frame_size = bfd_get_section_size_before_reloc (sectp); dwarf_eh_frame_section = sectp; } } else if (strcmp (sectp->name, RANGES_SECTION) == 0) { - dwarf_ranges_size = bfd_get_section_size_before_reloc (sectp); + dwarf2_per_objfile->ranges_size = bfd_get_section_size_before_reloc (sectp); dwarf_ranges_section = sectp; } } @@ -1037,37 +981,36 @@ dwarf2_locate_sections (bfd *ignore_abfd void dwarf2_build_psymtabs (struct objfile *objfile, int mainline) { - /* We definitely need the .debug_info and .debug_abbrev sections */ - dwarf_info_buffer = dwarf2_read_section (objfile, dwarf_info_section); - dwarf_abbrev_buffer = dwarf2_read_section (objfile, dwarf_abbrev_section); + dwarf2_per_objfile->info_buffer = dwarf2_read_section (objfile, dwarf_info_section); + dwarf2_per_objfile->abbrev_buffer = dwarf2_read_section (objfile, dwarf_abbrev_section); if (dwarf_line_section) - dwarf_line_buffer = dwarf2_read_section (objfile, dwarf_line_section); + dwarf2_per_objfile->line_buffer = dwarf2_read_section (objfile, dwarf_line_section); else - dwarf_line_buffer = NULL; + dwarf2_per_objfile->line_buffer = NULL; if (dwarf_str_section) - dwarf_str_buffer = dwarf2_read_section (objfile, dwarf_str_section); + dwarf2_per_objfile->str_buffer = dwarf2_read_section (objfile, dwarf_str_section); else - dwarf_str_buffer = NULL; + dwarf2_per_objfile->str_buffer = NULL; if (dwarf_macinfo_section) - dwarf_macinfo_buffer = dwarf2_read_section (objfile, + dwarf2_per_objfile->macinfo_buffer = dwarf2_read_section (objfile, dwarf_macinfo_section); else - dwarf_macinfo_buffer = NULL; + dwarf2_per_objfile->macinfo_buffer = NULL; if (dwarf_ranges_section) - dwarf_ranges_buffer = dwarf2_read_section (objfile, dwarf_ranges_section); + dwarf2_per_objfile->ranges_buffer = dwarf2_read_section (objfile, dwarf_ranges_section); else - dwarf_ranges_buffer = NULL; + dwarf2_per_objfile->ranges_buffer = NULL; if (dwarf_loc_section) - dwarf_loc_buffer = dwarf2_read_section (objfile, dwarf_loc_section); + dwarf2_per_objfile->loc_buffer = dwarf2_read_section (objfile, dwarf_loc_section); else - dwarf_loc_buffer = NULL; + dwarf2_per_objfile->loc_buffer = NULL; if (mainline || (objfile->global_psymbols.size == 0 @@ -1108,7 +1051,7 @@ dwarf2_build_psymtabs_easy (struct objfi pubnames_buffer = dwarf2_read_section (objfile, dwarf_pubnames_section); pubnames_ptr = pubnames_buffer; - while ((pubnames_ptr - pubnames_buffer) < dwarf_pubnames_size) + while ((pubnames_ptr - pubnames_buffer) < dwarf2_per_objfile->pubnames_size) { struct comp_unit_head cu_header; int bytes_read; @@ -1173,8 +1116,8 @@ dwarf2_build_psymtabs_hard (struct objfi struct cleanup *back_to; CORE_ADDR lowpc, highpc, baseaddr; - info_ptr = dwarf_info_buffer; - abbrev_ptr = dwarf_abbrev_buffer; + info_ptr = dwarf2_per_objfile->info_buffer; + abbrev_ptr = dwarf2_per_objfile->abbrev_buffer; /* We use dwarf2_tmp_obstack for objects that don't need to survive the partial symbol scan, like attribute values. @@ -1192,7 +1135,7 @@ dwarf2_build_psymtabs_hard (struct objfi 2) 30% of the attributes used the form DW_FORM_string. For DW_FORM_string, read_attribute simply hands back a pointer to - the null-terminated string in dwarf_info_buffer, so no dynamic + the null-terminated string in info_buffer, so no dynamic allocation is needed there either. 3) The remaining 1% of the attributes all used DW_FORM_block1. @@ -1207,20 +1150,21 @@ dwarf2_build_psymtabs_hard (struct objfi obstack_init (&dwarf2_tmp_obstack); back_to = make_cleanup (dwarf2_free_tmp_obstack, NULL); - /* Since the objects we're extracting from dwarf_info_buffer vary in + /* Since the objects we're extracting from .debug_info vary in length, only the individual functions to extract them (like read_comp_unit_head and read_partial_die) can really know whether the buffer is large enough to hold another complete object. - At the moment, they don't actually check that. If - dwarf_info_buffer holds just one extra byte after the last - compilation unit's dies, then read_comp_unit_head will happily - read off the end of the buffer. read_partial_die is similarly - casual. Those functions should be fixed. + At the moment, they don't actually check that. If .debug_info + holds just one extra byte after the last compilation unit's dies, + then read_comp_unit_head will happily read off the end of the + buffer. read_partial_die is similarly casual. Those functions + should be fixed. For this loop condition, simply checking whether there's any data left at all should be sufficient. */ - while (info_ptr < dwarf_info_buffer + dwarf_info_size) + while (info_ptr < (dwarf2_per_objfile->info_buffer + + dwarf2_per_objfile->info_size)) { struct cleanup *back_to_inner; struct dwarf2_cu cu; @@ -1234,25 +1178,25 @@ dwarf2_build_psymtabs_hard (struct objfi error ("Dwarf Error: wrong version in compilation unit header (is %d, should be %d) [in module %s]", cu.header.version, 2, bfd_get_filename (abfd)); return; } - if (cu.header.abbrev_offset >= dwarf_abbrev_size) + if (cu.header.abbrev_offset >= dwarf2_per_objfile->abbrev_size) { error ("Dwarf Error: bad offset (0x%lx) in compilation unit header (offset 0x%lx + 6) [in module %s]", (long) cu.header.abbrev_offset, - (long) (beg_of_comp_unit - dwarf_info_buffer), + (long) (beg_of_comp_unit - dwarf2_per_objfile->info_buffer), bfd_get_filename (abfd)); return; } if (beg_of_comp_unit + cu.header.length + cu.header.initial_length_size - > dwarf_info_buffer + dwarf_info_size) + > dwarf2_per_objfile->info_buffer + dwarf2_per_objfile->info_size) { error ("Dwarf Error: bad length (0x%lx) in compilation unit header (offset 0x%lx + 0) [in module %s]", (long) cu.header.length, - (long) (beg_of_comp_unit - dwarf_info_buffer), + (long) (beg_of_comp_unit - dwarf2_per_objfile->info_buffer), bfd_get_filename (abfd)); return; } /* Complete the cu_header */ - cu.header.offset = beg_of_comp_unit - dwarf_info_buffer; + cu.header.offset = beg_of_comp_unit - dwarf2_per_objfile->info_buffer; cu.header.first_die_ptr = info_ptr; cu.header.cu_head_ptr = beg_of_comp_unit; @@ -1278,20 +1222,7 @@ dwarf2_build_psymtabs_hard (struct objfi pst->read_symtab_private = (char *) obstack_alloc (&objfile->objfile_obstack, sizeof (struct dwarf2_pinfo)); - DWARF_INFO_BUFFER (pst) = dwarf_info_buffer; - DWARF_INFO_OFFSET (pst) = beg_of_comp_unit - dwarf_info_buffer; - DWARF_ABBREV_BUFFER (pst) = dwarf_abbrev_buffer; - DWARF_ABBREV_SIZE (pst) = dwarf_abbrev_size; - DWARF_LINE_BUFFER (pst) = dwarf_line_buffer; - DWARF_LINE_SIZE (pst) = dwarf_line_size; - DWARF_STR_BUFFER (pst) = dwarf_str_buffer; - DWARF_STR_SIZE (pst) = dwarf_str_size; - DWARF_MACINFO_BUFFER (pst) = dwarf_macinfo_buffer; - DWARF_MACINFO_SIZE (pst) = dwarf_macinfo_size; - DWARF_RANGES_BUFFER (pst) = dwarf_ranges_buffer; - DWARF_RANGES_SIZE (pst) = dwarf_ranges_size; - DWARF_LOC_BUFFER (pst) = dwarf_loc_buffer; - DWARF_LOC_SIZE (pst) = dwarf_loc_size; + DWARF_INFO_OFFSET (pst) = beg_of_comp_unit - dwarf2_per_objfile->info_buffer; baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); /* Store the function that reads in the rest of the symbol table */ @@ -1844,7 +1775,8 @@ skip_one_die (char *info_ptr, struct abb if (attr.form == DW_FORM_ref_addr) complaint (&symfile_complaints, "ignoring absolute DW_AT_sibling"); else - return dwarf_info_buffer + dwarf2_get_ref_die_offset (&attr, cu); + return dwarf2_per_objfile->info_buffer + + dwarf2_get_ref_die_offset (&attr, cu); } /* If it isn't DW_AT_sibling, skip this attribute. */ @@ -1985,22 +1917,12 @@ psymtab_to_symtab_1 (struct partial_symt struct attribute *attr; CORE_ADDR baseaddr; + dwarf2_per_objfile = objfile_data (pst->objfile, dwarf2_objfile_data_key); + /* Set local variables from the partial symbol table info. */ offset = DWARF_INFO_OFFSET (pst); - dwarf_info_buffer = DWARF_INFO_BUFFER (pst); - dwarf_abbrev_buffer = DWARF_ABBREV_BUFFER (pst); - dwarf_abbrev_size = DWARF_ABBREV_SIZE (pst); - dwarf_line_buffer = DWARF_LINE_BUFFER (pst); - dwarf_line_size = DWARF_LINE_SIZE (pst); - dwarf_str_buffer = DWARF_STR_BUFFER (pst); - dwarf_str_size = DWARF_STR_SIZE (pst); - dwarf_macinfo_buffer = DWARF_MACINFO_BUFFER (pst); - dwarf_macinfo_size = DWARF_MACINFO_SIZE (pst); - dwarf_ranges_buffer = DWARF_RANGES_BUFFER (pst); - dwarf_ranges_size = DWARF_RANGES_SIZE (pst); - dwarf_loc_buffer = DWARF_LOC_BUFFER (pst); - dwarf_loc_size = DWARF_LOC_SIZE (pst); - info_ptr = dwarf_info_buffer + offset; + + info_ptr = dwarf2_per_objfile->info_buffer + offset; baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); /* We're in the global namespace. */ @@ -2538,14 +2460,14 @@ dwarf2_get_pc_bounds (struct die_info *d found_base = cu_header->base_known; base = cu_header->base_address; - if (offset >= dwarf_ranges_size) + if (offset >= dwarf2_per_objfile->ranges_size) { complaint (&symfile_complaints, "Offset %d out of bounds for DW_AT_ranges attribute", offset); return 0; } - buffer = dwarf_ranges_buffer + offset; + buffer = dwarf2_per_objfile->ranges_buffer + offset; /* Read in the largest possible address. */ marker = read_address (obfd, buffer, cu, &dummy); @@ -4390,7 +4312,7 @@ dwarf2_read_abbrevs (bfd *abfd, struct d memset (cu->dwarf2_abbrevs, 0, ABBREV_HASH_SIZE * sizeof (struct abbrev_info *)); - abbrev_ptr = dwarf_abbrev_buffer + cu_header->abbrev_offset; + abbrev_ptr = dwarf2_per_objfile->abbrev_buffer + cu_header->abbrev_offset; abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); abbrev_ptr += bytes_read; @@ -4448,8 +4370,8 @@ dwarf2_read_abbrevs (bfd *abfd, struct d already read (which means we are about to read the abbreviations for the next compile unit) or if the end of the abbreviation table is reached. */ - if ((unsigned int) (abbrev_ptr - dwarf_abbrev_buffer) - >= dwarf_abbrev_size) + if ((unsigned int) (abbrev_ptr - dwarf2_per_objfile->abbrev_buffer) + >= dwarf2_per_objfile->abbrev_size) break; abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); abbrev_ptr += bytes_read; @@ -4518,7 +4440,7 @@ read_partial_die (struct partial_die_inf error ("Dwarf Error: Could not find abbrev number %d [in module %s]", abbrev_number, bfd_get_filename (abfd)); } - part_die->offset = info_ptr - dwarf_info_buffer; + part_die->offset = info_ptr - dwarf2_per_objfile->info_buffer; part_die->tag = abbrev->tag; part_die->has_children = abbrev->has_children; part_die->abbrev = abbrev_number; @@ -4587,8 +4509,8 @@ read_partial_die (struct partial_die_inf if (attr.form == DW_FORM_ref_addr) complaint (&symfile_complaints, "ignoring absolute DW_AT_sibling"); else - part_die->sibling = - dwarf_info_buffer + dwarf2_get_ref_die_offset (&attr, cu); + part_die->sibling = dwarf2_per_objfile->info_buffer + + dwarf2_get_ref_die_offset (&attr, cu); break; default: break; @@ -4603,7 +4525,7 @@ read_partial_die (struct partial_die_inf struct partial_die_info spec_die; char *spec_ptr; - spec_ptr = dwarf_info_buffer + spec_ptr = dwarf2_per_objfile->info_buffer + dwarf2_get_ref_die_offset (&spec_attr, cu); read_partial_die (&spec_die, abfd, spec_ptr, cu); if (spec_die.name) @@ -4645,7 +4567,7 @@ read_full_die (struct die_info **diep, b struct abbrev_info *abbrev; struct die_info *die; - offset = info_ptr - dwarf_info_buffer; + offset = info_ptr - dwarf2_per_objfile->info_buffer; abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read); info_ptr += bytes_read; if (!abbrev_number) @@ -5059,22 +4981,22 @@ read_indirect_string (bfd *abfd, char *b LONGEST str_offset = read_offset (abfd, buf, cu_header, (int *) bytes_read_ptr); - if (dwarf_str_buffer == NULL) + if (dwarf2_per_objfile->str_buffer == NULL) { error ("DW_FORM_strp used without .debug_str section [in module %s]", bfd_get_filename (abfd)); return NULL; } - if (str_offset >= dwarf_str_size) + if (str_offset >= dwarf2_per_objfile->str_size) { error ("DW_FORM_strp pointing outside of .debug_str section [in module %s]", bfd_get_filename (abfd)); return NULL; } gdb_assert (HOST_CHAR_BIT == 8); - if (dwarf_str_buffer[str_offset] == '\0') + if (dwarf2_per_objfile->str_buffer[str_offset] == '\0') return NULL; - return dwarf_str_buffer + str_offset; + return dwarf2_per_objfile->str_buffer + str_offset; } static unsigned long @@ -5318,8 +5240,8 @@ add_file_name (struct line_header *lh, /* Read the statement program header starting at OFFSET in - dwarf_line_buffer, according to the endianness of ABFD. Return a - pointer to a struct line_header, allocated using xmalloc. + .debug_line, according to the endianness of ABFD. Return a pointer + to a struct line_header, allocated using xmalloc. NOTE: the strings in the include directory and file name tables of the returned object point into debug_line_buffer, and must not be @@ -5335,7 +5257,7 @@ dwarf_decode_line_header (unsigned int o int i; char *cur_dir, *cur_file; - if (dwarf_line_buffer == NULL) + if (dwarf2_per_objfile->line_buffer == NULL) { complaint (&symfile_complaints, "missing .debug_line section"); return 0; @@ -5343,7 +5265,7 @@ dwarf_decode_line_header (unsigned int o /* Make sure that at least there's room for the total_length field. That could be 12 bytes long, but we're just going to fudge that. */ - if (offset + 4 >= dwarf_line_size) + if (offset + 4 >= dwarf2_per_objfile->line_size) { dwarf2_statement_list_fits_in_line_number_section_complaint (); return 0; @@ -5354,12 +5276,13 @@ dwarf_decode_line_header (unsigned int o back_to = make_cleanup ((make_cleanup_ftype *) free_line_header, (void *) lh); - line_ptr = dwarf_line_buffer + offset; + line_ptr = dwarf2_per_objfile->line_buffer + offset; /* read in the header */ lh->total_length = read_initial_length (abfd, line_ptr, NULL, &bytes_read); line_ptr += bytes_read; - if (line_ptr + lh->total_length > dwarf_line_buffer + dwarf_line_size) + if (line_ptr + lh->total_length > (dwarf2_per_objfile->line_buffer + + dwarf2_per_objfile->line_size)) { dwarf2_statement_list_fits_in_line_number_section_complaint (); return 0; @@ -5415,7 +5338,8 @@ dwarf_decode_line_header (unsigned int o line_ptr += bytes_read; lh->statement_program_start = line_ptr; - if (line_ptr > dwarf_line_buffer + dwarf_line_size) + if (line_ptr > (dwarf2_per_objfile->line_buffer + + dwarf2_per_objfile->line_size)) complaint (&symfile_complaints, "line number info header doesn't fit in `.debug_line' section"); @@ -8051,14 +7975,15 @@ dwarf_decode_macros (struct line_header char *mac_ptr, *mac_end; struct macro_source_file *current_file = 0; - if (dwarf_macinfo_buffer == NULL) + if (dwarf2_per_objfile->macinfo_buffer == NULL) { complaint (&symfile_complaints, "missing .debug_macinfo section"); return; } - mac_ptr = dwarf_macinfo_buffer + offset; - mac_end = dwarf_macinfo_buffer + dwarf_macinfo_size; + mac_ptr = dwarf2_per_objfile->macinfo_buffer + offset; + mac_end = dwarf2_per_objfile->macinfo_buffer + + dwarf2_per_objfile->macinfo_size; for (;;) { @@ -8205,8 +8130,8 @@ dwarf2_symbol_mark_computed (struct attr /* We don't know how long the location list is, but make sure we don't run off the edge of the section. */ - baton->size = dwarf_loc_size - DW_UNSND (attr); - baton->data = dwarf_loc_buffer + DW_UNSND (attr); + baton->size = dwarf2_per_objfile->loc_size - DW_UNSND (attr); + baton->data = dwarf2_per_objfile->loc_buffer + DW_UNSND (attr); baton->base_address = cu->header.base_address; if (cu->header.base_known == 0) complaint (&symfile_complaints, @@ -8227,9 +8152,9 @@ dwarf2_symbol_mark_computed (struct attr { /* Note that we're just copying the block's data pointer here, not the actual data. We're still pointing into the - dwarf_info_buffer for SYM's objfile; right now we never - release that buffer, but when we do clean up properly - this may need to change. */ + info_buffer for SYM's objfile; right now we never release + that buffer, but when we do clean up properly this may + need to change. */ baton->size = DW_BLOCK (attr)->size; baton->data = DW_BLOCK (attr)->data; } @@ -8244,4 +8169,12 @@ dwarf2_symbol_mark_computed (struct attr SYMBOL_OPS (sym) = &dwarf2_locexpr_funcs; SYMBOL_LOCATION_BATON (sym) = baton; } +} + +void _initialize_dwarf2_read (void); + +void +_initialize_dwarf2_read (void) +{ + dwarf2_objfile_data_key = register_objfile_data (); } Index: coffread.c =================================================================== RCS file: /cvs/src/src/gdb/coffread.c,v retrieving revision 1.53 diff -u -p -r1.53 coffread.c --- coffread.c 27 Feb 2004 17:46:11 -0000 1.53 +++ coffread.c 2 Apr 2004 03:00:37 -0000 @@ -634,7 +634,7 @@ coff_symfile_read (struct objfile *objfi info->stabsects, info->stabstrsect->filepos, stabstrsize); } - if (dwarf2_has_info (abfd)) + if (dwarf2_has_info (objfile)) { /* DWARF2 sections. */ dwarf2_build_psymtabs (objfile, mainline); Index: elfread.c =================================================================== RCS file: /cvs/src/src/gdb/elfread.c,v retrieving revision 1.42 diff -u -p -r1.42 elfread.c --- elfread.c 7 Feb 2004 23:13:47 -0000 1.42 +++ elfread.c 2 Apr 2004 03:00:37 -0000 @@ -575,7 +575,7 @@ elf_symfile_read (struct objfile *objfil str_sect->filepos, bfd_section_size (abfd, str_sect)); } - if (dwarf2_has_info (abfd)) + if (dwarf2_has_info (objfile)) { /* DWARF 2 sections */ dwarf2_build_psymtabs (objfile, mainline); Index: symfile.h =================================================================== RCS file: /cvs/src/src/gdb/symfile.h,v retrieving revision 1.27 diff -u -p -r1.27 symfile.h --- symfile.h 14 Feb 2004 15:46:33 -0000 1.27 +++ symfile.h 2 Apr 2004 03:00:37 -0000 @@ -315,7 +315,7 @@ extern void dwarf_build_psymtabs (struct /* From dwarf2read.c */ -extern int dwarf2_has_info (bfd *abfd); +extern int dwarf2_has_info (struct objfile *); extern void dwarf2_build_psymtabs (struct objfile *, int); extern void dwarf2_build_frame_info (struct objfile *); ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [rfa/dwarf] Use objfile_data mechanism for per-objfile data 2004-04-02 3:08 ` Daniel Jacobowitz @ 2004-04-02 3:47 ` Jim Blandy 2004-04-02 4:36 ` Daniel Jacobowitz 2004-04-02 19:08 ` Andrew Cagney 1 sibling, 1 reply; 11+ messages in thread From: Jim Blandy @ 2004-04-02 3:47 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: gdb-patches, ezannoni Daniel Jacobowitz <drow@false.org> writes: > On Thu, Apr 01, 2004 at 05:40:01PM -0500, Jim Blandy wrote: > > If they sit there for very long, I will have neglected my duties. But > > you've been working steadily on this for quite a while, so short of > > some disaster for you, I'm confident it'll get done. So if it would > > produce interference with your other patches, leave it for later. > > May as well get it right the first time, since I will need to merge > this to the branch anyway for the renamed variables. This better? > I got the most blatantly overlong lines, but not all of them; I'll add > re-indenting this file thoroughly to my list of things to do when I'm > done churning it. I also intend to move a lot of functions around for > more logical grouping. Glorious. If tested, please commit. > 2004-04-01 Daniel Jacobowitz <drow@mvista.com> > > * dwarf2read.c (dwarf2_objfile_data_key): New. > (struct dwarf2_per_objfile, dwarf2_per_objfile): New. > (dwarf_info_size, dwarf_abbrev_size, dwarf_line_size) > (dwarf_pubnames_size, dwarf_aranges_size, dwarf_loc_size) > (dwarf_macinfo_size, dwarf_str_size, dwarf_ranges_size) > (dwarf_frame_size, dwarf_eh_frame_size, dwarf_info_buffer) > (dwarf_abbrev_buffer, dwarf_line_buffer, dwarf_str_buffer) > (dwarf_macinfo_buffer, dwarf_ranges_buffer, dwarf_loc_buffer): > Remove variables. > (struct dwarf2_pinfo): Remove per-objfile members. Update comments. > (DWARF_ABBREV_SIZE, DWARF_LINE_SIZE) > (DWARF_LOC_SIZE, DWARF_MACINFO_SIZE, DWARF_STR_SIZE) > (DWARF_RANGES_SIZE, DWARF_INFO_BUFFER) > (DWARF_ABBREV_BUFFER, DWARF_LINE_BUFFER, DWARF_STR_BUFFER) > (DWARF_MACINFO_BUFFER, DWARF_RANGES_BUFFER, DWARF_LOC_BUFFER): > Remove macros. > (dwarf2_has_info): Take an objfile argument. Allocate per-objfile > data. > (dwarf2_locate_sections, dwarf2_build_psymtabs) > (dwarf2_build_psymtabs_easy, dwarf2_build_psymtabs_hard) > (skip_one_die, dwarf2_get_pc_bounds, dwarf2_read_abbrevs) > (read_partial_die, read_full_die, read_indirect_string) > (dwarf_decode_line_header, dwarf_decode_macros) > (dwarf2_symbol_mark_computed): Remove use of removed macros. > Update uses of removed variables. > (psymtab_to_symtab_1): Restore per-objfile data pointer. Remove use > of removed macros. > (_initialize_dwarf2_read): New function. > * symfile.h (dwarf2_has_info): Update prototype. > * coffread.c (coff_symfile_read): Update call to dwarf2_has_info. > * elfread.c (elf_symfile_read): Likewise. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [rfa/dwarf] Use objfile_data mechanism for per-objfile data 2004-04-02 3:47 ` Jim Blandy @ 2004-04-02 4:36 ` Daniel Jacobowitz 0 siblings, 0 replies; 11+ messages in thread From: Daniel Jacobowitz @ 2004-04-02 4:36 UTC (permalink / raw) To: gdb-patches On Thu, Apr 01, 2004 at 10:46:22PM -0500, Jim Blandy wrote: > > Daniel Jacobowitz <drow@false.org> writes: > > On Thu, Apr 01, 2004 at 05:40:01PM -0500, Jim Blandy wrote: > > > If they sit there for very long, I will have neglected my duties. But > > > you've been working steadily on this for quite a while, so short of > > > some disaster for you, I'm confident it'll get done. So if it would > > > produce interference with your other patches, leave it for later. > > > > May as well get it right the first time, since I will need to merge > > this to the branch anyway for the renamed variables. This better? > > I got the most blatantly overlong lines, but not all of them; I'll add > > re-indenting this file thoroughly to my list of things to do when I'm > > done churning it. I also intend to move a lot of functions around for > > more logical grouping. > > Glorious. If tested, please commit. Thanks, checked in. I'll merge the updated version to my branch, and have a more substantive patch for you tomorrow. > > > 2004-04-01 Daniel Jacobowitz <drow@mvista.com> > > > > * dwarf2read.c (dwarf2_objfile_data_key): New. > > (struct dwarf2_per_objfile, dwarf2_per_objfile): New. > > (dwarf_info_size, dwarf_abbrev_size, dwarf_line_size) > > (dwarf_pubnames_size, dwarf_aranges_size, dwarf_loc_size) > > (dwarf_macinfo_size, dwarf_str_size, dwarf_ranges_size) > > (dwarf_frame_size, dwarf_eh_frame_size, dwarf_info_buffer) > > (dwarf_abbrev_buffer, dwarf_line_buffer, dwarf_str_buffer) > > (dwarf_macinfo_buffer, dwarf_ranges_buffer, dwarf_loc_buffer): > > Remove variables. > > (struct dwarf2_pinfo): Remove per-objfile members. Update comments. > > (DWARF_ABBREV_SIZE, DWARF_LINE_SIZE) > > (DWARF_LOC_SIZE, DWARF_MACINFO_SIZE, DWARF_STR_SIZE) > > (DWARF_RANGES_SIZE, DWARF_INFO_BUFFER) > > (DWARF_ABBREV_BUFFER, DWARF_LINE_BUFFER, DWARF_STR_BUFFER) > > (DWARF_MACINFO_BUFFER, DWARF_RANGES_BUFFER, DWARF_LOC_BUFFER): > > Remove macros. > > (dwarf2_has_info): Take an objfile argument. Allocate per-objfile > > data. > > (dwarf2_locate_sections, dwarf2_build_psymtabs) > > (dwarf2_build_psymtabs_easy, dwarf2_build_psymtabs_hard) > > (skip_one_die, dwarf2_get_pc_bounds, dwarf2_read_abbrevs) > > (read_partial_die, read_full_die, read_indirect_string) > > (dwarf_decode_line_header, dwarf_decode_macros) > > (dwarf2_symbol_mark_computed): Remove use of removed macros. > > Update uses of removed variables. > > (psymtab_to_symtab_1): Restore per-objfile data pointer. Remove use > > of removed macros. > > (_initialize_dwarf2_read): New function. > > * symfile.h (dwarf2_has_info): Update prototype. > > * coffread.c (coff_symfile_read): Update call to dwarf2_has_info. > > * elfread.c (elf_symfile_read): Likewise. > > -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [rfa/dwarf] Use objfile_data mechanism for per-objfile data 2004-04-02 3:08 ` Daniel Jacobowitz 2004-04-02 3:47 ` Jim Blandy @ 2004-04-02 19:08 ` Andrew Cagney 2004-04-02 19:23 ` Daniel Jacobowitz 1 sibling, 1 reply; 11+ messages in thread From: Andrew Cagney @ 2004-04-02 19:08 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: Jim Blandy, gdb-patches, ezannoni > -extern int dwarf2_has_info (bfd *abfd); > +extern int dwarf2_has_info (struct objfile *); Did this get checked in? ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [rfa/dwarf] Use objfile_data mechanism for per-objfile data 2004-04-02 19:08 ` Andrew Cagney @ 2004-04-02 19:23 ` Daniel Jacobowitz 0 siblings, 0 replies; 11+ messages in thread From: Daniel Jacobowitz @ 2004-04-02 19:23 UTC (permalink / raw) To: Andrew Cagney; +Cc: Jim Blandy, gdb-patches, ezannoni On Fri, Apr 02, 2004 at 02:08:54PM -0500, Andrew Cagney wrote: > >-extern int dwarf2_has_info (bfd *abfd); > >+extern int dwarf2_has_info (struct objfile *); > > Did this get checked in? Oops! Fixed now. -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2004-04-02 19:23 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-04-01 17:16 [rfa/dwarf] Use objfile_data mechanism for per-objfile data Daniel Jacobowitz 2004-04-01 20:58 ` Jim Blandy 2004-04-01 21:06 ` Daniel Jacobowitz 2004-04-01 21:58 ` Jim Blandy 2004-04-01 22:01 ` Daniel Jacobowitz 2004-04-01 22:41 ` Jim Blandy 2004-04-02 3:08 ` Daniel Jacobowitz 2004-04-02 3:47 ` Jim Blandy 2004-04-02 4:36 ` Daniel Jacobowitz 2004-04-02 19:08 ` Andrew Cagney 2004-04-02 19:23 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox