• windbg关于.NET分析的扩展命令


    收到一个dump文件,运行环境的.net framework的详细版本是多少呢?

    dump信息与性能计数器结合分析时,想知道该dump运行的进程号是多少?

    dump定位到有效的堆栈信息,而对应的源码是怎么写的呢?

    mex扩展提供了大量节省人力搜索的命令,类似扩展可以到windbg网站了解:http://www.windbg.org/


    0:102> .time
    Debug session time: Wed Nov 15 10:44:19.000 2017 (UTC + 8:00)
    System Uptime: 116 days 10:02:02.508
    Process Uptime: 0 days 1:03:59.000
      Kernel time: 0 days 0:07:30.000
      User time: 0 days 3:58:17.000
    0:102> lmvm clr
    Browse full module list
    start             end                 module name
    000007fe`f8ba0000 000007fe`f950b000   clr        (pdb symbols)          c:symbolsclr.pdbAD25374E6B2F4798B4FDFDB14E19D79B2clr.pdb
        Loaded symbol image file: clr.dll
        Image path: C:WindowsMicrosoft.NETFramework64v4.0.30319clr.dll
        Image name: clr.dll
        Browse all global symbols  functions  data
        Timestamp:        Thu Sep 12 08:14:10 2013 (52310752)
        CheckSum:         00967281
        ImageSize:        0096B000
        File version:     4.0.30319.18408
        Product version:  4.0.30319.18408
        File flags:       8 (Mask 3F) Private
        File OS:          4 Unknown Win32
        File type:        2.0 Dll
        File date:        00000000.00000000
        Translations:     0409.04b0
        CompanyName:      Microsoft Corporation
        ProductName:      Microsoft® .NET Framework
        InternalName:     clr.dll
        OriginalFilename: clr.dll
        ProductVersion:   4.0.30319.18408
        FileVersion:      4.0.30319.18408 built by: FX451RTMGREL
        PrivateBuild:     DDBLD130
        FileDescription:  Microsoft .NET Runtime Common Language Runtime - WorkStation
        LegalCopyright:   © Microsoft Corporation.  All rights reserved.
        Comments:         Flavor=Retail
    0:102> !dml_proc
    DbgId  PID    Image file name
    0      2c40   c:WindowsSystem32inetsrvw3wp.exe
    

    OS Thread Id: 0x1c30 (199)
    Child SP         IP               Call Site
    0000000026265510 000000007734046a [GCFrame: 0000000026265510]
    0000000026265768 000000007734046a [GCFrame: 0000000026265768]
    0000000026265718 000000007734046a [HelperMethodFrame: 0000000026265718] System.Threading.Monitor.Enter(System.Object)
    0000000026265870 000007fef8bbe0e2 System.Environment+ResourceHelper.GetResourceStringCode(System.Object)
    0000000026265fb8 000007fefa0c10b4 [HelperMethodFrame_PROTECTOBJ: 0000000026265fb8] System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
    00000000262660e0 000007fef8bbdfb8 System.Environment+ResourceHelper.GetResourceString(System.String, System.Globalization.CultureInfo)
    0000000026266130 000007fef8bbe7f8 System.Environment.GetResourceStringLocal(System.String)
    0000000026266548 000007fefa0c10b4 [ContextTransitionFrame: 0000000026266548]
    0000000026266508 000007fefa0c10b4 [GCFrame: 0000000026266508]
    0000000026266768 000007fefa0c10b4 [HelperMethodFrame_2OBJ: 0000000026266768] System.Environment.GetResourceFromDefault(System.String)
    0000000026266890 000007fef8b880be System.Environment.GetResourceString(System.String, System.Object[])
    00000000262668d0 000007fef97b8306 System.IO.__Error.WinIOError(Int32, System.String)
    0000000026266920 000007fef8c29f51 System.IO.FileStream.Init(System.String, System.IO.FileMode, System.IO.FileAccess, Int32, Boolean, System.IO.FileShare, Int32, System.IO.FileOptions, SECURITY_ATTRIBUTES, System.String, Boolean, Boolean)
    0000000026266ab0 000007fef8c29585 System.IO.FileStream..ctor(System.String, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, Int32, System.IO.FileOptions, System.String, Boolean)
    0000000026266b60 000007fef8be60ba System.IO.FileStream..ctor(System.String, System.IO.FileMode)
    0000000026266be0 000007ff001c2b7b xxxxxxxxx.MDM.Pub.Common.MDMPubFunction.WriteTextFile(System.String)
    0000000026266c80 000007ff001f9b48 xxxxxxxxx.MDM.Interface.Server.Com.MDMInterfaceCore.ExecuteSql(System.String[], System.String, System.String ByRef)
    0000000026266db0 000007ff001c508c xxxxxxxxx.MDM.Interface.Server.Com.MDMInterface.MDMInterfaceJson(System.String, System.String, Boolean)
    0000000026268850 000007ff00456d72 xxxxxxxxx.MDM.Interface.Server.Com.MDMInterface.GenerateModifySql(System.String, Boolean, System.Data.DataTable, System.Data.DataTable, Newtonsoft.Json.Linq.JObject, System.String ByRef)
    000000002626a8f0 000007ff001c9bc6 xxxxxxxxx.MDM.Interface.Server.Com.MDMInterface.MDMInterfaceJson(System.String, System.String, Boolean)
    000000002626c390 000007ff001c27be xxxxxxxxx.MDM.Interface.Server.Com.MDMInterface.MDMInterfaceJson(System.String, System.String)
    000000002626c4b0 000007ff001c1dfb xxxxxxxxx.MDM.Interface.Server.Service.MDMInterfaceSrv.MDMInterfaceJson(System.String, System.String)
    000000002626cbe8 000007fefa0c10b4 [DebuggerU2MCatchHandlerFrame: 000000002626cbe8]
    000000002626ccd0 000007fefa0c10b4 [CustomGCFrame: 000000002626ccd0]
    000000002626cc98 000007fefa0c10b4 [GCFrame: 000000002626cc98]
    000000002626cc28 000007fefa0c10b4 [GCFrame: 000000002626cc28]
    000000002626cff8 000007fefa0c10b4 [HelperMethodFrame_PROTECTOBJ: 000000002626cff8] System.RuntimeMethodHandle._InvokeMethodFast(System.IRuntimeMethodInfo, System.Object, System.Object[], System.SignatureStruct ByRef, System.Reflection.MethodAttributes, System.RuntimeType)
    000000002626d140 000007fef8b9587f System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo, Boolean)
    000000002626d280 000007fef8be0426 System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
    000000002626d2d0 000007fef7a74c02 System.Web.Services.Protocols.LogicalMethodInfo.Invoke(System.Object, System.Object[])
    000000002626d350 000007fef7a8b132 System.Web.Services.Protocols.WebServiceHandler.Invoke()
    000000002626d3e0 000007fef7a8ad5b System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
    000000002626d450 000007fef7abdb68 System.Web.Services.Protocols.SyncSessionlessHandler.ProcessRequest(System.Web.HttpContext)
    000000002626d4b0 000007feefa0e5a8 System.Web.Script.Services.ScriptHandlerFactory+HandlerWrapper.ProcessRequest(System.Web.HttpContext)
    000000002626d4e0 000007fef3305c25 System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    000000002626d5a0 000007fef32d337a System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)
    000000002626d650 000007fef32e7030 System.Web.HttpApplication+ApplicationStepManager.ResumeSteps(System.Exception)
    000000002626d710 000007fef32d2879 System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(System.Web.HttpContext, System.AsyncCallback, System.Object)
    000000002626d770 000007fef32d777c System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest)
    000000002626d7f0 000007fef3a67ac3 System.Web.RequestQueue.WorkItemCallback(System.Object)
    000000002626d840 000007fef8ba3178 System.Threading.ExecutionContext.runTryCode(System.Object)
    000000002626df68 000007fefa0c10b4 [HelperMethodFrame_PROTECTOBJ: 000000002626df68] System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
    000000002626e090 000007fef8b917e1 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
    000000002626e0f0 000007fef8bdc419 System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
    000000002626e140 000007fef8bdba83 System.Threading.ThreadPoolWorkQueue.Dispatch()
    000000002626e1e0 000007fef8bdb8d5 System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
    000000002626e840 000007fefa0c10b4 [DebuggerU2MCatchHandlerFrame: 000000002626e840]
    000000002626ea18 000007fefa0c10b4 [ContextTransitionFrame: 000000002626ea18]
    000000002626ec00 000007fefa0c10b4 [DebuggerU2MCatchHandlerFrame: 000000002626ec00]
    0:199> !ip2md 000007ff001c2b7b
    MethodDesc:   000007ff00305610
    Method Name:  xxxxxxxxx.MDM.Pub.Common.MDMPubFunction.WriteTextFile(System.String)
    Class:        000007ff00321f20
    MethodTable:  000007ff00305638
    mdToken:      0000000006000071
    Module:       000007ff00300c20
    IsJitted:     yes
    CodeAddr:     000007ff001c28d0
    Transparency: Critical
    0:199> !DumpModule  000007ff00300c20
    Name:       C:WindowsMicrosoft.NETFramework64v4.0.30319Temporary ASP.NET Filescwbase1d2b51b62f03f15assemblydl3c065d636073700f_62f6d001xxxxxxxxx.MDM.Pub.Common.dll
    Attributes: PEFile
    Assembly:   00000000028b54c0
    LoaderHeap:              0000000000000000
    TypeDefToMethodTableMap: 000007ff00316038
    TypeRefToMethodTableMap: 000007ff003160e8
    MethodDefToDescMap:      000007ff00316660
    FieldDefToDescMap:       000007ff00316dd0
    MemberRefToDescMap:      000007ff00317068
    FileReferencesMap:       000007ff00317dc0
    AssemblyReferencesMap:   000007ff00317dc8
    MetaData start address:  000000006df7bdf4 (37564 bytes)
    0:199> !SaveModule  000007ff00300c20 D:xxxxxxxxx.MDM.Pub.Common.dll
    3 sections in file
    section 0 - VA=2000, VASize=13184, FileAddr=200, FileSize=13200
    section 1 - VA=16000, VASize=3b8, FileAddr=13400, FileSize=400
    section 2 - VA=18000, VASize=c, FileAddr=13800, FileSize=200
    
    0:192> !mex.p
    Name     Ses PID            PEB              Mods Handle Thrd
    ======== === ============== ================ ==== ====== ====
    w3wp.exe   0 2c40 (0n11328) 000007fffffde000 1927   6332  251
    
    CommandLine: c:windowssystem32inetsrvw3wp.exe -ap "cwbasev4.0" -v "v4.0" -l "webengine4.dll" -a \.pipeiisipm994a2419-0359-47c9-ae5b-d46cbbf85bfd -h "C:inetpub	empapppoolscwbasev4.0cwbasev4.0.config" -w "" -m 1
    Last event: 2c40.2308: Wake debugger - code 80000007 (first/second chance not available)
    
    Show Threads: Unique Stacks    !listthreads (!lt)    ~*kv
    
    0:208> !mex.help
    Mex currently has 255 extensions available.  Please specify a keyword to search.
    Or browse by category:
    
    All PowerShell[6] SystemCenter[3] Networking[12] Process[5] Mex[2] Kernel[27] DotNet[32] Decompile[15] Utility[40] Thread[27] Binaries[6] General[22]
    0:208> !mex.help -cat 'DotNet'
    Command                                     Description                                                         Category
    =========================================== =================================================================== ========
    aspnetcache                  (!aspnetcache) Display the ASP.NET Cache                                           DotNet
    aspxpagesext                                Like !aspxpages, but more powerful                                  DotNet
    clrstack2                            (!ck2) Prints the stack trace of a managed thread                          DotNet
    cordll                            (!cordll) Displays available CLR versions                                     DotNet
    dae                    (!DumpAllExceptions) Replacement for !dae                                                DotNet
    delegaterefs                       (!drefs) Displays information about objects referenced by delegates          DotNet
    displayobj                           (!do2) Display a managed object structure                                  DotNet
    dumpaspnetsession                           Prints information on ASP.NET InProc Sessions                       DotNet
    dumpdataset                                 Dumps a list of all DataSet objects                                 DotNet
    dumpdynamicassemblies2              (!dda2) Like !DumpDynamicAssemblies, but better                             DotNet
    dumphttpruntime2                            Dumps the HttpRuntime objects on the heap                           DotNet
    dumpwcfmessage                    (!wcfmsg) Dumps information about a WCF buffered message                      DotNet
    finalizable                  (!finalizable) Displays information about finalizable objects in the GC Heap       DotNet
    foreachobject                        (!feo) Runs a command against each CLR object                              DotNet
    gchandleinfo                    (!gchandle) Displays information on GC Handles                                  DotNet
    gcheapinfo                          (!gchi) Get info on the managed GC Heap                                     DotNet
    httpheaders                                 Print the contents of an HttpHeaderCollection                       DotNet
    ilspy                                       Automatically extracts the module from the dump, and launches ILSpy DotNet
    managedthreads                  (!mthreads) A !threads look-alike, with !aspxpagexext-like output               DotNet
    objectsummary                               Outputs object analysis summary                                     DotNet
    oracleclientperfcounters                    Display System.Data.OracleClient performance counters               DotNet
    printdbcommand                              Prints information about a DBCommand object                         DotNet
    printexception2                      (!pe2) Like !PrintException, with DML                                      DotNet
    sqlclientperfcounters                       Display System.Data.SqlClient performance counters                  DotNet
    sqlcmd                                      Provides information about ADO.NET Commands to SQL Server           DotNet
    sqlcn                                       Provides an overview of ADO.NET connections to SQL Server           DotNet
    sqlports                        (!sqlports) Gets the local and remote TCP ports from a SqlConnection object     DotNet
    staticfields                                Display static fields of a managed type                             DotNet
    svcthreads                    (!svcthreads) Find threads executing WCF services                                 DotNet
    tasktriage                         (!tasks) Analyzes the System.Threading.Tasks.Task objects still on the heap. DotNet
    wcfperfcounters                             Dumps performance counters for WCF services                         DotNet
    wcftcpconnectionpools               (!wtcp) Display WCF Net.TCP connection pools                                DotNet
    
    
    0:192> !clrstack2 208
    DbgId ThreadId Apartment Kind   CLR              GC Mode    GC Suspending?
      208     2590 MTA       Worker v4.0.30319.18408 Preemptive no
    
    SqlCommand
    ----------
    Command          0x00000008bfad3648
    CommandText      SP_Get_Data_Paged
    Connection       0x00000008bfad2da8
    ConnectionString data source=192.168.108.84;initial catalog=xxxxx;user id=yyyyyyy;password=xxxxxxxx;Connect Timeout=3600
    Timeout          01:40:00
    Duration?        00:00:07.7321433
    
    SP               IP               Function                                                                                                                                                                                                                                                   Source
    0000000acfb0c888 0000000000000000 InlinedCallFrame
    0000000acfb0c888 0000000000000000 InlinedCallFrame
    0000000acfb0c860 000007fef2c76e11 DomainNeutralILStubClass.IL_STUB_PInvoke(SNI_ConnWrapper*, SNI_Packet**, Int32)
    0000000acfb0c930 000007fef2c5d17f SNINativeMethodWrapper.SNIReadSyncOverAsync(System.Runtime.InteropServices.SafeHandle, IntPtr ByRef, Int32)
    0000000acfb0c9a0 000007fef2c5ce9e System.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync()
    0000000acfb0ca50 000007fef2c5cdb0 System.Data.SqlClient.TdsParserStateObject.TryReadNetworkPacket()
    0000000acfb0ca90 000007fef2c5d5a0 System.Data.SqlClient.TdsParserStateObject.TryPrepareBuffer()
    0000000acfb0cac0 000007fef2c60492 System.Data.SqlClient.TdsParserStateObject.TryReadByte(Byte ByRef)
    0000000acfb0cb00 000007fef2c5f4b7 System.Data.SqlClient.TdsParser.TryRun(System.Data.SqlClient.RunBehavior, System.Data.SqlClient.SqlCommand, System.Data.SqlClient.SqlDataReader, System.Data.SqlClient.BulkCopySimpleResultSet, System.Data.SqlClient.TdsParserStateObject, Boolean ByRef)
    0000000acfb0cca0 000007fef2c6c55d System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
    0000000acfb0cd10 000007fef2c6c4da System.Data.SqlClient.SqlDataReader.get_MetaData()
    0000000acfb0cd60 000007fef2c669bc System.Data.SqlClient.SqlCommand.FinishExecuteReader(System.Data.SqlClient.SqlDataReader, System.Data.SqlClient.RunBehavior, System.String)
    0000000acfb0cde0 000007fef2c6688b System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(System.Data.CommandBehavior, System.Data.SqlClient.RunBehavior, Boolean, Boolean, Int32, System.Threading.Tasks.Task ByRef, Boolean, System.Data.SqlClient.SqlDataReader)
    0000000acfb0cee0 000007fef2c65cfa System.Data.SqlClient.SqlCommand.RunExecuteReader(System.Data.CommandBehavior, System.Data.SqlClient.RunBehavior, Boolean, System.String, System.Threading.Tasks.TaskCompletionSource`1<System.Object>, Int32, System.Threading.Tasks.Task ByRef, Boolean)
    0000000acfb0cfb0 000007fef2c65a9b System.Data.SqlClient.SqlCommand.RunExecuteReader(System.Data.CommandBehavior, System.Data.SqlClient.RunBehavior, Boolean, System.String)
    0000000acfb0d040 000007fef2c64860 System.Data.SqlClient.SqlCommand.ExecuteReader(System.Data.CommandBehavior, System.String)
    0000000acfb0d100 000007fef2c644a4 System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(System.Data.CommandBehavior)
    0000000acfb0d160 000007fef2c69a55 System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(System.Data.CommandBehavior)
    0000000acfb0d190 000007fef2c4c5c5 System.Data.Common.DbDataAdapter.FillInternal(System.Data.DataSet, System.Data.DataTable[], Int32, Int32, System.String, System.Data.IDbCommand, System.Data.CommandBehavior)
    0000000acfb0d240 000007fef2c4c404 System.Data.Common.DbDataAdapter.Fill(System.Data.DataSet, Int32, Int32, System.String, System.Data.IDbCommand, System.Data.CommandBehavior)
    0000000acfb0d2f0 000007fef2c4c206 System.Data.Common.DbDataAdapter.Fill(System.Data.DataSet)
    0000000acfb0d3a0 000007fe9962c56e Genersoft.Platform.Core.DataAccess.Database.GetDataSet(System.String, System.String, System.Data.IDbDataParameter[], Boolean)
    0000000acfb0d470 000007fe99de3d47 Genersoft.Platform.Core.DataAccess.Database.RunProcGetDataSet(System.String, System.String, System.Data.IDbDataParameter[], Int32[])
    0000000acfb0d4f0 000007fe9a342beb Genersoft.Platform.Core.DataAccess.Database.GetPaginaryDataSet(System.String, System.String, System.String, System.String, System.String, System.String, Int32, Int32, Int32 ByRef, Int32 ByRef, System.String, System.String, System.String)
    0000000acfb0d590 000007fe9a358975 Genersoft.Platform.Workflow.Server.BusinessProcess.RefWorkItemBillMgr.GetWorkItemsWithCustomFields(System.String, System.String, Genersoft.Platform.Workflow.Spi.Model.InstanceApprovalState, Genersoft.Platform.Core.Common.GSPFilter)
    0000000acfb0d680 000007fe9a35793a GSP_WorkflowWebService.ORUWebService.GetWorkItemsWithCustomFields(System.String, System.String, System.String, System.String ByRef)
    0000000acfb0dbf8 0000000000000000 DebuggerU2MCatchHandlerFrame
    0000000acfb0dc58 0000000000000000 HelperMethodFrame_PROTECTOBJ [System.RuntimeMethodHandle.InvokeMethod(System.Object, System.Object[], System.Signature, Boolean)]
    0000000acfb0ddd0 000007fef7aed28c System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(System.Object, System.Object[], System.Object[])
    0000000acfb0de40 000007fef7aee2b1 System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
    0000000acfb0df60 000007fe9960b5e5 Genersoft.Platform.AppFramework.Service.GSPRestfulContext.Invoke(System.String, System.String, System.String, Boolean, System.String[], Int32[] ByRef, System.String[] ByRef)
    0000000acfb0e020 000007fe996093f4 Genersoft.Platform.AppFramework.RESTFulWebService.GSPHttpWebHandler.Invoke(System.IO.BinaryReader, System.Web.HttpContext)
    0000000acfb0e120 000007fe996088e9 Genersoft.Platform.AppFramework.RESTFulWebService.GSPHttpWebHandler.ProcessRequest(System.Web.HttpContext)
    0000000acfb0e260 000007fef1cd2d41 System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    0000000acfb0e340 000007fef1c98bd5 System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)
    0000000acfb0e3e0 000007fef254d8f8 System.Web.HttpApplication+ApplicationStepManager.ResumeSteps(System.Exception)
    0000000acfb0e490 000007fef2428cf3 System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(System.Web.HttpContext, System.AsyncCallback, System.Object)
    0000000acfb0e4f0 000007fef244c515 System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest)
    0000000acfb0e5b0 000007fef253d592 System.Web.Hosting.ISAPIRuntime.ProcessRequest(IntPtr, Int32)
    0000000acfb0e6d0 000007fef24066c0 DomainNeutralILStubClass.IL_STUB_COMtoCLR(Int64, Int32, IntPtr)
    0000000acfb0eaa8 0000000000000000 ContextTransitionFrame
    0000000acfb0ecc0 0000000000000000 ComMethodFrame
  • 相关阅读:
    C# DataGridview转换为DataTable
    未在本地计算机上注册“microsoft.ACE.oledb.12.0”提供程序
    ORM(Object Relational Mapping)框架
    C#开发小技巧
    Windows系统中Oracle11g R2 版本数据库卸载
    world特殊控制符输入
    Java中生成帮助文档
    Java类——JDBC链接、并操作MySQL数据库
    Java——实现对密码进行MD5加密
    HTTP协议详解
  • 原文地址:https://www.cnblogs.com/zhaoguan_wang/p/8158251.html
Copyright © 2020-2023  润新知