Skip to content
New issue

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

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

Already on GitHub? # to your account

Add brew debugger command #18050

Merged
merged 2 commits into from
Aug 15, 2024
Merged

Add brew debugger command #18050

merged 2 commits into from
Aug 15, 2024

Conversation

Rylan12
Copy link
Member

@Rylan12 Rylan12 commented Aug 14, 2024

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

This PR creates a new dev command called brew debugger which spawns a debugger for Homebrew commands. To use the debugger, add a method call to binding.break anywhere in the code. Then, run brew debugger <cmd> (this supports passing flags to the command by doing brew debugger -- <cmd> --flags). This will automatically spawn a debugger session at the breakpoint using rdbg and the debugger gem.

I've also added a VS Code launch configuration to attach to an existing debug session. If you're using VS Code, you can run brew debugger --open <cmd>. Then, use the Run and Debug tab of VS Code to attach to the debugger to use the VS Code debugging frontend. I'm happy to provide a video showing this if my description is confusing.

Ultimately, my goal is to allow you to add breakpoints in VS Code and just run directly from there avoiding the need to create a session using brew debugger, but that's going to take some more work. I'm not sure the rdbg VS Code extension will support that super cleanly at the moment, so I might need to add some more hack-y workarounds to do that. If anyone has any insight, feel free to let me know.

CC @issyl0 and @krehel because we talked about this today on the maintainer zoom

@Rylan12

This comment has been minimized.

@Rylan12 Rylan12 marked this pull request as ready for review August 15, 2024 03:00
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Looking good, thanks @Rylan12! A few comments but can always merge as-is and iterate.

@Rylan12 Rylan12 enabled auto-merge August 15, 2024 14:15
@Rylan12 Rylan12 merged commit dd8334b into master Aug 15, 2024
24 checks passed
@Rylan12 Rylan12 deleted the rdbg branch August 15, 2024 14:28
@Rylan12 Rylan12 mentioned this pull request Aug 15, 2024
7 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants