[gsoc] Interop Dart DevTools project
Change-Id: I44152702d1bf2e4815f5f32b2c57c3803f61e4b1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478660 Commit-Queue: Daco Harkes <dacoharkes@google.com> Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
This commit is contained in:
committed by
Commit Queue
parent
393a35b60b
commit
a4d66897ae
@@ -15,6 +15,7 @@ For GSoC related discussions please use the [dart-gsoc group](https://groups.goo
|
||||
* Daco Harkes ([dcharkes](https://github.com/dcharkes)) `dacoharkes@google.com`
|
||||
* Liam Appelbe ([liamappelbe](https://github.com/liamappelbe)) `liama@google.com`
|
||||
* Brian Quinlan ([bquinlan](https://github.com/brianquinlan)) `bquinlan@google.com`
|
||||
* Ben Konyi ([bkonyi](https://github.com/bkonyi)) `bkonyi@google.com`
|
||||
* More to come!
|
||||
|
||||
## Project Application Process
|
||||
@@ -33,6 +34,65 @@ Applications can be submitted through the [summerofcode.withgoogle.com](https://
|
||||
|
||||
**IMPORTANT**: Remember to submit _final proposals_ before [the March 31st deadline](https://developers.google.com/open-source/gsoc/timeline).
|
||||
|
||||
## **Idea:** Inspect native memory in Dart DevTools
|
||||
|
||||
- **Possible Mentor(s)**: `dacoharkes@google.com`, `bkonyi@google.com`
|
||||
- **Difficulty**: Hard
|
||||
- **Project size**: Large (350 hours)
|
||||
- **Skills**: Dart, C++
|
||||
|
||||
**Description**:
|
||||
When using the Dart debugger on `Pointer<X>` (where `X` extends `Struct` or `Union` or is a native type), the pointer itself is opaque. It would be extremely useful if the debugger could inspect the memory that the `Pointer` points to, effectively making `.ref` available as an inspectable getter.
|
||||
|
||||
For example, when debugging the following code:
|
||||
```dart
|
||||
import 'dart:ffi';
|
||||
import 'package:ffi/ffi.dart';
|
||||
|
||||
final class MyStruct extends Struct {
|
||||
@Int32()
|
||||
external int a;
|
||||
@Double()
|
||||
external double b;
|
||||
}
|
||||
|
||||
void main() {
|
||||
final ptr = malloc<MyStruct>();
|
||||
ptr.ref.a = 42;
|
||||
ptr.ref.b = 3.14;
|
||||
// Inspecting 'ptr' in the debugger should allow seeing 'a' and 'b'
|
||||
// (either via the binary layout or a higher-level abstraction).
|
||||
malloc.free(ptr);
|
||||
}
|
||||
```
|
||||
Currently, `ptr` only shows its memory address in the debugger.
|
||||
|
||||
However, dereferencing invalid pointers leads to segmentation faults. While `nullptr` (address 0) is easy to check, user-created pointers might point to invalid memory, and dereferencing them during a debug session should not crash the application.
|
||||
|
||||
This project involves:
|
||||
1. **Exploring UI integration**: We'd want to explore different ways of exposing native memory in the developer tools:
|
||||
* Updating Dart DevTools and the [Debug Adapter Protocol (DAP)](https://microsoft.github.io/debug-adapter-protocol/) to handle a new `Instance` type for `Pointer` so they are displayed properly across IDEs without an extension.
|
||||
* Extending the **Object Inspector** (found under the **VM Tools** tab in DevTools).
|
||||
2. **VM Service Protocol**: Extend the protocol to provide access to `Struct`/`Union` layout and annotations if not already available.
|
||||
3. **VM Runtime**: Implement a mechanism in the Dart VM to safely dereference pointers during debugging. This likely means intercepting segmentation faults (signals) during these specific read operations and converting them into a virtual exception or error message that the debugger can display, rather than crashing the process.
|
||||
|
||||
**Good Sample Project**:
|
||||
Create a standalone Flutter app that demonstrates a custom view for a `Pointer`.
|
||||
* The view should take a `Pointer` object (or a mock of one), compute the size of the data structure (the `X` in `Pointer<X>`), and display the memory contents. For the sample, you can assume valid pointers or mock the data retrieval to avoid crashes. **Bonus**: Implement this custom view directly in the [DevTools codebase](https://github.com/flutter/devtools) (e.g. in the Object Inspector) rather than as a standalone app.
|
||||
* **Standout**: Add a new method or property to the VM Service Protocol (requires building the Dart SDK) and use this new protocol feature in your sample application.
|
||||
|
||||
**Expected outcome**:
|
||||
A working feature in Dart DevTools (and underlying VM support) that allows
|
||||
developers to inspect the contents of `Pointer`s safely during debugging.
|
||||
|
||||
**Further reading**:
|
||||
|
||||
* [Dart VM Service Protocol](https://github.com/dart-lang/sdk/blob/main/runtime/vm/service/service.md)
|
||||
* [Dart Debug Adapter Protocol](https://github.com/dart-lang/sdk/blob/main/third_party/pkg/dap/tool/README.md)
|
||||
* [Dart DevTools source code](https://github.com/flutter/devtools)
|
||||
* https://github.com/dart-lang/sdk/issues/48882
|
||||
* https://github.com/dart-lang/native/issues/1034
|
||||
|
||||
## TODO: More ideas as they come!
|
||||
|
||||
# Template:
|
||||
|
||||
Reference in New Issue
Block a user