DebugGameEditor/DebugGame VisualStudio configurations creates undebuggable code

Hi,

in 4.9.2 there is no solution configuration that makes game code FULLY debuggable. I understand that DebugGame or DebugGameEditor solutions should be used when debugging code. However those configurations create unddebugable code. Common examples are compiled out variables or all functions. Also debugger can get crazy when stepping code line by line in debugger.

One of examples You can see in attached GIF file, where debugger goes crazy when stepping through code with F10 (step over).

David

57310-bez-nazwy-1.gif

Is this issue happening when you are playing your game, or are you just attempting to debug code through Visual Studio? Is the code in the gif you’ve provided your custom code, or is it engine code?
Exactly what is the unexpected behavior that is occurring in the gif?

I am attempting to debug code through Visual Studio.

Code in the GIF is engine code, however identical things happen in my custom code.

GIF captures my debug session when I firstly placed a breakpoint. Then after program executions breaks in breakpoint I am stepping through code with F10 button. Normal debugger behaviour in such cases as far as I know is stepping throug consecutive (!) lines of code. For example if arrow is in 16line the next line would be 17 and so forth. In gif You can see that this is violated because arrow jumps from line 136 to 138 omitting (!) line 137. This is tipical behaviour when code was compiled with optimizations and debugged binaries doesn’t match fully with source code. However when game is compiled in debug (!) configurations all optimizations should be turned off so code will be fully (!) debuggable.

In the case of functions, using the “Step Over” option will skip entering a function at a function call. To look at a function from the call, you would use “Step Into” instead.
I’m also not familiar with the term “compiled out variables”. Could you explain what you mean when you use this term?

Sean those are quite advanced programming issues, maybe You can forward our conversation to programmer? And I dong want to be mean, just want to get it over quick.

Hey-

Understanding exactly what you’re referring to helps us when trying to reproduce the issue. The sentence where you use the term is very confusing to follow and we’re just trying to make sure we know what you mean. Sometimes this requires directly asking so we don’t make the wrong conclusion.

From what I’ve found about compiled out variables, if running in debug mode doesn’t fix that you can put the following line at the top of your .cpp file with the variable you want to watch: #pragma optimize("", off) That will turn off those optimizations for all functions in the file from that line down. However, that kind of pragma should not be checked in since it will make the final product slower.

Cheers

When I said “compiled out” I meant that variable is absent due to optimizations done by compiler. Probably better term would be “optimized away”. Sometimes even all functions can be absent (so You cannot put breakpoint in it) due to optimalizations. I am attaching image from debug session where I break in 212 line and variable from line above is undefined for debugger due to optimalizations.
67270-
Anyway, I didn’t know about this pragma command. I’ve just tested it and it works great, thanks for that.

Hovewer this is only partial solution. This makes all my custom code fully debugable as I can turn off optimalizations by using Your pragma. But how to apply that to engine code? I am using precompiled UE in 4.9.2 version.

thanks

Hello?Hello?

Since you are using the launcher version, all of the source code is already precompiled. The only option if you’d like to debug the engine code would be to build the source version of the engine in Debug, or with the #pragma in place, and then switch your project over to that version of the engine.

Good, this is what I was thinking. Thanks for help :wink: