GDB 栈信息

使用info line命令来查看源代码在内存中的地址

(gdb) info line tst.c:func
        Line 5 of "tst.c" starts at address 0x8048456  and ends at 0x804845d .

 

#include<stdio.h>
void fun1()
{
    int var1;
    printf("hello world /n");
----
}

void fun2()
{
    int var1;
    printf("hello world /n");
    fun1();
}
void fun3()
{
    int var1;
    printf("hello world /n");
    fun2();
----
}
int main()
{
    fun3();
    return 0;
}

 

 

:~> gdb myStack
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-suse-linux"...
Using host libthread_db library "/lib64/libthread_db.so.1".
(gdb) b fun1
Breakpoint 1 at 0x4005b0: file myStack.cpp, line 5.
(gdb) b fun2
Breakpoint 2 at 0x4005ca: file myStack.cpp, line 12.
(gdb) b fun3
Breakpoint 3 at 0x4005e8: file myStack.cpp, line 18.
(gdb) r
Starting program: /data/dreamliang/myStack

Breakpoint 3, fun3 () at myStack.cpp:18
18     printf("hello world /n");
(gdb) bt
#0  fun3 () at myStack.cpp:18
#1  0x0000000000400607 in main () at myStack.cpp:24

(gdb) bt1
Undefined command: "bt1".  Try "help".
(gdb) bt
#0  fun3 () at myStack.cpp:18
#1  0x0000000000400607 in main () at myStack.cpp:24

(gdb) bt 1

#0  fun3 () at myStack.cpp:18
(More stack frames follow...)
(gdb) bt 2
#0  fun3 () at myStack.cpp:18
#1  0x0000000000400607 in main () at myStack.cpp:24
(gdb) c
Continuing.

Breakpoint 2, fun2 () at myStack.cpp:12
12     printf("hello world /n");
(gdb) bt
#0  fun2 () at myStack.cpp:12
#1  0x00000000004005fc in fun3 () at myStack.cpp:19
#2  0x0000000000400607 in main () at myStack.cpp:24
(gdb) up 1
#1  0x00000000004005fc in fun3 () at myStack.cpp:19
19     fun2();
(gdb) up 2

#2  0x0000000000400607 in main () at myStack.cpp:24
24     fun3();
(gdb) down 1
#1  0x00000000004005fc in fun3 () at myStack.cpp:19
19     fun2();
(gdb) down 2
#0  fun2 () at myStack.cpp:12
12     printf("hello world /n");
(gdb) f 1
#1  0x00000000004005fc in fun3 () at myStack.cpp:19
19     fun2();
(gdb) f 2
#2  0x0000000000400607 in main () at myStack.cpp:24
24     fun3();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值