Skip to content

Add cross-platform GDB debugger with C++ support#220

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/add-gdb-debugger
Draft

Add cross-platform GDB debugger with C++ support#220
Copilot wants to merge 5 commits intomainfrom
copilot/add-gdb-debugger

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 28, 2026

The OneWare.Debugger module had partial GDB MI code but was never wired up — the view shipped as a "Coming Soon!" placeholder and BreakpointStore had its debugger hooks commented out. This PR completes it into a working, cross-platform GDB debugger usable against C++ projects.

OneWare.Debugger

  • GdbSession becomes a concrete (non-abstract) class; RunCommand / RunCommandAsync are now public and a thread-safe IsRunning is exposed.
  • New IDebuggerService / DebuggerService (DI singleton) owns at most one active session, applies the shared breakpoints, forwards GDB output to IOutputService, and exposes StartAsync / Stop / Continue / Pause / Step / Next / Finish. Breakpoints toggled while a session is live are applied/removed automatically. Async MI mode is used everywhere except Windows (which falls back to the existing SIGINT helper for pause).
  • DebuggerModule registers the service, eagerly resolves it at startup so it observes the breakpoint store, and registers a Tools/Debugger/GDB Path FilePathSetting with OS-specific defaults (gdb.exe on Windows, gdb elsewhere) and PATH-based auto-detection at start time.
  • DebuggerViewModel / DebuggerView replace the placeholder with a functional toolbar (Start/Stop/Continue/Pause/Step/Next/Finish) and an executable picker, bound to IsDebugging / IsRunning for CanExecute.

OneWare.Essentials

  • BreakpointStore exposes a single shared Instance, and ExtendedTextEditor.SetEnableBreakpoints binds every editor margin to it. The previous per-margin store made cross-file debugging impossible — only breakpoints in the editor that started the session were observable. C++ already has CanAddBreakPoints => true, so C++ breakpoints now flow into the live GDB session without further wiring.
// Start a GDB session for any ELF / EXE; breakpoints from every open editor are applied.
var debugger = serviceProvider.Resolve<IDebuggerService>();
await debugger.StartAsync("/path/to/main");
debugger.Continue();

Tests

  • New tests/OneWare.Debugger.UnitTests/ with 6 tests for GDB MI output parsing: GdbCommandResult (^done with nested results, ^error,msg=..., ^running, ^connected) and GdbEvent (*stopped at a breakpoint with frame / fullname / line, *running).

Notes / follow-ups

  • _exec-run is used to launch the inferior with a fallback to _exec-continue; remote-target / attach flows are not yet exposed.
  • Settings UI lets users override the GDB path; Windows users debugging C++ should point this at their toolchain's gdb.exe (e.g. MSYS2 / MinGW) since one isn't auto-installed.
  • macOS ships lldb rather than gdb by default — users will need to install gdb (brew install gdb, code-sign) or we follow up with an lldb-mi backend behind the same IDebuggerService.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.myget.org
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.25.1/x64/codeql/csharp/tools/linux64/Semmle.Autobuild.CSharp /opt/hostedtoolcache/CodeQL/2.25.1/x64/codeql/csharp/tools/linux64/Semmle.Autobuild.CSharp (dns block)
    • Triggering command: /usr/share/dotnet/dotnet dotnet restore --no-dependencies /home/REDACTED/work/OneWare/OneWare/src/VtNetCore.Avalonia/VtNetCore.Avalonia.sln --packages /tmp/codeql-scratch-4731918ca57aa503/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-4731918ca57aa503/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-4731918ca57aa503/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
    • Triggering command: /usr/share/dotnet/dotnet dotnet restore --no-dependencies /home/REDACTED/work/OneWare/OneWare/src/VtNetCore.Avalonia/VtNetCore.Avalonia.App/VtNetCore.Avalonia.App.csproj --packages /tmp/codeql-scratch-4731918ca57aa503/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-4731918ca57aa503/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-4731918ca57aa503/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI linked an issue Apr 28, 2026 that may be closed by this pull request
Agent-Logs-Url: https://github.com/one-ware/OneWare/sessions/611f23d4-255c-4a97-9754-3675681a455e

Co-authored-by: hendrikmennen <25281882+hendrikmennen@users.noreply.github.com>
Copilot AI changed the title [WIP] Add GDB debugger for C++ support Add cross-platform GDB debugger with C++ support Apr 28, 2026
Copilot AI requested a review from hendrikmennen April 28, 2026 10:50
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.

Add GDB Debugger

2 participants