How to debug PhysX?
TL;DR What is the proper way to get UE4 to link to the debug version of PhysX?
I am attempting to work with the PhysX source code. I just want to be able to place breakpoints and step through the code. Mostly to dig around and maybe tweak a few things. I stumbled upon the PhysX project files in:
Then to debug the physics engine I can run UE4, open the PhysX project, and attach the debugger to UE4. However there was a problem when stepping through the code (line by line), the debugger jumps all over the place across several lines of code. This happens because the PhysX code has been mostly optimized away because UE4 is using the production build of PhysX.
So clearly the solution is to get UE4 to use the debug build of PhysX. I found the PhysX dll files in:
There is PhysX3DEBUG_x64.dll and PhysX3PROFILE_x64.dll. I confirmed that UE4 is using the profile build by deleting PhysX3PROFILE_x64.dll and checking if UE4 complains, which it does.
Then In the UE4 source I found that the PhysX dll is loaded in PhysXLibs.cpp:
From that code I figure that I need to enable UE_BUILD_DEBUG and undefine NDEBUG. I figured that changing the project configuration to "Debug" would do both these things. But it didn't. So instead I tried going into UE4's 'Configuration Properties/NMake/Preprocessor Definitions' and forcibly changing the line: 'UE_BUILD_DEVELOPMENT=1' with 'UE_BUILD_DEBUG=1' and removed the line 'NDEBUG=1'
Then I rebuilt UE4. Now, in order to confirm that I really am using PhysX3DEBUG_x64.dll instead of PhysX3PROFILE_x64.dll:
I deleted PhysX3PROFILE_x64.dll but the engine complained about not finding PhysX3PROFILE_x64.dll
Then I did the opposite and deleted PhysX3DEBUG_x64.dll but the engine did not complain about not finding PhysX3DEBUG_x64.dll
Question: So what is the proper way to get UE4 to link to the debug version of PhysX?
P.S. I'm using version 4.8 commit: 1933f7b14b1ff111916a3b0d0a7f45736654d3f9
This question was solved by Gordon, an NVIDIA developer, at their dev forums:
answered Sep 23 '15 at 10:46 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here