cppgc: Add gdb printers for compressed pointers

This CL adds the following gdb commands:
 cpcp <compressed-pointer>  # prints compressed pointer
 cpm <member>  # prints member value

Bug: chromium:1373391
Change-Id: If5cc121883afbe64f4b95965a48b52647179b9f8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3945108
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83633}
This commit is contained in:
Anton Bikineev 2022-10-11 16:08:57 +02:00 committed by V8 LUCI CQ
parent 1fada6b36f
commit 45106e33d0
3 changed files with 48 additions and 0 deletions

View File

@ -68,6 +68,8 @@ class V8_TRIVIAL_ABI MemberBase {
V8_INLINE void ClearFromGC() const { raw_.Clear(); }
private:
friend class MemberDebugHelper;
mutable RawStorage raw_;
};

View File

@ -4,6 +4,11 @@
#include "include/cppgc/internal/member-storage.h"
#include "include/cppgc/garbage-collected.h"
#include "include/cppgc/member.h"
#include "src/base/compiler-specific.h"
#include "src/base/macros.h"
namespace cppgc {
namespace internal {
@ -11,5 +16,26 @@ namespace internal {
uintptr_t CageBaseGlobal::g_base_ = CageBaseGlobal::kLowerHalfWordMask;
#endif // defined(CPPGC_POINTER_COMPRESSION)
// Debugging helpers.
#if defined(CPPGC_POINTER_COMPRESSION)
extern "C" V8_DONT_STRIP_SYMBOL V8_EXPORT_PRIVATE void*
_cppgc_internal_Decompress_Compressed_Pointer(uint32_t cmprsd) {
return MemberStorage::Decompress(cmprsd);
}
#endif // !defined(CPPGC_POINTER_COMPRESSION)
class MemberDebugHelper final {
public:
static void* PrintUncompressed(MemberBase* m) {
return const_cast<void*>(m->GetRaw());
}
};
extern "C" V8_DONT_STRIP_SYMBOL V8_EXPORT_PRIVATE void*
_cppgc_internal_Print_Member(MemberBase* m) {
return MemberDebugHelper::PrintUncompressed(m);
}
} // namespace internal
} // namespace cppgc

View File

@ -259,3 +259,23 @@ gdb.events.new_objfile.connect(newobj_handler)
gdb.execute("set environment V8_GDBINIT_SOURCED=1")
end
### CppGC helpers.
# Print compressed pointer.
define cpcp
call _cppgc_internal_Decompress_Compressed_Pointer((unsigned)($arg0))
end
document cpcp
Prints compressed pointer (raw value) after decompression.
Usage: cpcp compressed_pointer
end
# Print member.
define cpm
call _cppgc_internal_Print_Member((cppgc::internal::MemberBase*)(&$arg0))
end
document cpm
Prints member, compressed or not.
Usage: cpm member
end