简体   繁体   English

我可以从Windows上的ghc Haskell进程转储中收集哪些信息?

[英]What information can I glean from a dump of a ghc Haskell process on Windows?

One of the users of my command line application has reported what appears to be an infinite loop. 我的命令行应用程序的一个用户报告了看似无限循环的内容。 They helpfully took a dump of the process (via Task Manager) while it was in this state and sent it to me. 当它处于这种状态时,他们帮助转移了进程(通过任务管理器)并将其发送给我。

I'm not sure how to get useful information out of this dump. 我不确定如何从这个转储中获取有用的信息。 My normal technique of windbg -z the-dump-file.dmp -y releases\\v5.0.0 -i releases\\v5.0.0 doesn't give me much information that I know how to interpret. 我的常规技术windbg -z the-dump-file.dmp -y releases\\v5.0.0 -i releases\\v5.0.0并没有给我很多我知道如何解释的信息。 Are there ghc-specific tools I can use instead? 我可以使用ghc专用工具吗?

Moving forward, are the build options I should add or other things I should do to my release process to make this kind of post-mortem debugging more fruitful? 向前看,我应该添加的构建选项或我应该对我的发布过程做的其他事情,以使这种事后调试更有成效吗?

Here's an example of the stacks that I'm seeing. 这是我看到的堆栈的一个例子。 Not much useful info, especially for someone used to debugging C/C++ code in WinDbg. 没有太多有用的信息,特别是对于那些习惯在WinDbg中调试C / C ++代码的人。 :-) :-)

   0  Id: 112dc.cc18 Suspend: 1 Teb: 00000000`00341000 Unfrozen
*** ERROR: Module load completed but symbols could not be loaded for gbc.exe
 # Child-SP          RetAddr           Call Site
00 00000000`01b7d8d0 00000000`01049f71 gbc+0xc5676e
01 00000000`01b7d930 00000000`0104b5b4 gbc+0xc49f71
02 00000000`01b7d9a0 00000000`0104c644 gbc+0xc4b5b4
03 00000000`01b7da60 00000000`0104c1fa gbc+0xc4c644
04 00000000`01b7dab0 00000000`0042545b gbc+0xc4c1fa
05 00000000`01b7db30 00000000`011c40a0 gbc+0x2545b
06 00000000`01b7db38 00000000`0535bee1 gbc+0xdc40a0
07 00000000`01b7db40 00000000`010ffd80 0x535bee1
08 00000000`01b7db48 00000000`0535bee1 gbc+0xcffd80
09 00000000`01b7db50 00007ffb`3581fb01 0x535bee1
0a 00000000`01b7db58 00007ffb`3581b850 imm32!?MSCTF_NULL_THUNK_DATA_DLB+0x2e9
0b 00000000`01b7db60 00000000`00000010 imm32!CtfImmGetCompatibleKeyboardLayout
0c 00000000`01b7db68 00000000`00000000 0x10

   1  Id: 112dc.d324 Suspend: 1 Teb: 00000000`00349000 Unfrozen
 # Child-SP          RetAddr           Call Site
00 00000000`05c2fc48 00007ffb`36441563 ntdll!ZwWaitForWorkViaWorkerFactory+0x14
01 00000000`05c2fc50 00007ffb`34172774 ntdll!TppWorkerThread+0x293
02 00000000`05c2ff60 00007ffb`36470d61 kernel32!BaseThreadInitThunk+0x14
03 00000000`05c2ff90 00000000`00000000 ntdll!RtlUserThreadStart+0x21

   2  Id: 112dc.11b48 Suspend: 1 Teb: 00000000`0034b000 Unfrozen
 # Child-SP          RetAddr           Call Site
00 00000000`0642dd38 00007ffb`32f2988f ntdll!ZwWaitForSingleObject+0x14
01 00000000`0642dd40 00000000`00ffca15 KERNELBASE!WaitForSingleObjectEx+0x9f
02 00000000`0642dde0 00000000`00000000 gbc+0xbfca15

Some resources that might be useful. 一些可能有用的资源。 (If there are more up-to-date ones, I would like to see them myself.) (如果有更新的,我想亲自看看。)

A few important nuggets: 一些重要的小块:

The runtime flag +RTS -? 运行时标志+RTS -? Will tell you what runtime flags add debugging information. 将告诉您哪些运行时标志添加调试信息。 These will start with +RTS -D . 这些将从+RTS -D开始。 For example, +RTS -DS turns on a number of runtime assertions and sanity checks. 例如, +RTS -DS打开许多运行时断言和健全性检查。

The strange names you see are encoded in something called Z-encoding. 你看到的奇怪名字是用Z编码编码的。 This is defined at https://ghc.haskell.org/trac/ghc/browser/ghc/compiler/cmm/CLabel.hs . 这在https://ghc.haskell.org/trac/ghc/browser/ghc/compiler/cmm/CLabel.hs中定义。

If you can recompile the code with debugging symbols on and threading off, and still reproduce the bug, you can set breakpoints (or hit control-C) inside the debugger and backtrace from there. 如果您可以重新编译带有调试符号和线程的代码,并且仍然重现该错误,您可以在调试器中设置断点(或命中control-C)并从那里回溯。 You can examine memory with a command like print/a 0x006eb0c0 (although you seem to be using 64-bit pointers). 您可以使用print/a 0x006eb0c0等命令检查内存(尽管您似乎使用的是64位指针)。 You can see the assembly-language instruction that crashed with disassemble . 您可以看到因disassemble而崩溃的汇编语言指令。

You need to use the -ddump-stg compile flag to see what the variable names mean, because that is the last phase of the transformation before the program is assembled, and the variable names you see in the debugger correspond to the ones here. 您需要使用-ddump-stg编译标志来查看变量名称的含义,因为这是程序组装之前转换的最后阶段,并且您在调试器中看到的变量名称与此处的变量名称相对应。

You can instrument the code with Debug.Trace . 您可以使用Debug.Trace来检测代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM