I have a Visual Studio extension that hooks into debugging events. When the debugger stops at a line of code, my IDebugEventCallback2
callback gets called, and I can find out the filename and line number where the debugger has stopped via IDebugThread2::EnumFrameInfo
.
I'd like to know the range of source code lines that the current function spans.
I'm hoping it's possible to derive the information I need from the debugger interfaces - the debugger must know the line range of functions. If that's not possible, I'm open to any other methods. In an ideal world the solution would work without the project system - many people, myself included, use Visual Studio as a stand-alone debugger without using the project system. (Also, I can't rely on Roslyn - it needs to work in existing versions of Visual Studio.)
Edit: Carlos's method of using FileCodeModel
works well, as long as the file is part of a project. I'd still love to know whether there's a method that doesn't require the project system.
GetSourceRange()
returns the range of the current statement, not the whole frame, andSeek()
returns 0x80004001 "Not implemented" from the C++ debugger. (Not my downvote, BTW.) (And thanks for the pointer to your excellent CodeModel article, which I'd already looked at. :-) ) – Rojas