How do I debug RimWorld?

Started by longbyte1, May 14, 2014, 07:20:46 PM

Previous topic - Next topic

longbyte1

I'd like to trace the causes of a few problems in RimWorld, except I don't have the source, and the closest thing there is is .NET Reflector, which is, like all commercial software, ridiculously expensive. Not only that, but the RimWorld EXE isn't even pure .NET, so I have no idea how to debug. Another thing I could do is use Cheat Engine to print a disassembly, but the other problem is that RimWorld has 30 different threads that can't be stopped simultaneously, and the disassembly doesn't seem to be traceable. Yes, the "solution" is to just approach Tynan, but it's a catch-22, because he's on vacation, and he might not produce a fix until next month, and there may be more people having the same problem. :( So I'd like to find the problem myself and post the solution.

What do testers here use to look into the game code while the game is running? ILSpy is worthless in this case (but indispensable otherwise) because I have to look at what the game gets stuck doing when the bug happens.

Any PDB files I can use? Unity Player symbols?

pawnstorm

The "RimWorld EXE" is just a loader for unity games, it's not coded in .NET. I'm sure Tynan just uses the Unity Debugger to debug rimworld, but to use that I think you need all the source files.

I'm assuming you don't want to trace through all the MSIL code. If there are any useful debuggers out that that produce more humanly readable output than just MSIL, I'm sure you can find them here or here.

longbyte1

Problem is that decompiled source can't be compiled without correcting a few thousand errors. Most of them are just a matter of find+replace, but some are fatal and take some more work to figure out. I'm trying this right now, decompiling source and working upward from it.

pawnstorm

I didn't mean to suggest you decompile all the source, that'd be a mammoth task... I just meant I assume you'll want a debugger that shows you something that's at least a bit more readable than MSIL.

longbyte1

Quote from: pawnstorm on May 14, 2014, 08:56:21 PM
I didn't mean to suggest you decompile all the source, that'd be a mammoth task... I just meant I assume you'll want a debugger that shows you something that's at least a bit more readable than MSIL.

Like what? There doesn't seem to be anything available. :-\

pawnstorm

Quote from: longbyte1 on May 14, 2014, 09:21:15 PM
Quote from: pawnstorm on May 14, 2014, 08:56:21 PM
I didn't mean to suggest you decompile all the source, that'd be a mammoth task... I just meant I assume you'll want a debugger that shows you something that's at least a bit more readable than MSIL.

Like what? There doesn't seem to be anything available. :-\
Well, no free options I guess... How about this? http://community.sharpdevelop.net/blogs/marcueusebiu/archive/2011/04/12/ilspy-debugger-preview.aspx

longbyte1

Thanks. It looks extremely useful, but the one problem is that the RimWorld EXE is native and not a managed .NET assembly... no!!!! :(

I hope Tynan builds a non-native Unity player in the future. That would greatly help in debugging.

pawnstorm

Quote from: longbyte1 on May 14, 2014, 10:30:33 PM
Thanks. It looks extremely useful, but the one problem is that the RimWorld EXE is native and not a managed .NET assembly... no!!!! :(
You can attach it to a running process, have you tried that?

Quote from: longbyte1 on May 14, 2014, 10:30:33 PM
I hope Tynan builds a non-native Unity player in the future. That would greatly help in debugging.
Doubtful. I think the unity player isn't even written in a .NET compatible language, as far as I can tell it was compiled with Visual C++ 6.0.

Tynan

The exe is just Unity itself, which I did not write and cannot change. All the game code is in Assembly-CSharp.dll, which is pure managed code.
Tynan Sylvester - @TynanSylvester - Tynan's Blog

StorymasterQ

Tynan, aren't you on holidays? Get off the forums and concentrate on your recharge! :D
I like how this game can result in quotes that would be quite unnerving when said in public, out of context. - Myself

The dubious quotes list is now public. See it here

Coenmcj

Quote from: StorymasterQ on May 15, 2014, 08:29:03 PM
Tynan, aren't you on holidays? Get off the forums and concentrate on your recharge! :D
What he said! go have fun damn it!
Moderator on discord.gg/rimworld come join us! We don't bite

longbyte1

Quote from: pawnstorm on May 14, 2014, 10:39:24 PM
Quote from: longbyte1 on May 14, 2014, 10:30:33 PM
Thanks. It looks extremely useful, but the one problem is that the RimWorld EXE is native and not a managed .NET assembly... no!!!! :(
You can attach it to a running process, have you tried that?

I can't because the ILSpy debugger only shows managed processes. Since the RimWorld runtime is enclosed by Unity (which is not considered managed), it doesn't show up.

pawnstorm

Quote from: longbyte1 on May 15, 2014, 08:53:24 PM
I can't because the ILSpy debugger only shows managed processes. Since the RimWorld runtime is enclosed by Unity (which is not considered managed), it doesn't show up.
Ah bummer, I guess the ILSpy debugger is kinda useless for debugging rimworld then. You could try to create your own "debug mod". No idea if it works, I'm not a .NET expert, but perhaps you can add your own exception handlers to your mod using the events in AppDomain. Actually, that sounds like an interesting idea, perhaps I'll give that a try when I'm done with Vanilla+.

longbyte1

I'm not just trying to debug my mod; I'm also trying to debug the game itself.

pawnstorm

Yeah, that's what I mean... Mods are in the same AppDomain as the game, right? So you can create a mod that debugs the game ;)