How to debug C++?

The only way I’ve been able to debug is running editor through visual studio. Which means I have to restart every time I make a code changed… This can’t be the only way, please tell me? With Unity I can just attach to process and it works, with Unreal I get a time out error “failed to launch debug adapter” or something like that. Can I attach/detach to running Unreal instance?

1 Like

You can add breakpoints both in C++ and Blueprints. This will point you in the right direction if you still have issues: Intro to Debugging C++ for Unreal Engine using Visual Studio - YouTube
I highly recommend the video if you are having issues.

Check out:

1 Like

Use this line of code if you need to make sure something is working
UE_LOG(LogTemp, Warning, TEXT(“I just started running”));
and the string in the TEXT(" ") will display as yellow message in the Output Log window,
easy way to see that is to click the Output Log button to the left in the pic below.

you can click the Live Coding button to the right in the pic below to have the editor recompile and reload the C++ project.


or
restart the editor by closing the editor and rerunning the project through Visual Studio because sometimes code doesn’t work with the Live Coding button.

I normally never click this button in the yellow box below but this is called the Hot Reload button, who knows maybe you might like it

Live coding in combination with debug attachment or ctrl + alt + p in VS (debug ->attach) works amazingly.

One can spin up editor, launch game in editor or standalone, discover problem, attach to process, debug, codein solution, live code patch it, hit new breakpoint and debug newly patched code without shooting down game.

Also, one can add “SCOPED_NAMED_EVENT(myEvent, FColor::Red);” inside live coding patch and see update in UnrealInsights.
Live coding is best thing happen to ue4 after it getting f2p.

1 Like