This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v2] break gdb build on 32-bit host with ADI support
- From: Pedro Alves <palves at redhat dot com>
- To: Weimin Pan <weimin dot pan at oracle dot com>, gdb-patches at sourceware dot org
- Date: Fri, 25 Aug 2017 11:18:02 +0100
- Subject: Re: [PATCH v2] break gdb build on 32-bit host with ADI support
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D01B3356D9
- References: <1503624784-124602-1-git-send-email-weimin.pan@oracle.com>
$subject should be "unbreak", I hope. :-)
On 08/25/2017 02:33 AM, Weimin Pan wrote:
> @@ -240,7 +242,7 @@ adi_normalize_address (CORE_ADDR addr)
> adi_stat_t ast = get_adi_info (ptid_get_pid (inferior_ptid));
>
> if (ast.nbits)
> - return ((CORE_ADDR)(((long)addr << ast.nbits) >> ast.nbits));
> + return (addr & ((1 << ast.nbits) - 1)) ^ (addr & (-1 >> ast.nbits));
How did you test this? Doesn't look right to me.
Also, "-1 >>" is still an implementation-defined signed
right shift.
I _think_ this is what you want:
/* Clear upper bits. */
addr &= ((uint64_t) -1) >> ast.nbits;
/* Sign extend. */
CORE_ADDR signbit = (uint64_t) 1 << (64 - ast.nbits - 1);
return (addr ^ signbit) - signbit;
I.e., with ast.nbits == 4:
before: ffffffffffffffff
after: ffffffffffffffff
before: f7ffffffffffffff
after: 07ffffffffffffff
Thanks,
Pedro Alves