diff --git a/runtime/lib/debugger.cc b/runtime/lib/developer.cc similarity index 55% rename from runtime/lib/debugger.cc rename to runtime/lib/developer.cc index b2a91b183aa..32b8384d43a 100644 --- a/runtime/lib/debugger.cc +++ b/runtime/lib/developer.cc @@ -14,29 +14,19 @@ namespace dart { -// dart:debugger. +// Native implementations for the dart:developer library. -DEFINE_NATIVE_ENTRY(Debugger_breakHere, 0) { +DEFINE_NATIVE_ENTRY(Developer_debugger, 2) { + GET_NON_NULL_NATIVE_ARGUMENT(Bool, when, arguments->NativeArgAt(0)); + GET_NATIVE_ARGUMENT(String, msg, arguments->NativeArgAt(1)); Debugger* debugger = isolate->debugger(); if (!debugger) { - return Object::null(); + return when.raw(); } - debugger->BreakHere(); - return Object::null(); + if (when.value()) { + debugger->BreakHere(msg); + } + return when.raw(); } - -DEFINE_NATIVE_ENTRY(Debugger_breakHereIf, 1) { - Debugger* debugger = isolate->debugger(); - if (!debugger) { - return Object::null(); - } - GET_NON_NULL_NATIVE_ARGUMENT(Bool, expr, arguments->NativeArgAt(0)); - if (expr.value()) { - debugger->BreakHere(); - } - return Object::null(); -} - - } // namespace dart diff --git a/runtime/lib/debugger.dart b/runtime/lib/developer.dart similarity index 52% rename from runtime/lib/debugger.dart rename to runtime/lib/developer.dart index 8e381cad160..f62ef8b300d 100644 --- a/runtime/lib/debugger.dart +++ b/runtime/lib/developer.dart @@ -2,9 +2,4 @@ // 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. -import 'dart:_internal'; - -patch class Debugger { - /* patch */ static void breakHere() native "Debugger_breakHere"; - /* patch */ static void breakHereIf(bool expr) native "Debugger_breakHereIf"; -} +patch bool debugger({bool when: true, String msg}) native "Developer_debugger"; diff --git a/runtime/lib/debugger_sources.gypi b/runtime/lib/developer_sources.gypi similarity index 53% rename from runtime/lib/debugger_sources.gypi rename to runtime/lib/developer_sources.gypi index 3f54e81a0d5..4bedb6797d7 100644 --- a/runtime/lib/debugger_sources.gypi +++ b/runtime/lib/developer_sources.gypi @@ -1,13 +1,13 @@ -# Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +# Copyright (c) 2015, 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. -# Sources visible via dart:debugger library. +# Sources visible via dart:developer library. { 'sources': [ - 'debugger.cc', - 'debugger.dart', + 'developer.cc', + 'developer.dart', ], } diff --git a/runtime/observatory/tests/service/get_stack_rpc_test.dart b/runtime/observatory/tests/service/get_stack_rpc_test.dart index 550a3da9915..7c253aa29db 100644 --- a/runtime/observatory/tests/service/get_stack_rpc_test.dart +++ b/runtime/observatory/tests/service/get_stack_rpc_test.dart @@ -8,7 +8,7 @@ import 'package:unittest/unittest.dart'; import 'test_helper.dart'; import 'dart:async'; import 'dart:isolate' as isolate; -import 'dart:debugger' as debugger; +import 'dart:developer' as developer; int counter = 0; const stoppedAtLine = 23; @@ -19,7 +19,7 @@ void msgHandler(_) { } void periodicTask(_) { port.sendPort.send(34); - debugger.Debugger.breakHere(); // We will be at a breakpoint at the next line. + developer.debugger(msg: "foo", when: true); // We will be at the next line. counter++; if (counter % 300 == 0) { print('counter = $counter'); diff --git a/runtime/vm/bootstrap.cc b/runtime/vm/bootstrap.cc index bdb144f41af..c76ea3ae04b 100644 --- a/runtime/vm/bootstrap.cc +++ b/runtime/vm/bootstrap.cc @@ -47,10 +47,10 @@ static bootstrap_lib_props bootstrap_libraries[] = { collection, Bootstrap::collection_source_paths_, Bootstrap::collection_patch_paths_), - INIT_LIBRARY(ObjectStore::kDebugger, - debugger, - Bootstrap::debugger_source_paths_, - Bootstrap::debugger_patch_paths_), + INIT_LIBRARY(ObjectStore::kDeveloper, + developer, + Bootstrap::developer_source_paths_, + Bootstrap::developer_patch_paths_), INIT_LIBRARY(ObjectStore::kInternal, _internal, Bootstrap::_internal_source_paths_, diff --git a/runtime/vm/bootstrap.h b/runtime/vm/bootstrap.h index 21341748d72..76758b624b0 100644 --- a/runtime/vm/bootstrap.h +++ b/runtime/vm/bootstrap.h @@ -24,7 +24,7 @@ class Bootstrap : public AllStatic { static const char* core_source_paths_[]; static const char* collection_source_paths_[]; static const char* convert_source_paths_[]; - static const char* debugger_source_paths_[]; + static const char* developer_source_paths_[]; static const char* _internal_source_paths_[]; static const char* isolate_source_paths_[]; static const char* json_source_paths_[]; @@ -39,7 +39,7 @@ class Bootstrap : public AllStatic { static const char* core_patch_paths_[]; static const char* collection_patch_paths_[]; static const char* convert_patch_paths_[]; - static const char* debugger_patch_paths_[]; + static const char* developer_patch_paths_[]; static const char* _internal_patch_paths_[]; static const char* isolate_patch_paths_[]; static const char* math_patch_paths_[]; diff --git a/runtime/vm/bootstrap_natives.cc b/runtime/vm/bootstrap_natives.cc index cf3f76092c6..07c49280479 100644 --- a/runtime/vm/bootstrap_natives.cc +++ b/runtime/vm/bootstrap_natives.cc @@ -95,7 +95,7 @@ void Bootstrap::SetupNativeResolver() { library.set_native_entry_resolver(resolver); library.set_native_entry_symbol_resolver(symbol_resolver); - library = Library::DebuggerLibrary(); + library = Library::DeveloperLibrary(); ASSERT(!library.IsNull()); library.set_native_entry_resolver(resolver); library.set_native_entry_symbol_resolver(symbol_resolver); diff --git a/runtime/vm/bootstrap_natives.h b/runtime/vm/bootstrap_natives.h index 6c1613bf964..e723d2ed94e 100644 --- a/runtime/vm/bootstrap_natives.h +++ b/runtime/vm/bootstrap_natives.h @@ -63,8 +63,6 @@ namespace dart { V(Bigint_getUsed, 1) \ V(Bigint_getDigits, 1) \ V(Bigint_allocate, 4) \ - V(Debugger_breakHere, 0) \ - V(Debugger_breakHereIf, 1) \ V(Double_getIsNegative, 1) \ V(Double_getIsInfinite, 1) \ V(Double_getIsNaN, 1) \ @@ -89,6 +87,7 @@ namespace dart { V(Double_toStringAsFixed, 2) \ V(Double_toStringAsExponential, 2) \ V(Double_toStringAsPrecision, 2) \ + V(Developer_debugger, 2) \ V(JSSyntaxRegExp_factory, 4) \ V(JSSyntaxRegExp_getPattern, 1) \ V(JSSyntaxRegExp_getIsMultiLine, 1) \ diff --git a/runtime/vm/debugger.cc b/runtime/vm/debugger.cc index a33a3047b56..4650eacc5be 100644 --- a/runtime/vm/debugger.cc +++ b/runtime/vm/debugger.cc @@ -2275,7 +2275,7 @@ void Debugger::SignalBpReached() { } -void Debugger::BreakHere() { +void Debugger::BreakHere(const String& msg) { // We ignore this breakpoint when the VM is executing code invoked // by the debugger to evaluate variables values, or when we see a nested // breakpoint or exception event. @@ -2288,6 +2288,8 @@ void Debugger::BreakHere() { ASSERT(stack_trace_ == NULL); stack_trace_ = stack_trace; + // TODO(johnmccutchan): Send |msg| to Observatory. + // We are in the native call to Debugger_breakHere or Debugger_breakHereIf, // the developer gets a better experience by not seeing this call. To // accomplish this, we continue execution until the call exits (step out). diff --git a/runtime/vm/debugger.h b/runtime/vm/debugger.h index f70b6d97d1a..c95deb426db 100644 --- a/runtime/vm/debugger.h +++ b/runtime/vm/debugger.h @@ -442,7 +442,7 @@ class Debugger { void SignalBpReached(); void DebuggerStepCallback(); - void BreakHere(); + void BreakHere(const String& msg); void SignalExceptionThrown(const Instance& exc); void SignalIsolateEvent(DebuggerEvent::EventType type); diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc index 9fe9d98c74a..acf260b0e97 100644 --- a/runtime/vm/object.cc +++ b/runtime/vm/object.cc @@ -9837,8 +9837,8 @@ RawLibrary* Library::CollectionLibrary() { } -RawLibrary* Library::DebuggerLibrary() { - return Isolate::Current()->object_store()->debugger_library(); +RawLibrary* Library::DeveloperLibrary() { + return Isolate::Current()->object_store()->developer_library(); } diff --git a/runtime/vm/object.h b/runtime/vm/object.h index 5cb03109de7..e85bfdae35f 100644 --- a/runtime/vm/object.h +++ b/runtime/vm/object.h @@ -3046,7 +3046,7 @@ class Library : public Object { static RawLibrary* ConvertLibrary(); static RawLibrary* CoreLibrary(); static RawLibrary* CollectionLibrary(); - static RawLibrary* DebuggerLibrary(); + static RawLibrary* DeveloperLibrary(); static RawLibrary* InternalLibrary(); static RawLibrary* IsolateLibrary(); static RawLibrary* MathLibrary(); diff --git a/runtime/vm/object_store.cc b/runtime/vm/object_store.cc index 58ea3535cd4..c2c14d539df 100644 --- a/runtime/vm/object_store.cc +++ b/runtime/vm/object_store.cc @@ -62,7 +62,7 @@ ObjectStore::ObjectStore() core_library_(Library::null()), collection_library_(Library::null()), convert_library_(Library::null()), - debugger_library_(Library::null()), + developer_library_(Library::null()), internal_library_(Library::null()), isolate_library_(Library::null()), math_library_(Library::null()), diff --git a/runtime/vm/object_store.h b/runtime/vm/object_store.h index becebc245a0..c1d73126c7b 100644 --- a/runtime/vm/object_store.h +++ b/runtime/vm/object_store.h @@ -25,7 +25,7 @@ class ObjectStore { kCore, kCollection, kConvert, - kDebugger, + kDeveloper, kInternal, kIsolate, kMath, @@ -258,7 +258,7 @@ class ObjectStore { RawLibrary* core_library() const { return core_library_; } RawLibrary* collection_library() const { return collection_library_; } RawLibrary* convert_library() const { return convert_library_; } - RawLibrary* debugger_library() const { return debugger_library_; } + RawLibrary* developer_library() const { return developer_library_; } RawLibrary* internal_library() const { return internal_library_; } RawLibrary* isolate_library() const { return isolate_library_; } RawLibrary* math_library() const { return math_library_; } @@ -280,8 +280,8 @@ class ObjectStore { case kConvert: convert_library_ = value.raw(); break; - case kDebugger: - debugger_library_ = value.raw(); + case kDeveloper: + developer_library_ = value.raw(); break; case kInternal: internal_library_ = value.raw(); @@ -489,7 +489,7 @@ class ObjectStore { RawLibrary* core_library_; RawLibrary* collection_library_; RawLibrary* convert_library_; - RawLibrary* debugger_library_; + RawLibrary* developer_library_; RawLibrary* internal_library_; RawLibrary* isolate_library_; RawLibrary* math_library_; diff --git a/runtime/vm/vm.gypi b/runtime/vm/vm.gypi index 3dbe3895081..d662c2a53f9 100644 --- a/runtime/vm/vm.gypi +++ b/runtime/vm/vm.gypi @@ -15,8 +15,8 @@ 'collection_patch_cc_file': '<(gen_source_dir)/collection_patch_gen.cc', 'convert_cc_file': '<(gen_source_dir)/convert_gen.cc', 'convert_patch_cc_file': '<(gen_source_dir)/convert_patch_gen.cc', - 'debugger_cc_file': '<(gen_source_dir)/debugger_gen.cc', - 'debugger_patch_cc_file': '<(gen_source_dir)/debugger_patch_gen.cc', + 'developer_cc_file': '<(gen_source_dir)/developer_gen.cc', + 'developer_patch_cc_file': '<(gen_source_dir)/developer_patch_gen.cc', 'internal_cc_file': '<(gen_source_dir)/internal_gen.cc', 'internal_patch_cc_file': '<(gen_source_dir)/internal_patch_gen.cc', 'isolate_cc_file': '<(gen_source_dir)/isolate_gen.cc', @@ -115,8 +115,8 @@ 'generate_collection_patch_cc_file#host', 'generate_convert_cc_file#host', 'generate_convert_patch_cc_file#host', - 'generate_debugger_cc_file#host', - 'generate_debugger_patch_cc_file#host', + 'generate_developer_cc_file#host', + 'generate_developer_patch_cc_file#host', 'generate_internal_cc_file#host', 'generate_internal_patch_cc_file#host', 'generate_isolate_cc_file#host', @@ -134,7 +134,7 @@ '../lib/async_sources.gypi', '../lib/collection_sources.gypi', '../lib/core_sources.gypi', - '../lib/debugger_sources.gypi', + '../lib/developer_sources.gypi', '../lib/internal_sources.gypi', '../lib/isolate_sources.gypi', '../lib/math_sources.gypi', @@ -153,8 +153,8 @@ '<(collection_patch_cc_file)', '<(convert_cc_file)', '<(convert_patch_cc_file)', - '<(debugger_cc_file)', - '<(debugger_patch_cc_file)', + '<(developer_cc_file)', + '<(developer_patch_cc_file)', '<(internal_cc_file)', '<(internal_patch_cc_file)', '<(isolate_cc_file)', @@ -180,7 +180,7 @@ '../lib/async_sources.gypi', '../lib/collection_sources.gypi', '../lib/core_sources.gypi', - '../lib/debugger_sources.gypi', + '../lib/developer_sources.gypi', '../lib/internal_sources.gypi', '../lib/isolate_sources.gypi', '../lib/math_sources.gypi', @@ -995,12 +995,12 @@ ] }, { - 'target_name': 'generate_debugger_cc_file', + 'target_name': 'generate_developer_cc_file', 'type': 'none', 'toolsets':['host'], 'includes': [ # Load the shared library sources. - '../../sdk/lib/debugger/debugger_sources.gypi', + '../../sdk/lib/developer/developer_sources.gypi', ], 'sources/': [ # Exclude all .[cc|h] files. @@ -1011,36 +1011,36 @@ ], 'actions': [ { - 'action_name': 'generate_debugger_cc', + 'action_name': 'generate_developer_cc', 'inputs': [ '../tools/gen_library_src_paths.py', '<(libgen_in_cc_file)', '<@(_sources)', ], 'outputs': [ - '<(debugger_cc_file)', + '<(developer_cc_file)', ], 'action': [ 'python', 'tools/gen_library_src_paths.py', - '--output', '<(debugger_cc_file)', + '--output', '<(developer_cc_file)', '--input_cc', '<(libgen_in_cc_file)', '--include', 'vm/bootstrap.h', - '--var_name', 'dart::Bootstrap::debugger_source_paths_', - '--library_name', 'dart:debugger', + '--var_name', 'dart::Bootstrap::developer_source_paths_', + '--library_name', 'dart:developer', '<@(_sources)', ], - 'message': 'Generating ''<(debugger_cc_file)'' file.' + 'message': 'Generating ''<(developer_cc_file)'' file.' }, ] }, { - 'target_name': 'generate_debugger_patch_cc_file', + 'target_name': 'generate_developer_patch_cc_file', 'type': 'none', 'toolsets':['host'], 'includes': [ # Load the runtime implementation sources. - '../lib/debugger_sources.gypi', + '../lib/developer_sources.gypi', ], 'sources/': [ # Exclude all .[cc|h] files. @@ -1051,26 +1051,26 @@ ], 'actions': [ { - 'action_name': 'generate_debugger_patch_cc', + 'action_name': 'generate_developer_patch_cc', 'inputs': [ '../tools/gen_library_src_paths.py', '<(libgen_in_cc_file)', '<@(_sources)', ], 'outputs': [ - '<(debugger_patch_cc_file)', + '<(developer_patch_cc_file)', ], 'action': [ 'python', 'tools/gen_library_src_paths.py', - '--output', '<(debugger_patch_cc_file)', + '--output', '<(developer_patch_cc_file)', '--input_cc', '<(libgen_in_cc_file)', '--include', 'vm/bootstrap.h', - '--var_name', 'dart::Bootstrap::debugger_patch_paths_', - '--library_name', 'dart:debugger', + '--var_name', 'dart::Bootstrap::developer_patch_paths_', + '--library_name', 'dart:developer', '<@(_sources)', ], - 'message': 'Generating ''<(debugger_patch_cc_file)'' file.' + 'message': 'Generating ''<(developer_patch_cc_file)'' file.' }, ] }, diff --git a/sdk/lib/_internal/compiler/js_lib/debugger_patch.dart b/sdk/lib/_internal/compiler/js_lib/debugger_patch.dart deleted file mode 100644 index cde47c4d3d7..00000000000 --- a/sdk/lib/_internal/compiler/js_lib/debugger_patch.dart +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2015, 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. - -// Patch file for dart:debugger library. - -import 'dart:_js_helper' show patch; -import 'dart:_foreign_helper' show JS; - -@patch class Debugger { - /// Stop the program as if a breakpoint where hit at the following statement. - /// NOTE: When invoked, the isolate will not return until a debugger - /// continues execution. When running in the Dart VM the behaviour is the same - /// regardless of whether or not a debugger is connected. When compiled to - /// JavaScript, this uses the "debugger" statement, and behaves exactly as - /// that does. - @patch - @ForceInline() - static void breakHere() { - JS('', 'debugger'); - } - - /// If [expr] is true, stop the program as if a breakpoint where hit at the - /// following statement. See [breakHere]. - @patch - @ForceInline() - static void breakHereIf(bool expr) { - if (expr) { - breakHere(); - } - } -} \ No newline at end of file diff --git a/sdk/lib/_internal/compiler/js_lib/developer_patch.dart b/sdk/lib/_internal/compiler/js_lib/developer_patch.dart new file mode 100644 index 00000000000..0e38bd55daf --- /dev/null +++ b/sdk/lib/_internal/compiler/js_lib/developer_patch.dart @@ -0,0 +1,25 @@ +// Copyright (c) 2015, 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. + +// Patch file for dart:developer library. + +import 'dart:_js_helper' show patch; +import 'dart:_foreign_helper' show JS; + +/// If [when] is true, stop the program as if a breakpoint where hit at the +/// following statement. Returns the value of [when]. Some debuggers may +/// display [msg]. +/// NOTE: When invoked, the isolate will not return until a debugger +/// continues execution. When running in the Dart VM the behaviour is the same +/// regardless of whether or not a debugger is connected. When compiled to +/// JavaScript, this uses the "debugger" statement, and behaves exactly as +/// that does. +@patch +@ForceInline() +bool debugger({bool when: true, String msg}) { + if (when) { + JS('', 'debugger'); + } + return when; +} diff --git a/sdk/lib/_internal/libraries.dart b/sdk/lib/_internal/libraries.dart index ec82309b866..7cd70c258c2 100644 --- a/sdk/lib/_internal/libraries.dart +++ b/sdk/lib/_internal/libraries.dart @@ -54,10 +54,10 @@ const Map LIBRARIES = const { maturity: Maturity.STABLE, dart2jsPatchPath: "_internal/compiler/js_lib/core_patch.dart"), - "debugger": const LibraryInfo( - "debugger/debugger.dart", + "developer": const LibraryInfo( + "developer/developer.dart", maturity: Maturity.UNSTABLE, - dart2jsPatchPath: "_internal/compiler/js_lib/debugger_patch.dart"), + dart2jsPatchPath: "_internal/compiler/js_lib/developer_patch.dart"), "html": const LibraryInfo( "html/dartium/html_dartium.dart", diff --git a/sdk/lib/debugger/debugger.dart b/sdk/lib/debugger/debugger.dart deleted file mode 100644 index 30089883294..00000000000 --- a/sdk/lib/debugger/debugger.dart +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2015, 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. - -/// Programmatically trigger breakpoints. -library dart.debugger; - -/// Programmatically trigger breakpoints. -class Debugger { - /// Stop the program as if a breakpoint where hit at the following statement. - /// NOTE: When invoked, the isolate will not return until a debugger - /// continues execution. When running in the Dart VM the behaviour is the same - /// regardless of whether or not a debugger is connected. When compiled to - /// JavaScript, this uses the "debugger" statement, and behaves exactly as - /// that does. - external static void breakHere(); - - /// If [expr] is true, stop the program as if a breakpoint where hit at the - /// following statement. See [breakHere]. - external static void breakHereIf(bool expr); -} diff --git a/sdk/lib/developer/developer.dart b/sdk/lib/developer/developer.dart new file mode 100644 index 00000000000..4b5673507b1 --- /dev/null +++ b/sdk/lib/developer/developer.dart @@ -0,0 +1,22 @@ +// Copyright (c) 2015, 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. + +/// ## Status: Unstable +/// +/// The dart:developer library is unstable and its API might change slightly +/// as a result of developer feedback. This library is platform dependent and +/// therefore it has implementations for both dart2js and the Dart VM. Both are +/// under development and may not support all operations yet. +/// +library dart.developer; + +/// If [when] is true, stop the program as if a breakpoint where hit at the +/// following statement. Returns the value of [when]. Some debuggers may +/// display [msg]. +/// NOTE: When invoked, the isolate will not return until a debugger +/// continues execution. When running in the Dart VM the behaviour is the same +/// regardless of whether or not a debugger is connected. When compiled to +/// JavaScript, this uses the "debugger" statement, and behaves exactly as +/// that does. +external bool debugger({bool when: true, String msg}); diff --git a/sdk/lib/debugger/debugger_sources.gypi b/sdk/lib/developer/developer_sources.gypi similarity index 74% rename from sdk/lib/debugger/debugger_sources.gypi rename to sdk/lib/developer/developer_sources.gypi index d1221e5145f..fa6a87c9243 100644 --- a/sdk/lib/debugger/debugger_sources.gypi +++ b/sdk/lib/developer/developer_sources.gypi @@ -1,10 +1,10 @@ -# Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +# Copyright (c) 2015, 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. { 'sources': [ - 'debugger.dart', + 'developer.dart', # The above file needs to be first if additional parts are added to the lib. ], } diff --git a/tools/create_sdk.py b/tools/create_sdk.py index 8d59679865f..c9dec1ba420 100755 --- a/tools/create_sdk.py +++ b/tools/create_sdk.py @@ -205,7 +205,7 @@ def Main(): for library in [join('_blink', 'dartium'), join('_chrome', 'dart2js'), join('_chrome', 'dartium'), join('_internal', 'compiler'), - 'async', 'collection', 'convert', 'core', 'debugger', + 'async', 'collection', 'convert', 'core', 'developer', 'internal', 'io', 'isolate', join('html', 'dart2js'), join('html', 'dartium'), join('html', 'html_common'),