This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: mips gdbserver reports R0 != 0


On Thu, Jan 29, 2004 at 10:52:30AM +0900, Atsushi Nemoto wrote:
> >>>>> On Wed, 28 Jan 2004 10:34:15 +0900 (JST), Atsushi Nemoto <anemo@mba.ocn.ne.jp> said:
> drow> Explicitly zeroing the register cache should fix this, so I'd be
> drow> happier with that solution.
> 
> drow> [Do you have a copyright assignment on file for GDB, btw?  If
> drow> not, I'll make the patch myself for you to test, to spare us the
> drow> legal dance.]
> 
> anemo> No, I don't.  Please make the patch for me.  Then I will try
> anemo> it.  Thank you.
> 
> I just inserted a line:
> 
>   memset (regcache->registers, 0, register_bytes);
> 
> to new_register_cache() (regcache.c:108) and it fixed my problem.  I
> don't think anybody can do the legal dance on this line :-)

Indeed.  Thanks!  I've committed this.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

2004-01-30  Daniel Jacobowitz  <drow@mvista.com>

	* regcache.c (new_register_cache): Clear the allocated register
	buffer.  Suggested by Atsushi Nemoto <anemo@mba.ocn.ne.jp>.

Index: regcache.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/regcache.c,v
retrieving revision 1.6
diff -u -p -r1.6 regcache.c
--- regcache.c	13 Jun 2002 19:29:46 -0000	1.6
+++ regcache.c	30 Jan 2004 15:08:48 -0000
@@ -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.");
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]