* [PATCH] Linux/gdbserver: Clean up fetch_register and store_register
@ 2011-11-22 16:08 Maciej W. Rozycki
2011-12-06 19:33 ` Pedro Alves
0 siblings, 1 reply; 3+ messages in thread
From: Maciej W. Rozycki @ 2011-11-22 16:08 UTC (permalink / raw)
To: gdb-patches
Hi,
More changes to fetch_register and store_register -- the two functions
complement each other but their code looks as if they were written
independently and then at one point included here together.
This is an overall cleanup, although by no means exhaustive -- there are
still some minor issues I did not want to address lest I got buried into
this cleanup forever. Apart from obvious formatting fixes there are two
minor functional changes -- the result of .cannot_store_register is now
checked for a non-zero rather than explicit one. This change makes the
API of this backend consistent with that of .cannot_fetch_register. The
other change moves the retrieval of the PID used by ptrace in
fetch_register to immediately precede the loop it is used in, just like in
store_register.
No regressions on i686-linux-gnu or mips-linux-gnu (like with the
previous change I had to force srv_linux_regsets to "no" and deal with
some bitrot of that configuration to get indicative results). OK to
apply?
2011-11-22 Maciej W. Rozycki <macro@codesourcery.com>
gdb/gdbserver/
* linux-low.c (fetch_register, store_register): Make code
consistent, fix formatting.
Maciej
gdb-gdbserver-linux-fetch-store-format.diff
Index: gdb-fsf-trunk-quilt/gdb/gdbserver/linux-low.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/gdbserver/linux-low.c 2011-11-18 17:21:54.425560931 +0000
+++ gdb-fsf-trunk-quilt/gdb/gdbserver/linux-low.c 2011-11-18 17:21:54.445622134 +0000
@@ -3745,10 +3745,11 @@ fetch_register (struct regcache *regcach
if (regaddr == -1)
return;
- pid = lwpid_of (get_thread_lwp (current_inferior));
size = ((register_size (regno) + sizeof (PTRACE_XFER_TYPE) - 1)
- & - sizeof (PTRACE_XFER_TYPE));
+ & -sizeof (PTRACE_XFER_TYPE));
buf = alloca (size);
+
+ pid = lwpid_of (get_thread_lwp (current_inferior));
for (i = 0; i < size; i += sizeof (PTRACE_XFER_TYPE))
{
errno = 0;
@@ -3779,16 +3780,15 @@ store_register (struct regcache *regcach
if (regno >= the_low_target.num_regs)
return;
-
- if ((*the_low_target.cannot_store_register) (regno) == 1)
+ if ((*the_low_target.cannot_store_register) (regno))
return;
regaddr = register_addr (regno);
if (regaddr == -1)
return;
- errno = 0;
- size = (register_size (regno) + sizeof (PTRACE_XFER_TYPE) - 1)
- & - sizeof (PTRACE_XFER_TYPE);
+
+ size = ((register_size (regno) + sizeof (PTRACE_XFER_TYPE) - 1)
+ & -sizeof (PTRACE_XFER_TYPE));
buf = alloca (size);
memset (buf, 0, size);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Linux/gdbserver: Clean up fetch_register and store_register
2011-11-22 16:08 [PATCH] Linux/gdbserver: Clean up fetch_register and store_register Maciej W. Rozycki
@ 2011-12-06 19:33 ` Pedro Alves
2011-12-06 23:20 ` Maciej W. Rozycki
0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2011-12-06 19:33 UTC (permalink / raw)
To: gdb-patches; +Cc: Maciej W. Rozycki
On Tuesday 22 November 2011 16:08:22, Maciej W. Rozycki wrote:
> No regressions on i686-linux-gnu or mips-linux-gnu (like with the
> previous change I had to force srv_linux_regsets to "no" and deal with
> some bitrot of that configuration to get indicative results). OK to
> apply?
Okay. Thanks.
>
> 2011-11-22 Maciej W. Rozycki <macro@codesourcery.com>
>
> gdb/gdbserver/
> * linux-low.c (fetch_register, store_register): Make code
> consistent, fix formatting.
--
Pedro Alves
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Linux/gdbserver: Clean up fetch_register and store_register
2011-12-06 19:33 ` Pedro Alves
@ 2011-12-06 23:20 ` Maciej W. Rozycki
0 siblings, 0 replies; 3+ messages in thread
From: Maciej W. Rozycki @ 2011-12-06 23:20 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
On Tue, 6 Dec 2011, Pedro Alves wrote:
> > No regressions on i686-linux-gnu or mips-linux-gnu (like with the
> > previous change I had to force srv_linux_regsets to "no" and deal with
> > some bitrot of that configuration to get indicative results). OK to
> > apply?
>
> Okay. Thanks.
>
> > 2011-11-22 Maciej W. Rozycki <macro@codesourcery.com>
> >
> > gdb/gdbserver/
> > * linux-low.c (fetch_register, store_register): Make code
> > consistent, fix formatting.
This one applied now too, thanks.
Maciej
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-12-06 23:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-22 16:08 [PATCH] Linux/gdbserver: Clean up fetch_register and store_register Maciej W. Rozycki
2011-12-06 19:33 ` Pedro Alves
2011-12-06 23:20 ` Maciej W. Rozycki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox