From: "Maciej W. Rozycki" <macro@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH] Linux/gdbserver: Clean up fetch_register and store_register
Date: Tue, 22 Nov 2011 16:08:00 -0000 [thread overview]
Message-ID: <alpine.DEB.1.10.1111221427160.4191@tp.orcam.me.uk> (raw)
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);
next reply other threads:[~2011-11-22 16:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-22 16:08 Maciej W. Rozycki [this message]
2011-12-06 19:33 ` Pedro Alves
2011-12-06 23:20 ` Maciej W. Rozycki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.1.10.1111221427160.4191@tp.orcam.me.uk \
--to=macro@codesourcery.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox