-
Notifications
You must be signed in to change notification settings - Fork 5
Debug symbols
kianzarrin edited this page Oct 16, 2022
·
7 revisions
when debugging CS mods it would be useful to get file and line number in your exceptions stack trace like this:
Exception: test kian exception
at NetworkDetective.Test.Factorial (Int32 n) [0x00025] in C:\Users\dell\source\repos\NetworkDetective\NetowrkDetective\NetworkDetectiveMod.cs:35
at NetworkDetective.Test.Factorial (Int32 n) [0x0000a] in C:\Users\dell\source\repos\NetworkDetective\NetowrkDetective\NetworkDetectiveMod.cs:32
at NetworkDetective.Test.Factorial (Int32 n) [0x0000a] in C:\Users\dell\source\repos\NetworkDetective\NetowrkDetective\NetworkDetectiveMod.cs:32
at NetworkDetective.Test.Factorial (Int32 n) [0x0000a] in C:\Users\dell\source\repos\NetworkDetective\NetowrkDetective\NetworkDetectiveMod.cs:32
at NetworkDetective.NetworkDetectiveMod.OnEnabled () [0x00001] in C:\Users\dell\source\repos\NetworkDetective\NetowrkDetective\NetworkDetectiveMod.cs:50
To do this Load order tool ( github | steam ) can launch the game in debug mode (uses debug mono and patches CO to load symbols).

Modders need to also generate mdb file as explained below.
mono cannot use pdb files. So we need to convert it to mdb file. Not every version of pdb2mdb.exe works for us. So follow these steps to convert pdb to mdb
use the following Nuget package:
<ItemGroup>
<PackageReference Include="Mono.Unofficial.pdb2mdb" Version="4.2.3.4" />
</ItemGroup>generate pdb-only debug symbols ( optionally use the path map to display relative path instead of absolute path):
<PropertyGroup>
<DebugType>pdbonly</DebugType>
<PathMap>$(MSBuildProjectDirectory)\=$(ProjectName)\</PathMap>
</PropertyGroup>convert pdb2mdb in your post build script:
<Target Name="DeployToModDirectory" AfterTargets="Build">
<Delete Files="$(TargetPath).mdb" />
<Exec Command=' "$(PkgMono_Unofficial_pdb2mdb)\tools\pdb2mdb.exe" "$(TargetPath)" ' />
<Copy SourceFiles="$(TargetPath).mdb" DestinationFolder="$(DeployDir)" />
...