Visual Studio debugger on the PhysX code running inside UE4

Hello everyone.
I have been working with Unreal Engine 4 and thus with PhysX 3.3 since last year. After the PhysX source was made available through UE4 I’ve really wanted to work inside PhysX and atm I’m trying to get the Visual Studio debugger to step through the PhysX code that’s running inside UE4.

Unreal Engine 4 has the PhysX source inside:


Then the PhysX visual studio solution file is in:


So far I can:

  1. open UE4.sln with Visual Studio
  2. build and run the UE4 Editor with a debug configuration
  3. open PhysX.sln with Visual Studio
  4. attach the VS debugger to UE4
  5. set breakpoints and step through PhysX code

The problem is that the debugger is very erratic because UE4 is attaching to the release build (PhysX3PROFILE_x64.dll) instead of the debug build (PhysX3DEBUG_x64.dll) of PhysX. Despite building UE4 with its “Debug Editor” configuration.
Both dll files inside:


This is a UE4 integration with PhysX issue and I posted on the UE4 AnswerHub: with no luck.
So I’m here asking if anyone here has encountered this issue and if you would like to share your solution.
I’m hoping there is a clean logical solution and that I won’t have to hack and slash UE4’s build configuration to fix this.

Thank you for your time

You can compile UE4 with all third party libs in debug. In BuildConfiguration.cs just set

bDebugBuildsActuallyUseDebugCRT = true;

and recompile.

You can also compile with just physx in debug by modifying GetPhysXLibraryMode in PhysXBuild.cs. You will then need to make sure that the dlls also load with debug versions. This is done in LoadPhysXModules in PhysXLibs.cpp. The code should automatically load the correct dlls but if you get a crash it is likely that it has loaded profile dlls instead of the debug ones. It is straightforward to change the code to fix this.

With these changes you should be able to run in Development Editor config and have physx running in debug.



Oh man that worked perfectly!
Thank you so much.

In the end all I needed to do was build the PhysX solution to get the physx3debug_x64.pdb file.
Then change bDebugBuildsActuallyUseDebugCRT to true.

And now it all works.

Thank you Gordon.

You’ve written about modifying GetPhysXLibraryMode in PhysXBuild.cs and that “With these changes you should be able to run in Development Editor config and have physx running in debug.”
Unfortunately i’m getting “error LNK2038: mismatch detected for ‘RuntimeLibrary’: value ‘MDd_DynamicDebug’ doesn’t match value ‘MD_DynamicRelease’” while linking with such configuration and was wandering if anybody has any solution for this since i’m interested in only running PhysX in debug.

Thanks in advance for any help.