zoukankan      html  css  js  c++  java
  • delphi代码实现创建dump文件

    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

  • 相关阅读:
    收藏:详解交换机基础知识
    Linux Used内存到底哪里去了?
    TCP三次握手和四次挥手以及11种状态
    操作系统深度研究(75页PPT)
    命令行版的斗地主你玩过没?
    10大黑客专用的 Linux 操作系统
    (四)Linux命令大全:帮助命令
    (三)Linux命令大全:文件搜索命令
    (二)Linux命令大全:权限管理命令
    (一)Linux命令大全:文件处理命令
  • 原文地址:https://www.cnblogs.com/findumars/p/5671159.html
Copyright © 2011-2022 走看看