Mikhail
Mikhail

Reputation: 21

Breakpoint isn't hitting in WinDBG

There is a simple program in 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;
        }
    }
}

I wrote and compiled it in MVS 2019. I'm trying to debug it in WinDbg. It seems that I’m doing everything right, I registered the paths to the symbols, I indicated the location of the .cs file, I use the Launch executable program. (I'm using the .exe from the Debug folder). I put a breakpoint:

bp Stack_and_call_x86! main

It produces the following:

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.

OK, I put bm:

bm Stack_and_call_x86! main

Well, it seems to be set:

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

Then, run and get the following error:

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

P.S.

If I open the .cs file through File - Open Source File, and there put a breakpoint in the code, then it is set, but when I start it, I get an error:

Unable to insert breakpoint 0 at 00ca0001, Win32 error 0n998     "Invalid attempt to access memory address." bp0 at 00ca0001 failed

Upvotes: 1

Views: 1563

Answers (1)

Mikhail
Mikhail

Reputation: 21

For me the next steps are working:

  1. Download the sosex.dll
  2. In WinDbg:

    2.1. Open executable

    2.2. Write the following commands:

    • sxe ld clrjit
    • g
    • .load C:\SOSEX\sosex.dll (your path to sosex.dll)
    • !mbp Program.cs 14 (Your Name.cs file and line where you want to insert breakpoint)
    • g

Upvotes: 1

Related Questions