microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
718 stars 242 forks source link

Debugger is stepping in the code with action step over #7734

Closed FSchneiderYav closed 1 month ago

FSchneiderYav commented 2 months ago

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:

thloke commented 2 months ago

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.

FSchneiderYav commented 2 months ago

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

thloke commented 2 months ago

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?

FSchneiderYav commented 2 months ago

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

dannoe commented 2 months ago

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)

FSchneiderYav commented 2 months ago

I have no other breakpoints in the list.

kalberes commented 2 months ago

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.

FSchneiderYav commented 2 months ago

Yes with F5 it steps to the next line