Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

gdb: Examine memory & display width

2,114 views
Skip to first unread message

Florian Kaufmann

unread,
Sep 15, 2008, 3:30:15 PM9/15/08
to
I actual have a question about gdb. I didn't found a frequently used
gdb group, so I hope this group here is the best to post.

I am trying to customize the output of x such that I only get one
column.

I do:
(gdb) set width 22
(gdb) x/4xw myvar
0x22c8b0: 0x00000000 0x00000000 0x00000000 0x00000000

But it rather like to get:
0x22c8b0: 0x00000000
0x22c8b4: 0x00000000
0x22c8b8: 0x00000000
0x22c8bC: 0x00000000

What am I missing?


sve...@gmail.com

unread,
Sep 18, 2008, 5:19:24 AM9/18/08
to
As far as I know, there's no way to get x to behave like that. Even if
it does respect the line width, it will just wrap. You might consider
defining your own command, something like:

x /xw myvar
x /xw myvar + 1
x /xw myvar + 2
x /xw myvar + 3

Of course a custom command would be harder to make more general if you
aren't always looking for this exact type of output.

Paul Pluzhnikov

unread,
Sep 19, 2008, 12:08:04 AM9/19/08
to
Florian Kaufmann <sens...@gmail.com> writes:

> I am trying to customize the output of x such that I only get one
> column.
>

> (gdb) x/4xw myvar
> 0x22c8b0: 0x00000000 0x00000000 0x00000000 0x00000000
>
> But it rather like to get:
> 0x22c8b0: 0x00000000
> 0x22c8b4: 0x00000000
> 0x22c8b8: 0x00000000
> 0x22c8bC: 0x00000000
>
> What am I missing?

GDB isn't flexible that way :(
The code in gdb/printcmd.c reads:

do_examine (struct format_data fmt, CORE_ADDR addr)
...
maxelts = 8;
if (size == 'w')
maxelts = 4;
if (size == 'g')
maxelts = 2;
if (format == 's' || format == 'i')
maxelts = 1;

and then prints maxelts elements per line.

The good news is that you can build your own GDB which will do
exactly what you want.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.

federic...@gmail.com

unread,
Mar 27, 2014, 6:47:15 PM3/27/14
to
This is how, for instance, I print the current stack frame. Should be adjusted to any need.

set $pos = 0
while ($pos < ($ebp-$esp))
>x/wx $ebp-$pos
>set $pos = $pos + 4
>end

0xbffffc88: 0xbffffd08 <--- $ebp
0xbffffc84: 0x00000000
0xbffffc80: 0x080486d0
0xbffffc7c: 0x00000011
0xbffffc78: 0x0000000f
0xbffffc74: 0x0000000b
0xbffffc70: 0x00000009
0xbffffc6c: 0x00000007
0xbffffc68: 0x00000006
0xbffffc64: 0x00000014
0xbffffc60: 0x00000010
0xbffffc5c: 0x0000000e
0xbffffc58: 0x0000000a
0xbffffc54: 0x00000008
0xbffffc50: 0x00000006
0xbffffc4c: 0x00000005
0xbffffc48: 0x00000013
0xbffffc44: 0x0000000f
0xbffffc40: 0x0000000d
0xbffffc3c: 0x00000009
0xbffffc38: 0x00000007
0xbffffc34: 0x00000005
0xbffffc30: 0x00000004
0xbffffc2c: 0x00000012
0xbffffc28: 0x0000000e
0xbffffc24: 0x0000000c
0xbffffc20: 0x00000008
0xbffffc1c: 0x00000006
0xbffffc18: 0x00000004
0xbffffc14: 0x00000003
0xbffffc10: 0x00000011
0xbffffc0c: 0x0000000d
0xbffffc08: 0x0000000b
0xbffffc04: 0x00000007
0xbffffc00: 0x00000005
0xbffffbfc: 0x00000003
0xbffffbf8: 0x00000002
0xbffffbf4: 0xbffffcb4
0xbffffbf0: 0xb7fffac0
0xbffffbec: 0xbffffce0 <-- $esp

korov...@gmail.com

unread,
Jul 8, 2014, 3:52:00 PM7/8/14
to
set $start = <start_address>
(gdb) while ($start <= 0xa7059d6c)
>x/1xw $start
>set $start = $start + 4
>end

sebastien...@frameip.com

unread,
Jun 2, 2015, 8:20:31 PM6/2/15
to
Hi,

I'm looking wich command i must use with gdb
I attach the good process (gbp -p xxx) and i want looking all address of the memory with the value 700.

Can you help me ?

0 new messages