rpcs3 icon indicating copy to clipboard operation
rpcs3 copied to clipboard

[Feature request] Allow RPCS3 to be compiled in DEBUG mode

Open digant73 opened this issue 1 year ago • 12 comments

Quick summary

In order to instrument the code with debugging tools such as valgrind (e.g. under linux), Deleaker or even VS 2022 debugger it should be very useful to review the project allowing the compilation in DEBUG mode. Currently, most of the linking errors are on qt libs (and that should be fixable). We know that some libs could be affected by bugs in DEBUG mode but the main target of this FR is to allow to discover clear issues in RPCS3 source code. Currently this is not possible at all. Debugging the code in RELEASE mode is pretty much useless (I see an infinite number of access violation, they can be real or false issues but it is impossible to understand that not having a reference to source code for a further analysis)

Details

No response

digant73 avatar Sep 30 '24 20:09 digant73

It does compile in debug mode if you use CMake.

oltolm avatar Sep 30 '24 20:09 oltolm

You can debug with the source code in release in visual studio as far as I recall and as people have pointed out, you can compile in debug mode on linux with no issue.

Those access violation most likely are generated by the recompiled code and you won't see any source code anyway.

RipleyTom avatar Sep 30 '24 21:09 RipleyTom

It does compile in debug mode if you use CMake.

I have the latest cmake (3.29) version installed with VS 2022 and set VS to use CMakePresets.json file (that is present with the RPCS3 project) as configuration file but I got an error during the CMake cache creation:

Severity	Code	Description	Project	File	Line	Suppression State	Details
Error		CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.29/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find OpenAL (missing: OPENAL_LIBRARY OPENAL_INCLUDE_DIR)		C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.29/Modules/FindPackageHandleStandardArgs.cmake	230		

digant73 avatar Sep 30 '24 22:09 digant73

You can debug with the source code in release in visual studio as far as I recall and as people have pointed out, you can compile in debug mode on linux with no issue.

I know that. It is what I did but of course it is useless. You have no source code at all making impossible to put break points to catch possible issues

Those access violation most likely are generated by the recompiled code and you won't see any source code anyway.

Probably yes but it should be better to have the possibility to verify that (some games report few errors while others report an infinite list of errors). Valgrind etc. could help a lot discovering memory leaks and access violation

digant73 avatar Sep 30 '24 22:09 digant73

the cmake files seem to need some changes to work on Windows 11 and VS 2022. 3rd party libs are not properly found

digant73 avatar Sep 30 '24 22:09 digant73

Change the preset to this and set environment variable CMAKE_PREFIX_PATH=C:\Qt\6.7.3\msvc2019_64.

    {
      "name": "msvc",
      "displayName": "Windows x64",
      "generator": "Visual Studio 17 2022",
      "binaryDir": "build-msvc",
      "architecture": {
        "value": "x64",
        "strategy": "external"
      },
      "cacheVariables": {
        "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
        "USE_FAUDIO": "OFF",
        "USE_PRECOMPILED_HEADERS": "ON",
        "USE_SYSTEM_ZLIB": "OFF",
        "USE_NATIVE_INSTRUCTIONS": "ON",
        "BUILD_LLVM": "ON",
        "STATIC_LINK_LLVM": "ON",
        "USE_SYSTEM_OPENAL": "OFF",
        "USE_SYSTEM_CURL": "OFF"
      },
      "vendor": {
        "microsoft.com/VisualStudioSettings/CMake/1.0": {
          "hostOS": [
            "Windows"
          ]
        }
      }
    }

I only added this.

        "USE_SYSTEM_OPENAL": "OFF",
        "USE_SYSTEM_CURL": "OFF"

oltolm avatar Sep 30 '24 23:09 oltolm

Change the preset to this and set environment variable CMAKE_PREFIX_PATH=C:\Qt\6.7.3\msvc2019_64.

    {
      "name": "msvc",
      "displayName": "Windows x64",
      "generator": "Visual Studio 17 2022",
      "binaryDir": "build-msvc",
      "architecture": {
        "value": "x64",
        "strategy": "external"
      },
      "cacheVariables": {
        "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
        "USE_FAUDIO": "OFF",
        "USE_PRECOMPILED_HEADERS": "ON",
        "USE_SYSTEM_ZLIB": "OFF",
        "USE_NATIVE_INSTRUCTIONS": "ON",
        "BUILD_LLVM": "ON",
        "STATIC_LINK_LLVM": "ON",
        "USE_SYSTEM_OPENAL": "OFF",
        "USE_SYSTEM_CURL": "OFF"
      },
      "vendor": {
        "microsoft.com/VisualStudioSettings/CMake/1.0": {
          "hostOS": [
            "Windows"
          ]
        }
      }
    }

I only added this.

        "USE_SYSTEM_OPENAL": "OFF",
        "USE_SYSTEM_CURL": "OFF"

Ok with the above settings but then I got an error on ffmpeg:

Severity	Code	Description	Project	File	Line	Suppression State	Details
Error		CMake Error at 3rdparty/ffmpeg/CMakeLists.txt:49 (message):
  No FFMPEG prebuilt found with corresponding commit SHA (10d0ebc)		E:\console\git\rpcs3_diga\3rdparty/ffmpeg/CMakeLists.txt	49		

digant73 avatar Oct 01 '24 10:10 digant73

The ffmpeg submodule needs an update. Update it or download https://github.com/RPCS3/ffmpeg-core/releases/download/ec6367d/ffmpeg-windows-x64.zip and copy it to ${CMAKE_BINARY_DIR}/3rdparty/ffmpeg.zip.

oltolm avatar Oct 01 '24 10:10 oltolm

@oltolm submodule should be updated. However fixed with the zip file you provided. But now the issue is on QT. Although QT are properly installed and QTDIR env variable is set to E:\Qt\6.7.3\msvc2019_64\ I got the error:

Severity	Code	Description	Project	File	Line	Suppression State	Details
Error		CMake Error at 3rdparty/qt6.cmake:35 (message):
  Make sure the QTDIR env variable has been set properly.  (for example
  C:\Qt\6.6.3\msvc2019_64\)

  You can also try setting the Qt6_DIR preprocessor definiton.		E:\console\git\rpcs3_diga\3rdparty/qt6.cmake	35		

digant73 avatar Oct 01 '24 13:10 digant73

Set environment variable CMAKE_PREFIX_PATH=C:\Qt\6.7.3\msvc2019_64.

oltolm avatar Oct 01 '24 14:10 oltolm

Set environment variable CMAKE_PREFIX_PATH=C:\Qt\6.7.3\msvc2019_64.

my mistake. I set it to C:\Qt\6.7.3\msvc2019_64\ instead of E:\Qt\6.7.3\msvc2019_64\

digant73 avatar Oct 01 '24 14:10 digant73

getting a linking error:

Severity	Code	Description	Project	File	Line	Suppression State	Details
Error	LNK1104	cannot open file 'LLVMIntelJITEvents.lib' 	M:\console\git\rpcs3_diga\build-msvc\rpcs3_diga	M:\console\git\rpcs3_diga\build-msvc\LINK	1		

EDIT: fixed. I will provide a PR fixing the compilation on Windows 19/11 with cmake and MSVC updating also BUILDING.md

digant73 avatar Oct 01 '24 21:10 digant73