Make gdbserver reg_defs a vector of objects
gdb/ * regformats/regdef.h (reg): Add constructors. gdb/gdbserver/ * regcache.c (find_register_by_number): Return a ref. (find_regno): Use references. (register_size): Likewise. (register_data): Likewise. * tdesc.c (target_desc::~target_desc): Remove free calls. (target_desc::operator==): Use std::vector compare. (init_target_desc): Use reference. (tdesc_create_reg): Use reg constructors. * tdesc.h (struct target_desc): Replace pointer with object.
This commit is contained in:
parent
af9d57d205
commit
5cd3e386e0
@ -1,3 +1,7 @@
|
||||
2018-03-26 Alan Hayward <alan.hayward@arm.com>
|
||||
|
||||
* regformats/regdef.h (reg): Add constructors.
|
||||
|
||||
2018-03-25 Pedro Alves <palves@redhat.com>
|
||||
|
||||
* eval.c (evaluate_funcall): Swap OP_VAR_MSYM_VALUE/OP_VAR_VALUE
|
||||
|
@ -1,3 +1,15 @@
|
||||
2018-03-26 Alan Hayward <alan.hayward@arm.com>
|
||||
|
||||
* regcache.c (find_register_by_number): Return a ref.
|
||||
(find_regno): Use references.
|
||||
(register_size): Likewise.
|
||||
(register_data): Likewise.
|
||||
* tdesc.c (target_desc::~target_desc): Remove free calls.
|
||||
(target_desc::operator==): Use std::vector compare.
|
||||
(init_target_desc): Use reference.
|
||||
(tdesc_create_reg): Use reg constructors.
|
||||
* tdesc.h (struct target_desc): Replace pointer with object.
|
||||
|
||||
2018-03-23 Alan Hayward <alan.hayward@arm.com>
|
||||
|
||||
* regcache.c (find_register_by_number): Make static.
|
||||
|
@ -196,9 +196,9 @@ regcache_cpy (struct regcache *dst, struct regcache *src)
|
||||
dst->registers_valid = src->registers_valid;
|
||||
}
|
||||
|
||||
/* Return a pointer to the description of register N. */
|
||||
/* Return a reference to the description of register N. */
|
||||
|
||||
static const struct reg *
|
||||
static const struct reg &
|
||||
find_register_by_number (const struct target_desc *tdesc, int n)
|
||||
{
|
||||
return tdesc->reg_defs[n];
|
||||
@ -251,7 +251,7 @@ find_regno (const struct target_desc *tdesc, const char *name)
|
||||
{
|
||||
for (int i = 0; i < tdesc->reg_defs.size (); ++i)
|
||||
{
|
||||
if (strcmp (name, find_register_by_number (tdesc, i)->name) == 0)
|
||||
if (strcmp (name, find_register_by_number (tdesc, i).name) == 0)
|
||||
return i;
|
||||
}
|
||||
internal_error (__FILE__, __LINE__, "Unknown register %s requested",
|
||||
@ -288,7 +288,7 @@ register_cache_size (const struct target_desc *tdesc)
|
||||
int
|
||||
register_size (const struct target_desc *tdesc, int n)
|
||||
{
|
||||
return find_register_by_number (tdesc, n)->size / 8;
|
||||
return find_register_by_number (tdesc, n).size / 8;
|
||||
}
|
||||
|
||||
/* See common/common-regcache.h. */
|
||||
@ -303,7 +303,7 @@ static unsigned char *
|
||||
register_data (struct regcache *regcache, int n, int fetch)
|
||||
{
|
||||
return (regcache->registers
|
||||
+ find_register_by_number (regcache->tdesc, n)->offset / 8);
|
||||
+ find_register_by_number (regcache->tdesc, n).offset / 8);
|
||||
}
|
||||
|
||||
/* Supply register N, whose contents are stored in BUF, to REGCACHE.
|
||||
|
@ -25,9 +25,6 @@ target_desc::~target_desc ()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (reg *reg : reg_defs)
|
||||
xfree (reg);
|
||||
|
||||
xfree ((char *) arch);
|
||||
xfree ((char *) osabi);
|
||||
|
||||
@ -40,18 +37,9 @@ target_desc::~target_desc ()
|
||||
|
||||
bool target_desc::operator== (const target_desc &other) const
|
||||
{
|
||||
if (reg_defs.size () != other.reg_defs.size ())
|
||||
if (reg_defs != other.reg_defs)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < reg_defs.size (); ++i)
|
||||
{
|
||||
struct reg *reg = reg_defs[i];
|
||||
struct reg *reg2 = other.reg_defs[i];
|
||||
|
||||
if (reg != reg2 && *reg != *reg2)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Compare expedite_regs. */
|
||||
int i = 0;
|
||||
for (; expedite_regs[i] != NULL; i++)
|
||||
@ -72,10 +60,10 @@ init_target_desc (struct target_desc *tdesc)
|
||||
{
|
||||
int offset = 0;
|
||||
|
||||
for (reg *reg : tdesc->reg_defs)
|
||||
for (reg ® : tdesc->reg_defs)
|
||||
{
|
||||
reg->offset = offset;
|
||||
offset += reg->size;
|
||||
reg.offset = offset;
|
||||
offset += reg.size;
|
||||
}
|
||||
|
||||
tdesc->registers_size = offset / 8;
|
||||
@ -241,23 +229,12 @@ tdesc_create_reg (struct tdesc_feature *feature, const char *name,
|
||||
{
|
||||
struct target_desc *tdesc = (struct target_desc *) feature;
|
||||
|
||||
while (tdesc->reg_defs.size () < regnum)
|
||||
{
|
||||
struct reg *reg = XCNEW (struct reg);
|
||||
gdb_assert (regnum == 0 || regnum >= tdesc->reg_defs.size ());
|
||||
|
||||
reg->name = "";
|
||||
reg->size = 0;
|
||||
tdesc->reg_defs.push_back (reg);
|
||||
}
|
||||
if (regnum != 0)
|
||||
tdesc->reg_defs.resize (regnum);
|
||||
|
||||
gdb_assert (regnum == 0
|
||||
|| regnum == tdesc->reg_defs.size ());
|
||||
|
||||
struct reg *reg = XCNEW (struct reg);
|
||||
|
||||
reg->name = name;
|
||||
reg->size = bitsize;
|
||||
tdesc->reg_defs.push_back (reg);
|
||||
tdesc->reg_defs.emplace_back (name, bitsize);
|
||||
}
|
||||
|
||||
/* See common/tdesc.h. */
|
||||
|
@ -34,7 +34,7 @@ struct target_desc : tdesc_feature
|
||||
{
|
||||
/* A vector of elements of register definitions that
|
||||
describe the inferior's register set. */
|
||||
std::vector<struct reg *> reg_defs;
|
||||
std::vector<struct reg> reg_defs;
|
||||
|
||||
/* The register cache size, in bytes. */
|
||||
int registers_size;
|
||||
|
@ -21,6 +21,18 @@
|
||||
|
||||
struct reg
|
||||
{
|
||||
reg ()
|
||||
: name (""),
|
||||
offset (0),
|
||||
size (0)
|
||||
{}
|
||||
|
||||
reg (const char *_name, int _size)
|
||||
: name (_name),
|
||||
offset (0),
|
||||
size (_size)
|
||||
{}
|
||||
|
||||
/* The name of this register - NULL for pad entries. */
|
||||
const char *name;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user