From a4d66897aedc302ac415350def070c2b925a3e64 Mon Sep 17 00:00:00 2001 From: Daco Harkes Date: Thu, 5 Feb 2026 10:28:32 -0800 Subject: [PATCH] [gsoc] Interop Dart DevTools project Change-Id: I44152702d1bf2e4815f5f32b2c57c3803f61e4b1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478660 Commit-Queue: Daco Harkes Reviewed-by: Elliott Brooks --- docs/gsoc/Dart-GSoC-2026-Project-Ideas.md | 60 +++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/docs/gsoc/Dart-GSoC-2026-Project-Ideas.md b/docs/gsoc/Dart-GSoC-2026-Project-Ideas.md index 4d75721a57a..c6debe2db3e 100644 --- a/docs/gsoc/Dart-GSoC-2026-Project-Ideas.md +++ b/docs/gsoc/Dart-GSoC-2026-Project-Ideas.md @@ -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` (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(); + 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`), 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: