【问题标题】:Breakpoint isn't hitting in WinDBG断点在 WinDBG 中没有命中
【发布时间】:2019-11-11 04:43:58
【问题描述】:

C#中有一个简单的程序:

namespace Stack_and_call_x86
{
    class Program
    {
        static void Main(string[] args)
        {
            int result = Add(2,4);
        }

        static int Add (int a, int b)
        {
            int answer = a + b;
            return answer;
        }
    }
}

我在 MVS 2019 中编写并编译了它。我正在尝试在 WinDbg 中对其进行调试。似乎我做的一切都是正确的,我注册了符号的路径,我指出了 .cs 文件的位置,我使用了 Launch 可执行程序。 (我使用的是 Debug 文件夹中的 .exe)。我放了一个断点:

bp Stack_and_call_x86!主要

它产生以下内容:

WARNING: Unable to verify checksum for Stack_and_call_x86.exe
Operation not supported by integrated managed debugging.
error at 'Stack_and_call_x86! main'
The breakpoint expression "Stack_and_call_x86! Main" evaluates to the inline function.
Please use bm command to set breakpoints instead of bp.

好的,我放bm:

bm Stack_and_call_x86!主要

嗯,好像设置好了:

1: <MSIL: 00ca0000> @! "Stack_and_call_x86! Main"

然后,运行并得到以下错误:

ModLoad: 75e20000 75e99000 C: \ WINDOWS \ SysWOW64 \ ADVAPI32.dll
Breakpoint 1's offset expression evaluation failed.
Check for invalid symbols or bad syntax.

附言

如果我通过 File - Open Source File 打开 .cs 文件,并在代码中设置了一个断点,那么它是设置的,但是当我启动它时,我得到一个错误:

无法在 00ca0001 处插入断点 0,Win32 错误 0n998 “访问内存地址的尝试无效。” bp0 at 00ca0001 失败

【问题讨论】:

  • 对于托管代码,你应该依赖sos。它有一个与托管方法一起使用的!bpmd 方法。
  • @BrianRasmussen,是的,谢谢,我已经明白了。现在我正在使用 sosex。
  • 那么,你能回答你的问题了吗?
  • !sos.bpmd 和 !sosex.mbp 是最简单的选项。但是,通过一些手动工作,您仍然可以使用 bp。使用 !sos.name2ee Stack_and_call_x86.exe!Stack_and_call_x86.Program.Main 查找类型详细信息。如果它被jitted,你可以使用 bp 来打破它。如果还没有被jitted,可以用!sos.dumpmt -md 找到MethodDescr,然后用!sos.bpmd -md

标签: c# debugging windbg breakpoints


【解决方案1】:

对我来说,接下来的步骤正在发挥作用:

  1. 下载 sosex.dll
  2. 在 WinDbg 中:

    2.1。打开可执行文件

    2.2。编写以下命令:

    • sxe ld clrjit
    • g
    • .load C:\SOSEX\sosex.dll(你的 sosex.dll 路径)
    • !mbp Program.cs 14(您的 Name.cs 文件和您想要的行 插入断点)
    • g

【讨论】:

    猜你喜欢
    • 2012-01-06
    • 2012-03-24
    • 1970-01-01
    • 2014-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-12
    • 2012-06-01
    相关资源
    最近更新 更多