Re: GDB all VERSION

2013-02-04 Thread Pedro Alves
On 02/01/2013 10:04 PM, sfddfsd wrote:
> view the stack with x/8x $esp .
> 
> 0xb960:0x080484e00xbbb10x0804846b0xb7fc4ff4
> 0xb970:0x080484600x0xb9f80xb7e96e16
> 
> and print the string with value proof 0xbbb1 .
> 
> (gdb)x/s 0xbbb1
> 0xbbb1:"proof"
> 
> print the newly the stack with x/8x $esp and the result is.
> 
> 0xb960:0xe00x840x040x080xb10xfb0xff0xbf
> 
> 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


___
bug-gdb mailing list
bug-gdb@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-gdb


GDB all VERSION

2013-02-02 Thread sfddfsd
hi, I write for the tool gdb, this has a bug.
you should compile this code with gcc proof.c -o proof .

#include 

int main(int argc,char** argv)
{
if( argc == 2 )
{
printf("%s",argv[1]);
}
return 0;
}


the next step is run gdb -q proof and put a breakpoint in function printf.

the direction of prinf is

   0x0804843e <+34>:call   0x8048300 

and put break in 0x0804843e , then should run gdb -q proof.

view the stack with x/8x $esp .

0xb960:0x080484e00xbbb10x0804846b0xb7fc4ff4
0xb970:0x080484600x0xb9f80xb7e96e16

and print the string with value proof 0xbbb1 .

(gdb)x/s 0xbbb1
0xbbb1:"proof"

print the newly the stack with x/8x $esp and the result is.

0xb960:0xe00x840x040x080xb10xfb0xff0xbf

do you understand ??, this bug is in all version of gdb .

will wait for you answer,please.
regards.

___
bug-gdb mailing list
bug-gdb@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-gdb