我正在尝试使用 windbg 在我的 VS2010 .net4 应用程序中为未处理的异常获取正确的调用堆栈。主程序是一个控制台应用程序。这个 dll 正确加载了它的符号。在同一目录中,我有一个不会加载的 dll+匹配的 pdb。
我在 Windows Server 2008 R2、64 位(未安装 VS)上运行该应用程序。但是该应用程序是在 32 位上编译的。我正在使用 winX86 调试器附加到进程。
我已经从 http://www.stevestechspot.com/(32位版本)下载了支持 .net 4 的 sosex,sos.dll(来自“C:\Program Files (x86)\Debugging Tools for Windows (x86)\ clr10\sos.dll") 版本为 6.12.2.633。
发出以下命令:
sympath+ "...folder of exe and dll"
.loadby sos clr
.load sosex.dll
运行时 !mk 我得到以下信息:
Thread 0:
ESP EIP
00:U 0016ec6c 5f636578 0x5f636578
01:U 0016ec70 05f1380f SN!SN_MedistoreEngine::FetchNotes+0x13f [v:\mp\mp\src\sn\sn_medistoreengine.cpp @ 59]
02:M 0016edbc 07dd0db1 SN_Bridge.SNB_bridge.fetch_notes(IOD_Msg*, System.String, System.String, Boolean)(+0x4a IL)(+0x131 Native) [v:\mp\portal\commonutils\src\snb\snb_bridge.cpp, @ 142,0]
03:M 0016ef24 055bfde5 SN_Bridge.SNB_bridge.FetchNotesByStudyUId(System.String, System.String, System.Collections.Generic.List`1<SN_Bridge.SNB_StickyNote>)(+0x25 IL)(+0x55 Native) [v:\mp\portal\commonutils\src\snb\snb_bridge.cpp, @ 296,0]
04:M 0016efb0 055bfd22
"xxx.Services.StickyNotes.dll" was not found in the image list.
Debugger will attempt to load "xxx.Services.StickyNotes.dll" at given base 00000000.
Please provide the full image name, including the extension (i.e. kernel32.dll)
for more reliable results.Base address and size overrides can be given as
.reload <image.ext>=<base>,<size>.
Unable to add module at 00000000
"xxx.ni.Services.StickyNotes.dll" was not found in the image list.
Debugger will attempt to load "xxx.ni.Services.StickyNotes.dll" at given base 00000000.
Please provide the full image name, including the extension (i.e. kernel32.dll)
for more reliable results.Base address and size overrides can be given as
.reload <image.ext>=<base>,<size>.
Unable to add module at 00000000
xxx.Services.StickyNotes.StickyNotesLogic.StickyNotesByStudyID(System.String, System.String, System.String)(+0x1d IL)(+0x52 Native)
05:M 0016efcc 055ba0ab SNConsole.Program.Main(System.String[])(+0x101 IL)(+0x24b Native) [D:\Documents and Settings\tamar\My Documents\Visual Studio 2010\Projects\SNConsole\Program.cs, @ 48,17]
06:U 0016f02c 72da21db clr+0x21db
07:U 0016f034 72dae021 clr!DllUnregisterServerInternal+0x8025
08:U 0016f090 72dbc58d clr!DllUnregisterServerInternal+0x16591
运行 !clrstack 时,我得到以下信息:
PDB symbol for clr.dll not loaded
OS Thread Id: 0x2984 (0)
Child SP IP Call Site
0016edc8 5f636578 [InlinedCallFrame: 0016edc8]
0016edc4 07dd0db1 SN_Bridge.SNB_bridge.fetch_notes(IOD_Msg*, System.String, System.String, Boolean) [v:\mp\portal\commonutils\src\snb\snb_bridge.cpp @ 142]
0016ef30 055bfde5 SN_Bridge.SNB_bridge.FetchNotesByStudyUId(System.String, System.String, System.Collections.Generic.List`1<SN_Bridge.SNB_StickyNote>) [v:\mp\portal\commonutils\src\snb\snb_bridge.cpp @ 296]
0016efb0 055bfd22 xxx.Services.StickyNotes.StickyNotesLogic.StickyNotesByStudyID(System.String, System.String, System.String)
0016efcc 055ba0ab SNConsole.Program.Main(System.String[]) [D:\Documents and Settings\tamar\My Documents\Visual Studio 2010\Projects\SNConsole\Program.cs @ 48]
0016f25c 72da21db [GCFrame: 0016f25c]
如您所见,在这两种情况下,除了 xxx.Services.StickyNotes.dll 行之外,我都在堆栈中获得了文件名 + 行号。
我试过:
.realod /f ""c:...\xxx.Services.StickyNotes.dll" - 相同的错误和
ld "c:...\xxx.Services.StickyNotes.dll"导致
没有模块匹配 'c:...\Bin\xxx.Services.StickyNotes.dll'
使用 !sym quiet 没有帮助,我认为它甚至没有尝试加载 pdb,因为模块本身没有加载。
我不知道为什么这个特定的 dll 不会加载。SN_Console.exe 和 SNB_Bridge.dll 从同一目录加载没有问题。(我不关心异常本身,我植入了创建的代码。问题是关于建立一个好的调试环境)。
提前致谢,添马舰