Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/exception breakpoints #1434

Merged

Conversation

akpaevj
Copy link
Contributor

@akpaevj akpaevj commented Aug 3, 2024

Summary by CodeRabbit

  • New Features

    • Introduced conditional breakpoints, allowing breakpoints to be hit only under specified conditions.
    • Added support for exception breakpoint filters, enabling users to stop on uncaught exceptions or all exceptions.
    • New methods for setting exception breakpoints and managing breakpoints with conditions have been integrated.
    • Enhanced functionality in the breakpoint manager for better control over standard and exception breakpoints.
  • Bug Fixes

    • Enhanced error handling and clarity for thread stopping events, providing more context with error messages.
  • Chores

    • Updated the package.json for improved readability and structure, including the removal of the previously empty dependencies object.

Copy link

coderabbitai bot commented Aug 3, 2024

Walkthrough

The recent changes significantly enhance debugging capabilities by introducing conditional breakpoints, exception filtering, and refined breakpoint management. Key features include new properties for conditions, updated interfaces for better error handling, and the addition of methods for setting machine exception breakpoints. These improvements collectively streamline the debugging process, providing developers with increased control and clarity in their coding sessions.

Changes

Files Change Summary
src/OneScript.DebugProtocol/*.cs Introduced Condition property to Breakpoint and BreakpointDescriptor; enhanced IDebugEventListener and IDebuggerService for improved thread management and exception handling.
src/OneScript.DebugServices/*.cs Updated DefaultBreakpointManager and DefaultDebugController to support conditions for breakpoints and refined method signatures for clarity.
src/ScriptEngine/Machine/*.cs Enhanced breakpoint evaluation and error messaging in MachineInstance; added private method for managing stop events.
src/VSCode.DebugAdapter/*.cs Added methods for setting exception breakpoints; improved breakpoint handling in OscriptDebugSession; modified related methods for better usability.
src/VSCode.DebugAdapter/package.json Updated dependencies and improved formatting for readability, specifically removing an empty dependencies object.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Debugger
    participant BreakpointManager
    participant DebugSession

    User->>Debugger: Set Breakpoints with Conditions
    Debugger->>BreakpointManager: Update Breakpoints
    BreakpointManager->>Debugger: Acknowledge Update
    Debugger->>DebugSession: Notify Breakpoint Hit
    DebugSession->>User: Show Breakpoint Notification
Loading

Poem

🐰 In the land where code does bloom,
New breakpoints dance, dispelling gloom.
With conditions set and errors caught,
Debugging now is joy, not fraught!
Hops of joy through lines of text,
A rabbit’s cheer for what's next! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (2)
src/ScriptEngine/Machine/IDebugController.cs (1)

29-29: Discrepancies in SetBreakpoints Method Signatures

The SetBreakpoints method signatures in the following files do not match the new signature (string module, (int Line, string Condition)[] breakpoints):

  • src/VSCode.DebugAdapter/OscriptDebugSession.cs: public override void SetBreakpoints(Response response, dynamic arguments)
  • src/OneScript.DebugServices/DefaultDebugService.cs: _breakpointManager.SetBreakpoints(item.Key, points)

Please update these method signatures to conform to the new interface.

Analysis chain

LGTM! But verify the method usage in the codebase.

The code changes are approved.

However, ensure that the method SetBreakpoints is correctly implemented and used.


The search results show multiple occurrences of SetBreakpoints. We need to ensure that all instances match the new signature (string module, (int Line, string Condition)[] breakpoints).

Let's verify each instance to confirm they adhere to the new method signature.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all method calls to `SetBreakpoints` match the new signature.

# Test: Search for the method usage. Expect: Only occurrences of the new signature.
rg --type cs -A 5 $'SetBreakpoints'

Length of output: 5996


Script:

#!/bin/bash
# Verify the method signatures for SetBreakpoints in all relevant files.

# Check the method signature in src/VSCode.DebugAdapter/OscriptDebugSession.cs
rg --type cs -A 5 'SetBreakpoints' src/VSCode.DebugAdapter/OscriptDebugSession.cs

# Check the method signature in src/ScriptEngine/Machine/IDebugController.cs
rg --type cs -A 5 'SetBreakpoints' src/ScriptEngine/Machine/IDebugController.cs

# Check the method signature in src/OneScript.DebugServices/DefaultBreakpointManager.cs
rg --type cs -A 5 'SetBreakpoints' src/OneScript.DebugServices/DefaultBreakpointManager.cs

# Check the method signature in src/OneScript.DebugServices/DefaultDebugService.cs
rg --type cs -A 5 'SetBreakpoints' src/OneScript.DebugServices/DefaultDebugService.cs

Length of output: 2204

src/OneScript.DebugServices/DefaultDebugService.cs (1)

71-83: Ensure consistency in SetMachineBreakpoints implementations.

The method SetMachineBreakpoints in DefaultDebugService.cs has been updated with new logic to handle breakpoints with conditions. However, the following files do not reflect this change:

  • src/VSCode.DebugAdapter/DebugeeProcess.cs
  • src/VSCode.DebugAdapter/OscriptProtocols/Tcp/TcpDebugServerClient.cs
  • src/OneScript.DebugProtocol/IDebuggerService.cs

Please update these implementations and usages to ensure they match the new logic introduced in DefaultDebugService.cs.

Analysis chain

LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to SetMachineBreakpoints match the new logic.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `SetMachineBreakpoints` match the new logic.

# Test: Search for the function usage. Expect: Only occurrences of the new logic.
rg --type cs -A 5 $'SetMachineBreakpoints'

Length of output: 2128


Script:

#!/bin/bash
# Description: Verify all function calls to `SetMachineBreakpoints` match the new logic.

# Check the implementation of SetMachineBreakpoints in DebugeeProcess.cs
echo "Checking DebugeeProcess.cs..."
rg --type cs -A 10 'SetMachineBreakpoints' src/VSCode.DebugAdapter/DebugeeProcess.cs

# Check the implementation of SetMachineBreakpoints in TcpDebugServerClient.cs
echo "Checking TcpDebugServerClient.cs..."
rg --type cs -A 10 'SetMachineBreakpoints' src/VSCode.DebugAdapter/OscriptProtocols/Tcp/TcpDebugServerClient.cs

# Check the implementation of SetMachineBreakpoints in IDebuggerService.cs
echo "Checking IDebuggerService.cs..."
rg --type cs -A 10 'SetMachineBreakpoints' src/OneScript.DebugProtocol/IDebuggerService.cs

Length of output: 1565

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d6782a1 and 0980ac0.

Files ignored due to path filters (1)
  • src/VSCode.DebugAdapter/package-lock.json is excluded by !**/package-lock.json
