Rename 'dart:debugger' to 'dart:developer'

- Rename 'dart:debugger' to 'dart:developer'
- Make 'breakHere' and 'breakHereIf' top level functions.

R=iposva@google.com

Review URL: https://codereview.chromium.org//1132113002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45658 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
johnmccutchan@google.com
2015-05-08 21:24:57 +00:00
parent 9d88c5c476
commit 1f851efdbb
22 changed files with 114 additions and 134 deletions
@@ -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
@@ -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";
@@ -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',
],
}
@@ -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');
+4 -4
View File
@@ -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_,
+2 -2
View File
@@ -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_[];
+1 -1
View File
@@ -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);
+1 -2
View File
@@ -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) \
+3 -1
View File
@@ -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).
+1 -1
View File
@@ -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);
+2 -2
View File
@@ -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();
}
+1 -1
View File
@@ -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();
+1 -1
View File
@@ -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()),
+5 -5
View File
@@ -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_;
+24 -24
View File
@@ -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.'
},
]
},
@@ -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();
}
}
}
@@ -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;
}
+3 -3
View File
@@ -54,10 +54,10 @@ const Map<String, LibraryInfo> 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",
-21
View File
@@ -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);
}
+22
View File
@@ -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});
@@ -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.
],
}
+1 -1
View File
@@ -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'),