CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    May 1999
    Posts
    156

    HowTO: debug Release build

    Hi all,

    My app. work correctly in debug, as I can use TRACE and debug to check all is well. However, when I made a Release Build the program does not work the way it should. The Release Build compile and link OK.

    Please advise what could I have done wrong, and how to correct this. Can I do something like TRACE in debug mode? Thanks in advance.

    Will




  2. #2
    Join Date
    May 1999
    Posts
    3

    Re: HowTO: debug Release build

    Unfortunately, once your in release build all the debug information is stripped out, so to speak. Actually, it is just not added. If you're fond of Assembly then you can use a map file to locate errors (But this is a whole new discussion). Otherwise, you're probably left with adding MessageBoxes and analyzing other program behavior to tell you where your at and what the program is doing.
    Visual C++ ships with some tools that may help, by showing fired messages, etc., but, I'm not familiar enough with them to advise.


  3. #3
    Join Date
    May 1999
    Location
    Seattle, WA USA
    Posts
    423

    Re: HowTO: debug Release build

    You can build your release version with Debug info, & then debug it as you would the debug version (you may need to turn code optimization off). Just go to your project settings C/C++ tab and select Program Database for the Debug Info, and then go to the Link tab and click the Generate Debug Info check box. Then you can debug your program as normal.

    There is also a function called OutputDebugString, which acts just like the TRACE statement, except it also outputs in release builds. You can replace your TRACE calls with this function call.

    Also, 99.99% of release-build related errors are un-initialized variables. Make sure that all your variables are being initialized to something good before you use them (in Debug mode, all vars are initialized to 0).

    --michael


  4. #4
    Join Date
    Apr 1999
    Posts
    14

    Re: HowTO: debug Release build

    1st thing to look for: functions or statements inside TRACE() macros (not executed in release mode). Second thing: wrong or missing function parms, particularly like ommitting WPARAM/LPARAM args in message functions. If basic MessageBox() debugging doesnt help, you can always use OutputDebugString() even in release mode.


  5. #5
    Join Date
    Apr 1999
    Posts
    27,449

    Re: HowTO: debug Release build

    Actually, you can debug a release build with full symbols as was stated by another post. The debug information is stored as .PDB and .DBG files. If you ever install the NT version with debug symbols (a bunch of very large .DBG files), you can get the names of the NT kernel routines called when an exception occurs, instead of a bunch of assembly addresses in the call stack.

    However, you are correct if you don't have the source code or do not have .DBG files.

    Regards,

    Paul McKenzie


  6. #6
    Join Date
    May 1999
    Posts
    20

    Re: HowTO: debug Release build

    The best solution I can recommend is to always plan for debugging when developing your code and don't rely on stuff provided by the vendor. I generally build code so that it generates a log file. In that way, I can always tell what the heck its doing. I configure the operation of the program via a config file so I can selectively enable/disable various printouts. I never remove debug code from my software just disable it.


  7. #7
    Join Date
    May 1999
    Posts
    156

    Re: HowTO: debug Release build - A Big Thank you

    Hi gurus,

    Thank you very much for your suggestion. It certainly make this painful world of arm-wresting with VC++ a happier place to live in.

    The tips work !!

    Will


Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured