bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GDB all VERSION


From: Pedro Alves
Subject: Re: GDB all VERSION
Date: Mon, 04 Feb 2013 16:03:37 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

On 02/01/2013 10:04 PM, sfddfsd wrote:
> view the stack with x/8x $esp .
> 
> 0xbffff960:    0x080484e0    0xbffffbb1    0x0804846b    0xb7fc4ff4
> 0xbffff970:    0x08048460    0x00000000    0xbffff9f8    0xb7e96e16
> 
> and print the string with value proof 0xbffffbb1 .
> 
> (gdb)x/s 0xbffffbb1
> 0xbffffbb1:    "proof"
> 
> print the newly the stack with x/8x $esp and the result is.
> 
> 0xbffff960:    0xe0    0x84    0x04    0x08    0xb1    0xfb    0xff    0xbf
> 
> do you understand ??, this bug is in all version of gdb .

 (gdb) help x
 Examine memory: x/FMT ADDRESS.
 ADDRESS is an expression for the memory address to examine.
 FMT is a repeat count followed by a format letter and a size letter.
 Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),
   t(binary), f(float), a(address), i(instruction), c(char) and s(string).
 Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).
 The specified number of objects of the specified size are printed
 according to the format.

 Defaults for format and size letters are those previously used.
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 Default count is 1.  Default address is following last thing printed
 with this command or "print".

The manual says:

 "Each time you specify a unit size with @code{x}, that size becomes the
 default unit the next time you use @code{x}.  For the @samp{i} format,
 the unit size is ignored and is normally not written.  For the @samp{s} format,
                                                        ^^^^^^^^^^^^^^^^^^^^^^^
 the unit size defaults to @samp{b}, unless it is explicitly given.
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 Use @kbd{x /hs} to display 16-bit char strings and @kbd{x /ws} to display
 32-bit strings.  The next use of @kbd{x /s} will again display 8-bit strings.
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 Note that the results depend on the programming language of the
 current compilation unit.  If the language is C, the @samp{s}
 modifier will use the UTF-16 encoding while @samp{w} will use
 UTF-32.  The encoding is set by the programming language and cannot
 be altered."

So "x/s" implicitly sets size to 'b'.  So after x/s, the "previously
used" size is 'b', and your "x/8x $esp" becomes equivalent to
"x/8xb $esp".  Use "x/8xw $esp" to get back the previous output.

-- 
Pedro Alves




reply via email to

[Prev in Thread] Current Thread [Next in Thread]