This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[gdbserver] make regcache_supply (..., NULL) use more obvious
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 28 Jan 2011 13:02:55 +0000
- Subject: [gdbserver] make regcache_supply (..., NULL) use more obvious
regcache_supply when passed in a NULL buffer, memset's the register
value instead. I had to ask H.J. before where was this being used,
as my grep foo wasn't find it:
<http://sourceware.org/ml/gdb-patches/2010-10/msg00000.html>
This makes that NULL use more obvious (and simplifies the following patch).
Tested on x86_64-linux gdbserver and applied.
--
Pedro Alves
2011-01-28 Pedro Alves <pedro@codesourcery.com>
gdb/gdbserver/
* i387-fp.c (i387_xsave_to_cache): Make passing NULL as register
buffer explicit.
---
gdb/gdbserver/i387-fp.c | 54 ++++++++++++++++++++++++------------------------
1 file changed, 27 insertions(+), 27 deletions(-)
Index: src/gdb/gdbserver/i387-fp.c
===================================================================
--- src.orig/gdb/gdbserver/i387-fp.c 2011-01-13 15:07:52.516075004 +0000
+++ src/gdb/gdbserver/i387-fp.c 2011-01-28 12:05:59.311415002 +0000
@@ -468,61 +468,61 @@ i387_xsave_to_cache (struct regcache *re
int i, top;
unsigned long val;
unsigned int clear_bv;
- char *p;
+ gdb_byte *p;
/* The supported bits in `xstat_bv' are 1 byte. Clear part in
vector registers if its bit in xstat_bv is zero. */
clear_bv = (~fp->xstate_bv) & x86_xcr0;
/* Check if any x87 registers are changed. */
- if ((x86_xcr0 & I386_XSTATE_X87))
+ if ((x86_xcr0 & I386_XSTATE_X87) != 0)
{
int st0_regnum = find_regno ("st0");
- if ((clear_bv & I386_XSTATE_X87))
- p = NULL;
+ if ((clear_bv & I386_XSTATE_X87) != 0)
+ {
+ for (i = 0; i < 8; i++)
+ supply_register (regcache, i + st0_regnum, NULL);
+ }
else
- p = (char *) buf;
-
- for (i = 0; i < 8; i++)
{
- if (p)
- p = ((char *) &fp->st_space[0]) + i * 16;
- supply_register (regcache, i + st0_regnum, p);
+ p = (gdb_byte *) &fp->st_space[0];
+ for (i = 0; i < 8; i++)
+ supply_register (regcache, i + st0_regnum, p + i * 16);
}
}
- if ((x86_xcr0 & I386_XSTATE_SSE))
+ if ((x86_xcr0 & I386_XSTATE_SSE) != 0)
{
int xmm0_regnum = find_regno ("xmm0");
if ((clear_bv & I386_XSTATE_SSE))
- p = NULL;
+ {
+ for (i = 0; i < num_xmm_registers; i++)
+ supply_register (regcache, i + xmm0_regnum, NULL);
+ }
else
- p = (char *) buf;
-
- for (i = 0; i < num_xmm_registers; i++)
{
- if (p)
- p = ((char *) &fp->xmm_space[0]) + i * 16;
- supply_register (regcache, i + xmm0_regnum, p);
+ p = (gdb_byte *) &fp->xmm_space[0];
+ for (i = 0; i < num_xmm_registers; i++)
+ supply_register (regcache, i + xmm0_regnum, p + i * 16);
}
}
- if ((x86_xcr0 & I386_XSTATE_AVX))
+ if ((x86_xcr0 & I386_XSTATE_AVX) != 0)
{
int ymm0h_regnum = find_regno ("ymm0h");
- if ((clear_bv & I386_XSTATE_AVX))
- p = NULL;
+ if ((clear_bv & I386_XSTATE_AVX) != 0)
+ {
+ for (i = 0; i < num_xmm_registers; i++)
+ supply_register (regcache, i + ymm0h_regnum, NULL);
+ }
else
- p = (char *) buf;
-
- for (i = 0; i < num_xmm_registers; i++)
{
- if (p)
- p = ((char *) &fp->ymmh_space[0]) + i * 16;
- supply_register (regcache, i + ymm0h_regnum, p);
+ p = (gdb_byte *) &fp->ymmh_space[0];
+ for (i = 0; i < num_xmm_registers; i++)
+ supply_register (regcache, i + ymm0h_regnum, p + i * 16);
}
}