* regcache.c (struct regcache_descr): Remove outdated comment.

(init_regcache_descr): Remove sizeof_raw_register_valid_p
	overallocate hack.
	(regcache_xmalloc): Rename to ...
	(regcache_xmalloc_1): ... this.  Add `readonly_p' parameter.
	Allocate the regcache type accordingly.
	(regcache_xmalloc): New as wrapper around regcache_xmalloc_1.
	(regcache_xfree): Asser the source is also readonly.  Copy sizeof
	cooked registers, not raw.
	(regcache_dup_no_passthrough): Delete.
	(get_thread_arch_regcache): Use regcache_xmalloc_1.
	* h8300-tdep.c (h8300_push_dummy_call): Tweak comment to not
	mention obsolete write_register_bytes.
	* regcache.h (regcache_dup_no_passthrough): Delete declaration.
This commit is contained in:
Pedro Alves
2011-01-25 12:13:20 +00:00
parent f7605bc29f
commit 99e42fd82a
4 changed files with 64 additions and 46 deletions

View File

@ -1,3 +1,20 @@
2011-01-25 Pedro Alves <pedro@codesourcery.com>
* regcache.c (struct regcache_descr): Remove outdated comment.
(init_regcache_descr): Remove sizeof_raw_register_valid_p
overallocate hack.
(regcache_xmalloc): Rename to ...
(regcache_xmalloc_1): ... this. Add `readonly_p' parameter.
Allocate the regcache type accordingly.
(regcache_xmalloc): New as wrapper around regcache_xmalloc_1.
(regcache_xfree): Asser the source is also readonly. Copy sizeof
cooked registers, not raw.
(regcache_dup_no_passthrough): Delete.
(get_thread_arch_regcache): Use regcache_xmalloc_1.
* h8300-tdep.c (h8300_push_dummy_call): Tweak comment to not
mention obsolete write_register_bytes.
* regcache.h (regcache_dup_no_passthrough): Delete declaration.
2011-01-25 Pedro Alves <pedro@codesourcery.com> 2011-01-25 Pedro Alves <pedro@codesourcery.com>
Stop remote_read_bytes from handling partial reads itself. Stop remote_read_bytes from handling partial reads itself.

View File

