dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.31k stars 1.59k forks source link

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

Open dcharkes opened 6 months ago

dcharkes commented 6 months ago

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:

Goal user experience

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

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 commented 5 months ago

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.