From e063b7118c8399ed4332e26287d4a7b6aa69b068 Mon Sep 17 00:00:00 2001 From: ishell Date: Thu, 28 Jul 2016 10:09:10 -0700 Subject: [PATCH] [gdb] Define print functions used by gdb macros in the top level namespace to make them always be available. This should fix the following errors that sometimes appear when using V8 gdb macros: Cannot evaluate function -- may be inlined or No symbol "xxx" in namespace "v8::internal". Review-Url: https://codereview.chromium.org/2186293002 Cr-Commit-Position: refs/heads/master@{#38145} --- src/objects-printer.cc | 41 +++++++++++++++++++++++++++++++++++++++++ tools/gdbinit | 12 ++++++------ 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/src/objects-printer.cc b/src/objects-printer.cc index 15bd5e39bd..9aa51aa9a1 100644 --- a/src/objects-printer.cc +++ b/src/objects-printer.cc @@ -1469,3 +1469,44 @@ void JSObject::PrintTransitions(std::ostream& os) { // NOLINT #endif // defined(DEBUG) || defined(OBJECT_PRINT) } // namespace internal } // namespace v8 + +// +// The following functions are used by our gdb macros. +// +extern void _v8_internal_Print_Object(void* object) { + reinterpret_cast(object)->Print(); +} + +extern void _v8_internal_Print_Code(void* object) { + i::Isolate* isolate = i::Isolate::Current(); + isolate->FindCodeObject(reinterpret_cast(object))->Print(); +} + +extern void _v8_internal_Print_TypeFeedbackVector(void* object) { + if (reinterpret_cast(object)->IsSmi()) { + printf("Not a type feedback vector\n"); + } else { + reinterpret_cast(object)->Print(); + } +} + +extern void _v8_internal_Print_DescriptorArray(void* object) { + if (reinterpret_cast(object)->IsSmi()) { + printf("Not a descriptor array\n"); + } else { + reinterpret_cast(object)->Print(); + } +} + +extern void _v8_internal_Print_TransitionArray(void* object) { + if (reinterpret_cast(object)->IsSmi()) { + printf("Not a transition array\n"); + } else { + reinterpret_cast(object)->Print(); + } +} + +extern void _v8_internal_Print_StackTrace() { + i::Isolate* isolate = i::Isolate::Current(); + isolate->PrintStack(stdout); +} diff --git a/tools/gdbinit b/tools/gdbinit index 0f8704a27c..1eae053f2c 100644 --- a/tools/gdbinit +++ b/tools/gdbinit @@ -4,7 +4,7 @@ # Print HeapObjects. define job -print ((v8::internal::HeapObject*)($arg0))->Print() +call _v8_internal_Print_Object((void*)($arg0)) end document job Print a v8 JavaScript object @@ -13,7 +13,7 @@ end # Print Code objects containing given PC. define jco -job (v8::internal::Isolate::Current()->FindCodeObject((v8::internal::Address)$arg0)) +call _v8_internal_Print_Code((void*)($arg0)) end document jco Print a v8 Code object from an internal code address @@ -22,7 +22,7 @@ end # Print TypeFeedbackVector define jfv -print ((v8::internal::TypeFeedbackVector*)($arg0))->Print() +call _v8_internal_Print_TypeFeedbackVector((void*)($arg0)) end document jfv Print a v8 TypeFeedbackVector object @@ -31,7 +31,7 @@ end # Print DescriptorArray. define jda -print ((v8::internal::DescriptorArray*)($arg0))->Print() +call _v8_internal_Print_DescriptorArray((void*)($arg0)) end document jda Print a v8 DescriptorArray object @@ -40,7 +40,7 @@ end # Print TransitionArray. define jta -print ((v8::internal::TransitionArray*)($arg0))->Print() +call _v8_internal_Print_TransitionArray((void*)($arg0)) end document jta Print a v8 TransitionArray object @@ -49,7 +49,7 @@ end # Print JavaScript stack trace. define jst -print v8::internal::Isolate::Current()->PrintStack((FILE*) stdout, 1) +call _v8_internal_Print_StackTrace() end document jst Print the current JavaScript stack trace