@ -698,9 +698,8 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
else else
{ {
/* Heavens to Betsy --- it's really going in registers! /* Heavens to Betsy --- it's really going in registers!
It would be nice if we could use write_register_bytes Note that on the h8/300s, there are gaps between the
here, but on the h8/300s, there are gaps between registers in the register file. */
the registers in the register file. */
int offset; int offset;
for (offset = 0; offset < padded_len; offset += wordsize) for (offset = 0; offset < padded_len; offset += wordsize)

View File

@ -67,10 +67,8 @@ struct regcache_descr
/* Offset and size (in 8 bit bytes), of reach register in the /* Offset and size (in 8 bit bytes), of reach register in the
register cache. All registers (including those in the range register cache. All registers (including those in the range
[NR_RAW_REGISTERS .. NR_COOKED_REGISTERS) are given an offset. [NR_RAW_REGISTERS .. NR_COOKED_REGISTERS) are given an
Assigning all registers an offset makes it possible to keep offset. */
legacy code, such as that found in read_register_bytes() and
write_register_bytes() working. */
long *register_offset; long *register_offset;
long *sizeof_register; long *sizeof_register;
@ -108,12 +106,7 @@ init_regcache_descr (struct gdbarch *gdbarch)
/* Construct a strictly RAW register cache. Don't allow pseudo's /* Construct a strictly RAW register cache. Don't allow pseudo's
into the register cache. */ into the register cache. */
descr->nr_raw_registers = gdbarch_num_regs (gdbarch); descr->nr_raw_registers = gdbarch_num_regs (gdbarch);
descr->sizeof_raw_register_valid_p = gdbarch_num_regs (gdbarch);
/* FIXME: cagney/2002-08-13: Overallocate the register_valid_p
array. This pretects GDB from erant code that accesses elements
of the global register_valid_p[] array in the range
[gdbarch_num_regs .. gdbarch_num_regs + gdbarch_num_pseudo_regs). */
descr->sizeof_raw_register_valid_p = descr->sizeof_cooked_register_valid_p;
/* Lay out the register cache. /* Lay out the register cache.
@ -129,24 +122,27 @@ init_regcache_descr (struct gdbarch *gdbarch)
= GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, long); = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, long);
descr->register_offset descr->register_offset
= GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, long); = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, long);
for (i = 0; i < descr->nr_cooked_registers; i++) for (i = 0; i < descr->nr_raw_registers; i++)
{ {
descr->sizeof_register[i] = TYPE_LENGTH (descr->register_type[i]); descr->sizeof_register[i] = TYPE_LENGTH (descr->register_type[i]);
descr->register_offset[i] = offset; descr->register_offset[i] = offset;
offset += descr->sizeof_register[i]; offset += descr->sizeof_register[i];
gdb_assert (MAX_REGISTER_SIZE >= descr->sizeof_register[i]); gdb_assert (MAX_REGISTER_SIZE >= descr->sizeof_register[i]);
} }
/* Set the real size of the register cache buffer. */ /* Set the real size of the raw register cache buffer. */
descr->sizeof_raw_registers = offset;
for (; i < descr->nr_cooked_registers; i++)
{
descr->sizeof_register[i] = TYPE_LENGTH (descr->register_type[i]);
descr->register_offset[i] = offset;
offset += descr->sizeof_register[i];
gdb_assert (MAX_REGISTER_SIZE >= descr->sizeof_register[i]);
}
/* Set the real size of the readonly register cache buffer. */
descr->sizeof_cooked_registers = offset; descr->sizeof_cooked_registers = offset;
} }
/* FIXME: cagney/2002-05-22: Should only need to allocate space for
the raw registers. Unfortunately some code still accesses the
register array directly using the global registers[]. Until that
code has been purged, play safe and over allocating the register
buffer. Ulgh! */
descr->sizeof_raw_registers = descr->sizeof_cooked_registers;
return descr; return descr;
} }
@ -215,8 +211,9 @@ struct regcache
ptid_t ptid; ptid_t ptid;
}; };
struct regcache * static struct regcache *
regcache_xmalloc (struct gdbarch *gdbarch, struct address_space *aspace) regcache_xmalloc_1 (struct gdbarch *gdbarch, struct address_space *aspace,
int readonly_p)
{ {
struct regcache_descr *descr; struct regcache_descr *descr;
struct regcache *regcache; struct regcache *regcache;
@ -225,16 +222,32 @@ regcache_xmalloc (struct gdbarch *gdbarch, struct address_space *aspace)
descr = regcache_descr (gdbarch); descr = regcache_descr (gdbarch);
regcache = XMALLOC (struct regcache); regcache = XMALLOC (struct regcache);
regcache->descr = descr; regcache->descr = descr;
regcache->registers regcache->readonly_p = readonly_p;
= XCALLOC (descr->sizeof_raw_registers, gdb_byte); if (readonly_p)
regcache->register_valid_p {
= XCALLOC (descr->sizeof_raw_register_valid_p, gdb_byte); regcache->registers
= XCALLOC (descr->sizeof_cooked_registers, gdb_byte);
regcache->register_valid_p
= XCALLOC (descr->sizeof_cooked_register_valid_p, gdb_byte);
}
else
{
regcache->registers
= XCALLOC (descr->sizeof_raw_registers, gdb_byte);
regcache->register_valid_p
= XCALLOC (descr->sizeof_raw_register_valid_p, gdb_byte);
}
regcache->aspace = aspace; regcache->aspace = aspace;
regcache->readonly_p = 1;
regcache->ptid = minus_one_ptid; regcache->ptid = minus_one_ptid;
return regcache; return regcache;
} }
struct regcache *
regcache_xmalloc (struct gdbarch *gdbarch, struct address_space *aspace)
{
return regcache_xmalloc_1 (gdbarch, aspace, 1);
}
void void
regcache_xfree (struct regcache *regcache) regcache_xfree (struct regcache *regcache)
{ {
@ -382,11 +395,12 @@ regcache_cpy_no_passthrough (struct regcache *dst, struct regcache *src)
/* NOTE: cagney/2002-05-17: Don't let the caller do a no-passthrough /* NOTE: cagney/2002-05-17: Don't let the caller do a no-passthrough
move of data into the current regcache. Doing this would be move of data into the current regcache. Doing this would be
silly - it would mean that valid_p would be completely invalid. */ silly - it would mean that valid_p would be completely invalid. */
gdb_assert (dst->readonly_p); gdb_assert (dst->readonly_p && src->readonly_p);
memcpy (dst->registers, src->registers, dst->descr->sizeof_raw_registers); memcpy (dst->registers, src->registers,
dst->descr->sizeof_cooked_registers);
memcpy (dst->register_valid_p, src->register_valid_p, memcpy (dst->register_valid_p, src->register_valid_p,
dst->descr->sizeof_raw_register_valid_p); dst->descr->sizeof_cooked_register_valid_p);
} }
struct regcache * struct regcache *
@ -399,16 +413,6 @@ regcache_dup (struct regcache *src)
return newbuf; return newbuf;
} }
struct regcache *
regcache_dup_no_passthrough (struct regcache *src)
{
struct regcache *newbuf;
newbuf = regcache_xmalloc (src->descr->gdbarch, get_regcache_aspace (src));
regcache_cpy_no_passthrough (newbuf, src);
return newbuf;
}
int int
regcache_valid_p (const struct regcache *regcache, int regnum) regcache_valid_p (const struct regcache *regcache, int regnum)
{ {
@ -459,9 +463,8 @@ get_thread_arch_regcache (ptid_t ptid, struct gdbarch *gdbarch)
&& get_regcache_arch (list->regcache) == gdbarch) && get_regcache_arch (list->regcache) == gdbarch)
return list->regcache; return list->regcache;
new_regcache = regcache_xmalloc (gdbarch, new_regcache = regcache_xmalloc_1 (gdbarch,
target_thread_address_space (ptid)); target_thread_address_space (ptid), 0);
new_regcache->readonly_p = 0;
new_regcache->ptid = ptid; new_regcache->ptid = ptid;
gdb_assert (new_regcache->aspace != NULL); gdb_assert (new_regcache->aspace != NULL);

View File

@ -154,7 +154,6 @@ extern void regcache_restore (struct regcache *dst,
only transfer values already in the cache. */ only transfer values already in the cache. */
extern struct regcache *regcache_dup (struct regcache *regcache); extern struct regcache *regcache_dup (struct regcache *regcache);
extern struct regcache *regcache_dup_no_passthrough (struct regcache *);
extern void regcache_cpy (struct regcache *dest, struct regcache *src); extern void regcache_cpy (struct regcache *dest, struct regcache *src);
extern void regcache_cpy_no_passthrough (struct regcache *dest, extern void regcache_cpy_no_passthrough (struct regcache *dest,
struct regcache *src); struct regcache *src);