mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-18 08:38:10 +08:00
* objfiles.h (struct objfile): Add memebers data' and
num_data'.
(register_objfile_data, set_objfile_data, objfile_data): New prototypes. * objfiles.c (objfile_alloc_data, objfile_free_data): New prototypes. (allocate_objfile): Call objfile_alloc_data. (free_objfile): Call objfile_free_data. (struct objfile_data): New. (struct objfile_data_registration): New. (struct objfile_data_registry): New. (objfile_data_registry): New variable. (register_objfile_data): New function. (objfile_alloc_data, objfile_free_data): New functions. (set_objfile_data, objfile_data): New functions. * dwarf2-frame.c (dwarf2_frame_data): New variable. (dwarf2_frame_find_fde, add_fde): Use new per-objfile data mechanism. (_initialize_dwarf2_frame): New function and prototype.
This commit is contained in:
@ -1,3 +1,23 @@
|
|||||||
|
2003-07-13 Mark Kettenis <kettenis@gnu.org>
|
||||||
|
|
||||||
|
* objfiles.h (struct objfile): Add memebers `data' and `num_data'.
|
||||||
|
(register_objfile_data, set_objfile_data, objfile_data): New
|
||||||
|
prototypes.
|
||||||
|
* objfiles.c (objfile_alloc_data, objfile_free_data): New
|
||||||
|
prototypes.
|
||||||
|
(allocate_objfile): Call objfile_alloc_data.
|
||||||
|
(free_objfile): Call objfile_free_data.
|
||||||
|
(struct objfile_data): New.
|
||||||
|
(struct objfile_data_registration): New.
|
||||||
|
(struct objfile_data_registry): New.
|
||||||
|
(objfile_data_registry): New variable.
|
||||||
|
(register_objfile_data): New function.
|
||||||
|
(objfile_alloc_data, objfile_free_data): New functions.
|
||||||
|
(set_objfile_data, objfile_data): New functions.
|
||||||
|
* dwarf2-frame.c (dwarf2_frame_data): New variable.
|
||||||
|
(dwarf2_frame_find_fde, add_fde): Use new per-objfile data mechanism.
|
||||||
|
(_initialize_dwarf2_frame): New function and prototype.
|
||||||
|
|
||||||
2003-08-21 Andrew Cagney <cagney@redhat.com>
|
2003-08-21 Andrew Cagney <cagney@redhat.com>
|
||||||
|
|
||||||
* sh3-rom.c (sh3_open, sh3e_open): Use gdbarch_update_p to select
|
* sh3-rom.c (sh3_open, sh3e_open): Use gdbarch_update_p to select
|
||||||
|
@ -780,6 +780,8 @@ struct comp_unit
|
|||||||
bfd_vma dbase;
|
bfd_vma dbase;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const struct objfile_data *dwarf2_frame_data;
|
||||||
|
|
||||||
static unsigned int
|
static unsigned int
|
||||||
read_1_byte (bfd *bfd, char *buf)
|
read_1_byte (bfd *bfd, char *buf)
|
||||||
{
|
{
|
||||||
@ -1024,7 +1026,7 @@ dwarf2_frame_find_fde (CORE_ADDR *pc)
|
|||||||
|
|
||||||
offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
|
offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
|
||||||
|
|
||||||
fde = objfile->sym_private;
|
fde = objfile_data (objfile, dwarf2_frame_data);
|
||||||
while (fde)
|
while (fde)
|
||||||
{
|
{
|
||||||
if (*pc >= fde->initial_location + offset
|
if (*pc >= fde->initial_location + offset
|
||||||
@ -1044,8 +1046,8 @@ dwarf2_frame_find_fde (CORE_ADDR *pc)
|
|||||||
static void
|
static void
|
||||||
add_fde (struct comp_unit *unit, struct dwarf2_fde *fde)
|
add_fde (struct comp_unit *unit, struct dwarf2_fde *fde)
|
||||||
{
|
{
|
||||||
fde->next = unit->objfile->sym_private;
|
fde->next = objfile_data (unit->objfile, dwarf2_frame_data);
|
||||||
unit->objfile->sym_private = fde;
|
set_objfile_data (unit->objfile, dwarf2_frame_data, fde);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CC_HAS_LONG_LONG
|
#ifdef CC_HAS_LONG_LONG
|
||||||
@ -1441,3 +1443,12 @@ dwarf2_build_frame_info (struct objfile *objfile)
|
|||||||
frame_ptr = decode_frame_entry (&unit, frame_ptr, 0);
|
frame_ptr = decode_frame_entry (&unit, frame_ptr, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Provide a prototype to silence -Wmissing-prototypes. */
|
||||||
|
void _initialize_dwarf2_frame (void);
|
||||||
|
|
||||||
|
void
|
||||||
|
_initialize_dwarf2_frame (void)
|
||||||
|
{
|
||||||
|
dwarf2_frame_data = register_objfile_data ();
|
||||||
|
}
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "target.h"
|
#include "target.h"
|
||||||
#include "bcache.h"
|
#include "bcache.h"
|
||||||
|
|
||||||
|
#include "gdb_assert.h"
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include "gdb_stat.h"
|
#include "gdb_stat.h"
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -61,6 +62,9 @@ static void *map_to_file (int);
|
|||||||
|
|
||||||
static void add_to_objfile_sections (bfd *, sec_ptr, void *);
|
static void add_to_objfile_sections (bfd *, sec_ptr, void *);
|
||||||
|
|
||||||
|
static void objfile_alloc_data (struct objfile *objfile);
|
||||||
|
static void objfile_free_data (struct objfile *objfile);
|
||||||
|
|
||||||
/* Externally visible variables that are owned by this module.
|
/* Externally visible variables that are owned by this module.
|
||||||
See declarations in objfile.h for more info. */
|
See declarations in objfile.h for more info. */
|
||||||
|
|
||||||
@ -302,6 +306,8 @@ allocate_objfile (bfd *abfd, int flags)
|
|||||||
terminate_minimal_symbol_table (objfile);
|
terminate_minimal_symbol_table (objfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
objfile_alloc_data (objfile);
|
||||||
|
|
||||||
/* Update the per-objfile information that comes from the bfd, ensuring
|
/* Update the per-objfile information that comes from the bfd, ensuring
|
||||||
that any data that is reference is saved in the per-objfile data
|
that any data that is reference is saved in the per-objfile data
|
||||||
region. */
|
region. */
|
||||||
@ -561,6 +567,7 @@ free_objfile (struct objfile *objfile)
|
|||||||
|
|
||||||
if (objfile != NULL)
|
if (objfile != NULL)
|
||||||
{
|
{
|
||||||
|
objfile_free_data (objfile);
|
||||||
if (objfile->name != NULL)
|
if (objfile->name != NULL)
|
||||||
{
|
{
|
||||||
xmfree (objfile->md, objfile->name);
|
xmfree (objfile->md, objfile->name);
|
||||||
@ -1097,4 +1104,74 @@ is_in_import_list (char *name, struct objfile *objfile)
|
|||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Keep a registry of per-objfile data-pointers required by other GDB
|
||||||
|
modules. */
|
||||||
|
|
||||||
|
struct objfile_data
|
||||||
|
{
|
||||||
|
unsigned index;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct objfile_data_registration
|
||||||
|
{
|
||||||
|
struct objfile_data *data;
|
||||||
|
struct objfile_data_registration *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct objfile_data_registry
|
||||||
|
{
|
||||||
|
struct objfile_data_registration *registrations;
|
||||||
|
unsigned num_registrations;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct objfile_data_registry objfile_data_registry = { NULL, 0 };
|
||||||
|
|
||||||
|
const struct objfile_data *
|
||||||
|
register_objfile_data (void)
|
||||||
|
{
|
||||||
|
struct objfile_data_registration **curr;
|
||||||
|
|
||||||
|
/* Append new registration. */
|
||||||
|
for (curr = &objfile_data_registry.registrations;
|
||||||
|
*curr != NULL; curr = &(*curr)->next);
|
||||||
|
|
||||||
|
*curr = XMALLOC (struct objfile_data_registration);
|
||||||
|
(*curr)->next = NULL;
|
||||||
|
(*curr)->data = XMALLOC (struct objfile_data);
|
||||||
|
(*curr)->data->index = objfile_data_registry.num_registrations++;
|
||||||
|
|
||||||
|
return (*curr)->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
objfile_alloc_data (struct objfile *objfile)
|
||||||
|
{
|
||||||
|
gdb_assert (objfile->data == NULL);
|
||||||
|
objfile->num_data = objfile_data_registry.num_registrations;
|
||||||
|
objfile->data = XCALLOC (objfile->num_data, void *);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
objfile_free_data (struct objfile *objfile)
|
||||||
|
{
|
||||||
|
gdb_assert (objfile->data != NULL);
|
||||||
|
xfree (objfile->data);
|
||||||
|
objfile->data = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
set_objfile_data (struct objfile *objfile, const struct objfile_data *data,
|
||||||
|
void *value)
|
||||||
|
{
|
||||||
|
gdb_assert (data->index < objfile->num_data);
|
||||||
|
objfile->data[data->index] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
objfile_data (struct objfile *objfile, const struct objfile_data *data)
|
||||||
|
{
|
||||||
|
gdb_assert (data->index < objfile->num_data);
|
||||||
|
return objfile->data[data->index];
|
||||||
|
}
|
||||||
|
@ -379,6 +379,13 @@ struct objfile
|
|||||||
|
|
||||||
void *obj_private;
|
void *obj_private;
|
||||||
|
|
||||||
|
/* Per objfile data-pointers required by other GDB modules. */
|
||||||
|
/* FIXME: kettenis/20030711: This mechanism could replace
|
||||||
|
sym_stab_info, sym_private and obj_private entirely. */
|
||||||
|
|
||||||
|
void **data;
|
||||||
|
unsigned num_data;
|
||||||
|
|
||||||
/* Set of relocation offsets to apply to each section.
|
/* Set of relocation offsets to apply to each section.
|
||||||
Currently on the psymbol_obstack (which makes no sense, but I'm
|
Currently on the psymbol_obstack (which makes no sense, but I'm
|
||||||
not sure it's harming anything).
|
not sure it's harming anything).
|
||||||
@ -565,6 +572,16 @@ extern int in_plt_section (CORE_ADDR, char *);
|
|||||||
|
|
||||||
extern int is_in_import_list (char *, struct objfile *);
|
extern int is_in_import_list (char *, struct objfile *);
|
||||||
|
|
||||||
|
/* Keep a registry of per-objfile data-pointers required by other GDB
|
||||||
|
modules. */
|
||||||
|
|
||||||
|
extern const struct objfile_data *register_objfile_data (void);
|
||||||
|
extern void set_objfile_data (struct objfile *objfile,
|
||||||
|
const struct objfile_data *data, void *value);
|
||||||
|
extern void *objfile_data (struct objfile *objfile,
|
||||||
|
const struct objfile_data *data);
|
||||||
|
|
||||||
|
|
||||||
/* Traverse all object files. ALL_OBJFILES_SAFE works even if you delete
|
/* Traverse all object files. ALL_OBJFILES_SAFE works even if you delete
|
||||||
the objfile during the traversal. */
|
the objfile during the traversal. */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user