diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn index c74e0c4895b..f5c13e9615d 100644 --- a/runtime/BUILD.gn +++ b/runtime/BUILD.gn @@ -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", - ] -} diff --git a/runtime/lib/object.cc b/runtime/lib/object.cc index b7dcea3a208..70fe890f8dc 100644 --- a/runtime/lib/object.cc +++ b/runtime/lib/object.cc @@ -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(); } diff --git a/runtime/lib/stacktrace.cc b/runtime/lib/stacktrace.cc index bdd4ddde6f8..8be29793cf1 100644 --- a/runtime/lib/stacktrace.cc +++ b/runtime/lib/stacktrace.cc @@ -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 diff --git a/runtime/vm/BUILD.gn b/runtime/vm/BUILD.gn index 3af9130a330..b4bdf403039 100644 --- a/runtime/vm/BUILD.gn +++ b/runtime/vm/BUILD.gn @@ -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", diff --git a/runtime/vm/gdb_helpers.cc b/runtime/vm/gdb_helpers.cc new file mode 100644 index 00000000000..b50d912e0ed --- /dev/null +++ b/runtime/vm/gdb_helpers.cc @@ -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 diff --git a/runtime/vm/thread_interrupter_linux.cc b/runtime/vm/thread_interrupter_linux.cc index 399861bf2c9..8fe7265c54b 100644 --- a/runtime/vm/thread_interrupter_linux.cc +++ b/runtime/vm/thread_interrupter_linux.cc @@ -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 diff --git a/runtime/vm/vm_sources.gypi b/runtime/vm/vm_sources.gypi index d870c59b319..c6d50680966 100644 --- a/runtime/vm/vm_sources.gypi +++ b/runtime/vm/vm_sources.gypi @@ -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',