Addd set_gdbarch_data() method. Update register_gdbarch_data() interface.
This commit is contained in:
parent
175aa013d9
commit
9516075289
4 changed files with 203 additions and 50 deletions
|
@ -1,3 +1,20 @@
|
||||||
|
2001-02-06 Andrew Cagney <ac131313@cygnus.com>
|
||||||
|
|
||||||
|
* gdbarch.sh: Include "gdb_assert.h".
|
||||||
|
(struct gdbarch): Change ``nr_data'' to unsigned.
|
||||||
|
(alloc_gdbarch_data, free_gdbarch_data): New functions.
|
||||||
|
(gdbarch_free): Free the data-pointer vector. Use xfree to delete
|
||||||
|
architecture vector.
|
||||||
|
(struct gdbarch_data, struct gdbarch_data_registration): Move init
|
||||||
|
method to gdbarch_data. Add free method, make index unsigned.
|
||||||
|
(struct gdbarch_data_registry): Make nr unsigned.
|
||||||
|
(register_gdbarch_data): Add free parameter. Store in
|
||||||
|
gdbarch_data.
|
||||||
|
(init_gdbarch_data): Use set_gdbarch_data.
|
||||||
|
(set_gdbarch_data): New function.
|
||||||
|
|
||||||
|
* gdbarch.h, gdbarch.c: Re-generate.
|
||||||
|
|
||||||
2001-02-06 Michael Sokolov <msokolov@ivan.Harhan.ORG>
|
2001-02-06 Michael Sokolov <msokolov@ivan.Harhan.ORG>
|
||||||
|
|
||||||
* ser-unix.c (hardware_print_tty_state) [HAVE_SGTTY]: Call
|
* ser-unix.c (hardware_print_tty_state) [HAVE_SGTTY]: Call
|
||||||
|
|
|
@ -60,10 +60,14 @@
|
||||||
|
|
||||||
#include "floatformat.h"
|
#include "floatformat.h"
|
||||||
|
|
||||||
|
#include "gdb_assert.h"
|
||||||
|
|
||||||
/* Static function declarations */
|
/* Static function declarations */
|
||||||
|
|
||||||
static void verify_gdbarch (struct gdbarch *gdbarch);
|
static void verify_gdbarch (struct gdbarch *gdbarch);
|
||||||
|
static void alloc_gdbarch_data (struct gdbarch *);
|
||||||
static void init_gdbarch_data (struct gdbarch *);
|
static void init_gdbarch_data (struct gdbarch *);
|
||||||
|
static void free_gdbarch_data (struct gdbarch *);
|
||||||
static void init_gdbarch_swap (struct gdbarch *);
|
static void init_gdbarch_swap (struct gdbarch *);
|
||||||
static void swapout_gdbarch_swap (struct gdbarch *);
|
static void swapout_gdbarch_swap (struct gdbarch *);
|
||||||
static void swapin_gdbarch_swap (struct gdbarch *);
|
static void swapin_gdbarch_swap (struct gdbarch *);
|
||||||
|
@ -96,7 +100,7 @@ struct gdbarch
|
||||||
gdbarch_dump_tdep_ftype *dump_tdep;
|
gdbarch_dump_tdep_ftype *dump_tdep;
|
||||||
|
|
||||||
/* per-architecture data-pointers */
|
/* per-architecture data-pointers */
|
||||||
int nr_data;
|
unsigned nr_data;
|
||||||
void **data;
|
void **data;
|
||||||
|
|
||||||
/* per-architecture swap-regions */
|
/* per-architecture swap-regions */
|
||||||
|
@ -386,6 +390,8 @@ gdbarch_alloc (const struct gdbarch_info *info,
|
||||||
struct gdbarch *gdbarch = XMALLOC (struct gdbarch);
|
struct gdbarch *gdbarch = XMALLOC (struct gdbarch);
|
||||||
memset (gdbarch, 0, sizeof (*gdbarch));
|
memset (gdbarch, 0, sizeof (*gdbarch));
|
||||||
|
|
||||||
|
alloc_gdbarch_data (gdbarch);
|
||||||
|
|
||||||
gdbarch->tdep = tdep;
|
gdbarch->tdep = tdep;
|
||||||
|
|
||||||
gdbarch->bfd_arch_info = info->bfd_arch_info;
|
gdbarch->bfd_arch_info = info->bfd_arch_info;
|
||||||
|
@ -466,7 +472,8 @@ gdbarch_alloc (const struct gdbarch_info *info,
|
||||||
void
|
void
|
||||||
gdbarch_free (struct gdbarch *arch)
|
gdbarch_free (struct gdbarch *arch)
|
||||||
{
|
{
|
||||||
/* At the moment, this is trivial. */
|
gdb_assert (arch != NULL);
|
||||||
|
free_gdbarch_data (arch);
|
||||||
xfree (arch);
|
xfree (arch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4013,19 +4020,20 @@ set_gdbarch_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
|
||||||
|
|
||||||
struct gdbarch_data
|
struct gdbarch_data
|
||||||
{
|
{
|
||||||
int index;
|
unsigned index;
|
||||||
|
gdbarch_data_init_ftype *init;
|
||||||
|
gdbarch_data_free_ftype *free;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gdbarch_data_registration
|
struct gdbarch_data_registration
|
||||||
{
|
{
|
||||||
gdbarch_data_ftype *init;
|
|
||||||
struct gdbarch_data *data;
|
struct gdbarch_data *data;
|
||||||
struct gdbarch_data_registration *next;
|
struct gdbarch_data_registration *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gdbarch_data_registry
|
struct gdbarch_data_registry
|
||||||
{
|
{
|
||||||
int nr;
|
unsigned nr;
|
||||||
struct gdbarch_data_registration *registrations;
|
struct gdbarch_data_registration *registrations;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4035,7 +4043,8 @@ struct gdbarch_data_registry gdbarch_data_registry =
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gdbarch_data *
|
struct gdbarch_data *
|
||||||
register_gdbarch_data (gdbarch_data_ftype *init)
|
register_gdbarch_data (gdbarch_data_init_ftype *init,
|
||||||
|
gdbarch_data_free_ftype *free)
|
||||||
{
|
{
|
||||||
struct gdbarch_data_registration **curr;
|
struct gdbarch_data_registration **curr;
|
||||||
for (curr = &gdbarch_data_registry.registrations;
|
for (curr = &gdbarch_data_registry.registrations;
|
||||||
|
@ -4043,9 +4052,10 @@ register_gdbarch_data (gdbarch_data_ftype *init)
|
||||||
curr = &(*curr)->next);
|
curr = &(*curr)->next);
|
||||||
(*curr) = XMALLOC (struct gdbarch_data_registration);
|
(*curr) = XMALLOC (struct gdbarch_data_registration);
|
||||||
(*curr)->next = NULL;
|
(*curr)->next = NULL;
|
||||||
(*curr)->init = init;
|
|
||||||
(*curr)->data = XMALLOC (struct gdbarch_data);
|
(*curr)->data = XMALLOC (struct gdbarch_data);
|
||||||
(*curr)->data->index = gdbarch_data_registry.nr++;
|
(*curr)->data->index = gdbarch_data_registry.nr++;
|
||||||
|
(*curr)->data->init = init;
|
||||||
|
(*curr)->data->free = free;
|
||||||
return (*curr)->data;
|
return (*curr)->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4056,17 +4066,65 @@ static void
|
||||||
init_gdbarch_data (struct gdbarch *gdbarch)
|
init_gdbarch_data (struct gdbarch *gdbarch)
|
||||||
{
|
{
|
||||||
struct gdbarch_data_registration *rego;
|
struct gdbarch_data_registration *rego;
|
||||||
gdbarch->nr_data = gdbarch_data_registry.nr + 1;
|
|
||||||
gdbarch->data = xmalloc (sizeof (void*) * gdbarch->nr_data);
|
|
||||||
for (rego = gdbarch_data_registry.registrations;
|
for (rego = gdbarch_data_registry.registrations;
|
||||||
rego != NULL;
|
rego != NULL;
|
||||||
rego = rego->next)
|
rego = rego->next)
|
||||||
{
|
{
|
||||||
if (rego->data->index < gdbarch->nr_data)
|
struct gdbarch_data *data = rego->data;
|
||||||
gdbarch->data[rego->data->index] = rego->init ();
|
gdb_assert (data->index < gdbarch->nr_data);
|
||||||
|
if (data->init != NULL)
|
||||||
|
{
|
||||||
|
void *pointer = data->init (gdbarch);
|
||||||
|
set_gdbarch_data (gdbarch, data, pointer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Create/delete the gdbarch data vector. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
alloc_gdbarch_data (struct gdbarch *gdbarch)
|
||||||
|
{
|
||||||
|
gdb_assert (gdbarch->data == NULL);
|
||||||
|
gdbarch->nr_data = gdbarch_data_registry.nr;
|
||||||
|
gdbarch->data = xcalloc (gdbarch->nr_data, sizeof (void*));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
free_gdbarch_data (struct gdbarch *gdbarch)
|
||||||
|
{
|
||||||
|
struct gdbarch_data_registration *rego;
|
||||||
|
gdb_assert (gdbarch->data != NULL);
|
||||||
|
for (rego = gdbarch_data_registry.registrations;
|
||||||
|
rego != NULL;
|
||||||
|
rego = rego->next)
|
||||||
|
{
|
||||||
|
struct gdbarch_data *data = rego->data;
|
||||||
|
gdb_assert (data->index < gdbarch->nr_data);
|
||||||
|
if (data->free != NULL && gdbarch->data[data->index] != NULL)
|
||||||
|
{
|
||||||
|
data->free (gdbarch, gdbarch->data[data->index]);
|
||||||
|
gdbarch->data[data->index] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xfree (gdbarch->data);
|
||||||
|
gdbarch->data = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Initialize the current value of thee specified per-architecture
|
||||||
|
data-pointer. */
|
||||||
|
|
||||||
|
void
|
||||||
|
set_gdbarch_data (struct gdbarch *gdbarch,
|
||||||
|
struct gdbarch_data *data,
|
||||||
|
void *pointer)
|
||||||
|
{
|
||||||
|
gdb_assert (data->index < gdbarch->nr_data);
|
||||||
|
if (data->free != NULL && gdbarch->data[data->index] != NULL)
|
||||||
|
data->free (gdbarch, gdbarch->data[data->index]);
|
||||||
|
gdbarch->data[data->index] = pointer;
|
||||||
|
}
|
||||||
|
|
||||||
/* Return the current value of the specified per-architecture
|
/* Return the current value of the specified per-architecture
|
||||||
data-pointer. */
|
data-pointer. */
|
||||||
|
@ -4074,8 +4132,7 @@ init_gdbarch_data (struct gdbarch *gdbarch)
|
||||||
void *
|
void *
|
||||||
gdbarch_data (struct gdbarch_data *data)
|
gdbarch_data (struct gdbarch_data *data)
|
||||||
{
|
{
|
||||||
if (data->index >= current_gdbarch->nr_data)
|
gdb_assert (data->index < current_gdbarch->nr_data);
|
||||||
internal_error ("gdbarch_data: request for non-existant data.");
|
|
||||||
return current_gdbarch->data[data->index];
|
return current_gdbarch->data[data->index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1610,29 +1610,40 @@ extern int gdbarch_update_p (struct gdbarch_info info);
|
||||||
|
|
||||||
Reserve space for a per-architecture data-pointer. An identifier
|
Reserve space for a per-architecture data-pointer. An identifier
|
||||||
for the reserved data-pointer is returned. That identifer should
|
for the reserved data-pointer is returned. That identifer should
|
||||||
be saved in a local static.
|
be saved in a local static variable.
|
||||||
|
|
||||||
When a new architecture is selected, INIT() is called. When a
|
The per-architecture data-pointer can be initialized in one of two
|
||||||
previous architecture is re-selected, the per-architecture
|
ways: The value can be set explicitly using a call to
|
||||||
data-pointer for that previous architecture is restored (INIT() is
|
set_gdbarch_data(); the value can be set implicitly using the value
|
||||||
not called).
|
returned by a non-NULL INIT() callback. INIT(), when non-NULL is
|
||||||
|
called after the basic architecture vector has been created.
|
||||||
|
|
||||||
INIT() shall return the initial value for the per-architecture
|
When a previously created architecture is re-selected, the
|
||||||
data-pointer for the current architecture.
|
per-architecture data-pointer for that previous architecture is
|
||||||
|
restored. INIT() is not called.
|
||||||
|
|
||||||
|
During initialization, multiple assignments of the data-pointer are
|
||||||
|
allowed, non-NULL values are deleted by calling FREE(). If the
|
||||||
|
architecture is deleted using gdbarch_free() all non-NULL data
|
||||||
|
pointers are also deleted using FREE().
|
||||||
|
|
||||||
Multiple registrarants for any architecture are allowed (and
|
Multiple registrarants for any architecture are allowed (and
|
||||||
strongly encouraged). */
|
strongly encouraged). */
|
||||||
|
|
||||||
typedef void *(gdbarch_data_ftype) (void);
|
struct gdbarch_data;
|
||||||
extern struct gdbarch_data *register_gdbarch_data (gdbarch_data_ftype *init);
|
|
||||||
|
|
||||||
/* Return the value of the per-architecture data-pointer for the
|
typedef void *(gdbarch_data_init_ftype) (struct gdbarch *gdbarch);
|
||||||
current architecture. */
|
typedef void (gdbarch_data_free_ftype) (struct gdbarch *gdbarch,
|
||||||
|
void *pointer);
|
||||||
|
extern struct gdbarch_data *register_gdbarch_data (gdbarch_data_init_ftype *init,
|
||||||
|
gdbarch_data_free_ftype *free);
|
||||||
|
extern void set_gdbarch_data (struct gdbarch *gdbarch,
|
||||||
|
struct gdbarch_data *data,
|
||||||
|
void *pointer);
|
||||||
|
|
||||||
extern void *gdbarch_data (struct gdbarch_data*);
|
extern void *gdbarch_data (struct gdbarch_data*);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Register per-architecture memory region.
|
/* Register per-architecture memory region.
|
||||||
|
|
||||||
Provide a memory-region swap mechanism. Per-architecture memory
|
Provide a memory-region swap mechanism. Per-architecture memory
|
||||||
|
|
118
gdb/gdbarch.sh
118
gdb/gdbarch.sh
|
@ -855,29 +855,40 @@ extern int gdbarch_update_p (struct gdbarch_info info);
|
||||||
|
|
||||||
Reserve space for a per-architecture data-pointer. An identifier
|
Reserve space for a per-architecture data-pointer. An identifier
|
||||||
for the reserved data-pointer is returned. That identifer should
|
for the reserved data-pointer is returned. That identifer should
|
||||||
be saved in a local static.
|
be saved in a local static variable.
|
||||||
|
|
||||||
When a new architecture is selected, INIT() is called. When a
|
The per-architecture data-pointer can be initialized in one of two
|
||||||
previous architecture is re-selected, the per-architecture
|
ways: The value can be set explicitly using a call to
|
||||||
data-pointer for that previous architecture is restored (INIT() is
|
set_gdbarch_data(); the value can be set implicitly using the value
|
||||||
not called).
|
returned by a non-NULL INIT() callback. INIT(), when non-NULL is
|
||||||
|
called after the basic architecture vector has been created.
|
||||||
|
|
||||||
INIT() shall return the initial value for the per-architecture
|
When a previously created architecture is re-selected, the
|
||||||
data-pointer for the current architecture.
|
per-architecture data-pointer for that previous architecture is
|
||||||
|
restored. INIT() is not called.
|
||||||
|
|
||||||
|
During initialization, multiple assignments of the data-pointer are
|
||||||
|
allowed, non-NULL values are deleted by calling FREE(). If the
|
||||||
|
architecture is deleted using gdbarch_free() all non-NULL data
|
||||||
|
pointers are also deleted using FREE().
|
||||||
|
|
||||||
Multiple registrarants for any architecture are allowed (and
|
Multiple registrarants for any architecture are allowed (and
|
||||||
strongly encouraged). */
|
strongly encouraged). */
|
||||||
|
|
||||||
typedef void *(gdbarch_data_ftype) (void);
|
struct gdbarch_data;
|
||||||
extern struct gdbarch_data *register_gdbarch_data (gdbarch_data_ftype *init);
|
|
||||||
|
|
||||||
/* Return the value of the per-architecture data-pointer for the
|
typedef void *(gdbarch_data_init_ftype) (struct gdbarch *gdbarch);
|
||||||
current architecture. */
|
typedef void (gdbarch_data_free_ftype) (struct gdbarch *gdbarch,
|
||||||
|
void *pointer);
|
||||||
|
extern struct gdbarch_data *register_gdbarch_data (gdbarch_data_init_ftype *init,
|
||||||
|
gdbarch_data_free_ftype *free);
|
||||||
|
extern void set_gdbarch_data (struct gdbarch *gdbarch,
|
||||||
|
struct gdbarch_data *data,
|
||||||
|
void *pointer);
|
||||||
|
|
||||||
extern void *gdbarch_data (struct gdbarch_data*);
|
extern void *gdbarch_data (struct gdbarch_data*);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Register per-architecture memory region.
|
/* Register per-architecture memory region.
|
||||||
|
|
||||||
Provide a memory-region swap mechanism. Per-architecture memory
|
Provide a memory-region swap mechanism. Per-architecture memory
|
||||||
|
@ -1049,10 +1060,14 @@ cat <<EOF
|
||||||
|
|
||||||
#include "floatformat.h"
|
#include "floatformat.h"
|
||||||
|
|
||||||
|
#include "gdb_assert.h"
|
||||||
|
|
||||||
/* Static function declarations */
|
/* Static function declarations */
|
||||||
|
|
||||||
static void verify_gdbarch (struct gdbarch *gdbarch);
|
static void verify_gdbarch (struct gdbarch *gdbarch);
|
||||||
|
static void alloc_gdbarch_data (struct gdbarch *);
|
||||||
static void init_gdbarch_data (struct gdbarch *);
|
static void init_gdbarch_data (struct gdbarch *);
|
||||||
|
static void free_gdbarch_data (struct gdbarch *);
|
||||||
static void init_gdbarch_swap (struct gdbarch *);
|
static void init_gdbarch_swap (struct gdbarch *);
|
||||||
static void swapout_gdbarch_swap (struct gdbarch *);
|
static void swapout_gdbarch_swap (struct gdbarch *);
|
||||||
static void swapin_gdbarch_swap (struct gdbarch *);
|
static void swapin_gdbarch_swap (struct gdbarch *);
|
||||||
|
@ -1093,7 +1108,7 @@ printf " struct gdbarch_tdep *tdep;\n"
|
||||||
printf " gdbarch_dump_tdep_ftype *dump_tdep;\n"
|
printf " gdbarch_dump_tdep_ftype *dump_tdep;\n"
|
||||||
printf "\n"
|
printf "\n"
|
||||||
printf " /* per-architecture data-pointers */\n"
|
printf " /* per-architecture data-pointers */\n"
|
||||||
printf " int nr_data;\n"
|
printf " unsigned nr_data;\n"
|
||||||
printf " void **data;\n"
|
printf " void **data;\n"
|
||||||
printf "\n"
|
printf "\n"
|
||||||
printf " /* per-architecture swap-regions */\n"
|
printf " /* per-architecture swap-regions */\n"
|
||||||
|
@ -1196,6 +1211,8 @@ gdbarch_alloc (const struct gdbarch_info *info,
|
||||||
struct gdbarch *gdbarch = XMALLOC (struct gdbarch);
|
struct gdbarch *gdbarch = XMALLOC (struct gdbarch);
|
||||||
memset (gdbarch, 0, sizeof (*gdbarch));
|
memset (gdbarch, 0, sizeof (*gdbarch));
|
||||||
|
|
||||||
|
alloc_gdbarch_data (gdbarch);
|
||||||
|
|
||||||
gdbarch->tdep = tdep;
|
gdbarch->tdep = tdep;
|
||||||
EOF
|
EOF
|
||||||
printf "\n"
|
printf "\n"
|
||||||
|
@ -1238,7 +1255,8 @@ cat <<EOF
|
||||||
void
|
void
|
||||||
gdbarch_free (struct gdbarch *arch)
|
gdbarch_free (struct gdbarch *arch)
|
||||||
{
|
{
|
||||||
/* At the moment, this is trivial. */
|
gdb_assert (arch != NULL);
|
||||||
|
free_gdbarch_data (arch);
|
||||||
xfree (arch);
|
xfree (arch);
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
@ -1488,19 +1506,20 @@ cat <<EOF
|
||||||
|
|
||||||
struct gdbarch_data
|
struct gdbarch_data
|
||||||
{
|
{
|
||||||
int index;
|
unsigned index;
|
||||||
|
gdbarch_data_init_ftype *init;
|
||||||
|
gdbarch_data_free_ftype *free;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gdbarch_data_registration
|
struct gdbarch_data_registration
|
||||||
{
|
{
|
||||||
gdbarch_data_ftype *init;
|
|
||||||
struct gdbarch_data *data;
|
struct gdbarch_data *data;
|
||||||
struct gdbarch_data_registration *next;
|
struct gdbarch_data_registration *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gdbarch_data_registry
|
struct gdbarch_data_registry
|
||||||
{
|
{
|
||||||
int nr;
|
unsigned nr;
|
||||||
struct gdbarch_data_registration *registrations;
|
struct gdbarch_data_registration *registrations;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1510,7 +1529,8 @@ struct gdbarch_data_registry gdbarch_data_registry =
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gdbarch_data *
|
struct gdbarch_data *
|
||||||
register_gdbarch_data (gdbarch_data_ftype *init)
|
register_gdbarch_data (gdbarch_data_init_ftype *init,
|
||||||
|
gdbarch_data_free_ftype *free)
|
||||||
{
|
{
|
||||||
struct gdbarch_data_registration **curr;
|
struct gdbarch_data_registration **curr;
|
||||||
for (curr = &gdbarch_data_registry.registrations;
|
for (curr = &gdbarch_data_registry.registrations;
|
||||||
|
@ -1518,9 +1538,10 @@ register_gdbarch_data (gdbarch_data_ftype *init)
|
||||||
curr = &(*curr)->next);
|
curr = &(*curr)->next);
|
||||||
(*curr) = XMALLOC (struct gdbarch_data_registration);
|
(*curr) = XMALLOC (struct gdbarch_data_registration);
|
||||||
(*curr)->next = NULL;
|
(*curr)->next = NULL;
|
||||||
(*curr)->init = init;
|
|
||||||
(*curr)->data = XMALLOC (struct gdbarch_data);
|
(*curr)->data = XMALLOC (struct gdbarch_data);
|
||||||
(*curr)->data->index = gdbarch_data_registry.nr++;
|
(*curr)->data->index = gdbarch_data_registry.nr++;
|
||||||
|
(*curr)->data->init = init;
|
||||||
|
(*curr)->data->free = free;
|
||||||
return (*curr)->data;
|
return (*curr)->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1531,17 +1552,65 @@ static void
|
||||||
init_gdbarch_data (struct gdbarch *gdbarch)
|
init_gdbarch_data (struct gdbarch *gdbarch)
|
||||||
{
|
{
|
||||||
struct gdbarch_data_registration *rego;
|
struct gdbarch_data_registration *rego;
|
||||||
gdbarch->nr_data = gdbarch_data_registry.nr + 1;
|
|
||||||
gdbarch->data = xmalloc (sizeof (void*) * gdbarch->nr_data);
|
|
||||||
for (rego = gdbarch_data_registry.registrations;
|
for (rego = gdbarch_data_registry.registrations;
|
||||||
rego != NULL;
|
rego != NULL;
|
||||||
rego = rego->next)
|
rego = rego->next)
|
||||||
{
|
{
|
||||||
if (rego->data->index < gdbarch->nr_data)
|
struct gdbarch_data *data = rego->data;
|
||||||
gdbarch->data[rego->data->index] = rego->init ();
|
gdb_assert (data->index < gdbarch->nr_data);
|
||||||
|
if (data->init != NULL)
|
||||||
|
{
|
||||||
|
void *pointer = data->init (gdbarch);
|
||||||
|
set_gdbarch_data (gdbarch, data, pointer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Create/delete the gdbarch data vector. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
alloc_gdbarch_data (struct gdbarch *gdbarch)
|
||||||
|
{
|
||||||
|
gdb_assert (gdbarch->data == NULL);
|
||||||
|
gdbarch->nr_data = gdbarch_data_registry.nr;
|
||||||
|
gdbarch->data = xcalloc (gdbarch->nr_data, sizeof (void*));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
free_gdbarch_data (struct gdbarch *gdbarch)
|
||||||
|
{
|
||||||
|
struct gdbarch_data_registration *rego;
|
||||||
|
gdb_assert (gdbarch->data != NULL);
|
||||||
|
for (rego = gdbarch_data_registry.registrations;
|
||||||
|
rego != NULL;
|
||||||
|
rego = rego->next)
|
||||||
|
{
|
||||||
|
struct gdbarch_data *data = rego->data;
|
||||||
|
gdb_assert (data->index < gdbarch->nr_data);
|
||||||
|
if (data->free != NULL && gdbarch->data[data->index] != NULL)
|
||||||
|
{
|
||||||
|
data->free (gdbarch, gdbarch->data[data->index]);
|
||||||
|
gdbarch->data[data->index] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xfree (gdbarch->data);
|
||||||
|
gdbarch->data = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Initialize the current value of thee specified per-architecture
|
||||||
|
data-pointer. */
|
||||||
|
|
||||||
|
void
|
||||||
|
set_gdbarch_data (struct gdbarch *gdbarch,
|
||||||
|
struct gdbarch_data *data,
|
||||||
|
void *pointer)
|
||||||
|
{
|
||||||
|
gdb_assert (data->index < gdbarch->nr_data);
|
||||||
|
if (data->free != NULL && gdbarch->data[data->index] != NULL)
|
||||||
|
data->free (gdbarch, gdbarch->data[data->index]);
|
||||||
|
gdbarch->data[data->index] = pointer;
|
||||||
|
}
|
||||||
|
|
||||||
/* Return the current value of the specified per-architecture
|
/* Return the current value of the specified per-architecture
|
||||||
data-pointer. */
|
data-pointer. */
|
||||||
|
@ -1549,8 +1618,7 @@ init_gdbarch_data (struct gdbarch *gdbarch)
|
||||||
void *
|
void *
|
||||||
gdbarch_data (struct gdbarch_data *data)
|
gdbarch_data (struct gdbarch_data *data)
|
||||||
{
|
{
|
||||||
if (data->index >= current_gdbarch->nr_data)
|
gdb_assert (data->index < current_gdbarch->nr_data);
|
||||||
internal_error ("gdbarch_data: request for non-existant data.");
|
|
||||||
return current_gdbarch->data[data->index];
|
return current_gdbarch->data[data->index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue