DebugDiag script to load all symbols in a dump file
At times you really need to load symbols for all modules loaded in a dump either because you want to put a breakpoint on some function (which is not exported in a module or you want) or to see the right function names in call-stacks logged in the DebugDiag's log file for debugging purposes.
The existing Crash hang Analysis scripts load symbols for modules loaded in the process but they just don't load ALL the symbols. They only load symbols for modules that required to display in the report. Also the memory analysis scripts load symbols for modules which are required for looking at the memory allocations but the below script loads modules for ALL symbols loaded in the process
<%@ Language = VBScript %> <%@ Category = Load Symbols %> <%@ Description = Loading symbols for all modules in the process %> <%@ TopLevelScript = True %> <% Option Explicit %> <%
Const ANALYSIS_STEP_COUNT = 10
Dim g_Debugger, g_DataFile, g_Progress,g_OverallProgress,intPosition, intLen,g_ShortDumpFileName
Set g_Progress = Manager.Progress
g_Progress.SetOverallRange 0, Manager.DataFiles.Count * ANALYSIS_STEP_COUNT g_Progress.OverallPosition = 0 g_Progress.OverallStatus = ""
g_Progress.CurrentStatus = ""
g_Progress.CurrentPosition = 0 g_OverallProgress = 0 g_Progress.OverallStatus = "Starting Analysis"
' Main analysis and reporting loop. One iteration for each dump file
Manager.ReportInformation "This script is used to load symbols for all modules loaded in the dump file"
For Each g_DataFile In Manager.DataFiles If (UCase(Right(g_DataFile,4)) = ".DMP") Then Set g_Debugger = Manager.GetDebugger(g_DataFile)
If Not g_Debugger Is Nothing Then 'Trim g_DataFile down to just the filename itself for later use
intPosition = InStrRev(g_DataFile, "\", -1, 1)
intLen = Len(g_DataFile)
g_ShortDumpFileName = Right(g_DataFile, intLen - intPosition) 'Go ahead and get any extension objects we'll need later
g_Progress.OverallStatus = "Loading symbols for dump " & g_ShortDumpFileName
g_Debugger.Execute("!symfix c:\symcache")
g_Debugger.Execute(".reload")
g_Debugger.Execute("ld*")
Manager.Write "<h3> Finished Loading symbols for the dump file - " & g_DataFile & "<h3>" Else
Manager.ReportError "Unable to open the file " & g_DataFile & " for analysis.", "The file is probably " &_ "corrupt, and a new dump file of the targeted process will have to be created to do any analysis."
End If Manager.CloseDebugger g_DataFile End If Next
%>
|
The light highlighted in yellow above shows a call to g_Debugger.Execute() which executes a debugger command and returns you the output of that command. For e.g. the above line will call vertarget on the dump file. For more information on this method, go through the documentation (DebugDiag.chm) that comes with the DebugDiag tool and look for the DbgObj object.
Leave a comment