This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH V3] Add negative repeat count to 'x' command
- From: Pedro Alves <palves at redhat dot com>
- To: Simon Marchi <simon dot marchi at ericsson dot com>, Toshihito Kikuchi <k dot toshihito at yahoo dot de>, gdb-patches at sourceware dot org
- Date: Tue, 24 May 2016 19:26:36 +0100
- Subject: Re: [PATCH V3] Add negative repeat count to 'x' command
- Authentication-results: sourceware.org; auth=none
- References: <1461866539-24965-1-git-send-email-k dot toshihito at yahoo dot de> <c2d74e3a-d818-2af2-613e-57ce6bec97f9 at redhat dot com> <57433C3B dot 7000300 at yahoo dot de> <411a982a-a550-a8b7-81f3-7f7ef2aba863 at redhat dot com> <57449708 dot 2060604 at ericsson dot com>
On 05/24/2016 07:01 PM, Simon Marchi wrote:
> On 16-05-24 07:16 AM, Pedro Alves wrote:
>> Similar question with MMU targets though. Should "x/-1 0" wrap around
>> to a high address? If it does, it should wrap around taking into account
>> target address width. Say, on 32-bit, "0-1" is 0x0..0ffffffff not
>> 0xffffffffffffffff, even if gdb to use 64-bits for CORE_ADDR internally.
>> Does that work correctly?
>
> Does gdb know what's the upper limit of the address space?
There's gdbarch_addr_bit (and gdbarch_ptr_bit).
GDB gets it right if the expressions are done on target pointers:
(gdb) set architecture i386
The target architecture is assumed to be i386
(gdb) p ((char*)0)-1
$1 = 0xffffffff <error: Cannot access memory at address 0xffffffff>
(gdb) set architecture i386:x86-64
The target architecture is assumed to be i386:x86-64
(gdb) p ((char*)0)-1
$2 = 0xffffffffffffffff <error: Cannot access memory at address 0xffffffffffffffff>
> This is also a problem for arches with multiple memory spaces that use the
> high bits as address space identifier. Let's say I do x/-3s from
> 0x200000040 and it underflows, GDB might try to read from 0x1ffffffd0 for
> example, which makes no sense. I don't know if/how we can avoid it, as
> long as we use this hack for representing multiple address spaces in a
> single inferior. Anyway, it's not this patch's fault, so you can certainly
> ignore it.
Yeah.
Thanks,
Pedro Alves