CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: debug in release mode

  1. #1
    Join Date
    May 2015
    Posts
    277

    debug in release mode

    Hello,

    I have a multiple solutions (around 8 solutions ) and each of them have multiple projects.

    I am using the incredibuild and built all the solutions in the Release mode.

    Now when i try to attach the solution which i want to debug, and try to put the breakpoint in it:
    I get error :
    "Breakpoint currently will not be hit. No symbols have been loaded for this document"

    Not sure what I need to do. I use all the project settings ( which was already there) and since it is huge project, I am bit stuck the moment with this issue.

    Forgot to mention, that, I am using Debug -> "Attach to Process" to debug. Because I want to run to some scenario and put breakpoint after that.

    Just to let you know (about my expertise level), I am also bit new to visual studio env (eventhough i used c++ with eclipse earlier)

    Thanks a lot
    Any suggestions will help me a lot
    Pdk
    Last edited by pdk5; June 23rd, 2020 at 12:22 PM.

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,597

    Re: debug in release mode

    Why debug in release mode?
    Did you compile and link to include debug info?
    Is there a reason you're using attach rather than starting the app in the debugger?

  3. #3
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,193

    Re: debug in release mode

    Re-build the soultion using Debug mode. Release mode strips away debug info etc and does code optimisation. You should only compile as Release when you're happy with the solution - for final testing as Release build. Debug mode is what you use when you are developing and debugging. Release (as it's name implies) is for the 'final' release build. Note that Debug build can run slower than Release build - so don't do performance testing with Debug build.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.7.0)

  4. #4
    Join Date
    May 2015
    Posts
    277

    Re: debug in release mode

    @ kaud and GCDEF : Thanks a lot for the comments and inputs:

    Yes, I usually debug in debug mode. But this is special case, where i need to use the third party tool (with lot of settings). that can only be attached in Release mode. I am new to this project (so collegues had told me, that i can only use Release mode for this setup). So what they tell must be true.

    So i want to debug in Release mode, only this particular case.

    My collegue had told me earlier, i can still put breakpoint and debug in release mode.
    Last edited by pdk5; June 23rd, 2020 at 01:17 PM.

  5. #5
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,597

    Re: debug in release mode

    Quote Originally Posted by pdk5 View Post
    @ kaud and GCDEF : Thanks a lot for the comments and inputs:

    Yes, I usually debug in debug mode. But this is special case, where i need to use the third party tool (with lot of settings). that can only be attached in Release mode. I am new to this project (so collegues had told me, that i can only use Release mode for this setup). So what they tell must be true.

    So i want to debug in Release mode, only this particular case.

    My collegue had told me earlier, i can still put breakpoint and debug in release mode.
    Are you trying to debug a third party tool? You can't do that unless you have a debug version of it including their pdb file.

  6. #6
    Join Date
    Feb 2017
    Posts
    550

    Re: debug in release mode

    Quote Originally Posted by pdk5 View Post
    Any suggestions will help me a lot
    It's perfectly possible to debug without a debugger. Just put traces in the (release mode) code and go with the flow.

  7. #7
    Join Date
    May 2015
    Posts
    277

    Re: debug in release mode

    Im not debugging third party tool. Third party tool produces some kind of input to our application.

  8. #8
    Arjay's Avatar
    Arjay is online now Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,318

    Re: debug in release mode

    @pdk5. Read up on the differences between debug and release builds. The release build is usually optimized (e.g. the compiled binary may not match the source code). The debug build isn't optimized and debug symbols are generated. The symbols are essentally pointers from the binary to the code.

    There's a lot going on when you are debugging and what happens when break points are set, how the symbols are used to find the positions in the code and so on, but what is imoprtant is the symbols match the binaries.

    Now it is an option to create a release build with symbols, but with optimizations, you'll often be stepping through blamk lines of code (because the optimizations are performed by the compiler amd not reflected by the code).

    At any rate it is curious that the 3rd party dll can't be compiled in anything but the release build. That seems odd to me as it should be able to be compiled in debug or release.

  9. #9
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,597

    Re: debug in release mode

    Quote Originally Posted by pdk5 View Post
    Im not debugging third party tool. Third party tool produces some kind of input to our application.
    Can you explain in more detail what you're trying to do? If you're not debugging the third-party app, why not just debug yours? Why the need to attach to anything?

  10. #10
    Join Date
    May 2015
    Posts
    277

    Re: debug in release mode

    @Arjay: Thanks a lot for the info and patience to explain in detail helped a lot

    I am just still almost new comer in the company who have quite exp people around in same company.

    As per them, the third party application will only work with the Release version of our application (I donot know the history).

    Anyway (I am now able to get to the point where the exception is thrown with the Release build). I didnot have to do anything as our build setup had already setup to generate min debug info for the Release mode. I was giving the debug exe name and i figured out this issue.

    Now at least i have the call stack . I need to debug further ofcourse with the help of others (I am not familiar in that part of the code)

    @Kaud, GCDEF and Arjay: It was very helpful to discuss and correct my opions. Thankyou again

  11. #11
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,597

    Re: debug in release mode

    Quote Originally Posted by pdk5 View Post

    As per them, the third party application will only work with the Release version of our application (I donot know the history).
    That doesn't make much sense either.

  12. #12
    Join Date
    May 2015
    Posts
    277

    Re: debug in release mode

    Thankyou GCDEF, I'll update the thread if i come to know about this ..
    It is difficult to get clarifications (on all my doubts)when working remotely and collegues are bit busy
    Thankyou ,

  13. #13
    Join Date
    Feb 2017
    Posts
    550

    Re: debug in release mode

    Quote Originally Posted by pdk5 View Post
    It is difficult to get clarifications (on all my doubts)when working remotely and collegues are bit busy
    I seems you've disregarded my advice (in #6) completely. That's a mistake. Ask a college familiar with the application for the most likely bug location. With a little bit of luck a few narrowing traces will lead you to the exact spot.

    Narrowing traces works like a binary search, logarithmically by successive halving. It allows you to quickly track down any bug in large unfamiliar code bases and at the same time get a feel for the overall structure of the application. Tracing really is the ultimate debugger.

    My advice is to stop struggling with the tools. Put your doubts aside and concentrate on tracing down the bug instead.

    I know my position is somewhat controversial but my point is that just because there's a tool called debugger doesn't mean it's the only way to debug code. Using a debugger is often the easiest and fastest way to find bugs but not always.
    Last edited by wolle; June 28th, 2020 at 11:52 PM.

  14. #14
    Join Date
    May 2015
    Posts
    277

    Re: debug in release mode

    @wolle: Thanks a lot for the advice, will try that.
    Somehow I missed it, very sorry about it .

    Thankyou very much for the inputs and very helpful for me.

  15. #15
    Join Date
    Feb 2017
    Posts
    550

    Re: debug in release mode

    Quote Originally Posted by pdk5 View Post
    will try that.
    Tracing means you temporarily modify the source code. Make sure you're permitted to do so.

    Tag all traces you put in with comments so they can be easily located later and removed/commented out when the bug is fixed.

    Good luck!
    Last edited by wolle; June 29th, 2020 at 11:20 PM.

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)