• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

delphi代码实现创建dump文件

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

I used a "watchdog" thread for this, which checks if the mainform is responding, and make a minidump (you can load this dump with WinDbg, use map2dbg.exe to convert a Delphi .map to a .dbg).

FMainformHandle := Application.MainForm.Handle;
Result := SendMessageTimeOut( FMainformHandle, WM_NULL, 0, 0,
SMTO_NORMAL or SMTO_ABORTIFHUNG,
C_TIME_OUT_SECONDS * 1000, //wait 1minute
iRes) <> 0;
if not Result then
begin
hFile := CreateFile(PChar(Result), GENERIC_WRITE, FILE_SHARE_WRITE, nil,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
try
MiniDumpWriteDump(GetCurrentProcess, GetCurrentProcessId, hFile,
aDumpType, nil, nil ,nil);
finally
FileClose(hfile);
end;
end;
But you can also use

jclDebug.pas:
JclCreateThreadStackTraceFromID(MainthreadId)
for this (no need for WinDbg etc, only the JCL + Delphi .map)

3rd option is to use my new sampling profiler, which has a "process stack viewer", so you can watch the stack of any thread of a running process (I used SysInternals Process Explorer for this before, but it needs .dbg files). It uses .map, TD32, JDBG etc (any Delphi debug info) for stack tracing.
You can use this when you app hangs, to investigate the stack.

Windows API (for MiniDumpWriteDump):
http://sourceforge.net/projects/jedi-apilib/files/JEDI%20Windows%20API/
WinDbg:
http://www.microsoft.com/whdc/devtools/debugging/installx86.Mspx
Map2Dbg:
http://code.google.com/p/map2dbg/
JEDI JCL:
http://jcl.delphi-jedi.org/
AsmProfiler, samling mode: (still under development!)
http://asmprofiler.googlecode.com/files/AsmSamplingProfiler0.4.zip

 

http://stackoverflow.com/questions/2063655/how-to-debug-hanging-main-thread-in-delphi-application/2070194#2070194


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
delphi调用java编写的webservice发布时间:2022-07-18
下一篇:
delphi与汇编笔记(2)------关于EBP寄存器的说明与使用发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap