aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver/regcache.c
diff options
context:
space:
mode:
authorSergio Durigan Junior <sergiodj@redhat.com>2017-09-10 12:17:18 -0400
committerSergio Durigan Junior <sergiodj@redhat.com>2017-09-15 23:51:33 -0400
commitc4dfafabc575f4995a5aa18241adc275e63c846c (patch)
tree0f9602ece012d0f7cf1322514adb171089894c4e /gdb/gdbserver/regcache.c
parentebee3285b3a44ef2854e9ec84a0c92f5cca4da68 (diff)
downloadgdb-c4dfafabc575f4995a5aa18241adc275e63c846c.zip
gdb-c4dfafabc575f4995a5aa18241adc275e63c846c.tar.gz
gdb-c4dfafabc575f4995a5aa18241adc275e63c846c.tar.bz2
Use std::vector on tdesc->reg_defs (gdbserver/tdesc.h)
This is a followup patch to the build breakage fix on AArch64. While doing the fix, I found it better to convert tdesc->reg_defs (on gdbserver/tdesc.h) from using VEC to using std::vector. This makes the code easier to read and maintain, and also is one more step towards the C++fication. Regtested on BuildBot. 2017-09-16 Sergio Durigan Junior <sergiodj@redhat.com> * regcache.c (get_thread_regcache): Update code to use "std::vector" instead of "VEC" for "target_desc.reg_defs". (regcache_cpy): Likewise. (registers_to_string): Likewise. (registers_from_string): Likewise. (find_regno): Likewise. (supply_regblock): Likewise. (regcache_raw_read_unsigned): Likewise. * tdesc.c (init_target_desc): Likewise. (tdesc_create_reg): Likewise. * tdesc.h: Remove declaration of "tdesc_reg_p". Include <vector>. (struct target_desc) <reg_defs>: Convert to "std::vector". (target_desc): Do not initialize "reg_defs". (~target_desc): Update code to use "std::vector" instead of "VEC" for "target_desc.reg_defs". (operator==): Likewise.
Diffstat (limited to 'gdb/gdbserver/regcache.c')
-rw-r--r--gdb/gdbserver/regcache.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/gdb/gdbserver/regcache.c b/gdb/gdbserver/regcache.c
index d1a534c..7548091 100644
--- a/gdb/gdbserver/regcache.c
+++ b/gdb/gdbserver/regcache.c
@@ -53,9 +53,8 @@ get_thread_regcache (struct thread_info *thread, int fetch)
current_thread = thread;
/* Invalidate all registers, to prevent stale left-overs. */
- if (!VEC_empty (tdesc_reg_p, regcache->tdesc->reg_defs))
- memset (regcache->register_status, REG_UNAVAILABLE,
- VEC_length (tdesc_reg_p, regcache->tdesc->reg_defs));
+ memset (regcache->register_status, REG_UNAVAILABLE,
+ regcache->tdesc->reg_defs.size ());
fetch_inferior_registers (regcache, -1);
current_thread = saved_thread;
regcache->registers_valid = 1;
@@ -146,10 +145,9 @@ init_register_cache (struct regcache *regcache,
= (unsigned char *) xcalloc (1, tdesc->registers_size);
regcache->registers_owned = 1;
regcache->register_status
- = (unsigned char *) xmalloc (VEC_length (tdesc_reg_p, tdesc->reg_defs));
- if (!VEC_empty (tdesc_reg_p, tdesc->reg_defs))
- memset ((void *) regcache->register_status, REG_UNAVAILABLE,
- VEC_length (tdesc_reg_p, tdesc->reg_defs));
+ = (unsigned char *) xmalloc (tdesc->reg_defs.size ());
+ memset ((void *) regcache->register_status, REG_UNAVAILABLE,
+ tdesc->reg_defs.size ());
#else
gdb_assert_not_reached ("can't allocate memory from the heap");
#endif
@@ -206,7 +204,7 @@ regcache_cpy (struct regcache *dst, struct regcache *src)
#ifndef IN_PROCESS_AGENT
if (dst->register_status != NULL && src->register_status != NULL)
memcpy (dst->register_status, src->register_status,
- VEC_length (tdesc_reg_p, src->tdesc->reg_defs));
+ src->tdesc->reg_defs.size ());
#endif
dst->registers_valid = src->registers_valid;
}
@@ -219,11 +217,11 @@ registers_to_string (struct regcache *regcache, char *buf)
{
unsigned char *registers = regcache->registers;
const struct target_desc *tdesc = regcache->tdesc;
- int i;
- reg *reg;
- for (i = 0; VEC_iterate (tdesc_reg_p, tdesc->reg_defs, i, reg); i++)
+ for (int i = 0; i < tdesc->reg_defs.size (); ++i)
{
+ struct reg *reg = tdesc->reg_defs[i];
+
if (regcache->register_status[i] == REG_VALID)
{
bin2hex (registers, buf, register_size (tdesc, i));
@@ -259,12 +257,13 @@ registers_from_string (struct regcache *regcache, char *buf)
int
find_regno (const struct target_desc *tdesc, const char *name)
{
- int i;
- reg *reg;
+ for (int i = 0; i < tdesc->reg_defs.size (); ++i)
+ {
+ struct reg *reg = tdesc->reg_defs[i];
- for (i = 0; VEC_iterate (tdesc_reg_p, tdesc->reg_defs, i, reg); i++)
- if (strcmp (name, reg->name) == 0)
- return i;
+ if (strcmp (name, reg->name) == 0)
+ return i;
+ }
internal_error (__FILE__, __LINE__, "Unknown register %s requested",
name);
}
@@ -274,7 +273,7 @@ find_regno (const struct target_desc *tdesc, const char *name)
struct reg *
find_register_by_number (const struct target_desc *tdesc, int n)
{
- return VEC_index (tdesc_reg_p, tdesc->reg_defs, n);
+ return tdesc->reg_defs[n];
}
#ifndef IN_PROCESS_AGENT
@@ -390,7 +389,7 @@ supply_regblock (struct regcache *regcache, const void *buf)
{
int i;
- for (i = 0; i < VEC_length (tdesc_reg_p, tdesc->reg_defs); i++)
+ for (i = 0; i < tdesc->reg_defs.size (); i++)
regcache->register_status[i] = REG_VALID;
}
#endif
@@ -404,7 +403,7 @@ supply_regblock (struct regcache *regcache, const void *buf)
{
int i;
- for (i = 0; i < VEC_length (tdesc_reg_p, tdesc->reg_defs); i++)
+ for (i = 0; i < tdesc->reg_defs.size (); i++)
regcache->register_status[i] = REG_UNAVAILABLE;
}
#endif
@@ -437,7 +436,7 @@ regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
gdb_assert (regcache != NULL);
gdb_assert (regnum >= 0
- && regnum < VEC_length (tdesc_reg_p, regcache->tdesc->reg_defs));
+ && regnum < regcache->tdesc->reg_defs.size ());
size = register_size (regcache->tdesc, regnum);