How to debug in release mode? (vc++)

Started by
13 comments, last by harryx 22 years, 1 month ago
My program only crashes when run in release mode, so I cannot find out where it is going wrong. Is there any way to use the debug information given in release mode to find out where it went wrong in my code? Thanks
Advertisement

Not really.

Try printing out or wiriting to a file to narrow down the lines that are crashing your code.

Release only crashes are usually because you used a variable with allocating or initializing it. Debug puts default values in variables, but release mode does not.
First, put exception handlers in your code (have a message box pop up with an error description, for example). Then go back to debug mode and watch your variables in that routine/scope. Look for any variables that remain uninitialized, etc.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
Thanks but I think my problem is slightly nastier than this.

I am creating and deleting a fair number of texture objects in opengl, and I think that this is causing my memory to become fragmented which is leading to this problem.

Its either that or the fact that I am also creating and deleting a large amount of geometric data, which could also be causing it.

Id just like to know which it is...

quote:Original post by harryx
Thanks but I think my problem is slightly nastier than this.

I am creating and deleting a fair number of texture objects in opengl, and I think that this is causing my memory to become fragmented which is leading to this problem.

Its either that or the fact that I am also creating and deleting a large amount of geometric data, which could also be causing it.

Id just like to know which it is...




It''s neither. That would also crash you in debug if it crashes you at all. You''re probably reading from a block of memory without writing to it first, deleting something before you were really done with it (Debug sometimes is OK with that) or accessing past the end of an allocated chunk somewhere (Debug also lets you get away with that, since it tends to ''pad'' your memory.)

Fragmentation has nothing to do with it.
If you''re using MSVC, you can add debug info to a release build by going to Project->Settings, change "Settings For:" to Win32 - Release, goto Link and check "Generate Debug Info". Next, go to C/C++ and change "Debug Info:" to "Program database for Edit and Continue".

Recompile and you should be able to see all the symbol names and whatnot. Just be away that when stepping through optimized code, the cursor may jump around a bit as the compiler may remove/rearrange code for better performance.

codeka.com - Just click it.
Quite right Dean. Also, you can only really tell for sure what function you are in--the compiler is free to do all sorts of whacky things, so even watch symbols can''t be trusted half the time.
Thanks for the help,

I set up release mode as suggested, however when I hit f5 and start debugging (in release mode) I dont get the crash - although I do if I start with ctrl+f5 but then I dont get any useful debug info.

Basically generating debug info in release mode seems to avoid the crash in the same way as running in debug mode does.

The crash is seemingly random (ie I can test it once and it will crash, I then copy exactly what I did before and it doesnt crash)

This is why I was thinking it is something obscure like fragmented memory.

Any ideas?

what is the benefit of running in release mode?
i''ve noticed a smaller executable, but thats about it.

~ I am a DirectX to OpenGL convert! ~
quote:Original post by GekkoCube
what is the benefit of running in release mode?
i''ve noticed a smaller executable, but thats about it.

Non debug libraries (generally), for one thing, which are what clients/end-users are likely to have installed. If you released a commercial application built using debug libraries, only developers with those libraries installed would be able to run them.

Also, release mode strips out the debug information which a cracker could find very useful...

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

This topic is closed to new replies.

Advertisement