From: Yao Qi <qiyaoltc@gmail.com>
To: Pedro Alves <palves@redhat.com>
Cc: Alan Hayward <Alan.Hayward@arm.com>,
"gdb-patches\@sourceware.org" <gdb-patches@sourceware.org>,
Subject: Re: extract_unsigned_integer API (Re: [PATCH] Remove MAX_REGISTER_SIZE from frame.c)
Date: Mon, 03 Apr 2017 13:58:00 -0000 [thread overview]
Message-ID: <86d1ctlhin.fsf@gmail.com> (raw)
In-Reply-To: <2427e9d3-4d91-7d63-a8e4-36aeb233b86e@redhat.com> (Pedro Alves's message of "Tue, 28 Mar 2017 23:23:24 +0100")
Pedro Alves <palves@redhat.com> writes:
> Thinking about this a bit more, if we went this direction, I think the
> simplest would be to add an extract::size() method that returned the
> size of the buffer, and use that for bounds when filling in the
> data, like:
>
> extractor extr;
> frame_unwind_register (frame, regnum, ext.buffer (), ext.size ());
> return extr.extract (type_len, byte_order);
>
> If type_len is larger than the buffer size, then we'll still get an
> error either inside extractor::extract, and maybe earlier
> inside frame_unwind_register (if it had that size parameter).
Yes, that is the simplest way.
>
> Though for the particular case of frame_unwind_register, since the
> frame machinery works with struct value's, inside frame_unwind_register
> there's going to be a value created already, and that has a contents
> buffer we could access directly. So e.g.,
> inside frame_unwind_register_signed, we should be able to use
> frame_unwind_register_value directly thus avoid the need for the local
> buffer and copying data.
How is the patch below?
--
Yao (齐尧)
From d8f91babfcd6810ff4942aa8275d3d447ae1a83a Mon Sep 17 00:00:00 2001
From: Yao Qi <yao.qi@linaro.org>
Date: Wed, 29 Mar 2017 16:49:11 +0100
Subject: [PATCH] Use frame_unwind_register_value in
frame_unwind_register_unsigned
gdb:
2017-03-29 Yao Qi <yao.qi@linaro.org>
* frame.c (frame_unwind_register_unsigned): Call
frame_unwind_register_value.
---
gdb/frame.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/gdb/frame.c b/gdb/frame.c
index d98003d..a10f3e5 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1270,10 +1270,27 @@ frame_unwind_register_unsigned (struct frame_info *frame, int regnum)
struct gdbarch *gdbarch = frame_unwind_arch (frame);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int size = register_size (gdbarch, regnum);
- gdb_byte buf[MAX_REGISTER_SIZE];
+ struct value *value = frame_unwind_register_value (frame, regnum);
- frame_unwind_register (frame, regnum, buf);
- return extract_unsigned_integer (buf, size, byte_order);
+ gdb_assert (value != NULL);
+
+ if (value_optimized_out (value))
+ {
+ throw_error (OPTIMIZED_OUT_ERROR,
+ _("Register %d was not saved"), regnum);
+ }
+ if (!value_entirely_available (value))
+ {
+ throw_error (NOT_AVAILABLE_ERROR,
+ _("Register %d is not available"), regnum);
+ }
+
+ ULONGEST r = extract_unsigned_integer (value_contents_all (value), size,
+ byte_order);
+
+ release_value (value);
+ value_free (value);
+ return r;
}
ULONGEST
--
1.9.1
next prev parent reply other threads:[~2017-04-03 13:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-24 10:01 [PATCH] Remove MAX_REGISTER_SIZE from frame.c Alan Hayward
2017-03-01 12:32 ` Yao Qi
2017-03-24 14:49 ` Alan Hayward
2017-04-03 20:41 ` Yao Qi
2017-03-28 14:09 ` extract_unsigned_integer API (Re: [PATCH] Remove MAX_REGISTER_SIZE from frame.c) Pedro Alves
2017-03-28 16:13 ` Yao Qi
2017-03-28 16:57 ` Pedro Alves
2017-03-28 22:23 ` Pedro Alves
2017-04-03 13:58 ` Yao Qi [this message]
2017-04-04 11:01 ` Pedro Alves
2017-04-05 13:56 ` Yao Qi
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=86d1ctlhin.fsf@gmail.com \
--to=qiyaoltc@gmail.com \
--cc=Alan.Hayward@arm.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
/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