From: Yao Qi <yao@codesourcery.com>
To: Nan Xiao <xiaonan19830818@qq.com>
Cc: gdb <gdb@sourceware.org>
Subject: Re: How to use "frame addr" command in gdb?
Date: Wed, 19 Nov 2014 06:49:00 -0000 [thread overview]
Message-ID: <874mtvhegh.fsf@codesourcery.com> (raw)
In-Reply-To: <tencent_375579DA7B8E36B268074E90@qq.com> (Nan Xiao's message of "Wed, 19 Nov 2014 13:45:41 +0800")
Nan Xiao <xiaonan19830818@qq.com> writes:
> I use gdb to debug this program, and find 'frame n' command works OK:
> (gdb) bt
> #0 func1 (a=10) at a.c:5
> #1 0x08050b67 in func2 (a=10) at a.c:11
> #2 0x08050b89 in func3 (a=10) at a.c:18
> #3 0x08050bb9 in main () at a.c:24
> (gdb) frame 2
> #2 0x08050b89 in func3 (a=10) at a.c:18
>
> But when I want to use "frame addr" command, it seems not work well:
>
> (gdb) frame 0x08050bb9
> #0 0x00000000 in ?? ()
> (gdb) frame 0x08050b89
> #0 0x00000000 in ?? ()
> (gdb) frame 0x08050b92
> #0 0x00000000 in ?? ()
>
> How to use "frame addr" command? Thanks very much in advance! I can't
> find other reference except the manual.
You pass the wrong address to command "frame". The addresses in the
output of "bt" command are the pc values in each frame. They are not
the address of frames.
(gdb) help frame
Select and print a stack frame.
With no argument, print the selected stack frame. (See also "info frame").
An argument specifies the frame to select.
It can be a stack frame number or the address of the frame.
^^^^^^^^^^^^^^^^^^^^^^^^
With argument, nothing is printed if input is coming from
a command file or a user-defined command.
We should pass "the address of the frame" to command "frame", and it can
be got from command "info frame".
(gdb) bt
#0 func1 (a=10) at 2.c:6
#1 0x08048452 in func2 (a=10) at 2.c:12
#2 0x08048474 in func3 (a=10) at 2.c:19
#3 0x08048493 in main () at 2.c:25
(gdb) info frame 2
Stack frame at 0xbfffee70:
^^^^^^^^^^ the address of the frame
eip = 0x8048474 in func3 (2.c:19); saved eip = 0x8048493
called by frame at 0xbfffee90, caller of frame at 0xbfffee54
source language c.
Arglist at 0xbfffee68, args: a=10
Locals at 0xbfffee68, Previous frame's sp is 0xbfffee70
Saved registers:
ebp at 0xbfffee68, eip at 0xbfffee6c
(gdb) frame 0xbfffee70
#2 0x08048474 in func3 (a=10) at 2.c:19
19 c = 2 * func2(a);
--
Yao (齐尧)
next prev parent reply other threads:[~2014-11-19 6:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-19 5:46 Nan Xiao
2014-11-19 6:49 ` Yao Qi [this message]
2014-11-19 7:09 ` =?gb18030?B?TmFuIFhpYW8=?=
2014-11-19 9:48 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874mtvhegh.fsf@codesourcery.com \
--to=yao@codesourcery.com \
--cc=gdb@sourceware.org \
--cc=xiaonan19830818@qq.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).