Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Wei-min Pan <weimin.pan@oracle.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] break gdb build on 32-bit host with ADI support
Date: Thu, 24 Aug 2017 21:51:00 -0000	[thread overview]
Message-ID: <0cc71221-6713-a449-fb49-65be69507e70@redhat.com> (raw)
In-Reply-To: <1ed3ad56-1f9e-a6a7-7736-741989c5ed86@oracle.com>

On 08/24/2017 09:27 PM, Wei-min Pan wrote:

>>>> Use paddress instead?  Also spaces around '*' and after the cast.
>>> Where is paddress defined? I tried casting to "uint64" which yields to
>>> "unsigned long" on a 64-bit host and didn't bode well with %llx.
>>   $ grep paddress *.h
>>   utils.h:extern const char *paddress (struct gdbarch *gdbarch,
>> CORE_ADDR addr);
> 
> On a 64-bit host:
> ...
> sparc64-tdep.c: In function 'void do_assign(CORE_ADDR, size_t, int)':
> sparc64-tdep.c:449:56: error: expected ')' before 'vaddr'
>      error(_("No ADI information at 0x%llx"), (paddress)vaddr);
>                                                         ^~~~~
> sparc64-tdep.c:449:61: error: format '%llx' expects argument of type
> 'long long
> unsigned int', but argument 2 has type 'const char* (*)(gdbarch*,
> CORE_ADDR) {ak
> a const char* (*)(gdbarch*, long unsigned int)}' [-Werror=format=]
>      error(_("No ADI information at 0x%llx"), (paddress)vaddr);
>                                                              ^
> cc1plus: all warnings being treated as errors
> make: *** [sparc64-tdep.o] Error 1

Of course.  paddress is a function.  See any of the other ~400 uses
in the tree.  Something like:

 error(_("No ADI information at %s"), paddress (gdbarch, vaddr));

>>>> looks suspiciously bogus to me.  Consider a 32-bit host
>>>> remote/cross debugging a SPARC64 target machine.  Also consider
>>>> a Win64-hosted GDB.
>>> Good point. Changing it to:
>>>
>>>        return ((long long)(((long long)addr << ast.nbits) >>
>>> ast.nbits));
>>>
>>> Thanks.
>> Still looks odd to me.
>> Why are you shifting signed types, for instance?
>> Any why do you need the casts in the first place, BTW?
> 
> We need to sign extend to get a normalized address, based on the
> definitions in ADI space:
> 
>         ADI versioned address - a VA with ADI bits (63-60) set
>         Normalized address - a VA with bit 59 sign extended into ADI bits

OK, but then please do it with valid/portable C/C++ code, with
the usual masking and xoring.
Left shifting signed integer values is undefined C++11.
Right shifting a signed integer is implementation defined.

Thanks,
Pedro Alves


      reply	other threads:[~2017-08-24 21:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-24 17:34 Weimin Pan
2017-08-24 18:07 ` Pedro Alves
2017-08-24 19:09   ` Wei-min Pan
2017-08-24 19:23     ` Pedro Alves
2017-08-24 20:27       ` Wei-min Pan
2017-08-24 21:51         ` Pedro Alves [this message]

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=0cc71221-6713-a449-fb49-65be69507e70@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=weimin.pan@oracle.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