🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #1130

Re: GDB all VERSION

#1130
From: Pedro Alves
Date: Mon, 04 Feb 2013 16:03
55 lines
4621 bytes
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
Technical Details
Message-ID: <mailman.19007.1359998767.855.bug-gdb@gnu.org>
Path: arc1-ca.pugleaf.net!bp2ni27936wib.1!nntp.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!193.141.40.65.MISMATCH!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!xlned.com!feeder1.xlned.com!border2.nntp.ams.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!nrc-news.nrc.ca!newsfeed.news.ucla.edu!usenet.stanford.edu!not-for-mail
References: <BLU0-SMTP400F554C8BB1D667AE2B3B4D1030@phx.gbl>

Show Full Headers
Complete Article Headers
X-Google-Thread: f0ead4270c,622731240da8fcc,start
X-Google-Attributes: gidf0ead4270c,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: ENGLISH,ASCII-7-bit
X-Received: by 10.180.81.8 with SMTP id v8mr1764065wix.7.1360469144822;
        Sat, 09 Feb 2013 20:05:44 -0800 (PST)
Path: arc1-ca.pugleaf.net!bp2ni27936wib.1!nntp.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!193.141.40.65.MISMATCH!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!xlned.com!feeder1.xlned.com!border2.nntp.ams.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!nrc-news.nrc.ca!newsfeed.news.ucla.edu!usenet.stanford.edu!not-for-mail
From: Pedro Alves <palves@redhat.com>
Newsgroups: gnu.gdb.bug
Subject: Re: GDB all VERSION
Date: Mon, 04 Feb 2013 16:03:37 +0000
Lines: 57
Approved: bug-gdb@gnu.org
Message-ID: <mailman.19007.1359998767.855.bug-gdb@gnu.org>
References: <BLU0-SMTP400F554C8BB1D667AE2B3B4D1030@phx.gbl>
NNTP-Posting-Host: lists.gnu.org
Mime-Version: 1.0
X-Trace: usenet.stanford.edu 1359998767 14442 208.118.235.17 (4 Feb 2013 17:26:07 GMT)
X-Complaints-To: action@cs.stanford.edu
Cc: gnu@gnu.org, bug-gdb@gnu.org
To: sfddfsd <angelofthedark@windowslive.com>
Envelope-to: bug-gdb@gnu.org
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
 rv:17.0) Gecko/20130110 Thunderbird/17.0.2
In-Reply-To: <BLU0-SMTP400F554C8BB1D667AE2B3B4D1030@phx.gbl>
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x
X-Received-From: 209.132.183.28
X-BeenThere: bug-gdb@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "Bug reports for GDB, the GNU debugger" <bug-gdb.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-gdb>,
 <mailto:bug-gdb-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-gdb>
List-Post: <mailto:bug-gdb@gnu.org>
List-Help: <mailto:bug-gdb-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-gdb>,
 <mailto:bug-gdb-request@gnu.org?subject=subscribe>
Bytes: 4147
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit