AL icon indicating copy to clipboard operation
AL copied to clipboard

Debugger is stepping in the code with action step over

Open FSchneiderYav opened this issue 1 year ago • 8 comments

1. Describe the bug I have a strange behavior with the debugger. When I start the debugger and call a report without a breakpoint. The report is performed without the debugger starting. But if I add a breakpoint before the report and call the report again. The debugger is stopping at the breakpoint, that's what I expect. But when I use now the Step Over, the debugger is stopping at the triggers in the report. For example at the trigger OnAfterGetRecord. And is not stepping over the whole report. Same behavior is in pages.

2. To Reproduce Steps to reproduce the behavior:

  1. Add a breakpoint in page 42 "Sales Order" in the line DocumentAttachmentDetails.RunModal(); (Line 1267)
  2. Start a session with a active debugger
  3. Open a Sales Order and use the action Attachements
  4. The debugger is now stopping at the breakpoint
  5. Use now Step Over
  6. The debugger is stopping in the page 1173 "Document Attachment Details" in function GetCaptionClass (Why is the debugger stopping here?)
  7. When I use now the action Step out
  8. The debugger is stopping on different functions like GetCaptionClass, OnNewRecord and OnAfterGetCurrRecord

3. Expected behavior I expect, that the debugger is stopping at the breakpoint like in step 4. But wenn I use Step Over, the debugger should not stop anywhere in the page

4. Actual behavior The debugger is stopping in the page 1173 "Document Attachment Details" and is not stepping over

5. Versions:

  • AL Language: v13.0.971907
  • Visual Studio Code: Version: 1.88.1 (user setup) Commit: e170252f762678dec6ca2cc69aba1570769a5d39 Date: 2024-04-10T17:41:02.734Z Electron: 28.2.8 ElectronBuildId: 27744544 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Windows_NT x64 10.0.22621
  • Business Central: Version: W1 23.1 (Platform 23.0.13804.0 + Application 23.1.13431.13812)
  • List of Visual Studio Code extensions that you have installed: AL Language

FSchneiderYav avatar Apr 29 '24 08:04 FSchneiderYav

In your launch.json do you have breakOnError or breakOnRecordWrite set? If so, was there an error or record write where the unexpected breaks happened?

Looking at the code where it breaks, I don't see any reason why there would be an error or record write, but if you could confirm that would be great.

thloke avatar Apr 30 '24 01:04 thloke

Hi, I have "breakOnError": "ExcludeTry" there is no error and no write

{
     "name":  "8.X DEV LOKAL",
     "server":  "http://PROD-BC23-1-dev",
     "serverInstance":  "BC",
     "dependencyPublishingOption":  "Ignore",
     "type":  "al",
     "environmentType":  "OnPrem",
     "breakOnError":  "ExcludeTry",
     "authentication":  "UserPassword",
     "request":  "launch"
 }

There are some examples where the debugger stops: This is where the breakpoint is: image This is after StepOver image image image

FSchneiderYav avatar Apr 30 '24 05:04 FSchneiderYav

So this is by design for now, and has been for as long as I can tell. Because the breakpoint is on the last line in the method, when you step over it the method scope no longer exists and we stop on the next frame to be executed which just happens to be the GetCaptionClass method.

From what I understand, your ask is that it behaves more like a continue (F5) instead?

@kalberes - maybe you have more input on this scenario?

thloke avatar Apr 30 '24 07:04 thloke

Yes it is since a long time. But not only if it is the last Step When I add a breakpoint in the Sales Order page here image And Step over, the debugger is not moving to the MoveNegSalesLine.ShowDocument(). It is moving there image

FSchneiderYav avatar Apr 30 '24 07:04 FSchneiderYav

Can you make sure that you don't have any entries in your breakpoint list in VSC for this position: grafik

Old breakpoints are not correctly shown in vsc but recognized by the debugger, if they are set in a "wrong" tab. (see #7611)

dannoe avatar Apr 30 '24 14:04 dannoe

I have no other breakpoints in the list.

FSchneiderYav avatar May 02 '24 04:05 FSchneiderYav

I think it is by design now and you cannot step over modal state. This has been like this like forever, since I am not aware of anyone changing modal UI (page, report) execution context. If you put a breakpoint on the next line (ShowDocument) it should be hit though. If not that is a bug.

kalberes avatar May 02 '24 13:05 kalberes

Yes with F5 it steps to the next line

FSchneiderYav avatar May 03 '24 04:05 FSchneiderYav