Files selected for processing (19)
  • src/OneScript.DebugProtocol/Breakpoint.cs (1 hunks)
  • src/OneScript.DebugProtocol/IDebugEventListener.cs (1 hunks)
  • src/OneScript.DebugProtocol/IDebuggerService.cs (1 hunks)
  • src/OneScript.DebugServices/BreakpointDescriptor.cs (1 hunks)
  • src/OneScript.DebugServices/DefaultBreakpointManager.cs (1 hunks)
  • src/OneScript.DebugServices/DefaultDebugController.cs (2 hunks)
  • src/OneScript.DebugServices/DefaultDebugService.cs (2 hunks)
  • src/OneScript.DebugServices/TcpEventCallbackChannel.cs (1 hunks)
  • src/OneScript.DebugServices/ThreadManager.cs (1 hunks)
  • src/OneScript.DebugServices/ThreadStoppedEventArgs.cs (1 hunks)
  • src/ScriptEngine/Machine/IDebugController.cs (1 hunks)
  • src/ScriptEngine/Machine/MachineInstance.cs (6 hunks)
  • src/ScriptEngine/Machine/MachineStopManager.cs (5 hunks)
  • src/ScriptEngine/Machine/MachineStoppedEventArgs.cs (1 hunks)
  • src/VSCode.DebugAdapter/DebugSession.cs (2 hunks)
  • src/VSCode.DebugAdapter/DebugeeProcess.cs (1 hunks)
  • src/VSCode.DebugAdapter/OscriptDebugSession.cs (5 hunks)
  • src/VSCode.DebugAdapter/OscriptProtocols/Tcp/TcpDebugServerClient.cs (1 hunks)
  • src/VSCode.DebugAdapter/package.json (7 hunks)
Files skipped from review due to trivial changes (1)
  • src/VSCode.DebugAdapter/package.json
Additional comments not posted (43)
src/OneScript.DebugProtocol/Breakpoint.cs (1)

18-18: LGTM! The addition of the Condition property enhances debugging capabilities.

The Condition property allows specifying conditions for breakpoints, which improves control over debugging.

src/OneScript.DebugServices/ThreadStoppedEventArgs.cs (1)

