Add gdb helper functions for creating a handle and using ToCString with RawObjects.

Improves gdb debugging when Object::Handle() is optimized away.

Replace some intermediate static_libraries with source_sets to fix export issue.

R=regis@google.com, vegorov@google.com, zra@google.com

Review-Url: https://codereview.chromium.org/2957843002 .
This commit is contained in:
Ryan Macnak
2017-06-29 14:31:40 -07:00
parent d29c5d3a72
commit f1b7e8ed8c
7 changed files with 99 additions and 58 deletions
+5 -21
View File
@@ -259,7 +259,11 @@ libdart_library("libdart_with_precompiler") {
action("generate_version_cc_file") {
deps = [
":libdart_dependency_helper",
"third_party/double-conversion/src:libdouble_conversion",
"vm:libdart_lib_jit",
"vm:libdart_lib_nosnapshot_with_precompiler",
"vm:libdart_vm_jit",
"vm:libdart_vm_nosnapshot_with_precompiler",
]
inputs = [
"../tools/utils.py",
@@ -281,23 +285,3 @@ action("generate_version_cc_file") {
rebase_path("vm/version_in.cc", root_build_dir),
]
}
executable("libdart_dependency_helper") {
configs += [
":dart_config",
":dart_maybe_product_config",
]
if (is_fuchsia) {
configs -= [ "//build/config:symbol_visibility_hidden" ]
}
deps = [
"third_party/double-conversion/src:libdouble_conversion",
"vm:libdart_lib_jit",
"vm:libdart_lib_nosnapshot_with_precompiler",
"vm:libdart_vm_jit",
"vm:libdart_vm_nosnapshot_with_precompiler",
]
sources = [
"vm/libdart_dependency_helper.cc",
]
}
-4
View File
@@ -17,15 +17,11 @@ namespace dart {
DECLARE_FLAG(bool, trace_type_checks);
// Helper function in stacktrace.cc.
void _printCurrentStackTrace();
DEFINE_NATIVE_ENTRY(DartAsync_fatal, 1) {
// The dart:async library code entered an unrecoverable state.
const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0));
const char* msg = instance.ToCString();
OS::PrintErr("Fatal error in dart:async: %s\n", msg);
_printCurrentStackTrace();
FATAL(msg);
return Object::null();
}
-24
View File
@@ -181,28 +181,4 @@ const StackTrace& GetCurrentStackTrace(int skip_frames) {
return stacktrace;
}
// An utility method for convenient printing of dart stack traces when
// inside 'gdb'. Note: This function will only work when there is a
// valid exit frame information. It will not work when a breakpoint is
// set in dart code and control is got inside 'gdb' without going through
// the runtime or native transition stub.
void _printCurrentStackTrace() {
const StackTrace& stacktrace = GetCurrentStackTrace(0);
OS::PrintErr("=== Current Trace:\n%s===\n", stacktrace.ToCString());
}
// Like _printCurrentStackTrace, but works in a NoSafepointScope.
void _printCurrentStackTraceNoSafepoint() {
StackFrameIterator frames(StackFrameIterator::kDontValidateFrames,
Thread::Current(),
StackFrameIterator::kNoCrossThreadIteration);
StackFrame* frame = frames.NextFrame();
while (frame != NULL) {
OS::PrintErr("%s\n", frame->ToCString());
frame = frames.NextFrame();
}
}
} // namespace dart
+9 -9
View File
@@ -45,7 +45,7 @@ static_library("libdart_platform") {
vm_sources_list = processed_gypis.vm_sources
static_library("libdart_vm_jit") {
source_set("libdart_vm_jit") {
configs += [
"..:dart_config",
"..:dart_maybe_product_config",
@@ -62,7 +62,7 @@ static_library("libdart_vm_jit") {
include_dirs = [ ".." ]
}
static_library("libdart_vm_precompiled_runtime") {
source_set("libdart_vm_precompiled_runtime") {
configs += [
"..:dart_config",
"..:dart_maybe_product_config",
@@ -80,7 +80,7 @@ static_library("libdart_vm_precompiled_runtime") {
include_dirs = [ ".." ]
}
static_library("libdart_vm_nosnapshot") {
source_set("libdart_vm_nosnapshot") {
configs += [
"..:dart_config",
"..:dart_maybe_product_config",
@@ -98,7 +98,7 @@ static_library("libdart_vm_nosnapshot") {
include_dirs = [ ".." ]
}
static_library("libdart_vm_nosnapshot_with_precompiler") {
source_set("libdart_vm_nosnapshot_with_precompiler") {
configs += [
"..:dart_config",
"..:dart_maybe_product_config",
@@ -117,7 +117,7 @@ static_library("libdart_vm_nosnapshot_with_precompiler") {
include_dirs = [ ".." ]
}
static_library("libdart_vm_with_precompiler") {
source_set("libdart_vm_with_precompiler") {
configs += [
"..:dart_config",
"..:dart_maybe_product_config",
@@ -230,7 +230,7 @@ template("generate_core_libraries") {
all_libsources = rebase_path(invoker.allsources, ".", "../lib")
static_library("libdart_lib_nosnapshot_with_precompiler") {
source_set("libdart_lib_nosnapshot_with_precompiler") {
configs += [
"..:dart_config",
"..:dart_maybe_product_config",
@@ -244,7 +244,7 @@ template("generate_core_libraries") {
include_dirs = [ ".." ]
}
static_library("libdart_lib_with_precompiler") {
source_set("libdart_lib_with_precompiler") {
configs += [
"..:dart_config",
"..:dart_maybe_product_config",
@@ -258,7 +258,7 @@ template("generate_core_libraries") {
include_dirs = [ ".." ]
}
static_library("libdart_lib_jit") {
source_set("libdart_lib_jit") {
configs += [
"..:dart_config",
"..:dart_maybe_product_config",
@@ -270,7 +270,7 @@ template("generate_core_libraries") {
include_dirs = [ ".." ]
}
static_library("libdart_lib_precompiled_runtime") {
source_set("libdart_lib_precompiled_runtime") {
configs += [
"..:dart_config",
"..:dart_maybe_product_config",
+81
View File
@@ -0,0 +1,81 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "lib/stacktrace.h"
#include "vm/object.h"
#include "vm/stack_frame.h"
namespace dart {
#if !defined(PRODUCT)
DART_EXPORT
void _printRawObject(RawObject* object) {
OS::PrintErr("%s\n", Object::Handle(object).ToCString());
}
DART_EXPORT
Object* _handle(RawObject* object) {
return &Object::Handle(object);
}
// An utility method for convenient printing of dart stack traces when
// inside 'gdb'. Note: This function will only work when there is a
// valid exit frame information. It will not work when a breakpoint is
// set in dart code and control is got inside 'gdb' without going through
// the runtime or native transition stub.
DART_EXPORT
void _printDartStackTrace() {
const StackTrace& stacktrace = GetCurrentStackTrace(0);
OS::PrintErr("=== Current Trace:\n%s===\n", stacktrace.ToCString());
}
// Like _printDartStackTrace, but works in a NoSafepointScope. Use it if you're
// in the middle of a GC or interested in stub frames.
DART_EXPORT
void _printStackTrace() {
StackFrameIterator frames(StackFrameIterator::kDontValidateFrames,
Thread::Current(),
StackFrameIterator::kNoCrossThreadIteration);
StackFrame* frame = frames.NextFrame();
while (frame != NULL) {
OS::PrintErr("%s\n", frame->ToCString());
frame = frames.NextFrame();
}
}
class PrintObjectPointersVisitor : public ObjectPointerVisitor {
public:
PrintObjectPointersVisitor() : ObjectPointerVisitor(Isolate::Current()) {}
void VisitPointers(RawObject** first, RawObject** last) {
for (RawObject** p = first; p <= last; p++) {
Object& obj = Object::Handle(*p);
OS::PrintErr("%p: %s\n", p, obj.ToCString());
}
}
};
DART_EXPORT
void _printStackTraceWithLocals() {
PrintObjectPointersVisitor visitor;
StackFrameIterator frames(StackFrameIterator::kDontValidateFrames,
Thread::Current(),
StackFrameIterator::kNoCrossThreadIteration);
StackFrame* frame = frames.NextFrame();
while (frame != NULL) {
OS::PrintErr("%s\n", frame->ToCString());
frame->VisitObjectPointers(&visitor);
frame = frames.NextFrame();
}
}
#endif // !PRODUCT
} // namespace dart
+3
View File
@@ -15,6 +15,8 @@
namespace dart {
#ifndef PRODUCT
DECLARE_FLAG(bool, thread_interrupter);
DECLARE_FLAG(bool, trace_thread_interrupter);
@@ -69,6 +71,7 @@ void ThreadInterrupter::RemoveSignalHandler() {
SignalHandler::Remove();
}
#endif // !PRODUCT
} // namespace dart
+1
View File
@@ -203,6 +203,7 @@
'gc_marker.h',
'gc_sweeper.cc',
'gc_sweeper.h',
'gdb_helpers.cc',
'globals.h',
'growable_array.h',
'growable_array_test.cc',