From: Alan Hayward <Alan.Hayward@arm.com>
To: Luis Machado <lgustavo@codesourcery.com>
Cc: Yao Qi <qiyaoltc@gmail.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
nd <nd@arm.com>
Subject: Re: [PATCH 2/3] Allocate data in cached_reg_t
Date: Wed, 11 Jan 2017 10:54:00 -0000 [thread overview]
Message-ID: <A8159F24-FDED-4444-BB18-1A0336A58B4E@arm.com> (raw)
In-Reply-To: <4553e987-6404-8123-eae7-48f85bf62388@codesourcery.com>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 2085 bytes --]
> On 10 Jan 2017, at 17:42, Luis Machado <lgustavo@codesourcery.com> wrote:
>
> On 01/10/2017 06:59 AM, Yao Qi wrote:
>> On 17-01-09 14:11:13, Luis Machado wrote:
>>>> @@ -6306,7 +6306,7 @@ remote_console_output (char *msg)
>>>> typedef struct cached_reg
>>>> {
>>>> int num;
>>>> - gdb_byte data[MAX_REGISTER_SIZE];
>>>> + gdb_byte *data;
>>>
>>> Would it make sense to go C++ and use a data structure that can take
>>> care of variable sizes? Just thinking if that would be easier than
>>> handling allocation/deallocation of the data.
>>>
>>
>> Do you suggest std::vector? We still need to allocate/deallocate it
>> if we change "gdb_byte *data" to "std::vector<gdb_byte> *data", or we
>> have to convert cached_reg to class, and do RAII.
>>
>
> Something like std::vector, yes. But it is true we will still need to allocate the vector itself.
>
> I was pondering about the benefits of not being limited to a specific register size. Then we wouldn't need to worry about adjusting things as we have to do now.
>
> As i see it, data[register_size(register_size (gdbarch, num)] wouldn't be much different than data[MAX_REGISTER_SIZE]. The only thing is that we're setting the max register size dynamically.
>
> We may or may not need this flexibility right now, but who knows what weird architectures we may have in the future.
I avoided using data[register_size(gdbarch, num)] as dynamically sized arrays are a gcc extension - itâs not something we can expect to work on other compilers.
Plus there is a danger of it using up all the stack. Aarch64 SVE will have a max register size of 256, potentially this could grow further in the future.
This is why I used alloca in patches 1/3 and 2/3.
I know that gcc avoid using std::vector because itâs fairly slow. I think gcc also have newer c++ like replacements for VEC, but am not sure what they have thatâs suitable. However, Iâd suggest thatâs something that should be done as part of the work to move gdb to c++, and not this patch.
Alan.\x16º&Öéj×!zÊÞ¶êç×~µÛ¹b²Ö«r\x18\x1dnr\x17¬
next prev parent reply other threads:[~2017-01-11 10:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-09 10:57 Alan Hayward
2017-01-09 20:11 ` Luis Machado
2017-01-10 12:59 ` Yao Qi
2017-01-10 17:42 ` Luis Machado
2017-01-11 10:54 ` Alan Hayward [this message]
2017-01-18 9:03 ` 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=A8159F24-FDED-4444-BB18-1A0336A58B4E@arm.com \
--to=alan.hayward@arm.com \
--cc=gdb-patches@sourceware.org \
--cc=lgustavo@codesourcery.com \
--cc=nd@arm.com \
--cc=qiyaoltc@gmail.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