• ADPLUS使用配置文件设置断点时无法创建DUMP文件原因分析


    ADPLUS简介

    ADPLUS.vbs是Debugging Tool for Windows里带的一个VBS脚本。我们可以用它很方便地生成进程的内存转储文件。从Debugging Tool for Windows版本6.12.2.633后,ADPLUS.vbs被ADPLUS.EXE所替代。原有的VBS脚本更名为adplus_old.vbs.

    背景

    在一台服务器上,ASP.NET出现随机崩溃的情况。为了解决这个问题,我们决定用ADPLUS收集dump.

    我们使用如下配置文件:

    <ADPlus Version='2'>

    <Breakpoints>

    <Breakpoint Name= "MyBP" Address="KERNEL32!ExitProcess">

    <Actions>Log;Stacks;FullDump</Actions>

    <ReturnAction> Q</ReturnAction>

    </Breakpoint>

    <Breakpoint Name= "MyBP2" Address="KERNEL32!TerminateProcess">

    <Actions>Log;Stacks;FullDump</Actions>

    <ReturnAction>Q</ReturnAction>

    </Breakpoint>

    </Breakpoints>

    </ADPlus>

    但奇怪的是却无法生成dump,在dump目录中只有一个Minidump.

    clip_image002

    检查

    首先,我们检查Adplus日志文件。在这个文件中包含了CDB运行的所有信息,非常有用。在日志文件中,我们发现如下错误:

    Unable to create file 'MyBP2 c:\dumps\20101108_160516_Crash_Mode\FULLDUMP_Breakpoint MyBP2_w3wp.exe__1c0c_2010-11-08_16-07-18-706_1d04.dmp' - Win32 error 0n123

    "The filename, directory name, or volume label syntax is incorrect."

    从名字上看,看起来CDB收到了一个非法的文件名。”MyBP2 c:\dumps\20101108_160516_Crash_Mode\FULLDUMP_Breakpoint MyBP2_w3wp.exe__1c0c_2010-11-08_16-07-18-706_1d04.dmp” 看起来不象一个合法的文件名。这是怎么回事?

    然后我们用ProcessMonitor监视adplus.exe和CDB.EXE,发现如下结果:

    clip_image004

    从名字上看,这个名字很明显有问题:

    C:DebuggersMyBP2 c:dumps20101108_163827_Crash_ModeFULLDUMP_Breakpoint MyBP2_w3wp.exe__12fc_2010-11-08_16-38-40-568_2940.dmp

    前边多了个C:DebuggersMyBP2

    这是怎么回事?

    那个MyBp2是断点名字,为什么会出现dump文件名字中呢?我们继续从ADPLUS LOG中寻找线索:

    0:027> *--- Configuring breakpoints ---

    0:027> BP KERNEL32!TerminateProcess @".echo Breakpoint MyBP2;.echo;.echo Call stacks below ---;~*kvn250;.echo;.dump -u /ma /c Breakpoint MyBP2 ${AdpDumpDirEsc}\FULLDUMP_Breakpoint MyBP2_${AdpProcName}_.dmp;Q"

    请注意Breakpoint和MyBp2中间有个空格,难道这个命令有问题,我们用Windbg试一下:

    1. 运行notepad

    2. 把windbg附加过去,输入如下命令:clip_image005

    3. 出现的错误信息与日志中一致。

    clip_image007

    因此,可以确认是由于adplus.exe给CDB传了错误参数所致。

    幸运的是adplus.exe是用.NET写的,我们可以用Reflector打开看看:

    很快地我们可以发现.dump命令是KeyWord2Command生成的:

            private string KeyWord2Command(string KeyWord, string Context, bool UseEscapedFlnm)

    {

    switch (key)

    {

    case "MINIDUMP":

    case "FULLDUMP":

    case "CUSTOMDUMP":

    {

    str4 = ".dump -u " + str3;

    if (Context != "")

    {

    str4 = str4 + " /c " + Context;

    }

    string str7 = str4;

    return (str7 + " " + str2 + key + "_" + Context + "_${AdpProcName}_.dmp");

    }

    …}

    根据Windbg的文档,/c参数要用引号包括,但这里没有。这应该是adplus.exe的一个bug.

    我的ADPLUS版本为:7.01.002 02/27/2009

    附录:

    .NET Reflector

    http://www.red-gate.com/products/reflector/

    Process Monitor

    http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx

    Debugging Tool for Windows

    http://www.microsoft.com/china/whdc/DevTools/Debugging/default.mspx

    Robert

  • 相关阅读:
    $dp$模板
    字符串基础
    基础算法

    图论
    山中无甲子,寒尽不知年
    模板集合(持续更新)
    数学基础——同余
    9.19 考试总结
    1-5-17:菲波那契数列
  • 原文地址:https://www.cnblogs.com/symphonygcr/p/4060750.html
Copyright © 2020-2023  润新知