# \[Help\] Variables being shown wrong while debugging

**URL:** <https://forums.unrealengine.com/t/help-variables-being-shown-wrong-while-debugging/1537998>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, Visual-Studio, question\
**Created:** [December 19, 2023, 12:09pm UTC](https://forums.unrealengine.com/t/help-variables-being-shown-wrong-while-debugging/1537998 "2023-12-19T12:09:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulohf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@paulohf](https://forums.unrealengine.com/u/paulohf)\
**Post date:** [December 19, 2023, 12:09pm UTC](https://forums.unrealengine.com/t/help-variables-being-shown-wrong-while-debugging/1537998/1 "2023-12-19T12:09:59Z")

</div>

I’m using a clean install of the last version of the Visual Studio 2022, it’s updated and there’s no extra extensions.

But when I try to debug my code, some variables are shown wrong, some Arrays have missed index or half of the information is there, like instead of showing a FVector, show a FVector but with X, Y or Z information missing. And when I add a breakpoint the compiler doesn’t stop there, if I add a UE\_LOG, the log is printed, but still the breakpoint doesn’t pause the compiler. Also, the UE\_LOG show the correct information, but the debugger doesn’t.

At the beginning the debugger worked as normal, but now I can’t trust the information that it shows

---

<div class="post-metadata">

**Author:** ![IrSoil](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@IrSoil](https://forums.unrealengine.com/u/IrSoil)\
**Post date:** [December 19, 2023, 4:10pm UTC](https://forums.unrealengine.com/t/help-variables-being-shown-wrong-while-debugging/1537998/2 "2023-12-19T16:10:37Z")

</div>

I wonder how are you checking variables content when you can’t set breakpoints? Anyway, as a wild guess, the solution for last problem i comes about was posted here: [Increase the Number of Modules Loaded When Attaching the Debugger](https://forums.unrealengine.com/t/increase-the-number-of-modules-loaded-when-attaching-the-debugger/661624)

---

<div class="post-metadata">

**Author:** ![paulohf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@paulohf](https://forums.unrealengine.com/u/paulohf)\
**Post date:** [December 20, 2023, 8:12am UTC](https://forums.unrealengine.com/t/help-variables-being-shown-wrong-while-debugging/1537998/3 "2023-12-20T08:12:10Z")

</div>

Well, not all breakpoints was unreachable, but since the solution you linked worked for the breakpoints, I assume that only the “deeper” breakpoints was unreachable.

But sadly I still can’t see most of the variables values, only printing, here’s an example:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/2/3/623d9140bb5b5f35d50599799d138acc60955a3b.png)

Here guideMap is a TMap, in the index 13 there’s half of the information and in the 14 onward there’s no information, but if I print any index, it shows the variable value normal, I just can’t see while debugging.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/d/4/3d49fa1ce3fbfe132202cfe0d3608cf1494852c5.png)

At some point it start to shows the variables again.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/1/9/119a15114df992785a418db9640d79a9956d42ba.png)

But it keeps fragmenting from time to time.

There’s another bug where it shows the variable as point flutuation value like: “3.3464534E+10” or something like that (I just typed this number randomly) but again, when I print it, it’s normal.

The last one drove me crazy like: “Why I’m getting this value?! I already checked all the code, why?!”

---

<div class="post-metadata">

**Author:** ![paulohf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@paulohf](https://forums.unrealengine.com/u/paulohf)\
**Post date:** [December 21, 2023, 9:19am UTC](https://forums.unrealengine.com/t/help-variables-being-shown-wrong-while-debugging/1537998/4 "2023-12-21T09:19:13Z")

</div>

Sadly the breakpoint still not working:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/8/4/384c7c39d453f46f2b19d8769cf79bd84554201b.png)

Here the compiler never stop at this breakpoint, but print the “?”. And if I add a breakpoint inside the NextBlock() it stop there.

I don’t know what to do anymore, without the debug is beign hard to fix the bugs, compiler not stopping in the breakpoint, variables with wrong values but print correct values.

Help ☹

---

<div class="post-metadata">

**Author:** ![DavidMcEwen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DavidMcEwen](https://forums.unrealengine.com/u/DavidMcEwen)\
**Post date:** [December 21, 2023, 7:20pm UTC](https://forums.unrealengine.com/t/help-variables-being-shown-wrong-while-debugging/1537998/5 "2023-12-21T19:20:54Z")

</div>

If you are using anything beyond a debug build with Unreal the code gets optimised, which will produce the issues you are seeing. It very much depends on how the compiler treats the code how easy to debug it will be when optimised.

However to save running debug builds you can just wrap code with some macros - UE\_DISABLE\_OPTIMIZATION and UE\_ENABLE\_OPTIMIZATION (or in UE4 PRAGMA\_DISABLE\_OPTIMIZATION and PRAGMA\_ENABLE\_OPTIMIZATION). Personally I usually mark the whole file I’m interested in.

If you do that you should be able to use breakpoints and see the relevant variables in the debugger - you may still hit optimised code as you step through if you go to a different file, but just add the macros to that file if needed.

Hope that helps.

---

<div class="post-metadata">

**Author:** ![paulohf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@paulohf](https://forums.unrealengine.com/u/paulohf)\
**Post date:** [December 22, 2023, 2:36pm UTC](https://forums.unrealengine.com/t/help-variables-being-shown-wrong-while-debugging/1537998/6 "2023-12-22T14:36:18Z")

</div>

How to use it? I tried like this:

```auto
UE_DISABLE_OPTIMIZATION

#MY code

UE_ENABLE_OPTIMIZATION

```

Also tried with Disable/Enabled inverted and didn’t work.I searched for it on google and there’s only 3 links mentioning it, one of then did the same as I did above, but for me it didn’t work.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/c/2/cc29c47cfcc340119d36e1665d1b61ba495f1be0.png)

Tried to change to DebugGame Editor and this partially worked, some variables I can see, like the floating point value now show the value properly, but not the TMap.

---

<div class="post-metadata">

**Author:** ![DavidMcEwen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DavidMcEwen](https://forums.unrealengine.com/u/DavidMcEwen)\
**Post date:** [December 23, 2023, 12:38pm UTC](https://forums.unrealengine.com/t/help-variables-being-shown-wrong-while-debugging/1537998/7 "2023-12-23T12:38:13Z")

</div>

For the macros just put them around a function or functions. For those that you’ve disabled optimisation on it should be the same as what you see in a debug build.

What are you seeing in a TMap? Can you see inside a TArray properly?

If you don’t see the members you can try disabling if it’s enabled:  
`Tools->Options` window:  
`Debugging -> Options -> Debugging -> General -> Show raw structure of the object in variable windows`

---

<div class="post-metadata">

**Author:** ![paulohf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@paulohf](https://forums.unrealengine.com/u/paulohf)\
**Post date:** [December 23, 2023, 3:41pm UTC](https://forums.unrealengine.com/t/help-variables-being-shown-wrong-while-debugging/1537998/8 "2023-12-23T15:41:21Z")

</div>

With “Show raw structure of the object in variable windows” enabled I don’t know where I can find the values, I tried every dropdown menu, but didn’t found it:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/f/a/efa4c6a6a8d6ad345c150e8728d93e14cf63ea5f.png)

And I can see all the TArray values properly (Without “Show raw structure of the object in variable windows”):

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/6/b/a6b7e01887ce6c4af989fc6e99efbea3ceff0556.png)

Those are the same keys that I have in the TMap