20-20: LGTM! The addition of the ErrorMessage property enhances the class's functionality.

The ErrorMessage property allows storing an error message related to the thread's stop event, providing more context for debugging.

src/OneScript.DebugServices/BreakpointDescriptor.cs (1)

16-16: LGTM! The addition of the Condition property enhances the functionality of the class.

The Condition property allows storing a condition associated with a breakpoint, enabling conditional breakpoints.

src/OneScript.DebugProtocol/IDebugEventListener.cs (1)

15-15: LGTM! But verify the method usage in the codebase.

The code changes are approved.

However, ensure that all method calls to ThreadStopped match the new signature.

src/ScriptEngine/Machine/IDebugController.cs (5)

37-37: LGTM! But verify the method usage in the codebase.

The code changes are approved.

However, ensure that the method GetCondition is correctly implemented and used.

Verification successful

The method GetCondition is correctly implemented and used. All occurrences match the new signature.

  • src/ScriptEngine/Machine/MachineStopManager.cs
  • src/ScriptEngine/Machine/IDebugController.cs
  • src/OneScript.DebugServices/DefaultBreakpointManager.cs
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all method calls to `GetCondition` match the new signature.

# Test: Search for the method usage. Expect: Only occurrences of the new signature.
rg --type cs -A 5 $'GetCondition'

Length of output: 1447


35-35: LGTM! But verify the method usage in the codebase.

The code changes are approved.

However, ensure that the method FindBreakpoint is correctly implemented and used.

Verification successful

Verified: The method FindBreakpoint is correctly implemented and used with the new signature.

  • IDebugController.cs: Declaration of FindBreakpoint.
  • MachineStopManager.cs: Usage of FindBreakpoint.
  • DefaultBreakpointManager.cs: Implementation of FindBreakpoint.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all method calls to `FindBreakpoint` match the new signature.

# Test: Search for the method usage. Expect: Only occurrences of the new signature.
rg --type cs -A 5 $'FindBreakpoint'

Length of output: 1555


31-31: LGTM! But verify the method usage in the codebase.

The code changes are approved.

However, ensure that the method StopInAnyException is correctly implemented and used.

Verification successful

Verification successful!

The method StopInAnyException is correctly implemented and used in the codebase.

  • Defined in src/ScriptEngine/Machine/IDebugController.cs.
  • Used in src/ScriptEngine/Machine/MachineInstance.cs.
  • Implemented in src/OneScript.DebugServices/DefaultBreakpointManager.cs.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all method calls to `StopInAnyException` match the new signature.

# Test: Search for the method usage. Expect: Only occurrences of the new signature.
rg --type cs -A 5 $'StopInAnyException'

Length of output: 1580


33-33: LGTM! But verify the method usage in the codebase.

The code changes are approved.

However, ensure that the method StopInUncaughtException is correctly implemented and used.

Verification successful

The method StopInUncaughtException is correctly implemented and used.

  • Declaration: src/ScriptEngine/Machine/IDebugController.cs
  • Usage: src/ScriptEngine/Machine/MachineInstance.cs
  • Implementation: src/OneScript.DebugServices/DefaultBreakpointManager.cs
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all method calls to `StopInUncaughtException` match the new signature.

# Test: Search for the method usage. Expect: Only occurrences of the new signature.
rg --type cs -A 5 $'StopInUncaughtException'

Length of output: 1327


27-27: LGTM! But verify the method usage in the codebase.

The code changes are approved.

However, ensure that the method SetExceptionBreakpoints is correctly implemented and used.

Verification successful

The method SetExceptionBreakpoints is correctly implemented and used.

  • The method is defined in IDebugController.cs.
  • It is implemented in DefaultBreakpointManager.cs.
  • It is used in DefaultDebugService.cs.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all method calls to `SetExceptionBreakpoints` match the new signature.

# Test: Search for the method usage. Expect: Only occurrences of the new signature.
rg --type cs -A 5 $'SetExceptionBreakpoints'

Length of output: 4270

src/ScriptEngine/Machine/MachineStoppedEventArgs.cs (4)

18-19: LGTM!

The constructor now initializes the ErrorMessage property to an empty string, providing a default value.


22-26: LGTM!

The constructor now includes an optional errorMessage parameter, improving flexibility.


33-33: LGTM!

The ErrorMessage property is new and enhances the class by conveying error information.


39-39: LGTM!

The enum MachineStopReason has been extended with a new member BreakpointConditionError, enhancing the granularity of stop reasons.

