Debugging compressed pointers in Blink

207 views
Skip to first unread message

Daniel Libby

unread,
Sep 21, 2022, 3:01:36 PM9/21/22
to blink-dev
https://crrev.com/c/3835682 enabled pointer compression for Blink Member<> pointers. How are folks handling these while debugging (either live or crash dumps)? Is there some tooling available that will look up and apply the cage base? 

I didn't see anything mentioned in https://docs.google.com/document/d/1neGN8Jq-1JLrWK3cvwRIfrSjLgE0Srjv-uq7Ze38Iao/edit# but maybe there are better known tools/techniques from v8 (which IIUC has had compressed pointers for some time now).

Kentaro Hara

unread,
Sep 21, 2022, 7:14:23 PM9/21/22
to Daniel Libby, Michael Lippautz, blink-dev

2022年9月22日(木) 4:01 'Daniel Libby' via blink-dev <blin...@chromium.org>:
https://crrev.com/c/3835682 enabled pointer compression for Blink Member<> pointers. How are folks handling these while debugging (either live or crash dumps)? Is there some tooling available that will look up and apply the cage base? 

I didn't see anything mentioned in https://docs.google.com/document/d/1neGN8Jq-1JLrWK3cvwRIfrSjLgE0Srjv-uq7Ze38Iao/edit# but maybe there are better known tools/techniques from v8 (which IIUC has had compressed pointers for some time now).

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/4b3e5bbb-134a-4483-9a1e-8e33fbc6f38en%40chromium.org.

Anton Bikineev

unread,
Sep 22, 2022, 11:43:34 AM9/22/22
to Kentaro Hara, Daniel Libby, Michael Lippautz, blink-dev
We have plans to provide more debugging tooling for Oilpan. I haven't had a need to examine compressed pointers myself, however I see that some simple gdb/windbg function that'd follow pointers would be useful.

Daniel Cheng

unread,
Sep 22, 2022, 11:51:35 AM9/22/22
to Anton Bikineev, Kentaro Hara, Daniel Libby, Michael Lippautz, blink-dev
Is there a callable C++ function that can turn a compressed pointer into the actual pointer value?

Daniel

Anton Bikineev

unread,
Sep 22, 2022, 2:10:36 PM9/22/22
to Daniel Cheng, Kentaro Hara, Daniel Libby, Michael Lippautz, blink-dev
There is "cppgc::internal::CompressedPointer::Decompress(void*)". I would, however, hide it behind a simpler name in .gdbinit.

Ian Kilpatrick

unread,
Oct 10, 2022, 1:22:04 PM10/10/22
to Anton Bikineev, Daniel Cheng, Kentaro Hara, Daniel Libby, Michael Lippautz, blink-dev
Is there a bug to follow regarding the debuggability of the pointers?

Ian

Stefan Zager

unread,
Oct 10, 2022, 2:32:39 PM10/10/22
to Ian Kilpatrick, Anton Bikineev, Daniel Cheng, Kentaro Hara, Daniel Libby, Michael Lippautz, blink-dev
I ran into this today, and it's pretty frustrating:

(rr) p inner_node_                                                                              
$11 = {                                                                                          
  <cppgc::internal::MemberBase> = {                                                              
    raw_ = {                                                                                    
      static kCompressedSentinel = 1,                                                            
      value_ = 2148082696                                                                        
    }                                                                                            
  },                                                                                            
  <cppgc::internal::DisabledCheckingPolicy> = {<No data fields>}, <No data fields>}              
(rr) p inner_node_.Load()                                                                        
Couldn't find method blink::Member<blink::Node>::Load                                            
(rr) p inner_node_.raw_.Load()                                                                  
Cannot evaluate function -- may be inlined                                                      
(rr) p cppgc::internal::CompressedPointer::Decompress(inner_node_.raw_.value_)                  
Cannot evaluate function -- may be inlined                                                      
(rr)  

I found that I can avoid the issue with this in args.gn:

cppgc_enable_caged_heap = false
cppgc_enable_pointer_compression = false

... but I would prefer a better solution. 

Daniel Cheng

unread,
Oct 10, 2022, 2:45:53 PM10/10/22
to Stefan Zager, Ian Kilpatrick, Anton Bikineev, Kentaro Hara, Daniel Libby, Michael Lippautz, blink-dev
For now, I guess it should be sufficient to add something to v8/include/cppgc/internal/member-storage.h like

#ifndef NDEBUG  // DCHECK_IS_ON() would be nicer, but not sure what v8 uses
extern "C" void* DecompressPointerForDebugger(uint32_t value) {
  return cppgc::internal::CompressedPointer::Decompress(value);
}
#endif

Which should hopefully be callable from the debugger and not eliminated by the linker?

Daniel

Stefan Zager

unread,
Oct 10, 2022, 3:20:01 PM10/10/22
to Daniel Cheng, Stefan Zager, Ian Kilpatrick, Anton Bikineev, Kentaro Hara, Daniel Libby, Michael Lippautz, blink-dev
Maybe add NOINLINE for good measure, but yeah, I think that should work.

Anton Bikineev

unread,
Oct 11, 2022, 10:05:39 AM10/11/22
to Daniel Cheng, Stefan Zager, Ian Kilpatrick, Kentaro Hara, Daniel Libby, Michael Lippautz, blink-dev
Which should hopefully be callable from the debugger and not eliminated by the linker?
We can apply __attribute__((used,retain)) to make sure that the linker doesn't strip the functions with --gc-sections, same as did for V8 helpers (a week ago :) ). I'll prepare a CL.

Anton Bikineev

unread,
Oct 11, 2022, 10:19:41 AM10/11/22
to Daniel Cheng, Stefan Zager, Ian Kilpatrick, Kentaro Hara, Daniel Libby, Michael Lippautz, blink-dev
I'm now submitting a CL that adds some quick gdb helpers:

  (gdb) source v8/tools/gdbinit
  # Print Member:
  (gdb) cpm <member-name>
  # Print Compressed Pointer:
  (gdb) cpcp <compressed-32-bit-value>

It currently erases the pointee type, but this can be improved in the future.

Dave Tapuska

unread,
Oct 11, 2022, 11:00:18 AM10/11/22
to Anton Bikineev, Daniel Cheng, Stefan Zager, Ian Kilpatrick, Kentaro Hara, Daniel Libby, Michael Lippautz, blink-dev

Christian Biesinger

unread,
Oct 11, 2022, 11:04:16 AM10/11/22
to Dave Tapuska, Anton Bikineev, Daniel Cheng, Stefan Zager, Ian Kilpatrick, Kentaro Hara, Daniel Libby, Michael Lippautz, blink-dev
Perhaps we should add a prettyprinter for cppgc::internal::MemberBase which automatically calls that function?

Christian

Anton Bikineev

unread,
Oct 12, 2022, 10:20:39 AM10/12/22
to Christian Biesinger, Dave Tapuska, Daniel Cheng, Stefan Zager, Ian Kilpatrick, Kentaro Hara, Daniel Libby, Michael Lippautz, blink-dev
Perhaps we should add a prettyprinter for cppgc::internal::MemberBase which automatically calls that function?
I just added a pretty-printer for (cppgc|blink)::(Weak|Untraced)Member. Any feedback is appreciated!
Since simple 'print' should work now, I think that 'cpcp' and 'cpm' can be obsolete. A general note: we plan to add debugging support for Oilpan (in our OKRs). As soon as we agree on the interface, it would probably be worth updating debugging.md.
Reply all
Reply to author
Forward
0 new messages