From: Daniel Jacobowitz Date: Fri, 30 Jan 2004 15:08:57 +0000 (+0000) Subject: * regcache.c (new_register_cache): Clear the allocated register X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2a68b70e968968e8f47030cdf6369f1e6fef4d57;p=binutils-gdb.git * regcache.c (new_register_cache): Clear the allocated register buffer. Suggested by Atsushi Nemoto . --- diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 603c33f2527..ea3fca9ea25 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,8 @@ +2004-01-30 Daniel Jacobowitz + + * regcache.c (new_register_cache): Clear the allocated register + buffer. Suggested by Atsushi Nemoto . + 2003-10-13 Daniel Jacobowitz * linux-low.c (linux_resume): Take a struct thread_resume * diff --git a/gdb/gdbserver/regcache.c b/gdb/gdbserver/regcache.c index be3b3a7f33e..bc64ebcbb97 100644 --- a/gdb/gdbserver/regcache.c +++ b/gdb/gdbserver/regcache.c @@ -1,5 +1,5 @@ /* Register support routines for the remote server for GDB. - Copyright 2001, 2002 + Copyright 2001, 2002, 2004 Free Software Foundation, Inc. This file is part of GDB. @@ -101,7 +101,10 @@ new_register_cache (void) 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.");