src/OneScript.DebugServices/TcpEventCallbackChannel.cs (1)

24-26: LGTM! But verify the method usage in the codebase.

The code changes are approved.

However, ensure that all method calls to ThreadStopped include the new parameter errorMessage.

Verification successful

All method calls to ThreadStopped include the new parameter errorMessage.

The code changes are correctly implemented, and all relevant method calls have been updated to include the new parameter.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all method calls to `ThreadStopped` include the new parameter `errorMessage`.

# Test: Search for the method usage. Expect: Only occurrences of the new signature.
rg --type cs -A 5 $'ThreadStopped'

Length of output: 5116

src/OneScript.DebugServices/DefaultBreakpointManager.cs (6)

20-24: LGTM! But verify the method usage in the codebase.

The code changes are approved.

However, ensure that the method SetExceptionBreakpoints is used appropriately in the codebase.


50-51: LGTM! But verify the method usage in the codebase.

The code changes are approved.

However, ensure that the method StopInAnyException is used appropriately in the codebase.

Verification successful

Method StopInAnyException is used appropriately in the codebase.

  • The method is declared in IDebugController.cs.
  • The method is used in MachineInstance.cs to control the stopping mechanism for exceptions.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the method `StopInAnyException`.

# Test: Search for the method usage. Expect: Appropriate usage of the method.
rg --type cs -A 5 $'StopInAnyException'

Length of output: 1580


53-54: LGTM! But verify the method usage in the codebase.

The code changes are approved.

However, ensure that the method StopInUncaughtException is used appropriately in the codebase.

Verification successful

The method StopInUncaughtException is used appropriately in the codebase.

  • The method is used in a conditional statement to determine if the execution should stop due to an uncaught exception.
  • The context provided confirms that the method is part of the exception handling logic and is used correctly.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the method `StopInUncaughtException`.

# Test: Search for the method usage. Expect: Appropriate usage of the method.
rg --type cs -A 5 $'StopInUncaughtException'

Length of output: 1327


Script:

#!/bin/bash
# Description: Gather more context around the usage of `_stopManager.Breakpoints` in MachineInstance.cs

# Test: Search for the usage of `_stopManager.Breakpoints` in MachineInstance.cs
rg --type cs -A 10 $'_stopManager.Breakpoints' src/ScriptEngine/Machine/MachineInstance.cs

Length of output: 582


37-39: LGTM! But verify the method usage in the codebase.

The code changes are approved.

However, ensure that the method FindBreakpoint is used appropriately in the codebase.

Verification successful

The method FindBreakpoint is used appropriately in the codebase.

  • The method is used in MachineStopManager within the HitBreakpointOnLine method to check if a breakpoint exists at a given module and line number.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the method `FindBreakpoint`.

# Test: Search for the method usage. Expect: Appropriate usage of the method.
rg --type cs -A 5 $'FindBreakpoint'

Length of output: 1555


Script:

#!/bin/bash
# Description: Gather more context around the usage of the method `FindBreakpoint` in `MachineStopManager`.

# Extract 10 lines before and after the usage of `FindBreakpoint` in `MachineStopManager`.
rg --type cs -A 10 -B 10 'FindBreakpoint' src/ScriptEngine/Machine/MachineStopManager.cs

Length of output: 695


26-34: LGTM! But verify the method usage in the codebase.

The code changes are approved.

However, ensure that the method SetBreakpoints is used appropriately in the codebase.


42-43: LGTM! But verify the method usage in the codebase.

The code changes are approved.

However, ensure that the method GetCondition is used appropriately in the codebase.

Verification successful

The method GetCondition is used appropriately in the codebase.

The code checks for a non-empty condition and evaluates it within a try-catch block, ensuring safe execution.

  • MachineStopManager.cs: Verified usage of GetCondition.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the method `GetCondition`.

# Test: Search for the method usage. Expect: Appropriate usage of the method.
rg --type cs -A 5 $'GetCondition'

Length of output: 1447


Script:

#!/bin/bash
# Description: Extract more context around the usage of the method `GetCondition` in `MachineStopManager.cs`.

# Test: Search for the method usage and include more lines of context.
rg --type cs -A 10 -B 10 $'GetCondition' src/ScriptEngine/Machine/MachineStopManager.cs

Length of output: 1130

src/OneScript.DebugProtocol/IDebuggerService.cs (1)

21-25: LGTM! But verify the method usage in the codebase.

The code changes are approved.

