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

☂️ [vm/ffi] Multi language debugging #55832

Open
dcharkes opened this issue May 24, 2024 · 1 comment
Open

☂️ [vm/ffi] Multi language debugging #55832

dcharkes opened this issue May 24, 2024 · 1 comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-ffi type-enhancement A request for a change that isn't a bug

Comments

@dcharkes
Copy link
Contributor

dcharkes commented May 24, 2024

Now that Dart has interoperability with C through dart:ffi, C++/Rust/Go (when using extern C), Objective-C through FFIgen, Java/Kotlin through JNIgen, we should see if we can improve the debugging experience.

Current situation

Basically, there are currently two approaches that are combined in a debugging session:

  1. Run the Dart debugger, and have no access to C/C++/Rust/Java/Kotlin/Objective-C/Swift.
  2. Run the native debugger (in xcode, Android studio, vscode with c++ plugin) and have no access to Dart variables and Dart breakpoints.

A typical debug session looks like the following:

  • Run the debugger for the language you see the behavior in that you didn't expect (e.g. a crash, exception, or something) and inspect where values come from.
  • As soon as you hit a FFI boundary, restart your debug session in the debugger for the other language to see where the value in the other language comes from.
  • Repeat.
  • And of course this process can be somewhat streamlined by adding prints in both languages.

Goal user experience

The north star goal would be to have a debugging experience in which:

  • Breakpoints can be set in all languages
  • One can step through all languages (across FFI boundaries)
  • The values of variables can be read in all languages
  • Watchpoints can be set on variables in all languages

Details

We need to investigate what technical approach to take here. Does something such as a multi-language debug info or debugging protocol already exist? (We have considered in the past to make Dart output the dwarf debuginfo so that C/C++ debuggers can understand dwarf. But typical C/C++ debuggers don't deal well with a JIT compiled language, so it would only help for AOT. And going that direction would only help for C/C++/Obj-C/Rust/Go + Dart debugging, not for JVM based languages.)

Filing this as an umbrella issue. Happy for people to post feature requests or suggestions on how to tackle this problem. We will likely split this issue out in smaller tasks later.

Some related issues:

@dcharkes dcharkes added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-ffi labels May 24, 2024
@a-siva a-siva added the type-enhancement A request for a change that isn't a bug label May 29, 2024
@dcharkes
Copy link
Contributor Author

dcharkes commented Jul 1, 2024

Possible approach: Using 2 debuggers at the same time

@helin24 suggested we could possibly start two debuggers on the same process.

As a first step, this should be possible with vscode for example by starting the debugger for one language (for example c/c++) and attaching in the other (Dart).

A second step could be wrapping such logic in a plugin so that you send requests about what variable are in frame to both debugging sessions and then combining the info before sending it back to IDE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-ffi type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants