/* Register support routines for the remote server for GDB.
- Copyright (C) 2001-2014 Free Software Foundation, Inc.
+ Copyright (C) 2001-2015 Free Software Foundation, Inc.
This file is part of GDB.
{
struct regcache *regcache;
- regcache = (struct regcache *) inferior_regcache_data (thread);
+ regcache = inferior_regcache_data (thread);
/* Threads' regcaches are created lazily, because biarch targets add
the main thread/lwp before seeing it stop for the first time, and
struct thread_info *saved_thread = current_thread;
current_thread = thread;
+ /* Invalidate all registers, to prevent stale left-overs. */
+ memset (regcache->register_status, REG_UNAVAILABLE,
+ regcache->tdesc->num_registers);
fetch_inferior_registers (regcache, -1);
current_thread = saved_thread;
regcache->registers_valid = 1;
{
struct regcache *regcache;
- regcache = (struct regcache *) inferior_regcache_data (thread);
+ regcache = inferior_regcache_data (thread);
if (regcache == NULL)
return;
fetches. This way they'll read as zero instead of
garbage. */
regcache->tdesc = tdesc;
- regcache->registers = xcalloc (1, tdesc->registers_size);
+ regcache->registers
+ = (unsigned char *) xcalloc (1, tdesc->registers_size);
regcache->registers_owned = 1;
- regcache->register_status = xcalloc (1, tdesc->num_registers);
+ regcache->register_status
+ = (unsigned char *) xcalloc (1, tdesc->num_registers);
gdb_assert (REG_UNAVAILABLE == 0);
#else
gdb_assert_not_reached ("can't allocate memory from the heap");
struct regcache *
new_register_cache (const struct target_desc *tdesc)
{
- struct regcache *regcache;
+ struct regcache *regcache = XCNEW (struct regcache);
gdb_assert (tdesc->registers_size != 0);
- regcache = xmalloc (sizeof (*regcache));
return init_register_cache (regcache, tdesc, NULL);
}
static void
free_register_cache_thread (struct thread_info *thread)
{
- struct regcache *regcache
- = (struct regcache *) inferior_regcache_data (thread);
+ struct regcache *regcache = inferior_regcache_data (thread);
if (regcache != NULL)
{
return tdesc->reg_defs[n].size / 8;
}
+/* See common/common-regcache.h. */
+
+int
+regcache_register_size (const struct regcache *regcache, int n)
+{
+ return register_size (regcache->tdesc, n);
+}
+
static unsigned char *
register_data (struct regcache *regcache, int n, int fetch)
{