General discussion

Locked

Debugging Virtual Functions in Managed C++ App

By M_a_r_k ·
I am developing a Managed C++ application using Visual Studio.NET 2003. This is the first Managed C++ app I've ever written. While debugging, when I attempt to step into a virtual function, the debugger is unable to find the source file where the virtual function is located. I get this error:
"There is no source code available for the current location." I can step into the assembly language of the called virtual function but not the C++ source code.

I also tried this with a very small test program consisting only of main(), one base class and one derived class containing a virtual function. The whole program was in a single module. I encountered the same debugger problem. The debugger couldn't even locate the called source code even though it's in the same module as the calling function. The code works and the debugger returns properly from the called function, but it just won't show the source.

I rebuilt everything in unmanaged C++ and the debugger works fine. Very annoying not being able to debug virtual functions.

Anyone have a clue what's going on? Thanks.

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Try Unit Tests Instead

by Wayne M. In reply to Debugging Virtual Functio ...

I can't help with the debugger problem, but I can suggest that you try writing some test code instead.

Create a shell test program (I believe there is probably a .Net version of the xUnit family available on the Internet) and create some inputs to drive the failing condition and some output evaluations to detect it. Don't get hung up on writing tests at the per-class level, rather write them at the highest level that makes sense for your project.

After getting used to test first design, you may never go back to using a debugger again.

Collapse -

Unit testing

by M_a_r_k In reply to Try Unit Tests Instead

Are you referring to using the old printf/cout method of testing? I don't know anything about this xUnit. Is it more powerful or flexible than a good debugger? Debuggers are great (when they work reliably) because you can step through code and watch any variable change and see what's going on in memory.

Collapse -

I have the same problem.

by jamesuts2004 In reply to Debugging Virtual Functio ...

I have the same problem. I cannot access virtual function with debugging. It always say
"There is no source code available for the current location." I am using visual studio.net 2003 professional.

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums