我正在尝试使用windbg为我的VS2010 .net4应用程序中的未处理异常获取正确的callstack。 主程序是一个控制台应用程序。这个dll正确加载了它的符号。 在同一目录中,我有一个dll +匹配的pdb,不会加载。
我在Windows服务器2008 R2 64位上运行应用程序(没有安装VS)。但该应用程序是在32位编译。我正在使用winX86调试器附加到进程。
我已经下载了支持.net 4的sosex http://www.stevestechspot.com/(32位版本) sos.dll(来自“C:\ Program Files(x86)\ Windows调试工具(x86)\ clr10 \ sos.dll”)版本为6.12.2.633。
发出以下命令:
sympath +“... exe和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:... \宾\ xxx.Services.StickyNotes.dll'
使用!sym noisy没有帮助,我认为它甚至没有尝试加载pdb,因为模块本身没有加载。
我无法弄清楚为什么这个特定的dll不会加载。 SN_Console.exe和SNB_Bridge.dll从同一目录加载没有问题。 (我不关心异常本身,我种下了创建的代码。问题在于建立一个良好的调试环境。)
提前致谢, 塔马
答案 0 :(得分:3)
我碰巧亲自回答了这个问题,但这是有记录的故事,万一其他人偶然发现它:http://blogs.microsoft.co.il/blogs/sasha/archive/2011/01/16/clr-4-does-not-use-loadlibrary-to-load-assemblies.aspx
总体情况是CLR 4不使用LoadLibrary来加载程序集,因此调试器无法获取DLL及其符号。