Jump to content

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


Recommended Posts

Yeah that's what I tried, but nothing. I think there must be some step that maybe Mac Unity developers know but isn't in your instructions. Because I followed your instructions to the letter, and it does not work.

Link to comment
Share on other sites

  • 1 month later...

I was able to get this mostly working (Development Build displayed on KSP,  Attach to unity Debugger is successful, Exception Support set to true) however, none of my break points are triggering. I can see my code changes after I compile.  Has anyone else seen this behavior? I am using Visual Studio 2013 on Windows 10.

Thanks

User error, duh moment on setting breakpoints correctly. 

Edited by gomker
adding OS
Link to comment
Share on other sites

  • 3 weeks later...
On 17/09/2016 at 3:57 PM, Aerospike said:

The unity download archive only provides a download for Unity 5.4.0f3 but KSP 1.2.0 expects Unity 5.4.0p4.

In case anybody else is looking for the download of the correct Version, you can find it here: https://unity3d.com/unity/qa/patch-releases/5.4.0p4
 

Unless I'm missing something, 5.4.0p4 is Unity Pro and will require a licence if you want to actually run it for profiling etc...

Link to comment
Share on other sites

7 minutes ago, Padishar said:

Unless I'm missing something, 5.4.0p4 is Unity Pro and will require a licence if you want to actually run it for profiling etc...

uh, no. it is patch 4. Nothing more. All Unity version can profile now. The paying upgrade are for build,s marketing tool, removing the splash screen and the like.

Link to comment
Share on other sites

Just now, sarbian said:

uh, no. it is patch 4. Nothing more. All Unity version can profile now. The paying upgrade are for build,s marketing tool, removing the splash screen and the like.

Hmm, when I tried downloading it I got a full install which asked me to sign in with my Unity account when I ran it. The free version doesn't do this...

Link to comment
Share on other sites

22 hours ago, Padishar said:

Hmm, when I tried downloading it I got a full install which asked me to sign in with my Unity account when I ran it. The free version doesn't do this...

As far as I know the Personal Edition of Unity requires a (free) Account as well now. I'm unable to check that, because for some strange reason Unity does not want to start (it was working without problems yesterday...):huh:

 

Anyway: Yes, the patch is an installation file (not sure if it is a full install?). BUT! You don't even have to install it! Just open the .exe file with winzip/7-zip/winrar and extract the player file. The directory structure inside the self extracting archive is just the same as it is in your local installation of unity. :)

Edited by Aerospike
clarification
Link to comment
Share on other sites

1 hour ago, Aerospike said:

As far as I know the Personal Edition of Unity requires a (free) Account as well now. I'm unable to check that, because for some strange reason Unity does not want to start (it was working without problems yesterday...):huh:

 

Anyway: Yes, the patch is an installation file (not sure if it is a full install?). BUT! You don't even have to install it! Just open the .exe file with winzip/7-zip/winrar and extract the player file. The directory structure inside the self extracting archive is just the same as it is in your local installation of unity. :)

No, I definitely don't have to sign in when I run the personal version of Unity.

As for my strange installation problems, originally I had installed 5.4.0f3 and this was working without needing to sign in.  I knew that KSP wouldn't run with the player included with that so, because it said on the Unity site that the "patch" was actually a full install, I uninstalled 5.4.0f3 first before installing the patch.  This insisted I sign in with an account and when I did it said I couldn't run it because I had no licence.

I need to use the Unity profiler so just copying the player file out isn't good enough.  Anyway, I completely removed all traces of Unity and then reinstalled 5.4.0f3 and then installed the "patch" version without uninstalling first and now it doesn't ask me to sign in and it runs ok (though whether this was actually required is unknown).  I copied the debug player into KSP 1.2 and tested the profiler within Unity and it's all working fine.

Link to comment
Share on other sites

3 minutes ago, Padishar said:

No, I definitely don't have to sign in when I run the personal version of Unity.

You are right of course. When launching unity without a stored login, you can either log in or choose "work offline".
Guess I must have missed that button when I first installed unity and thought that I had to create an account. :wink:

Link to comment
Share on other sites

Well, getting close.

Did all the steps for Linux (including compiling the Unity debugger), can attach to the Player process (and pause it to inspect where it is at the moment etc), but cannot set breakpoints.  Keeps telling me "Debugger operation failed - Target could not be interrupted".  Google is of no more assistance, any ideas?

KSP 1.2.0.1509 (x64, of course), Monodevelop 5.10, Debian "Jessie"


EDIT: NVM, it works.  It does help not having 2 copies of your DLL in GameData (one of which was the original non-Debug version)... been tearing my hair out why my changes weren't doing anything! :P

 

Edited by micha
Stupid Me
Link to comment
Share on other sites

  • 2 weeks later...

Guys, I have a trouble with getting my Mono to debug KSP 1.2 on Windows

