开发者

debug c# managed application: how to set a breakpoint when it opens a file

开发者 https://www.devze.com 2022-12-13 17:25 出处:网络
I have开发者_如何学运维 a big project which is a C# project, I have the source but I didn\'t build the entire project(it\'s too large). And the project is not in a VS.NET project, it\'s built by Makef

I have开发者_如何学运维 a big project which is a C# project, I have the source but I didn't build the entire project(it's too large). And the project is not in a VS.NET project, it's built by Makefile. So I am using VS.NET to attach to the process when it is running.

Now what I want is when the process opens a specific file, I want to break it and get a stack trace. Firstly I can accept only get the trace without the symbol - I can build the DLL with symbols in another run. I can use procmon.exe to see the trace to open files, but I don't know how to set breakpoint based on the file being opened. Please suggest.


System.Diagnostics.Debugger.Break();


Assuming your makefile is producing PDB files as Yuriy mentioned, you can do the following:

1) Attach the VS Debugger to the process you are running and
   immediately hit pause/break
2) Open the file you want the debugger to break in VS editor
3) Set the breakpoint at the desired location, optionally you
   can add conditions if you like (right click on the breakpoint)
4) Hit Run (F5)

This should break the debugger at the desired location when that code executes.

0

精彩评论

暂无评论...
验证码 换一张
取 消