/* Register support routines for the remote server for GDB.
- Copyright (C) 2001-2017 Free Software Foundation, Inc.
+ Copyright (C) 2001-2018 Free Software Foundation, Inc.
This file is part of GDB.
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;
regcache->registers_valid = 0;
}
-static int
-regcache_invalidate_one (struct inferior_list_entry *entry,
- void *pid_p)
-{
- struct thread_info *thread = (struct thread_info *) entry;
- int pid = *(int *) pid_p;
-
- /* Only invalidate the regcaches of threads of this process. */
- if (ptid_get_pid (entry->id) == pid)
- regcache_invalidate_thread (thread);
-
- return 0;
-}
-
/* See regcache.h. */
void
regcache_invalidate_pid (int pid)
{
- find_inferior (&all_threads, regcache_invalidate_one, &pid);
+ /* Only invalidate the regcaches of threads of this process. */
+ for_each_thread (pid, regcache_invalidate_thread);
}
/* See regcache.h. */
regcache_invalidate (void)
{
/* Only update the threads of the current process. */
- int pid = ptid_get_pid (current_thread->entry.id);
+ int pid = current_thread->id.pid ();
regcache_invalidate_pid (pid);
}
= (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
#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;
}
+/* Return a reference to the description of register N. */
+
+static const struct reg &
+find_register_by_number (const struct target_desc *tdesc, int n)
+{
+ return tdesc->reg_defs[n];
+}
#ifndef IN_PROCESS_AGENT
{
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)
{
if (regcache->register_status[i] == REG_VALID)
{
int
find_regno (const struct target_desc *tdesc, const char *name)
{
- int i;
- reg *reg;
-
- for (i = 0; VEC_iterate (tdesc_reg_p, tdesc->reg_defs, i, reg); i++)
- if (strcmp (name, reg->name) == 0)
- return i;
+ for (int i = 0; i < tdesc->reg_defs.size (); ++i)
+ {
+ if (strcmp (name, find_register_by_number (tdesc, i).name) == 0)
+ return i;
+ }
internal_error (__FILE__, __LINE__, "Unknown register %s requested",
name);
}
-#endif
-
-struct reg *
-find_register_by_number (const struct target_desc *tdesc, int n)
-{
- return VEC_index (tdesc_reg_p, tdesc->reg_defs, n);
-}
-
-#ifndef IN_PROCESS_AGENT
static void
free_register_cache_thread (struct thread_info *thread)
{
}
}
-static void
-free_register_cache_thread_one (struct inferior_list_entry *entry)
-{
- struct thread_info *thread = (struct thread_info *) entry;
-
- free_register_cache_thread (thread);
-}
-
void
regcache_release (void)
{
/* Flush and release all pre-existing register caches. */
- for_each_inferior (&all_threads, free_register_cache_thread_one);
+ for_each_thread (free_register_cache_thread);
}
#endif
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. */
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.
#endif
}
+#ifndef IN_PROCESS_AGENT
+
+/* Supply register called NAME with value zero to REGCACHE. */
+
+void
+supply_register_by_name_zeroed (struct regcache *regcache,
+ const char *name)
+{
+ supply_register_zeroed (regcache, find_regno (regcache->tdesc, name));
+}
+
+#endif
+
/* Supply the whole register set whose contents are stored in BUF, to
REGCACHE. If BUF is NULL, all the registers' values are recorded
as unavailable. */
{
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
{
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
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);