This repository has been archived by the owner on Sep 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Debugging
spacehamster edited this page Feb 24, 2021
·
10 revisions
Line numbers in mod assemblies for kingmaker can be enabled with the following steps:
- Build assemblies with portable debugging symbols
- Download the dnSpy debug mono runtime: 2018.4.10 for kingmaker, 2019.4.0 for wrath
- Replace
C:\Program Files (x86)\Steam\steamapps\common\Pathfinder Kingmaker\MonoBleedingEdge\EmbedRuntime\mono-2.0-bdwgc.dll
with the dnspy debugmono-2.0-bdwgc.dll
Functions patched with harmony can be dumped to a file for inspection with a decompiler. This is especially handy for checking that transpilers are applied correctly. This is done by setting environment variables as follows:
Environment.SetEnvironmentVariable("MONOMOD_DMD_TYPE", "cecil");
Environment.SetEnvironmentVariable("MONOMOD_DMD_DUMP", "./mmdump");
harmony.PatchAll();
Environment.SetEnvironmentVariable("MONOMOD_DMD_DUMP", "");
- Download the dnSpy debug mono runtime: 2018.4.10 for kingmaker, 2019.4.0 for wrath
- Replace
C:\Program Files (x86)\Steam\steamapps\common\Pathfinder Kingmaker\MonoBleedingEdge\EmbedRuntime\mono-2.0-bdwgc.dll
with the dnspy debugmono-2.0-bdwgc.dll
- Open DnSpy and start debugging.
- Either go to Debug -> Start Debugging and select Unity debug engine
- Or choose
Unity (Connect)
to start debugging after the game has already been started. dnSpy's mono.dll will look for an environment variable calledDNSPY_UNITY_DBG
(Unity with .NET 2.0-3.5 assemblies) or DNSPY_UNITY_DBG2 (Unity with .NET 4.x assemblies).-
--debugger-agent=transport=dt_socket,server=y,address=127.0.0.1:55555,suspend=n
or -
--debugger-agent=transport=dt_socket,server=y,address=127.0.0.1:55555,suspend=n,no-hide-debugger
to enable detection of the debugger.
-
** Important note ** If dnSpy gives you garbled variables/other, it is highly suggested you try using Ilspy - dnSpy and Ilspy are not perfect and in some cases one or the other might work better.