AL icon indicating copy to clipboard operation
AL copied to clipboard

Debugger doesn't support some breakpoint Expression types/formats, but the error is not reported and buried in the Locals section...

Open dzzzb opened this issue 4 years ago • 7 comments

1. Describe the bug I just wasted an hour or two of my life, trying to determine why conditional breakpoints seemingly didn't work, when in fact it appears to be a limitation of the AL extension for VSC - but one that's very quietly reported, nowhere useful, the developer might never see it!!

2. To Reproduce

  1. Have some code that you need to debug, but you need to only break when a condition is met involving a GUID, e.g. in a loop.
  2. Create a breakpoint in VSC and add a condition Expression to it, e.g. IsNullGuid(SomeRecord.SomeField)
  3. Run the debugger and see that the breakpoint is always hit, even when SomeRecord.SomeField is clearly not a NullGuid.

3. Expected behavior

  • I expected the Expression to work.
  • I now expect at least an error to be reported somewhere I can see it / am not likely to miss it... i.e. in a popup message box, etc. - for all such errors of unsupported Expressions (not just those involving Guids).

4. Actual behavior

  • There is an error, but it's buried at the bottom of the Locals tab as an _ALException: image image
  • This exception should be caught by VSC and reported clearly and unambiguously to the user, and the debugger should stop, so the user can evaluate the problem and determine an alternative condition for their breakpoint!
  • But instead, the debugger continues running and stopping on the breakpoint, despite the condition not being met / being invalid. So the user tries and fails with other expressions - until, IF they are miraculously lucky, they notice the _ALException.

5. Versions:

  • AL Language:
Name: AL Language
Id: ms-dynamics-smb.al
Description: AL development tools for Dynamics 365 Business Central
Version: 8.2.545335
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-dynamics-smb.al
  • Visual Studio Code: 1.62.2
  • Business Central:
  • List of Visual Studio Code extensions that you have installed: image

dzzzb avatar Nov 18 '21 15:11 dzzzb

There is limited conditional breakpoint support today in the debugger. It has been there added as a slice for a long time, but has not yet been scoped. For now we support max as much as the old C/SIDE debugger has supported. The _ALException is added to the local variables on errors the server sends.

kalberes avatar Nov 19 '21 00:11 kalberes

The _ALException is added to the local variables on errors the server sends.

Yes, as I eventually discovered. But this is not at all helpful to users. Until they notice that, they waste hours trying to determine why their expression does not give a visible error but does not work. And why let the debugger continue to run if the language threw an exception? Is it because there's difficulty differentiating AL exceptions from code vs. from the platform?

dzzzb avatar Nov 19 '21 10:11 dzzzb

I will also say that the debugging experience appears to be very poorly documented or at least poorly searchable in this aspect. I found no relevant results for searches like Business Central debugger breakpoint condition OR expression. Something like this should be clearly documented as a gotcha until it's fixed, and be optimised to actually appear in search engines.

dzzzb avatar Nov 19 '21 10:11 dzzzb

Also, am I correct that Hit Count and Log Message type breakpoints are not supported at all by AL? If not, then please can they be disabled in the VSC GUI?

dzzzb avatar Nov 19 '21 11:11 dzzzb

And why let the debugger continue to run if the language threw an exception? Is it because there's difficulty differentiating AL exceptions from code vs. from the platform?

It was not the language throwing an exception. But the debug engine. Not all exceptions stop debugging. On the documentation issue. You have a point that it would be nice that we document something you expect from other debug engines to work and does not work here. Though there is nothing new here. We are compatible with the minimum bar hopefully on conditional breakpoints, the old C/SIDE debugger. This should still be the valid documentation for it. https://docs.microsoft.com/en-us/dynamics-nav/how-to--set-conditional-breakpoints I can see it the other way around had we supported complex expressions in conditional breakpoint evaluation that should have been documented. Else we can just have a huge list. Why don't you also ask why don't we document that we do not support intellisense when adding a watch or using the debug console. Also what about hit counts, log messages. That is also not supported. Why don't we document that we do not support that? The list is big. But hopefully with time all these will be supported.

kalberes avatar Nov 19 '21 14:11 kalberes

Spent some time today trying to figure out why "Log Message" didn't appear to produce any output when I saw that the breakpoint's red dot in the editor gutter has a tooltip that tells users that breakpoints of this particular type are not supported.

I feel that "Log Message" would greatly benefit my debugging experience. Thank you in advance for (re)considering adding this to the VS Code extension!

jhoek avatar Nov 01 '23 10:11 jhoek