如何使用“*。stackdump”进行调试文件在cygwin [英] how to debug using "*.stackdump" file in cygwin

查看:1154
本文介绍了如何使用“*。stackdump”进行调试文件在cygwin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是cygwin(和linux)的新手。

I am newbie on cygwin(and linux).

当我试图运行基于C语言的可执行文件时,分段错误发生,我采取stackdump文件。但是,我不知道如何使用它来调试。

When I tried to run my executable file based on C language, segmentation fault occured, and I take stackdump file. but, I don't know how to use it for debugging.

我一直在寻找如何使用stackdump文件调试的方式,但我不能找到它。
任何小提示对我非常有用。感谢阅读我可怜的英语(英语不是我的第一语言)。

I have been searching for the way how to debug using stackdump file, but I cound't find it. Any small tips are very useful to me. thanks for reading my poor english (english is not my 1st language).

推荐答案

需要编译你的程序传递给gcc的标志 -ggdb 否则stackdump信息是无用的。我建议还通过 -O0 标志,以便调试与gdb将更容易,因为代码将不会优化。

First: you need to compile your program passing to gcc the flag -ggdb otherwise the stackdump info is useless. I suggest to pass also the -O0 flag so that debugging with gdb will be more easy as the code will not be optimized.

第二:stackdump提供堆栈中存在的地址,
在32位的示例中,我们有两个地址:

Second: the stackdump provide the addresses present in the stack, in this example on 32bit we have two addresses:

$ cat t-invmod.exe.stackdump
Stack trace:
Frame     Function  Args
0028C878  61032BCB (000000F4, 0000EA60, 000000A4, 0028C8D8)
0028C998  610E7A7A (00000001, 0028CA3F, 00000001, 611A2C80)

地址可以来自程序或加载的共享库。

The address can be coming from your programs or from loaded shared libs.

要将地址转换为代码位置,请使用 addr2line
示例:

To convert the address to code position, use addr2line. Example:

$ addr2line.exe -a 610E7A7A -a 61032BCB -e /usr/bin/cygwin1.dll 
0x610e7a7a
/usr/src/debug/cygwin-2.5.1-1/winsup/cygwin/cygerrno.h:36
0x61032bcb
/usr/src/debug/cygwin-2.5.1-1/winsup/cygwin/cygerrno.h:35

地址告诉我,崩溃是在一个共享的lib而不是在程序中。您可以使用 ldd 来标识地址所属的地址:

In this case the high address told me that the crash was in a shared lib and not in the program. You can use ldd to identify to what the addresses belong:

$ ldd t-invmod.exe
        ntdll.dll => /cygdrive/c/Windows/SysWOW64/ntdll.dll (0x776d0000)
        kernel32.dll => /cygdrive/c/Windows/syswow64/kernel32.dll (0x75500000)
        KERNELBASE.dll => /cygdrive/c/Windows/syswow64/KERNELBASE.dll (0x75a10000)
        SYSFER.DLL => /cygdrive/c/Windows/SysWOW64/SYSFER.DLL (0x73480000)
        cygflint.dll => /usr/bin/cygflint.dll (0x5f390000)
        cygwin1.dll => /usr/bin/cygwin1.dll (0x61000000)
        cyggmp-10.dll => /usr/bin/cyggmp-10.dll (0x589e0000)
        cygmpfr-4.dll => /usr/bin/cygmpfr-4.dll (0x51080000)
        cyggcc_s-1.dll => /usr/bin/cyggcc_s-1.dll (0x5ece0000)
        cygntl-9.dll => /usr/bin/cygntl-9.dll (0x50270000)
        cygstdc++-6.dll => /usr/bin/cygstdc++-6.dll (0x4b340000)

如果地址低于dll ,它属于你的程序;如果它属于共享库,你需要安装相对的* debuginfo包来恢复位置信息。

If the address is lower than dll's one, it belongs to your program; If it belongs to shared lib you need to installl the relative *debuginfo package for recovering the location information.

这篇关于如何使用“*。stackdump”进行调试文件在cygwin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