However, ensure that the method SetMachineExceptionBreakpoints is used appropriately in the codebase.

Verification successful

The method SetMachineExceptionBreakpoints is used appropriately in the codebase.

The method is correctly invoked and implemented in the following files:

  • src/VSCode.DebugAdapter/DebugeeProcess.cs
  • src/VSCode.DebugAdapter/OscriptProtocols/Tcp/TcpDebugServerClient.cs
  • src/OneScript.DebugServices/DefaultDebugService.cs
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the method `SetMachineExceptionBreakpoints`.

# Test: Search for the method usage. Expect: Appropriate usage of the method.
rg --type cs -A 5 $'SetMachineExceptionBreakpoints'

Length of output: 2256

src/OneScript.DebugServices/ThreadManager.cs (1)

73-74: LGTM! The addition of ErrorMessage enhances debugging information.

Including the ErrorMessage in the ThreadStoppedEventArgs provides additional context for debugging purposes.

src/OneScript.DebugServices/DefaultDebugController.cs (3)

58-58: LGTM! The addition of ErrorMessage enhances debugging information.

Including the ErrorMessage in the _callbackService.ThreadStopped invocation provides additional context for debugging purposes.


63-63: LGTM! The refactoring improves readability.

Using expression-bodied members for the Wait and DetachFromThread methods streamlines the code.

Also applies to: 80-80


84-91: LGTM! The switch expression modernizes the code.

Using a switch expression reduces verbosity and the new case for MachineStopReason.BreakpointConditionError ensures all relevant cases are handled.

src/ScriptEngine/Machine/MachineStopManager.cs (4)

45-45: LGTM! The addition of LastStopErrorMessage enhances error handling.

Adding LastStopErrorMessage provides feedback on errors encountered during debugging, improving the robustness of the debugging process.


73-97: LGTM! The expanded logic improves error handling.

The additional checks for breakpoint conditions and handling errors during their evaluation enhance the robustness of the debugging process.


120-120: LGTM! The renaming improves clarity.

Renaming HitBreakpointOnLine to FindBreakpoint makes the method's functionality clearer.


148-148: LGTM! The simplification enhances readability.

Simplifying the default assignment from default(StopPoint) to default maintains functionality and improves code readability.

src/VSCode.DebugAdapter/OscriptProtocols/Tcp/TcpDebugServerClient.cs (1)

136-139: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to SetMachineExceptionBreakpoints match the new signature.

Verification successful

Verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to SetMachineExceptionBreakpoints match the new signature.

#!/bin/bash
# Description: Verify the arguments passed to SetMachineExceptionBreakpoints in different files.

# Check the context around each occurrence to ensure the correct usage.
rg --type cs -A 5 'SetMachineExceptionBreakpoints' src/VSCode.DebugAdapter/DebugeeProcess.cs
rg --type cs -A 5 'SetMachineExceptionBreakpoints' src/VSCode.DebugAdapter/OscriptProtocols/Tcp/TcpDebugServerClient.cs
rg --type cs -A 5 'SetMachineExceptionBreakpoints' src/OneScript.DebugServices/DefaultDebugService.cs
rg --type cs -A 5 'SetMachineExceptionBreakpoints' src/OneScript.DebugProtocol/IDebuggerService.cs
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `SetMachineExceptionBreakpoints` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cs -A 5 $'SetMachineExceptionBreakpoints'

Length of output: 2256

src/OneScript.DebugServices/DefaultDebugService.cs (1)

54-61: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to SetMachineExceptionBreakpoints match the new signature.

Verification successful

Verified: All occurrences of SetMachineExceptionBreakpoints match the new signature.

  • DebugeeProcess.cs: The method is called with a string array filters.
  • TcpDebugServerClient.cs: The method is defined with a string array filters.
  • IDebuggerService.cs: The method is declared with a string array filters.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `SetMachineExceptionBreakpoints` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cs -A 5 $'SetMachineExceptionBreakpoints'

Length of output: 2256


Script:

#!/bin/bash
# Description: Gather more context around the occurrences of SetMachineExceptionBreakpoints

# Check the context around the call in DebugeeProcess.cs
rg --type cs -A 10 -B 10 'SetMachineExceptionBreakpoints' src/VSCode.DebugAdapter/DebugeeProcess.cs

# Check the context around the definition in TcpDebugServerClient.cs
rg --type cs -A 10 -B 10 'SetMachineExceptionBreakpoints' src/VSCode.DebugAdapter/OscriptProtocols/Tcp/TcpDebugServerClient.cs

