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

dap_adapters: add gdb #70

Merged
merged 2 commits into from
Nov 28, 2024
Merged

dap_adapters: add gdb #70

merged 2 commits into from
Nov 28, 2024

Conversation

jansol
Copy link

@jansol jansol commented Nov 26, 2024

Nothing special here, just launching gdb with -i=dap. Nicer to have it as a builtin type instead of a custom DAP though.

@RemcoSmitsDev
Copy link
Owner

Hey, yeah totally agree, thanks for adding this!
Do you have a task example that we can share inside a specific Zed channel for GDB?

@Anthony-Eid
Copy link
Collaborator

Thank you for implementing this!

@Anthony-Eid
Copy link
Collaborator

Anthony-Eid commented Nov 26, 2024

Hey, yeah totally agree, thanks for adding this! Do you have a task example that we can share inside a specific Zed channel for GDB?

I think it would be similar to lldb

{
  "label": "LLDB Debug Zed",
  "program": "$ZED_WORKTREE_ROOT/target/debug/zed",
  "adapter": "gdb",
  "request": "launch"
  "initialize_args": {
      "stopAtBeginningOfMainSubprogram": true
   }
}

@RemcoSmitsDev
Copy link
Owner

RemcoSmitsDev commented Nov 26, 2024

Would it be similar to LLDB? I would like to add a default config for debugging Zed with GDB inside the /.zed/debug.json and inside the initial-debug-tasks.json.

  {
    "label": "Debug Zed with LLDB",
    "adapter": "lldb",
    "program": "$ZED_WORKTREE_ROOT/target/debug/zed",
    "request": "launch",
    "cwd": "$ZED_WORKTREE_ROOT"
  }

GDB debug task example??

  {
    "label": "Debug Zed with GDB",
    "adapter": "gdb",
    "program": "$ZED_WORKTREE_ROOT/target/debug/zed",
    "request": "launch",
    "cwd": "$ZED_WORKTREE_ROOT"
  }

@jansol
Copy link
Author

jansol commented Nov 26, 2024

I have this left over in the project where I tested last time:

  {
    "label": "Launch in GDB",
    "adapter": "gdb",
    "session_type": "launch",
    "program": "$ZED_WORKTREE_ROOT/build/main-binary",
    "initialize_args": {
      "args": [],
      "cwd": "$ZED_WORKTREE_ROOT",
      "env": {},
      "stopAtBeginningOfMainSubprogram": true
    }
  }

But it seems the format has changed since then?

Also the stopAtBeginningOfMainSubprogram should really not be needed. It's just the only way I've gotten the debugger to actually open instead of exiting immediately.

Copy link
Owner

@RemcoSmitsDev RemcoSmitsDev left a comment

Choose a reason for hiding this comment

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

Could you also add this to the .zed/debug.json? I wanted to push this change, but I cannot to your fork.

  {
    "label": "Debug Zed with GDB",
    "adapter": "gdb",
    "program": "$ZED_WORKTREE_ROOT/target/debug/zed",
    "request": "launch",
    "cwd": "$ZED_WORKTREE_ROOT",
    "initialize_args": {
      "stopAtBeginningOfMainSubprogram": true
    }
  }

crates/dap_adapters/src/gdb.rs Outdated Show resolved Hide resolved
@RemcoSmitsDev
Copy link
Owner

I also saw that GDB support attach, we might want to implement that as well. Happy to help to make that work, but cannot get GDB to work on my MacBook.

@jansol
Copy link
Author

jansol commented Nov 28, 2024

Attaching to a process with GDB is indeed possible, but requires special permissions (SYS_PTRACE capability or root) so that should probably wait until we have some form of polkit integration for escalating privileges.

@RemcoSmitsDev
Copy link
Owner

Alright, thanks for the clarification and your contribution!

@Anthony-Eid
Copy link
Collaborator

We should add a cfg flag to disable gfb on m series macs because there’s no arm port available.

That way people can’t select it when it’s bot possible to use

@RemcoSmitsDev RemcoSmitsDev merged commit 4068960 into RemcoSmitsDev:debugger Nov 28, 2024
@jansol jansol deleted the gdb branch November 28, 2024 20:43
@jansol
Copy link
Author

jansol commented Nov 28, 2024

GDB is apparently perfectly fine on aarch64, just not on macOS.

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