public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Alan Hayward <Alan.Hayward@arm.com>
To: Pedro Alves <palves@redhat.com>
Cc: Yao Qi <qiyaoltc@gmail.com>,
	"gdb-patches@sourceware.org"	<gdb-patches@sourceware.org>,
	nd <nd@arm.com>
Subject: Re: [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE (2/4)
Date: Wed, 24 May 2017 10:20:00 -0000	[thread overview]
Message-ID: <F9111331-8942-4E4A-A495-1007A0488E3B@arm.com> (raw)
In-Reply-To: <40597975-9458-e9af-8915-9d303bb1ed98@redhat.com>


> On 24 May 2017, at 10:20, Pedro Alves <palves@redhat.com> wrote:
> 
> On 05/24/2017 10:07 AM, Alan Hayward wrote:
> 
>>> Hmm, I think you may have misunderstood.  The main point was to
>>> avoid having to have T/LONGEST temporary at all here:
> 
> ...
> 
>>> 
>>> and maybe the need for all the templating.
>>> 
>> 
>> Would still need to have eater signed/unsigned versions of the functions,
>> or maybe have “bool signed” parameter.
> 
> Parameter sounds fine to me.
> 
>> Are you suggesting something like this:
>> (Warning - this snippet may not even compile, and I’m not sure on the endian
>> logic)
> 
> Yes, exactly.  WDYT?

I’m happy in principle with it (after fix ups)

> 
>> Meanwhile raw_collect_integer doesn’t need a signed parameter:
> 
> Wouldn't we need to support ADDR_LEN larger than the register size?

This might be me misunderstanding gdb,
But I assumed that addr would always be shorter than the register size.
If addr is bigger than the register size then the most significant bits will
be chopped off (including the sign), which I think would be a bad idea?


> 
> On 24 May 2017, at 10:29, Pedro Alves <palves@redhat.com> wrote:
> 
> On 05/24/2017 10:07 AM, Alan Hayward wrote:
>> /* Copy COPY_LEN bytes from SOURCE to DEST, then sign extend or zero extend
>>   to FILL_LEN bytes.  */
>> void copy_and_fill_to_size (const gdb_byte *dest, const gdb_byte *source,
>> 			    int copy_len, int fill_len, bool is_signed,
>> 			    enum bfd_endian byte_order)
>> {
>>  signed int len_diff = fill_len - copy_len;
>>  gdb_assert (len_diff >= 0);
>> 
>>  if (byte_order == BFD_ENDIAN_BIG)
>>    memcpy (dest+len_diff, source, copy_len);
>>  else
>>    memcpy (dest, source, copy_len);
> 
> Note here I was thinking you'd need to handle truncation as well.
> I.e., only copy fill_len bytes when fill_len is narrower than
> copy_len.  So I'd probably rename copy_len/fill_len to dest_len/source_len
> to match 'dest' and 'source', and name the function something
> else that doesn't have "fill" in it.

Agreed (regardless of the outcome for the previous question).


Alan.



  reply	other threads:[~2017-05-24 10:20 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-04 10:12 [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE Alan Hayward
2017-04-04 17:19 ` John Baldwin
2017-04-05 10:27   ` Alan Hayward
2017-04-11 15:37 ` Yao Qi
2017-05-05  8:03   ` [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE (1/4) Alan Hayward
2017-05-05 21:44     ` Yao Qi
2017-05-05  8:04   ` [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE (2/4) Alan Hayward
2017-05-05 19:51     ` John Baldwin
2017-05-12  8:53     ` Yao Qi
2017-05-16 11:16       ` Alan Hayward
2017-05-22 12:07         ` Yao Qi
2017-05-22 16:05           ` Alan Hayward
2017-05-22 17:15             ` Pedro Alves
2017-05-23 17:49               ` Alan Hayward
2017-05-23 18:30                 ` Pedro Alves
2017-05-24  9:08                   ` Alan Hayward
2017-05-24  9:20                     ` Pedro Alves
2017-05-24 10:20                       ` Alan Hayward [this message]
2017-05-24 11:07                         ` Pedro Alves
2017-05-24 19:45                           ` Alan Hayward
2017-05-25 10:46                             ` Pedro Alves
2017-05-25 11:43                               ` Yao Qi
2017-05-25 11:48                                 ` Pedro Alves
2017-05-26  8:54                                   ` Alan Hayward
2017-05-26 10:26                                     ` Pedro Alves
2017-05-26 15:30                                       ` Alan Hayward
2017-05-26 15:49                                         ` Pedro Alves
2017-05-26 16:18                                           ` Alan Hayward
2017-05-26 16:00                                         ` John Baldwin
2017-05-24  9:29                     ` Pedro Alves
2017-05-05  8:04   ` [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE (3/4) Alan Hayward
2017-05-05 21:54     ` Yao Qi
2017-05-05  8:04   ` [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE (4/4) Alan Hayward
2017-06-07  8:31     ` Alan Hayward
2017-06-08 20:27       ` Maciej W. Rozycki
2017-06-09 10:31         ` Alan Hayward
2017-06-09 11:03           ` Pedro Alves
2017-06-09 11:48             ` Maciej W. Rozycki
2017-06-09 12:05               ` Pedro Alves
2017-06-09 13:23                 ` Maciej W. Rozycki
2017-06-09 14:29                   ` Pedro Alves
2017-06-12  9:09                     ` Alan Hayward
2017-06-12 18:11                       ` Pedro Alves
2017-06-12 14:29                     ` 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=F9111331-8942-4E4A-A495-1007A0488E3B@arm.com \
    --to=alan.hayward@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=nd@arm.com \
    --cc=palves@redhat.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).