7

This is the display of my gdb

(gdb) x/20bx 0xbffff2c0
0xbffff2c0: 0xd4    0xf2    0xff    0xbf    0x16    0x8f    0x04    0x08
0xbffff2c8: 0x05    0x00    0x00    0x00    0x00    0x00    0x0c    0x42
0xbffff2d0: 0x6b    0x00    0x00    0x00

Is is possible to change it to 4 bytes in a row?

3 Answers 3

8

gdb (at least in the 7.1 and 7.6 source I looked at) hard-wires the maximum number of elements per line that x will print, based on the format.

maxelts = 8;
if (size == 'w')
  maxelts = 4;
if (size == 'g')
  maxelts = 2;
if (format == 's' || format == 'i')
  maxelts = 1;

A workaround to get what you want is to type x/4bx 0xbffff2c0 to print 4 elements and then type just enter to print each successive set of 4 elements.

Sign up to request clarification or add additional context in comments.

Comments

5

Use x/20wx

(gdb) x/20bx &result
0x7fff5fbff5f4: 0xff    0x7f    0x00    0x00    0x5e    0x10    0xc0    0x5f
0x7fff5fbff5fc: 0xff    0x7f    0x00    0x00    0x10    0xf6    0xbf    0x5f
0x7fff5fbff604: 0xff    0x7f    0x00    0x00

(gdb) x/20wx &result
0x7fff5fbff5f4: 0x00007fff  0x5fc0105e  0x00007fff  0x5fbff610
0x7fff5fbff604: 0x00007fff  0x8994d5fd  0x00007fff  0x00000000
0x7fff5fbff614: 0x00000000  0x00000001  0x00000000  0x5fbff7e8
0x7fff5fbff624: 0x00007fff  0x00000000  0x00000000  0x5fbff804
0x7fff5fbff634: 0x00007fff  0x5fbff830  0x00007fff  0x5fbff847

1 Comment

Oh. I mean row 1 start from 0xbffff2c0' row 2 start from 0xbffff2c4`.. Sorry for didn't make things clear
0

I use python to wrap the original output from gdb, then adjust it's format as requested in the question, then output to the console.

@user229044 I think you should focus on the method I provide.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.