none
Breakpoint not hit in native C++ implementation of profiler

    Question

  • Hi.

     

    I had to reinstall my computer from scratch a few weeks ago (Win7 x64).

    Now, I'm unable to debug my project: a native C++ implementation of profiler API that change managed code (IL) on the fly before loading it.

    In short: from VS2010, I run an external process that is profiled with my own native C++ DLL.

    I start without debug, with an option for my started app (in HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Option\MyApp.exe) specifying 'debugger' to 'vsjitdebugger.exe'.

    I also specify 'BreakOnDllLoad' to 1 in  HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Option\MyProfiler.dll

    At startup, the vsjitdebugger ask me what VS i want to debug my process and it stops when loading MyProfiler.dll. I'm able to put breakpoints in DllMain and run to them with no problem.

    BUT, when I put breakpoints in any other places (in my classes implementing profiling DCOM interfaces), they are not hit! If I add DebugBreak(); __debugbreak(); it does not stop either.

    I debug for a few days with traces in the code, but it is not a solution!

    What's wrong?

     

    For your information, I just try to debug again, but from home.

    Fortunately, I choose the wrong debugger: VS2008 instead of VS2010 and... it works! I'm able to debug my DLL.

    I would prefer to be able to debug with VS2010 because I don't want to install VS2008 at work only to be able to debug my project...

    I compare options and they seem the same!?!?

     Any idea?

     

    I tried to debug my project directly on Integration Server (it has both VS2008 and VS2010 installed) and I wasn't able to debug!?!?

    What's the difference?

     

    Many Thanks.

    Wednesday, April 20, 2011 11:53 AM

Answers

  • Ok, I found the answer myself: I change C++ property 'Debug Information Format' from 'Program Database for Edit And Continue (/ZI)' to 'Program Database (/Zi)' and it works now!!!

    I don't think I have changed any thing else (because I changed it a few days ago and I tried again yesterday only).

    Wednesday, June 8, 2011 12:10 PM

All replies

  • So,  you can debug the C++ project with VS2008, but not VS2010, even though they have same project settings, am I right?

     

    A breakpoint will not hit if the corresponding symbol file is not loaded, so you may check the symbol file setting of both VS2008 and VS2010, select Tools -> Options -> Debugging -> Symbols;


    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, April 21, 2011 3:17 AM
  • In fact, this is the same project!

    It is a little bit complicated: it is a LanguageService for Visual T#: a language specialized for unit testing, developed with C#.

    I use T# v1 to test T# v2 (currently in development).

    Thus, when running tests, T# run an external program (aka tsharp-remote.exe) that load and run the tests from the test project binaries. This binary run the same external program, but for v2 that is "profiled" to be able to change IL at load time (for mocking purposes). So, I cannot debug just pressing F5!

    I added an entry in HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\tsharp-remote.exe : "Debugger"="vsjitdebugger.exe" so that the debugger is  launched at start of the application.

    I added an entry for TSharpAOP-x64.dll at the same place, with "BreakOnDllLoad"=1 and "Debugger"="vsjitdebugger.exe"

     

    When I run my tests, the tsharp-remote.exe file is loaded and the debugger ask me what debugger to choose. I can choose any one because I do not want to debug this one. Then the second tsharp-remote.exe is run (v2) and if I choose VS2010 instance for debugging, it only breaks in my C# code. If I choose VS2008 instance for debugging, it stops at the beginning of my DLL (the profiler for tsharp-remote.exe v2) and the breakpoints in C++ are hit!

     

    If I try to do the same thing on my Integration Server (it has both VS) it do not stop on C++ breakpoints... My work computer does not have VS2008 installed and I cannot debug C++ part.

     

    I just verify all settings for both VS2008 and VS2010, they are exactly the same. I verify both at home and at work and they are exactly the same...

     

    I have to work from home... it's not a good thing. What if my home computer crashes? I will not be able to do anything!

     

    Thanks for your help.

    Thursday, April 21, 2011 1:40 PM
  • In VS, after adding the breakpoint, did you specify the location? As an example, {,,MyProfiler.dll}DllMain if you want to break when MyProfiler.dll gets loaded. To debug any specific function please specify the function name instead of DllMain. For more syntax, please follow this link http://msdn.microsoft.com/en-us/library/wztycb7f.aspx


    --Trevor H.
    Send files to Hotmail.com: "MS_TREVORH"
    Thursday, May 19, 2011 4:46 PM
    Owner
  • In fact, I'm able to set breakpoints in DllMain and it stops as expected.

    Problem is for my C++ Methods. It does not stop at all!

    Friday, May 27, 2011 1:18 AM
  • Ok, I found the answer myself: I change C++ property 'Debug Information Format' from 'Program Database for Edit And Continue (/ZI)' to 'Program Database (/Zi)' and it works now!!!

    I don't think I have changed any thing else (because I changed it a few days ago and I tried again yesterday only).

    Wednesday, June 8, 2011 12:10 PM
  • Hi, I'm with the same problem, using Visual Studio 2017. The project that I'm trying to debug is OpenCover (https://github.com/OpenCover/opencover) and I can´t debug the profiler. When I attach the process profiled Visual Studio tells me that there are no symbols loaded. Is there something else that I can do?
    Tuesday, October 30, 2018 11:47 AM