Question about VM vs DevTools responsibility for Pointer inspection

68 views
Skip to first unread message

Ibn Ahmad

unread,
Mar 1, 2026, 6:45:39 AM (9 days ago) Mar 1
to dart-gsoc
Hi mentors, I’m exploring the “Inspect Native Memory in Dart DevTools” project and looking into how pointer inspection might flow through the stack.
When exposing dereferenced pointer data to DevTools, would we prefer the VM Service Protocol return already-structured field data (offset + typed value) or should it return raw memory bytes and just let DevTools handle the layout interpretation?
I’m trying to understand where you see the cleanest separation of responsibilities between VM and tooling..

Also, are there any existing issues or discussions youd recommend looking at that relate to this part of the stack so I can start exploring the relevant code paths?

Daco Harkes

unread,
Mar 2, 2026, 2:37:22 AM (8 days ago) Mar 2
to Ibn Ahmad, dart-gsoc
Hi Ibn,

We don't have a preference for how the problem is solved. Please explore and prototype and argue for tpros and cons of the possible approaches.

For wokring on issues in the codebase, you can look at https://github.com/dart-lang/sdk/issues?q=is%3Aissue%20state%3Aopen%20label%3Alibrary-ffi, especially the ones marked with contributions welcome. For VM service bugs to work on cc @Ben Konyi 

Kind regards,

 •  Daco Harkes
 •  Software Engineer
 •  dacoh...@google.com 


--
You received this message because you are subscribed to the Google Groups "dart-gsoc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dart-gsoc+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/dart-gsoc/950521b4-7c56-43fb-b523-b53fab9efe13n%40googlegroups.com.

Ibn Ahmad

unread,
Mar 5, 2026, 2:13:23 PM (5 days ago) Mar 5
to dart-gsoc
Hi Daco, hope you're doing well.
Thanks for the direction. After digging into the DevTools Object Inspector flow and the VM service inspection path, this is what I came up with and what I’m leaning toward and planning to prototype. It’s basically a hybrid design with a clean separation. Please let me know if I am thinking in the right direction and if there are any corrections that could be made with my approach

My proposed approach:

  1. VM Service Protocol: add a small RPC that safely reads memory bytes

  • Example shape: readMemory(address, length) -> { bytes } or { error }

  • This would give us a useful baseline even when we dont know the static Pointer type.

  1. VM Service Protocol: add a separate RPC for FFI layout metadata for Struct/Union classes

  • Example shape: getFfiLayout(classId) -> fields with { name, offset, size, nativeType }, plus alignment/size

  • This reuses the VM’s existing FFI layout computation so tooling does not need to reimplement the rules.

  1. DevTools: add a Pointer renderer in the Object Inspector

  • Always show address + a hex view (based on readMemory)

  • If a concrete struct type is known (either selected by the user in DevTools, or provided later via DAP), show a “Fields” panel that decodes values using { bytes + layout }.

  • If readMemory fails, show a non-fatal error like “Could not read memory at 0x…”.

Safety plan (VM runtime):

  • Implement a guarded read path that attempts the memory copy and converts access violations into an error result.

  • On Linux/macOS: temporary SIGSEGV/SIGBUS handler around the read (scoped), returning an error instead of crashing.

  • On Windows: catch access violations via SEH for the read path.

  • Add guardrails like max read siz and keep the handler strictly scoped to the debug read.

Pros/cons:

  • Bytes-only from VM: simplest VM/protocol, great fallback but DevTools needs layout to show fields.

  • Structured fields from VM: best UX but pushes decoding and type handling into the VM and protocol and I think it might be harder to evolve as well.

  • bytes + layout metadata method: keeps VM responsible for safe read + authoritative layout, keeps decoding/UI in DevTools and still supports a great “raw hex” fallback.

Next steps I’m planning on taking:

  • First I’ll prototype the DevTools Pointer view using mocked payloads (hex + fields) to validate the UI.

  • Then I’ll wire it to a real VM service call for bytes, followed by layout metadata.

  • In parallel I’ll scan the library-ffi issues marked “contributions welcome” and try to pick a small starter issue to land a PR.

Could you please let me know if the nextsteps I am planning on taking are in the right direction or should I change gears.

Once I have the first UI prototype working I can share screenshots and a short writeup comparing the approaches with concrete tradeoffs.

Thank you so much

Best,
Ibn


Daco Harkes

unread,
Mar 6, 2026, 6:13:03 AM (4 days ago) Mar 6
to Ibn Ahmad, dart-gsoc
Hi Ibn,

Tackle the hardest problems first, such as reading the memory. The UI is nice, but I'm sure we can make the UI work in the end.

Also take a look at the other conversation on this mailing list where Gurleen and Nourhan suggested using a separate process for memory reads as a safer way.

Kind regards,

 •  Daco Harkes
 •  Software Engineer
 •  dacoh...@google.com 

Reply all
Reply to author
Forward
0 new messages