# Check the context around the declaration in IDebuggerService.cs
rg --type cs -A 10 -B 10 'SetMachineExceptionBreakpoints' src/OneScript.DebugProtocol/IDebuggerService.cs

Length of output: 2229

src/VSCode.DebugAdapter/DebugeeProcess.cs (1)

204-207: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to SetExceptionsBreakpoints match the new signature.

Verification successful

Verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to SetExceptionsBreakpoints match the new signature. The current search shows one call in OscriptDebugSession.cs that matches the new signature.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `SetExceptionsBreakpoints` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type cs -A 5 $'SetExceptionsBreakpoints'

Length of output: 1062

src/VSCode.DebugAdapter/DebugSession.cs (3)

121-125: Verify the appropriateness of the default value for line.

The constructor now defaults line to zero. Ensure this default value is appropriate for all use cases where the line number is not explicitly provided.


271-272: LGTM!

Using Array.Empty<Breakpoint>() instead of creating a new array optimizes memory usage.


277-287: LGTM!

The new SetExceptionBreakpointsResponseBody class mirrors the structure of SetBreakpointsResponseBody and is consistent with the existing codebase.

src/VSCode.DebugAdapter/OscriptDebugSession.cs (4)

43-60: LGTM!

The changes to support conditional breakpoints and exception breakpoint filters enhance debugging capabilities.


165-182: LGTM!

The new SetExceptionBreakpoints method correctly processes incoming requests to set exception breakpoints.


212-217: LGTM!

The addition of the Condition property to the Breakpoint object enhances flexibility in setting breakpoints.


250-258: LGTM!

The additional errorMessage parameter in the ThreadStopped method allows for more context when a thread is stopped.

src/ScriptEngine/Machine/MachineInstance.cs (4)

76-77: LGTM!

Changing CreateFrameScopes to a static expression-bodied method simplifies its definition while retaining functionality.


Line range hint 243-262: LGTM!

The modification to accept an ExecutionFrame object instead of an integer frameId enhances type safety and clarity.


292-301: LGTM!

The restructuring of EvaluateInFrame into an overload improves code readability and separates concerns effectively.


1305-1313: LGTM!

The new EmitStopByException method encapsulates the logic for emitting a stop event when an exception occurs, enhancing debugging capabilities.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0980ac0 and 867cdb2.

