Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Source Level Debugging the Network Stack

Discussion in 'Multiplayer' started by DougRichardson, Dec 15, 2017.

  1. DougRichardson

    DougRichardson

    Joined:
    Oct 7, 2017
    Posts:
    74
    I've followed the instructions on Unity-Technologies/networking to get the Networking stack source code for Unity 2017.2, build it, and use it from Unity. I've verified my version of the DLL is properly installed by printing a message with Debug.Log in the networking code.

    However, I have not figured out how to source level debug from visual studio (that is, my breakpoints are not hit). I tried attaching to the Unity process from the networking solution opened in Visual Studio 2017. While I am able to attach, my breakpoints show up as hollow red circles (normally they are solid red). When the code that executes my Debug.Log gets hit (which I have the breakpoint on), the breakpoint is does not cause the debugger to pause on that line.

    FWIW, I have been able to debug "normal" Unity scripts from Visual Studio.
     
  2. Nevak

    Nevak

    Joined:
    Sep 27, 2012
    Posts:
    20
    I know this is bit of an old thread, but I just found the same issue myself and I finally got to the solution so I'll leave it here for the future:

    After you have followed all the steps here: https://bitbucket.org/Unity-Technologies/networking and you have built the solution and copied all the stuff in the "Output" folder to the Editor/Data/UnityExtensions/Networking directory, you need an extra step:

    • Generate the up-to-date mdb symbol files! as visual studio will not generate these. It only generates pdb files.

    You can do this with the pdb2mdb.exe tool (located in %UNITY_INSTALL_DIR%\Editor\Data\MonoBleedingEdge\lib\mono\4.5\pdb2mdb.exe)

    Personally I created a simple generate_mdb.bat file with the following inside:

    So now you can do:

    And it will generate a fresh .mdb file next to your dll

    You can also edit the .csproj files and add this line to generate the mdb files automatically after you build the dlls (Add this to the <Target> node of the .csproj file):


    Also note that when you set a breakpoint in the Engine.Networking code, it might appear unreachable (white circle) until you actually hit the "Play" button in the editor, since the UnityEngine.Networking module doesn't get loaded until the game is actually running.

    Hope it helps someone :)
     
    DougRichardson likes this.