General discussion

  • Creator
    Topic
  • #2188965

    Debugging Virtual Functions in Managed C++ App

    Locked

    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.

All Comments

  • Author
    Replies
    • #3046547

      Try Unit Tests Instead

      by wayne m. ·

      In reply to Debugging Virtual Functions in Managed C++ App

      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.

      • #3046442

        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.

    • #3137778

      I have the same problem.

      by jamesuts2004 ·

      In reply to Debugging Virtual Functions in Managed C++ App

      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.

Viewing 1 reply thread