Incorrect debug symbols, and breakpoints

I am constantly running into a problem while debugging c++ code where attaching to UE4-Editor process during debug will load the symbols, but will load incorrect symbols.

So when I step through my code, and decide to “step in” to the call - it steps into an old call

For instance:

float ATurretBase::track(float delta) {

	bool found;
	auto loc = getTargetWorldPosition(found);

	if (found) {
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, loc.ToString());
	}

	auto rot = FMath::RInterpTo(GetActorRotation(), getTargetLookAtRot(loc), delta, .5);

	//this->SetActorRotation(rot);
	rotateToTarget(rot);

	return 0;
}

rotateToTarget will step into SetActorRotation (which was the old call).

I have deleted Saved and Intermediary directories, recompiled the project with Debug Game Editor, and am still getting this behavior during debug.

What can I do to get debugging working correctly?

In addition to deleting the “Intermediate” and “Saved” directories, you’ll want to delete the “Binaries” directory as well. That folder will contain your build results, such as the executables, dlls, and debugging symbols.

Finally, have you verified that your build can successfully compile? If Visual Studio is set to run the last successful build (regardless if the latest build succeeds), you can run into issues where your program execution does not match your source code. This makes breakpoints and stepping rather confusing. To further verify this, I’d add some code elsewhere and see if the debugger behaves as expected by stepping through the newly added statements.

If all else fails, I’d probably try deleting everything except for the following…

  • Config
  • Content
  • Source
  • Project.uproject

Everything else can be reconstructed from the above four things. My team only keeps the above four on source control, in addition to the editor dlls in the “Binaries” folder to avoid obligating artists to install VS2015.