我正在使用VS.NET 2010。我编写了一个非常简单的.NET 4.0应用程序。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestWindbg
{
class Program
{
static void Main(string[] args)
{
Console.ReadLine();
Func1();
}
static void Func1()
{
int i = 0;
int j = i + 2;
Console.WriteLine(j);
}
}
}
我通过windbg 6.12.0002.633打开已编译的可执行文件。输入以下命令来加载sosex
.loadby sosex clr
然后,输入以下命令来设置断点
!mbm TestWindbg.Program.Func1
!mbp Program.cs 16
然后运行程序。没有一个破发点被击中。
有什么想法吗?
*编辑*
在这里,我按照Marc的请求粘贴关于我的环境的更多细节
0:004> !mbl
1 eu: disable *!TESTWINDBG.PROGRAM.FUNC1 ILOffset=0: pass=1 oneshot=false thread=ANY
2 eu: disable Program.cs, line 16: pass=1 oneshot=false thread=ANY
0:004> .chain
Extension DLL search Path:
C:\Program Files\Debugging Tools for Windows (x64)\WINXP;C:\Program Files\Debugging Tools for Windows (x64)\winext;C:\Program Files\Debugging Tools for Windows (x64)\winext\arcade;C:\Program Files\Debugging Tools for Windows (x64)\pri;C:\Program Files\Debugging Tools for Windows (x64);C:\Program Files\Debugging Tools for Windows (x64)\winext\arcade;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\10.0\DLLShared\;C:\Program Files (x86)\Shoreline Communications\ShoreWare Client\;C:\Program Files (x86)\Perforce;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\
Extension DLL chain:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\sosex: image 4.5.0.0, API 1.0.0, built Mon May 21 11:39:36 2012
[path: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\sosex.dll]
dbghelp: image 6.11.0001.404, API 6.1.6, built Wed Feb 25 18:10:27 2009
[path: C:\Program Files\Debugging Tools for Windows (x64)\dbghelp.dll]
ext: image 6.11.0001.404, API 1.0.0, built Wed Feb 25 18:10:26 2009
[path: C:\Program Files\Debugging Tools for Windows (x64)\winext\ext.dll]
exts: image 6.11.0001.404, API 1.0.0, built Wed Feb 25 18:10:17 2009
[path: C:\Program Files\Debugging Tools for Windows (x64)\WINXP\exts.dll]
uext: image 6.11.0001.404, API 1.0.0, built Wed Feb 25 18:10:20 2009
[path: C:\Program Files\Debugging Tools for Windows (x64)\winext\uext.dll]
ntsdexts: image 6.1.7015.0, API 1.0.0, built Wed Feb 25 18:09:22 2009
[path: C:\Program Files\Debugging Tools for Windows (x64)\WINXP\ntsdexts.dll]
0:004> sx
ct - Create thread - ignore
et - Exit thread - ignore
cpr - Create process - ignore
epr - Exit process - break
ld - Load module - output
ud - Unload module - ignore
ser - System error - ignore
ibp - Initial breakpoint - break
iml - Initial module load - ignore
out - Debuggee output - output
av - Access violation - break - not handled
asrt - Assertion failure - break - not handled
aph - Application hang - break - not handled
bpe - Break instruction exception - break
bpec - Break instruction exception continue - handled
eh - C++ EH exception - second-chance break - not handled
clr - CLR exception - second-chance break - not handled
clrn - CLR notification exception - second-chance break - handled
cce - Control-Break exception - break
cc - Control-Break exception continue - handled
cce - Control-C exception - break
cc - Control-C exception continue - handled
dm - Data misaligned - break - not handled
dbce - Debugger command exception - ignore - handled
gp - Guard page violation - break - not handled
ii - Illegal instruction - second-chance break - not handled
ip - In-page I/O error - break - not handled
dz - Integer divide-by-zero - break - not handled
iov - Integer overflow - break - not handled
ch - Invalid handle - break
hc - Invalid handle continue - not handled
lsq - Invalid lock sequence - break - not handled
isc - Invalid system call - break - not handled
3c - Port disconnected - second-chance break - not handled
svh - Service hang - break - not handled
sse - Single step exception - break
ssec - Single step exception continue - handled
sbo - Stack buffer overflow - break - not handled
sov - Stack overflow - break - not handled
vs - Verifier stop - break - not handled
vcpp - Visual C++ exception - ignore - handled
wkd - Wake debugger - break - not handled
wob - WOW64 breakpoint - break - handled
wos - WOW64 single step exception - break - handled
* - Other exception - second-chance break - not handled
*编辑8/17/2012 *
多亏了colinsmith,我想你得到了最贴切的答案。我把我的程序编译成32位程序。切换到使用32位Windbg和32位sosex。按照相同的步骤设置断点。现在,如果我做!mbl
。断点列表以不同方式显示。
0 e : disable *!TESTWINDBG.PROGRAM.FUNC1 ILOffset=0: pass=1 oneshot=false thread=ANY
TestWindbg!TestWindbg.Program.Func1() (PENDING JIT)
以前,我没有看到(PENDING JIT)
这一行。继续程序,Windbg成功地停止在断点。
我不知道为什么64位程序不能工作。我检查了64位sosex.dll和64位程序符号路径.一切看起来都是正确的。也许,它是sosex.dll中的一个bug?
我使用的是Windows4.0,我的.NET运行在Windows200864位的R2中。
发布于 2012-08-18 12:01:23
这里有一些建议,需要检查的东西:
在设置断点之前等待加载模块
您可以尝试在设置断点之前等待运行时/JITter/模块加载/初始化。
使用:
sxe ld:clrjit
负载后的断裂)或sxe ld:MyModuleAssemblyName
这将导致在调试器拥有occurred....you之后进入调试器,然后可以执行!mbm
等等。
检查您的程序私有符号(来自它的.pdb)是否已正确加载
使用:
lml
再匹配(显示已加载且未能加载符号)lme
再匹配(仅显示未能加载符号)。您也可以使用!sym noisy
对符号加载活动进行详细跟踪,例如帮助发现何时已损坏.pdbs等。
有关PDB相关错误代码的有用参考:
关于验证符号是否正确加载的一般性讨论,请参阅:
使用32位或64位WinDBG
此外,您是否可以尝试在32位调试器下运行您的程序,而不是使用64位调试器(并使用course...and编译的32位SOSEX插件作为x86)...and,看看是否得到了相同的结果。
使用SOSEX的最新版本
在Steves中,他说他破坏了XP (你看上去正在使用)...maybe的兼容性,这就是问题所在。(日期:2012年6月8日)
发布于 2021-09-22 20:09:20
作为另一种选择,只要您控制了源代码,就可以尝试在您的DebugBreak代码中添加一个C#语句。在编译成二进制文件之后,Windbg将中断。
DebugBreak在C# How can I use DebugBreak() in C#?中的一个很好的参考
https://stackoverflow.com/questions/11768921
复制相似问题