Files selected for processing (1)
  • src/VSCode.DebugAdapter/package.json (7 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/VSCode.DebugAdapter/package.json

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 867cdb2 and 33f9967.

Files selected for processing (3)
  • src/OneScript.DebugServices/DefaultBreakpointManager.cs (2 hunks)
  • src/ScriptEngine/Machine/IDebugController.cs (1 hunks)
  • src/ScriptEngine/Machine/MachineInstance.cs (6 hunks)
Additional comments not posted (18)
src/ScriptEngine/Machine/IDebugController.cs (6)

27-27: LGTM!

The method SetExceptionBreakpoints is correctly defined to accept an array of string filters.


29-29: LGTM!

The method SetBreakpoints is correctly defined to accept a module and an array of tuples containing line numbers and conditions.


31-31: LGTM!

The method StopOnAnyException is correctly defined to return a boolean indicating whether to stop on any exception.


33-33: LGTM!

The method StopOnUncaughtException is correctly defined to return a boolean indicating whether to stop on uncaught exceptions.


35-35: LGTM!

The method FindBreakpoint is correctly defined and the new name improves clarity regarding its purpose.


37-37: LGTM!

The method GetCondition is correctly defined to return a string containing the condition associated with a specific breakpoint.

src/OneScript.DebugServices/DefaultBreakpointManager.cs (6)

21-27: LGTM!

The method SetExceptionBreakpoints correctly handles exception breakpoints by clearing and setting filters.


29-37: LGTM!

The method SetBreakpoints correctly handles breakpoints by associating conditions with specific lines.


40-42: LGTM!

The method FindBreakpoint correctly checks for the existence of a breakpoint and the new name improves clarity.


45-46: LGTM!

The method GetCondition correctly retrieves the condition associated with a specific breakpoint.


53-54: LGTM!

The method StopOnAnyException correctly checks if the manager should stop execution on all exceptions.


56-57: LGTM!

The method StopOnUncaughtException correctly checks if the manager should stop execution on uncaught exceptions.

src/ScriptEngine/Machine/MachineInstance.cs (6)

76-77: LGTM!

The method CreateFrameScopes has been correctly simplified to a static expression-bodied method.


Line range hint 243-262: LGTM!

The method EvaluateInFrame has been correctly modified to accept an ExecutionFrame object, enhancing type safety and clarity.


292-301: LGTM!

The original implementation of EvaluateInFrame has been correctly moved to a new overload, improving code readability and separating concerns.


411-417: LGTM!

The logic for handling exceptions during code execution has been correctly expanded with the introduction of the shouldRethrow variable, enhancing control flow.


1305-1313: LGTM!

The method EmitStopOnException correctly encapsulates the logic for emitting a stop event when an exception occurs, enhancing debugging capabilities.


1314-1321: LGTM!

The method EmitStopEventIfNecessary has been correctly updated to include a call to EmitStopOnException, aligning with the overall enhancements to exception handling and debugging.

{
filter = "uncaught",
label = "Uncaught exceptions",
description = "Stops when any uncaught exception occurs"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Давай на русском напишем? Все-таки наша аудитория русскоязычная на 99.99999%

Copy link
Contributor Author

@akpaevj akpaevj Aug 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сделал

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 33f9967 and 2b8a2ce.

Files selected for processing (1)
  • src/VSCode.DebugAdapter/OscriptDebugSession.cs (5 hunks)
Additional comments not posted (5)
src/VSCode.DebugAdapter/OscriptDebugSession.cs (5)

43-43: Support for Conditional Breakpoints Added.

The property supportsConditionalBreakpoints is now set to true, enabling conditional breakpoints.


46-60: Exception Breakpoint Filters Added.

Two new exception breakpoint filters have been added: "uncaught" and "all". This enhances the debugging capabilities by allowing users to stop on specific types of exceptions.


165-182: New Method: SetExceptionBreakpoints.

This method processes incoming requests to set exception breakpoints based on provided filters. It logs the command, constructs a list of accepted filters, and invokes _process.SetExceptionsBreakpoints.


212-217: Conditional Breakpoints Support Added.

The Breakpoint object now includes a Condition property, allowing breakpoints to be set with specific conditions.


250-258: Enhanced Error Reporting in ThreadStopped.

The ThreadStopped function now includes an errorMessage parameter. If an error message is present, it is sent to the output stream, providing more context when a thread is stopped.

@akpaevj akpaevj requested a review from EvilBeaver August 4, 2024 22:42
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
src/ScriptEngine/Machine/MachineInstance.cs (1)

1316-1316: Ensure consistent formatting.

The blank line added for separation is fine, but ensure consistent formatting throughout the file.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2b8a2ce and 60ebc10.

Files selected for processing (9)
  • src/OneScript.DebugProtocol/IDebuggerService.cs (1 hunks)
  • src/OneScript.DebugServices/DefaultBreakpointManager.cs (2 hunks)
  • src/OneScript.DebugServices/DefaultDebugService.cs (1 hunks)
  • src/ScriptEngine/Machine/IDebugController.cs (1 hunks)
  • src/ScriptEngine/Machine/MachineInstance.cs (2 hunks)
  • src/VSCode.DebugAdapter/DebugSession.cs (3 hunks)
  • src/VSCode.DebugAdapter/DebugeeProcess.cs (1 hunks)
  • src/VSCode.DebugAdapter/OscriptDebugSession.cs (8 hunks)
  • src/VSCode.DebugAdapter/OscriptProtocols/Tcp/TcpDebugServerClient.cs (1 hunks)
Files skipped from review as they are similar to previous changes (5)
  • src/OneScript.DebugProtocol/IDebuggerService.cs
  • src/OneScript.DebugServices/DefaultBreakpointManager.cs
  • src/OneScript.DebugServices/DefaultDebugService.cs
  • src/VSCode.DebugAdapter/DebugeeProcess.cs
  • src/VSCode.DebugAdapter/OscriptProtocols/Tcp/TcpDebugServerClient.cs
Additional comments not posted (17)
src/ScriptEngine/Machine/IDebugController.cs (6)

27-28: Addition of SetExceptionBreakpoints method approved.

The method signature is clear and aligns with the interface's purpose.


28-30: Modification of SetBreakpoints method approved.

The updated method signature enhances functionality by allowing conditional breakpoints.


31-32: Addition of StopOnAnyException method approved.

The method signature is clear and aligns with the interface's purpose.


33-35: Addition of StopOnUncaughtException method approved.

The method signature is clear and aligns with the interface's purpose.


35-36: Renaming of Find to FindBreakpoint approved.

The new name clarifies the method's purpose.


36-37: Addition of GetCondition method approved.

The method signature is clear and aligns with the interface's purpose.

src/VSCode.DebugAdapter/DebugSession.cs (3)

121-126: Addition of Breakpoint constructor approved.

The new constructor simplifies the instantiation of a Breakpoint when the line number is not specified.


272-273: Optimization of SetBreakpointsResponseBody approved.

The use of Array.Empty<Breakpoint>() enhances memory efficiency.


278-289: Addition of SetExceptionBreakpointsResponseBody class approved.

The class mirrors the structure of SetBreakpointsResponseBody and includes a constructor that initializes its breakpoints property.

src/VSCode.DebugAdapter/OscriptDebugSession.cs (5)

48-67: Enhancement of Initialize method approved.

The changes enhance debugging capabilities by enabling support for conditional breakpoints and exception filter options.


172-195: Addition of SetExceptionBreakpoints method approved.

The method processes incoming requests to set exception breakpoints based on filters provided in the arguments.


196-196: Enhancement of SetBreakpoints method approved.

The changes enhance the flexibility of breakpoint management by allowing breakpoints to be set with specific conditions.


192-192: Modification of ThreadStopped method approved.

The changes allow the method to send error messages to the output stream if they are present, providing more context when a thread is stopped.


487-491: Addition of GetFromContainer method approved.

The method retrieves a value from a dynamic container, returning a default value if the property is not found.

src/ScriptEngine/Machine/MachineInstance.cs (3)

412-413: Variable shouldRethrow improves readability.

The introduction of the shouldRethrow variable enhances the readability and maintainability of the exception handling logic.


414-418: Expanded logic for emitting stop events is comprehensive.

The expanded logic for emitting stop events now includes checks for both breakpoints and uncaught exceptions, providing a more comprehensive response to exceptions during execution.


1307-1315: New method EmitStopOnException encapsulates stop event logic.

The new method EmitStopOnException encapsulates the logic for handling stop events when exceptions occur, improving the modularity and readability of the code.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 60ebc10 and ba75813.

Files selected for processing (1)
  • src/OneScript.DebugServices/DefaultBreakpointManager.cs (2 hunks)
Additional comments not posted (6)
src/OneScript.DebugServices/DefaultBreakpointManager.cs (6)

18-21: LGTM! Private fields are initialized properly.

The _exceptionBreakpointsFilters and _breakpoints fields are initialized correctly.


22-26: LGTM! The SetExceptionBreakpoints method is implemented correctly.

The method clears existing filters and populates _exceptionBreakpointsFilters with the provided filters.


Line range hint 27-36:
LGTM! The SetBreakpoints method is implemented correctly.

The method updates _breakpoints with the provided breakpoints, linking conditions to specific lines.


39-44: LGTM! The FindBreakpoint and GetCondition methods are implemented correctly.

The methods find a breakpoint and retrieve its condition using LINQ.


47-49: LGTM! The Clear method is implemented correctly.

The method clears _breakpoints and _exceptionBreakpointsFilters.


51-67: LGTM! The StopOnAnyException, StopOnUncaughtException, and NeedStopOnException methods are implemented correctly.

The methods handle stopping on exceptions based on filters.

@EvilBeaver EvilBeaver merged commit ad7fe24 into EvilBeaver:develop Aug 5, 2024
1 of 2 checks passed
@Mr-Rm
Copy link
Collaborator

Mr-Rm commented Aug 5, 2024

Может теряться сообщение об ошибке в условии точки останова:

  • ставим точку с условием 1/0 < 2
  • запускаем отладку
  • получаем сообщение
    Не удалось выполнить условие точки останова: {Модуль <имя модуля недоступно> / Ошибка в строке: 0 / Деление на ноль}
    <исходный код недоступен>

@akpaevj
Copy link
Contributor Author

akpaevj commented Aug 5, 2024

Может теряться сообщение об ошибке в условии точки останова:

  • ставим точку с условием 1/0 < 2
  • запускаем отладку
  • получаем сообщение
    Не удалось выполнить условие точки останова: {Модуль <имя модуля недоступно> / Ошибка в строке: 0 / Деление на ноль}
    <исходный код недоступен>

А что ты ожидаешь там увидеть?

@akpaevj akpaevj deleted the feature/exception-breakpoints branch August 5, 2024 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants