Jump to content

Cross-Platform Debugging Help


Recommended Posts

Somebody recently posted a bug to the Custom Asteroids thread that only appears in 64-bit KSP for Linux, but completely breaks asteroids when it does appear. The problem? I only have KSP for Windows, and I've confirmed that the bug doesn't appear there.

Any advice on how to diagnose and fix a problem when you can't reproduce the conditions it requires? Thanks!

Edited by Starstrider42
Thread move request fulfilled
Link to comment
Share on other sites

One trick to narrow down exactly what is happening is to error trap code as follows:


public void MethodName()
{
string errorLine = "1";
try
{
errorLine = "2";
--Line of Code
errorLine = "3";
--Line of Code
errorLine = '4';
--Line of Code
etc.
--Last line of Code
errorLine = "25"'
}
catch(Exception e)
{
print("Error MethodName " + errorLine + " " + e)
}

This way, if (and only if) there is an error, it prints the fact to the debug log (and output_log.txt). Then using whatever number prints for the errorLine variable, you can tell exactly which line of code is failing.

Then have whoever is seeing the error send you the debug log as normal.

The caveats to this are that is is decent chunk of overhead in terms of what the code is doing and in your time to get it setup correctly. Also, there has to be an error thrown for the try-catch block to see. If the "error" is something else, such as a foreach call not executing because the list it references is emtpy, this trick will not catch that.

D.

Link to comment
Share on other sites

That was actually the reason I came up with the code in my previous post, a way to only print to the log on error.

I did that so I could distribute my release version with the code in place without having to release a dev version for testing.

As I was trying to track down the errors happening since 0.24 released, pretty much my entire mod has that enabled at the moment, but the intention is that only the critical bits for save/load will have it once I can get things settled down.

D.

Link to comment
Share on other sites

I had reason to do this myself last night to isolate a bug. I ended up putting an Ubuntu Live CD on a thumb drive. Once rebooted into Ubuntu I just installed Steam and then installed KSP. I got KSP running with my mod but then went to sleep. In theory it should be an easy way to test things like this in the future. Supposedly there are even persistent thumb drive linux distros which would make it all much easier.

Edited by noisybit
words
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...