This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH V3] Add negative repeat count to 'x' command


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]