Search Unity

Monodevelop Debugging: Breakpoints do not work in play mode.

Discussion in 'Editor & General Support' started by neginfinity, Dec 6, 2016.

  1. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    Alright.

    I've recently ugpraded to 5.5.0f3
    Code (csharp):
    1.  
    2. Version 5.5.0f3 (38b4efef76f0) Personal
    3. Thu, 24 Nov 2016 13:54:18 GMT
    4. Branch: 5.5/release
    5.  
    And I've just realized that MonoDevelop debugging no longer reliably works in play mode.
    Basically, good portion of my breakponts are ignored.
    monodevelopbug-1.png
    monodevelopbug-2.png
    This does not trigger debugger even when monodevelop is attached.
    I can debug functions that originate from within OnDrawGizmos, though, and can successfully set breakpoints on certain lines of code. But not all of them (the way it used to work).

    How do I fix this?

    ---Additional info--

    I'm starting to suspect that editor compiles scripts in release mode with debugging information disabled. If that's the case, I'd like to revert to the old behavior. How do I do it?
     
  2. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    There was a similar bug on the compiler preview, evidently it hasn't been fixed
     
  3. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    Sigh. So, downgrading is the only option? What's the latest version without this issue?
     
  4. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    5.4 does still use the old compiler.
     
  5. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
  6. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    iamthwee likes this.
  7. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    @neginfinity

    It looks like bug 851079 should have been corrected in 5.5.0f3, so maybe you are seeing something slightly different.

    What makes you suspect this? It indeed could be the case, but I've not seen anything yet here to suggest this is happening.

    Also, do you know if this is specific to a certain project or to certain code from that project?
     
  8. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    Well, if I pause debugger, I can set up breakpoings, but only on some lines (on a very small percentage of lines). For example breakpoint on line with initial initialization assignment will probably fall through (even if it assign result of a function call), but it might be possible to set up a breakpoint on some of my function calls.

    Normally this kind of things happen (in C++ code, anyway), when compiler optimizations are enabled, and compiler starts optimizing things away. Meaning you see the line of code, but it is either collapsed or completely removed in the actual exe, so you can't put a breakpoint on it.

    Basically, when I setup breakpoints in monodevelop, everything looks fine, but when I attach to editor, they all get that "breakpoint with a hole in it" appearacne meaning they are not functioning (all of them). If I "pause" debugging (which will interrupt code execution), and start manually re-setting breakpoints (meaning remove and set them up again), then some breakpoints will set and work, but that'll be a minority of them..

    I ran into this issue on a nearly blank project with a single monobehavior. Basically, this was a quick test I made to experiment with something.

    Do you need a repro?
     
  9. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    @neginfinity

    Thanks for the information. Although it is a pretty simple case, I would like a repro project. These debugger/breakpoint issues can be very sensitive to the specific IL code involved, so I want to be sure we can see the same thing you are seeing. Please submit a bug report with this project. Thanks!
     
  10. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    Submitted a bug report. Case 859744

    Here's a repro project.

    It has nearly no code and all breakpoints fail to trigger.
     

    Attached Files:

  11. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Thanks! Please ping here with the bug number when you get one.
     
  12. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    Case 859744
     
    iamthwee likes this.
  13. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Thanks, we'll have a look at this.
     
  14. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    I'll most likely will be downgrading meanwhile. As hilarious as it may sound, apparently Monodevelop seem to be the best option for unity code editing. VisualStudio has formatting bug that affects C# and greatly annoys me, and VS Code's omnisharp seems to be intent on spamming hundreds of useless "warnings" without any fix for them.
     
  15. Deleted User

    Deleted User

    Guest

    I think that it will fail if there is a cursor after the first letter of the line that sets the breakpoint.
     
  16. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    Speaking of which it would be great to know if there are any news about this.

    I got one response from QA asking for more details, send them those details, and never heard from them back.
     
  17. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    @neginfinity

    It looks like the bug report is stuck waiting for our QA team to process your latest response. I'll ping them to get this case moving.
     
  18. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    Got a response from QA, the whole thing starts looking like a Heisenbug at this point. Apparently they're unable to reproduce it on multiple machines.
     
  19. AndyBlock

    AndyBlock

    Joined:
    Oct 12, 2016
    Posts:
    35
    I don't suppose there is any news on this? I'm having the same problem (initially after upgrading from 5.3.5p8 to 5.5.0f3, and also on 5.5.0p4 and 5.5.1f1).
     
  20. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    QA told me that problem does not exist in 5.6. Which appears to be true. I suggest to roll back to 5.4 till 5.6 is released as non-beta (which should happent in March). I'm currently using 5.4.3 myself.

    Of course if Unity hotfixed this issue, that would be grand.
     
  21. lolun

    lolun

    Joined:
    Nov 25, 2014
    Posts:
    16
    I am on 5.6.0f3 and I'm still seeing this issue. So it does exist in 5.6
     
  22. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    @lolu476
    Please try the latest 5.6 patch release. There was a different, but similar, bug that we were able to reproduce. We've corrected it now, but I'm interested to see if it correct the issue you have.
     
  23. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    The problem seem o persist in 5.6.0f3 and often affect editor efxtension code, like OnDrawGizmos(). Braakpoints that are not at the very first line of the function definition frequently do not trigger, and cannot be set inside a function until you step through a function.
     
  24. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Are you using the same project submitted with case 859744? These issues can be (unfortunately) very sensitive to specific source code. If you're seeing a bad behavior with a different project, but might need a new bug report to check it.
     
  25. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    I'm using different code. I haven't yet tested the old repro, but as far as I can tell, it is not code dependent.

    I get consistent behavior, where I can only place breakpoints at the beginning of the function, and not at any line inside the function, even when there's reachable code.Meaning the lines are not optimized away or anything. Breakpoints only light up when I'm walking through the code line by line.
     
  26. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    I was able to try the original repo case again, and it worked properly with the latest MonoDevelop and Unity 5.6. But there might still be something wrong here, as this issue has proven to be rather sensitive to a number of factors.

    Please try the original project again if you have a chance.

    Also, if you can use Unity 5.6.1, you might want to try Visual Studio for Mac, which Microsoft just released. It is effectively a rebranded version of the latest Xamarin Studio. But the debugger plugin for Unity is the same one used by VSTU, which is much better than the debugger plugin for Unity used in MonoDevelop.

    I've not tried Visual Studio for Mac with your case yet, but it might be worth a look.
     
  27. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    I'm on windows.

    I'll try repro later this week and post results.

    I'm using monodevelop instead of visual studio because monodevelop (surprisingly) offer better support for custom formatting, and because visual studio has certain incredibly annoying code formatting behavior that most likely isn't going to be fixed any time soon.
     
  28. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    Alright. This codebase routinely experiences the issue I mentioned pretty much at every turn, in many functions. For example, breakpoints cannot be set within CameraRotation::Update on most lines.

    I'll check out old repro again later.
     
  29. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Sorry, I do recall from our earlier conversation that you are on Windows. I had forgotten that fact.

    I'll try out the project you linked above to track down any issue. Let me know about the original reproduction case as well.
     
  30. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    I think the problem is fixed in 5.6.1. I've been working on a fairly complex piece of code for roughly a week, but haven't encountered it even once. Had to upgrade due to 5.6.0 not supporting post processing effects in scene view (due to a bug).
     
    JoshPeterson likes this.
  31. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,276
    [Can not upgrade to 5.6.1 yet due to asset package compatibility, but]
    having debug issues too on windows 5.5.1 like the above, but also coroutine debugging is a nightmare (perhaps a separate thread!) because:

    - the variable names become $origionalName so hovering over variables shows nothing
    - stepping into a function or 'next line' often appears to jump a load of code instead of what it should do

    - if it is after a www call I switch back to the editor and it often shows an error about audioclip and www which makes no sense
    - debugger simply fails sometimes and has to be re-attached
    - editor locks up (bug reported before - common in 5.5.1 when debugging or closing project)
     
  32. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    The problem is back in 2017.3

    As far as I can tell, the issue is that debugging data for breakpoints isn't generated instantly and only appears after something like 5 minutes in the debugger.

    Can this nonsense be finally fixed once and for all?
     
    Coeur_EF likes this.
  33. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    @neginfinity

    I see that you have re-opened the bug report as well. We will investigate this issue. Thanks!
     
  34. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    Yeah. I would love to see this fixed. This issue is very irritating, because it renders quick debugging unreliable. Basically I can only reliably place breakpoints at the very first line of a function, and on any other line breakpoints cannot be placed unless debugger has been attached for a while.

    I'm not sure at which moment exactly debugging data becomes fully available.
     
  35. Waqas-Anwar

    Waqas-Anwar

    Joined:
    Feb 2, 2015
    Posts:
    26