Jump to content

KSP Plugin debugging and profiling for Visual Studio and Monodevelop on all OS


Recommended Posts

I've not seen any mention of it so far but I would expect it to work in exactly the same way.  It will almost certainly require (lots of) changes to the  MoveInitializerIntoAwake calls and you will obviously need to use the correct version of Unity (5.2.4f1).  You may be able to use the mdb2pdb supplied with that Unity for VS2015 (or you may still need to get a newer one from a newer version of Mono).

Link to comment
Share on other sites

18 minutes ago, Padishar said:

I've not seen any mention of it so far but I would expect it to work in exactly the same way.  It will almost certainly require (lots of) changes to the  MoveInitializerIntoAwake calls and you will obviously need to use the correct version of Unity (5.2.4f1).  You may be able to use the mdb2pdb supplied with that Unity for VS2015 (or you may still need to get a newer one from a newer version of Mono).

Yep.

Link to comment
Share on other sites

So I gave it a go... Unity 5.2.4f1. Took the 64 bit dev player. Replaced KSP.exe with it.
Added the "PlayerConnectionConfigFile" file (From OP). Started KSP expecting bunches of "main thread" errors... but I got NONE.
Tried out KSP, seemed to be working fine, no errors in log.
So I skipped the old patcher, went straight for a mdb2pdb using the one from Unity 5.2.4f1. using mono downloaded.
As per this post.
Attached the Unity Debugger to VS. Working just fine. No errors, breakpoints, watches, etc all working.

The one thing I did a little differently, I copied the player_win_development_x64.pdb from the same location as the dev player.exe from Unity. Not sure if this has anything to do with it... But I am debugging error free.

Edited by JPLRepo
Link to comment
Share on other sites

Yep, that is one really useful tool. And a bit frightening when I look at the memory use of MJ GUI...

Learn to use Profiler.BeginSample("MyMethodName") and Profiler.EndSample(). You will need a "#define ENABLE_PROFILER" for those to work

Link to comment
Share on other sites

On 31.3.2016 at 10:52 PM, JPLRepo said:

So I gave it a go... Unity 5.2.4f1. Took the 64 bit dev player. Replaced KSP.exe with it.
Added the "PlayerConnectionConfigFile" file (From OP). Started KSP expecting bunches of "main thread" errors... but I got NONE.
Tried out KSP, seemed to be working fine, no errors in log.
So I skipped the old patcher, went straight for a mdb2pdb using the one from Unity 5.2.4f1. using mono downloaded.
As per this post.
Attached the Unity Debugger to VS. Working just fine. No errors, breakpoints, watches, etc all working.

The one thing I did a little differently, I copied the player_win_development_x64.pdb from the same location as the dev player.exe from Unity. Not sure if this has anything to do with it... But I am debugging error free.

Confirmed working for 1.1, instead of KSP.exe you should replace KSP_x64.exe for 64bit.

Link to comment
Share on other sites

Any trick to getting this working for 1.1? I have debug output (file/lines in exceptions now) but I can't attach the debugger.

EDIT: Didn't copy the connection file to KSP_Data

Edited by rbray89
Link to comment
Share on other sites

8 minutes ago, rbray89 said:

Any trick to getting this working for 1.1? I have debug output (file/lines in exceptions now) but I can't attach the debugger.

No tricks.. Do everyting from the OP.. EXCEPT running the Patch ... that's no longer required.
Makes sure you have the right Unity version. 5.2.4f1 and get the winplayer 64 bit exe or whatever platform you need from that Unity version to replace the exe.
Put the PlayerConnectionConfigFile in the right folder for 32 or 64 bit (there are now two).
I couldn't get mono to work from Unity to create the dll.mdb so I just downloaded Mono and used that (As I'm using VS 2015).
 

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

I don't think anyone already stated that you don't need to install Unity. You can open the installer with an archive extractor (such as 7-zip) and take the file directly, it's located in $_OUTDIR\windowsstandalonesupport\Variations\win64_development_mono\player_win.exe

I don't know if it's possible to make a tool that would download and unzip player_win.exe directly from the online Unity website (using resume-on-error web server capability if it is enabled on their site, to seek directly the interesting parts). This would avoid to download the whole installer (2GB), without breaking Unity agreement. On the other hand, it probably can be handy at some point to have the unity editor (for the profiler and other tools).

Edited by Youen
Link to comment
Share on other sites

  • 1 month later...

Couldn't figure out why my Profiler.BeginSample() stuff wasn't working.  Apparently it's conditionally compiled away if you don't have both the DEVELOPMENT and ENABLE_PROFILER set (I was only using ENABLE_PROFILER).  So this is what I ended up using:

#if DEBUG
#define ENABLE_PROFILER
#define DEVELOPMENT
#endif

 

Link to comment
Share on other sites

@sarbian The issue isn't the debugger. The debug UnityPlayer itself doesn't do anything. I've tried copying it over, renaming it, chmod, copying KSP and overwriting the MacOS portions from UnityPlayer. Nothing seems to work. So simply, I cannot get a debug version of KSP running in OSX.

Link to comment
Share on other sites

1 hour ago, Heed said:

@sarbian The issue isn't the debugger. The debug UnityPlayer itself doesn't do anything. I've tried copying it over, renaming it, chmod, copying KSP and overwriting the MacOS portions from UnityPlayer. Nothing seems to work. So simply, I cannot get a debug version of KSP running in OSX.

Did you add the PlayerConnectionFile to the KSP_Data (or whatever it is called on OSX) folder? Without that mono wont start the debugger IIRC

Edited by Thomas P.
Link to comment
Share on other sites

Yeah I did. Just to be clear, the UnityPlayer renamed to KSP_x64_Dbg.app will not run AT ALL. So it doesn't actually matter about the the PlayerConnectionFile, since I don't even get a UI. Nothing happens. You execute, and the app flashes and closes. No logs, no messages, nothing. This happens no matter what I try and do with the UnityPlayer.app

Link to comment
Share on other sites

From what I see in the OSX zip the app is "KSP.app"  so it should how you rename the dev package. Other managed to make it work on OSX since I had some feedback on the app path in Unity install.

Link to comment
Share on other sites

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...