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();" |
60 "native function schedulePauseOnNextStatement();" | 61 "native function schedulePauseOnNextStatement();" |
61 "native function cancelPauseOnNextStatement();" | 62 "native function cancelPauseOnNextStatement();" |
62 "native function reconnect();" | 63 "native function reconnect();" |
63 "native function createContextGroup();") {} | 64 "native function createContextGroup();") {} |
64 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( | 65 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( |
65 v8::Isolate* isolate, v8::Local<v8::String> name) { | 66 v8::Isolate* isolate, v8::Local<v8::String> name) { |
66 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 67 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
67 if (name->Equals(context, v8::String::NewFromUtf8( | 68 if (name->Equals(context, v8::String::NewFromUtf8( |
68 isolate, "print", v8::NewStringType::kNormal) | 69 isolate, "print", v8::NewStringType::kNormal) |
69 .ToLocalChecked()) | 70 .ToLocalChecked()) |
(...skipping 30 matching lines...) Expand all Loading... |
100 .FromJust()) { | 101 .FromJust()) { |
101 return v8::FunctionTemplate::New(isolate, | 102 return v8::FunctionTemplate::New(isolate, |
102 UtilsExtension::CompileAndRunWithOrigin); | 103 UtilsExtension::CompileAndRunWithOrigin); |
103 } else if (name->Equals(context, v8::String::NewFromUtf8( | 104 } else if (name->Equals(context, v8::String::NewFromUtf8( |
104 isolate, "setCurrentTimeMSForTest", | 105 isolate, "setCurrentTimeMSForTest", |
105 v8::NewStringType::kNormal) | 106 v8::NewStringType::kNormal) |
106 .ToLocalChecked()) | 107 .ToLocalChecked()) |
107 .FromJust()) { | 108 .FromJust()) { |
108 return v8::FunctionTemplate::New(isolate, | 109 return v8::FunctionTemplate::New(isolate, |
109 UtilsExtension::SetCurrentTimeMSForTest); | 110 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); |
110 } else if (name->Equals(context, | 118 } else if (name->Equals(context, |
111 v8::String::NewFromUtf8( | 119 v8::String::NewFromUtf8( |
112 isolate, "schedulePauseOnNextStatement", | 120 isolate, "schedulePauseOnNextStatement", |
113 v8::NewStringType::kNormal) | 121 v8::NewStringType::kNormal) |
114 .ToLocalChecked()) | 122 .ToLocalChecked()) |
115 .FromJust()) { | 123 .FromJust()) { |
116 return v8::FunctionTemplate::New( | 124 return v8::FunctionTemplate::New( |
117 isolate, UtilsExtension::SchedulePauseOnNextStatement); | 125 isolate, UtilsExtension::SchedulePauseOnNextStatement); |
118 } else if (name->Equals(context, v8::String::NewFromUtf8( | 126 } else if (name->Equals(context, v8::String::NewFromUtf8( |
119 isolate, "cancelPauseOnNextStatement", | 127 isolate, "cancelPauseOnNextStatement", |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 static void SetCurrentTimeMSForTest( | 267 static void SetCurrentTimeMSForTest( |
260 const v8::FunctionCallbackInfo<v8::Value>& args) { | 268 const v8::FunctionCallbackInfo<v8::Value>& args) { |
261 if (args.Length() != 1 || !args[0]->IsNumber()) { | 269 if (args.Length() != 1 || !args[0]->IsNumber()) { |
262 fprintf(stderr, "Internal error: setCurrentTimeMSForTest(time)."); | 270 fprintf(stderr, "Internal error: setCurrentTimeMSForTest(time)."); |
263 Exit(); | 271 Exit(); |
264 } | 272 } |
265 inspector_client_->setCurrentTimeMSForTest( | 273 inspector_client_->setCurrentTimeMSForTest( |
266 args[0].As<v8::Number>()->Value()); | 274 args[0].As<v8::Number>()->Value()); |
267 } | 275 } |
268 | 276 |
| 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 |
269 static void SchedulePauseOnNextStatement( | 286 static void SchedulePauseOnNextStatement( |
270 const v8::FunctionCallbackInfo<v8::Value>& args) { | 287 const v8::FunctionCallbackInfo<v8::Value>& args) { |
271 if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsString()) { | 288 if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsString()) { |
272 fprintf( | 289 fprintf( |
273 stderr, | 290 stderr, |
274 "Internal error: schedulePauseOnNextStatement('reason', 'details')."); | 291 "Internal error: schedulePauseOnNextStatement('reason', 'details')."); |
275 Exit(); | 292 Exit(); |
276 } | 293 } |
277 v8::internal::Vector<uint16_t> reason = ToVector(args[0].As<v8::String>()); | 294 v8::internal::Vector<uint16_t> reason = ToVector(args[0].As<v8::String>()); |
278 v8_inspector::StringView reason_view(reason.start(), reason.length()); | 295 v8_inspector::StringView reason_view(reason.start(), reason.length()); |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 argv[i]); | 696 argv[i]); |
680 Exit(); | 697 Exit(); |
681 } | 698 } |
682 frontend_runner.Append(new ExecuteStringTask(chars)); | 699 frontend_runner.Append(new ExecuteStringTask(chars)); |
683 } | 700 } |
684 | 701 |
685 frontend_runner.Join(); | 702 frontend_runner.Join(); |
686 backend_runner.Join(); | 703 backend_runner.Join(); |
687 return 0; | 704 return 0; |
688 } | 705 } |
OLD | NEW |