I've done everything like @sarbian told (got the right Unity, patched it, replaced exe with the player from Unity, put "PlayerConnectionConfigFile" to KSP_x64_Data folder) and got KSP running in development mode. But when I try to attach to process in Mono there's no processes listed. If I have Unity Editor running at that time, it shows the Editor but no luck with KSP.

I feel that I'm one step away but can't figure out what am I doing wrong.

Edited by Ser
Link to comment
Share on other sites

On 08/10/2016 at 1:01 PM, Ser said:

I feel that I'm one step away but can't figure out what am I doing wrong

Windows, Linux ? It works here on Windows and Mono. Are the .mdb are properly generated (I spent an hour wondering why it was not working until I noticed my pdb2mdb.exe was not where it used to be) ? 

Edited by sarbian
Link to comment
Share on other sites

2 hours ago, sarbian said:

Windows, Linux ? It works here on Windows and Mono. Are the .mdb are properly generated (I spent an hour wondering why it was not working until I noticed my pdb2mdb.exe was not where it used to be) ? 

I'm trying on Windows. The weirdest thing is that my Mono 5.9.6 that was installed with Unity generates a pdb file instead of mdb :huh: and I have no idea how to change it, so I had to convert it with pdb2mdb and then put both near the plugin's dll.

Is it really an mdb file that makes KSP appear in the process list? If so, when it should appear in the list if my plugin initializes at the flight scene?

What do you mean by " pdb2mdb.exe was not where it used to be"? It just woked and generated an mdb file. Have no idea whether its contents are properly generated. Is there a way to check it?

Edited by Ser
Link to comment
Share on other sites

Indeed, the missing mdb should not prevent the process from showing up in the list.

Did you test with the unity editor profiler ? In Unity go to the Windows menu and choose Profiler. The window has an "Active profile" button up top that show the list of thing that it can profile. You should see the "WindowPlayer" when KSP runs.

Since you have the gfame running in dev mode I guess the only remaing culprit would be the "PlayerConnectionConfigFile" in KSP_x64_Data (you launch the x64 build right ?). Windows did not sneak in an extension to the file name ? You may want to build a dumy/empty project game in Unity with the "Development Build" check box checked. It will create that file in the build and you could try to use that one instead of mine.

Link to comment
Share on other sites

@sarbian I've tried what you said:

Have built a new Unity project with Development build, Autoconnect profiler and Script debugging enabled, and replaced your PlayerConnectionConfigFile with generated one. It contains the string "listen 1143278402 1 1" - the numbers are slightly different from yours. Unity profiler starts to show signs of life once KSP is launched: in the Overview column there's FlightCamera, FlightGlobals, Krakensbane etc. The interesting thing is that in the "Active profiler" dropdown there's still only "Editor" and "<Enter IP>" listed but the Editor isn't checked. Mono doesn't see the KSP process as well. Looks like Unity can't list the process but can profile it though :huh: Tried disabling my firewall but with no result.

Edited by Ser
Link to comment
Share on other sites

@sarbian Thanks for your help, I've managed to get it working.

The steps that helped me:

Replaced contents of the PlayerConnectionConfigFile with the string: listen 1143278402 1 1 (not sure if that's necessary)

Generated the .mdb file with the pdb2mdb shipped with Unity, i.e \Unity\Editor\Data\Mono\lib\mono\2.0\pdb2mdb.exe

Started MonoDevelop after KSP. That have brought WindowsPlayer (that is KSP) to process list to attach to.

 

Windows, KSP 1.2, Unity 5.4.0p4, Mono Develop 5.9.6 shipped with Unity

Edited by Ser
Link to comment
Share on other sites

  • 3 weeks later...

I've been trying to debug a mod and I get these messages on the dev console:

get_realtimeSinceStartup can only be called from the main thread

What are the suggestions? Is there any way to patch it?
EDIT: can't remove these calls (Time.realtimeSinceStartup) from the mod code as the whole mod depends on it.

Edited by RockyTV
Link to comment
Share on other sites

11 hours ago, RockyTV said:

I've been trying to debug a mod and I get these messages on the dev console:


get_realtimeSinceStartup can only be called from the main thread

What are the suggestions? Is there any way to patch it?
EDIT: can't remove these calls (Time.realtimeSinceStartup) from the mod code as the whole mod depends on it.

When running under the debugger, certain things are done from a different thread to the main one.  You are probably initialising some variable with the result of that function in a constructor (or just directly in the class definition).  Set it to a sensible value there instead (e.g. 0) and then do the call to get_realtimeSinceStartup in the Start or Awake function of your class...

BTW: a link to github or other way to view the source is always helpful when trying to get help with plugin development...

Edited by Padishar
Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...
  • 2 weeks later...
On 08.10.2016 at 2:01 PM, Ser said:

when I try to attach to process in Mono there's no processes listed

I have had the same trouble but with Visual Studio. The solution for my case was:
KSP Main Menu > Settings > General > Simulate In Background (should be ON).

Link to comment
Share on other sites

  • 1 month later...

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