OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if !defined(_WIN32) && !defined(_WIN64) | 5 #if !defined(_WIN32) && !defined(_WIN64) |
6 #include <unistd.h> // NOLINT | 6 #include <unistd.h> // NOLINT |
7 #endif // !defined(_WIN32) && !defined(_WIN64) | 7 #endif // !defined(_WIN32) && !defined(_WIN64) |
8 | 8 |
9 #include <locale.h> | 9 #include <locale.h> |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 public: | 50 public: |
51 UtilsExtension() | 51 UtilsExtension() |
52 : v8::Extension("v8_inspector/utils", | 52 : v8::Extension("v8_inspector/utils", |
53 "native function print();" | 53 "native function print();" |
54 "native function quit();" | 54 "native function quit();" |
55 "native function setlocale();" | 55 "native function setlocale();" |
56 "native function read();" | 56 "native function read();" |
57 "native function load();" | 57 "native function load();" |
58 "native function compileAndRunWithOrigin();" | 58 "native function compileAndRunWithOrigin();" |
59 "native function setCurrentTimeMSForTest();" | 59 "native function setCurrentTimeMSForTest();" |
60 "native function setMemoryInfoForTest();" | |
61 "native function schedulePauseOnNextStatement();" | 60 "native function schedulePauseOnNextStatement();" |
62 "native function cancelPauseOnNextStatement();" | 61 "native function cancelPauseOnNextStatement();" |
63 "native function reconnect();" | 62 "native function reconnect();" |
64 "native function createContextGroup();") {} | 63 "native function createContextGroup();") {} |
65 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( | 64 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( |
66 v8::Isolate* isolate, v8::Local<v8::String> name) { | 65 v8::Isolate* isolate, v8::Local<v8::String> name) { |
67 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 66 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
68 if (name->Equals(context, v8::String::NewFromUtf8( | 67 if (name->Equals(context, v8::String::NewFromUtf8( |
69 isolate, "print", v8::NewStringType::kNormal) | 68 isolate, "print", v8::NewStringType::kNormal) |
70 .ToLocalChecked()) | 69 .ToLocalChecked()) |
(...skipping 30 matching lines...) Expand all Loading... |
101 .FromJust()) { | 100 .FromJust()) { |
102 return v8::FunctionTemplate::New(isolate, | 101 return v8::FunctionTemplate::New(isolate, |
103 UtilsExtension::CompileAndRunWithOrigin); | 102 UtilsExtension::CompileAndRunWithOrigin); |
104 } else if (name->Equals(context, v8::String::NewFromUtf8( | 103 } else if (name->Equals(context, v8::String::NewFromUtf8( |
105 isolate, "setCurrentTimeMSForTest", | 104 isolate, "setCurrentTimeMSForTest", |
106 v8::NewStringType::kNormal) | 105 v8::NewStringType::kNormal) |
107 .ToLocalChecked()) | 106 .ToLocalChecked()) |
108 .FromJust()) { | 107 .FromJust()) { |
109 return v8::FunctionTemplate::New(isolate, | 108 return v8::FunctionTemplate::New(isolate, |
110 UtilsExtension::SetCurrentTimeMSForTest); | 109 UtilsExtension::SetCurrentTimeMSForTest); |
111 } else if (name->Equals(context, v8::String::NewFromUtf8( | |
112 isolate, "setMemoryInfoForTest", | |
113 v8::NewStringType::kNormal) | |
114 .ToLocalChecked()) | |
115 .FromJust()) { | |
116 return v8::FunctionTemplate::New(isolate, | |
117 UtilsExtension::SetMemoryInfoForTest); | |
118 } else if (name->Equals(context, | 110 } else if (name->Equals(context, |
119 v8::String::NewFromUtf8( | 111 v8::String::NewFromUtf8( |
120 isolate, "schedulePauseOnNextStatement", | 112 isolate, "schedulePauseOnNextStatement", |
121 v8::NewStringType::kNormal) | 113 v8::NewStringType::kNormal) |
122 .ToLocalChecked()) | 114 .ToLocalChecked()) |
123 .FromJust()) { | 115 .FromJust()) { |
124 return v8::FunctionTemplate::New( | 116 return v8::FunctionTemplate::New( |
125 isolate, UtilsExtension::SchedulePauseOnNextStatement); | 117 isolate, UtilsExtension::SchedulePauseOnNextStatement); |
126 } else if (name->Equals(context, v8::String::NewFromUtf8( | 118 } else if (name->Equals(context, v8::String::NewFromUtf8( |
127 isolate, "cancelPauseOnNextStatement", | 119 isolate, "cancelPauseOnNextStatement", |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 static void SetCurrentTimeMSForTest( | 259 static void SetCurrentTimeMSForTest( |
268 const v8::FunctionCallbackInfo<v8::Value>& args) { | 260 const v8::FunctionCallbackInfo<v8::Value>& args) { |
269 if (args.Length() != 1 || !args[0]->IsNumber()) { | 261 if (args.Length() != 1 || !args[0]->IsNumber()) { |
270 fprintf(stderr, "Internal error: setCurrentTimeMSForTest(time)."); | 262 fprintf(stderr, "Internal error: setCurrentTimeMSForTest(time)."); |
271 Exit(); | 263 Exit(); |
272 } | 264 } |
273 inspector_client_->setCurrentTimeMSForTest( | 265 inspector_client_->setCurrentTimeMSForTest( |
274 args[0].As<v8::Number>()->Value()); | 266 args[0].As<v8::Number>()->Value()); |
275 } | 267 } |
276 | 268 |
277 static void SetMemoryInfoForTest( | |
278 const v8::FunctionCallbackInfo<v8::Value>& args) { | |
279 if (args.Length() != 1) { | |
280 fprintf(stderr, "Internal error: setMemoryInfoForTest(value)."); | |
281 Exit(); | |
282 } | |
283 inspector_client_->setMemoryInfoForTest(args[0]); | |
284 } | |
285 | |
286 static void SchedulePauseOnNextStatement( | 269 static void SchedulePauseOnNextStatement( |
287 const v8::FunctionCallbackInfo<v8::Value>& args) { | 270 const v8::FunctionCallbackInfo<v8::Value>& args) { |
288 if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsString()) { | 271 if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsString()) { |
289 fprintf( | 272 fprintf( |
290 stderr, | 273 stderr, |
291 "Internal error: schedulePauseOnNextStatement('reason', 'details')."); | 274 "Internal error: schedulePauseOnNextStatement('reason', 'details')."); |
292 Exit(); | 275 Exit(); |
293 } | 276 } |
294 v8::internal::Vector<uint16_t> reason = ToVector(args[0].As<v8::String>()); | 277 v8::internal::Vector<uint16_t> reason = ToVector(args[0].As<v8::String>()); |
295 v8_inspector::StringView reason_view(reason.start(), reason.length()); | 278 v8_inspector::StringView reason_view(reason.start(), reason.length()); |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 argv[i]); | 679 argv[i]); |
697 Exit(); | 680 Exit(); |
698 } | 681 } |
699 frontend_runner.Append(new ExecuteStringTask(chars)); | 682 frontend_runner.Append(new ExecuteStringTask(chars)); |
700 } | 683 } |
701 | 684 |
702 frontend_runner.Join(); | 685 frontend_runner.Join(); |
703 backend_runner.Join(); | 686 backend_runner.Join(); |
704 return 0; | 687 return 0; |
705 } | 688 } |
OLD | NEW |