/* Register support routines for the remote server for GDB.
- Copyright 2001, 2002
+ Copyright (C) 2001, 2002, 2004, 2005
Free Software Foundation, Inc.
This file is part of GDB.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
#include "server.h"
#include "regdef.h"
struct inferior_regcache_data
{
int registers_valid;
- char *registers;
+ unsigned char *registers;
};
static int register_bytes;
regcache = malloc (sizeof (*regcache));
- regcache->registers = malloc (register_bytes);
+ /* Make sure to zero-initialize the register cache when it is created,
+ in case there are registers the target never fetches. This way they'll
+ read as zero instead of garbage. */
+ regcache->registers = calloc (1, register_bytes);
if (regcache->registers == NULL)
fatal ("Could not allocate register cache.");
void
registers_to_string (char *buf)
{
- char *registers = get_regcache (current_inferior, 1)->registers;
+ unsigned char *registers = get_regcache (current_inferior, 1)->registers;
convert_int_to_ascii (registers, buf, register_bytes);
}
registers_from_string (char *buf)
{
int len = strlen (buf);
- char *registers = get_regcache (current_inferior, 1)->registers;
+ unsigned char *registers = get_regcache (current_inferior, 1)->registers;
if (len != register_bytes * 2)
{
return reg_defs[n].size / 8;
}
-static char *
+static unsigned char *
register_data (int n, int fetch)
{
- char *registers = get_regcache (current_inferior, fetch)->registers;
+ unsigned char *registers
+ = get_regcache (current_inferior, fetch)->registers;
return registers + (reg_defs[n].offset / 8);
}