Search code examples
cgdb

why does gdb increment memory addresses in units of 10


I'm trying to understand why gdb shows memory addresses in increments of 10[hex]. I have compiled my c program with -m32 -z execstack -fno-stack-protector flags and turned of ASLR.

When I debug my program, it shows me the following enter image description here

When I attempt to query the next address it appears to cycle through the bytes

enter image description here

I'm having trouble understanding this behavior of gdb.

Furthermore, if I create a char buf[n] size of n in my c program I can't accurately count the space used by buf while debugging, I'm wondering how the cycling effect plays into this as well.


Solution

  • I think your are confused by little-endian (of 32-bit integers):

    In memory the first 8 bytes are

    0x54ffffc5 -> c5 ff ff 54
    0x54ffffc5 -> c5 ff ff 54
    

    so if you step one byte in memory you will find

    <skip first byte> ff ff 54 c5 ff ff 54 ...
    

    so you see (as 32-bit integer)

    ff ff 54 c5 -> 0xc554ffff