c语言,gdb

Get gdb call stack http://blog.csdn.net/zoufeiyy/article/details/1490241

Debugging with GDB - Examining the Stack  http://web.mit.edu/gnu/doc/html/gdb_8.html

1)准备: gcc -g 
        ##########################################################################################
        CFLAGS += -I.. -g
        msview: msview.o
            $(CC) $(CFLAGS) -o $@ msview.o $(LDFLAGS) $(LDLIBS)
        ##########################################################################################
        # Standard object building
        .c.o:
            $(CC) $(CFLAGS) -g -c $< -o $@
        ##########################################################################################    
        # Standard object building for dynamic library components using -fPIC
        .c.lo:
            $(CC) $(CFLAGS) -g -fPIC -c $< -o $@
        ##########################################################################################
    (2break
            $       gdb ./msview 
            (gdb) break unpack.c:76
            (gdb) run data
    (3)查看调用堆栈
            (gdb) bt
            #0  msr_unpack (record=0x7ffff7ed2010 "000001D", ' ' <repeats 13 times>, "\a\262", reclen=4096, 
            ppmsr=0x7fffffffe210, dataflag=1 '\001', verbose=0 '\000') at unpack.c:76
            #1  0x0000000000417320 in msr_parse (record=0x7ffff7ed2010 "000001D", ' ' <repeats 13 times>, "\a\262", 
            recbuflen=4096, ppmsr=0x7fffffffe210, reclen=4096, dataflag=1 '\001', verbose=0 '\000')
            at parseutils.c:108
            #2  0x000000000040311a in ms_readmsr_main (ppmsfp=0x7fffffffe1a0, ppmsr=0x7fffffffe210, 
            msfile=0x7fffffffe66b "data", reclen=4096, fpos=0x0, last=0x0, skipnotdata=1 '\001', 
            dataflag=1 '\001', selections=0x0, verbose=0 '\000') at fileutils.c:552
            #3  0x0000000000401d6e in ms_readmsr (ppmsr=0x7fffffffe210, msfile=0x7fffffffe66b "data", reclen=-1, 
            fpos=0x0, last=0x0, skipnotdata=1 '\001', dataflag=1 '\001', verbose=0 '\000') at fileutils.c:105
            #4  0x00000000004017a2 in main (argc=2, argv=0x7fffffffe3b8) at msview.c:75
            
            断点打在 msr_unpack,npack.c:76
                        --msr_parse    parseutils.c:108
                            --ms_readmsr_main fileutils.c:552
                                --main    msview.c:75
 
 

GDB调试器用法 https://i.cnblogs.com/EditPosts.aspx?postid=4778015

看内存:  x

   (gdb) x/10xb  0x400703  以十六进制方式查看内存地址0x400703开始10个字节的value。


  

  

参考:

1. 通过 GDB 学习 C 语言 http://blog.jobbole.com/87482/

2. Linux gdb设置和管理断点 http://www.cnblogs.com/rosesmall/archive/2012/04/13/2445527.html

3.Vim与GCC和gdb完美组合 http://www.cnblogs.com/Shirlies/p/3278937.html

4. GDB使用基础(转载) http://bbs.21ic.com/blog-678712-84132.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值