* mips gdbserver reports R0 != 0
@ 2004-01-27 10:35 Atsushi Nemoto
2004-01-27 14:17 ` Daniel Jacobowitz
0 siblings, 1 reply; 7+ messages in thread
From: Atsushi Nemoto @ 2004-01-27 10:35 UTC (permalink / raw)
To: gdb-patches
When I run gdbserver with multi-thread programs on Linux/MIPS, I
noticed sometimes 'step' or 'next' do not work correctly. I found
that a value of R0 register in 'info reg' output was not 0
(0x30303030) when this problem happen.
> (gdb) c
> Continuing.
> [New Thread 1026]
> [Switching to Thread 1026]
>
> Breakpoint 2, function1 (arg=0x0) at next.c:30
> 30 if (func1() == 0) {
> (gdb) info reg
> zero at v0 v1 a0 a1 a2 a3
> R0 30303030 30048401 004009c8 00000001 00000000 00000000 7f7ffd28 00000000
I could not see the reason (maybe regcache?), but this patch fixed my
problem.
--- gdb-6.0/gdb/gdbserver/linux-mips-low.c.org Wed Jun 12 02:32:39 2002
+++ gdb-6.0/gdb/gdbserver/linux-mips-low.c Tue Jan 27 19:31:58 2004
@@ -69,9 +69,6 @@
if (mips_regmap[regno] == -1)
return 1;
- if (find_regno ("zero") == regno)
- return 1;
-
return 0;
}
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: mips gdbserver reports R0 != 0
2004-01-27 10:35 mips gdbserver reports R0 != 0 Atsushi Nemoto
@ 2004-01-27 14:17 ` Daniel Jacobowitz
2004-01-27 15:01 ` Atsushi Nemoto
0 siblings, 1 reply; 7+ messages in thread
From: Daniel Jacobowitz @ 2004-01-27 14:17 UTC (permalink / raw)
To: Atsushi Nemoto; +Cc: gdb-patches
On Tue, Jan 27, 2004 at 07:37:15PM +0900, Atsushi Nemoto wrote:
> When I run gdbserver with multi-thread programs on Linux/MIPS, I
> noticed sometimes 'step' or 'next' do not work correctly. I found
> that a value of R0 register in 'info reg' output was not 0
> (0x30303030) when this problem happen.
>
> > (gdb) c
> > Continuing.
> > [New Thread 1026]
> > [Switching to Thread 1026]
> >
> > Breakpoint 2, function1 (arg=0x0) at next.c:30
> > 30 if (func1() == 0) {
> > (gdb) info reg
> > zero at v0 v1 a0 a1 a2 a3
> > R0 30303030 30048401 004009c8 00000001 00000000 00000000 7f7ffd28 00000000
>
> I could not see the reason (maybe regcache?), but this patch fixed my
> problem.
Did it fix the stepping problem, or did it fix the value displayed for
$zero?
The register at that address is actually a saved flag used for syscall
restarting. I have some local patches to support it properly, but I
haven't had time to do anything with them :( Partly because of the
number of gross hacks involved.
> --- gdb-6.0/gdb/gdbserver/linux-mips-low.c.org Wed Jun 12 02:32:39 2002
> +++ gdb-6.0/gdb/gdbserver/linux-mips-low.c Tue Jan 27 19:31:58 2004
> @@ -69,9 +69,6 @@
> if (mips_regmap[regno] == -1)
> return 1;
>
> - if (find_regno ("zero") == regno)
> - return 1;
> -
> return 0;
> }
>
> ---
> Atsushi Nemoto
>
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: mips gdbserver reports R0 != 0
2004-01-27 14:17 ` Daniel Jacobowitz
@ 2004-01-27 15:01 ` Atsushi Nemoto
2004-01-27 17:12 ` Daniel Jacobowitz
0 siblings, 1 reply; 7+ messages in thread
From: Atsushi Nemoto @ 2004-01-27 15:01 UTC (permalink / raw)
To: drow; +Cc: gdb-patches
>>>>> On Tue, 27 Jan 2004 09:17:18 -0500, Daniel Jacobowitz <drow@mvista.com> said:
>> I could not see the reason (maybe regcache?), but this patch fixed
>> my problem.
drow> Did it fix the stepping problem, or did it fix the value
drow> displayed for $zero?
Both. My stepping problem is triggered by wrong $zero value. I tried
with 'set debug remote 1' and found gdb inserted breakpoint at wrong
place when stepping 'beqz' instruction.
drow> The register at that address is actually a saved flag used for
drow> syscall restarting. I have some local patches to support it
drow> properly, but I haven't had time to do anything with them :(
drow> Partly because of the number of gross hacks involved.
The 'that address' means &pt_regs->regs[0] in kernel, right?
I had not noticed that. Thank you. So my patch is not correct.
Maybe the correct fix is clearing register cache in
new_register_cache(). I will try later.
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: mips gdbserver reports R0 != 0
2004-01-27 15:01 ` Atsushi Nemoto
@ 2004-01-27 17:12 ` Daniel Jacobowitz
2004-01-28 1:33 ` Atsushi Nemoto
0 siblings, 1 reply; 7+ messages in thread
From: Daniel Jacobowitz @ 2004-01-27 17:12 UTC (permalink / raw)
To: Atsushi Nemoto; +Cc: gdb-patches
On Wed, Jan 28, 2004 at 12:07:17AM +0900, Atsushi Nemoto wrote:
> >>>>> On Tue, 27 Jan 2004 09:17:18 -0500, Daniel Jacobowitz <drow@mvista.com> said:
>
> >> I could not see the reason (maybe regcache?), but this patch fixed
> >> my problem.
>
> drow> Did it fix the stepping problem, or did it fix the value
> drow> displayed for $zero?
>
> Both. My stepping problem is triggered by wrong $zero value. I tried
> with 'set debug remote 1' and found gdb inserted breakpoint at wrong
> place when stepping 'beqz' instruction.
Oh, I see how this happens now. Thanks for the explanation; in that
case something definitely needs to be done.
> drow> The register at that address is actually a saved flag used for
> drow> syscall restarting. I have some local patches to support it
> drow> properly, but I haven't had time to do anything with them :(
> drow> Partly because of the number of gross hacks involved.
>
> The 'that address' means &pt_regs->regs[0] in kernel, right?
>
> I had not noticed that. Thank you. So my patch is not correct.
>
> Maybe the correct fix is clearing register cache in
> new_register_cache(). I will try later.
Explicitly zeroing the register cache should fix this, so I'd be
happier with that solution.
[Do you have a copyright assignment on file for GDB, btw? If not, I'll
make the patch myself for you to test, to spare us the legal dance.]
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: mips gdbserver reports R0 != 0
2004-01-27 17:12 ` Daniel Jacobowitz
@ 2004-01-28 1:33 ` Atsushi Nemoto
2004-01-29 1:51 ` Atsushi Nemoto
0 siblings, 1 reply; 7+ messages in thread
From: Atsushi Nemoto @ 2004-01-28 1:33 UTC (permalink / raw)
To: drow; +Cc: gdb-patches
>>>>> On Tue, 27 Jan 2004 12:12:04 -0500, Daniel Jacobowitz <drow@mvista.com> said:
>> Maybe the correct fix is clearing register cache in
>> new_register_cache(). I will try later.
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.]
No, I don't. Please make the patch for me. Then I will try it.
Thank you.
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: mips gdbserver reports R0 != 0
2004-01-28 1:33 ` Atsushi Nemoto
@ 2004-01-29 1:51 ` Atsushi Nemoto
2004-01-30 15:09 ` Daniel Jacobowitz
0 siblings, 1 reply; 7+ messages in thread
From: Atsushi Nemoto @ 2004-01-29 1:51 UTC (permalink / raw)
To: drow; +Cc: gdb-patches
>>>>> 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 :-)
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: mips gdbserver reports R0 != 0
2004-01-29 1:51 ` Atsushi Nemoto
@ 2004-01-30 15:09 ` Daniel Jacobowitz
0 siblings, 0 replies; 7+ messages in thread
From: Daniel Jacobowitz @ 2004-01-30 15:09 UTC (permalink / raw)
To: gdb-patches; +Cc: Atsushi Nemoto
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.");
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-01-30 15:09 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-27 10:35 mips gdbserver reports R0 != 0 Atsushi Nemoto
2004-01-27 14:17 ` Daniel Jacobowitz
2004-01-27 15:01 ` Atsushi Nemoto
2004-01-27 17:12 ` Daniel Jacobowitz
2004-01-28 1:33 ` Atsushi Nemoto
2004-01-29 1:51 ` Atsushi Nemoto
2004-01-30 15:09 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox