Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: test/inspector/inspector-test.cc

Issue 2579403002: [inspector] introduce limit for amount of stored async stacks (Closed)
Patch Set: addressed comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/inspector/debugger/async-stacks-limit-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "include/libplatform/libplatform.h" 11 #include "include/libplatform/libplatform.h"
12 #include "include/v8.h" 12 #include "include/v8.h"
13 13
14 #include "src/base/platform/platform.h" 14 #include "src/base/platform/platform.h"
15 #include "src/flags.h" 15 #include "src/flags.h"
16 #include "src/inspector/test-interface.h"
16 #include "src/utils.h" 17 #include "src/utils.h"
17 #include "src/vector.h" 18 #include "src/vector.h"
18 19
19 #include "test/inspector/inspector-impl.h" 20 #include "test/inspector/inspector-impl.h"
20 #include "test/inspector/task-runner.h" 21 #include "test/inspector/task-runner.h"
21 22
22 namespace { 23 namespace {
23 24
24 std::vector<TaskRunner*> task_runners; 25 std::vector<TaskRunner*> task_runners;
25 26
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 } 251 }
251 TaskRunner::FromContext(context)->Append(task.release()); 252 TaskRunner::FromContext(context)->Append(task.release());
252 } 253 }
253 }; 254 };
254 255
255 class InspectorExtension : public v8::Extension { 256 class InspectorExtension : public v8::Extension {
256 public: 257 public:
257 InspectorExtension() 258 InspectorExtension()
258 : v8::Extension("v8_inspector/inspector", 259 : v8::Extension("v8_inspector/inspector",
259 "native function attachInspector();" 260 "native function attachInspector();"
260 "native function detachInspector();") {} 261 "native function detachInspector();"
262 "native function setMaxAsyncTaskStacks();") {}
261 263
262 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( 264 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
263 v8::Isolate* isolate, v8::Local<v8::String> name) { 265 v8::Isolate* isolate, v8::Local<v8::String> name) {
264 v8::Local<v8::Context> context = isolate->GetCurrentContext(); 266 v8::Local<v8::Context> context = isolate->GetCurrentContext();
265 if (name->Equals(context, 267 if (name->Equals(context,
266 v8::String::NewFromUtf8(isolate, "attachInspector", 268 v8::String::NewFromUtf8(isolate, "attachInspector",
267 v8::NewStringType::kNormal) 269 v8::NewStringType::kNormal)
268 .ToLocalChecked()) 270 .ToLocalChecked())
269 .FromJust()) { 271 .FromJust()) {
270 return v8::FunctionTemplate::New(isolate, InspectorExtension::Attach); 272 return v8::FunctionTemplate::New(isolate, InspectorExtension::Attach);
271 } else if (name->Equals(context, 273 } else if (name->Equals(context,
272 v8::String::NewFromUtf8(isolate, "detachInspector", 274 v8::String::NewFromUtf8(isolate, "detachInspector",
273 v8::NewStringType::kNormal) 275 v8::NewStringType::kNormal)
274 .ToLocalChecked()) 276 .ToLocalChecked())
275 .FromJust()) { 277 .FromJust()) {
276 return v8::FunctionTemplate::New(isolate, InspectorExtension::Detach); 278 return v8::FunctionTemplate::New(isolate, InspectorExtension::Detach);
279 } else if (name->Equals(context, v8::String::NewFromUtf8(
280 isolate, "setMaxAsyncTaskStacks",
281 v8::NewStringType::kNormal)
282 .ToLocalChecked())
283 .FromJust()) {
284 return v8::FunctionTemplate::New(
285 isolate, InspectorExtension::SetMaxAsyncTaskStacks);
277 } 286 }
278 return v8::Local<v8::FunctionTemplate>(); 287 return v8::Local<v8::FunctionTemplate>();
279 } 288 }
280 289
281 private: 290 private:
282 static void Attach(const v8::FunctionCallbackInfo<v8::Value>& args) { 291 static void Attach(const v8::FunctionCallbackInfo<v8::Value>& args) {
283 v8::Isolate* isolate = args.GetIsolate(); 292 v8::Isolate* isolate = args.GetIsolate();
284 v8::Local<v8::Context> context = isolate->GetCurrentContext(); 293 v8::Local<v8::Context> context = isolate->GetCurrentContext();
285 v8_inspector::V8Inspector* inspector = 294 v8_inspector::V8Inspector* inspector =
286 InspectorClientImpl::InspectorFromContext(context); 295 InspectorClientImpl::InspectorFromContext(context);
287 if (!inspector) { 296 if (!inspector) {
288 fprintf(stderr, "Inspector client not found - cannot attach!"); 297 fprintf(stderr, "Inspector client not found - cannot attach!");
289 Exit(); 298 Exit();
290 } 299 }
291 inspector->contextCreated( 300 inspector->contextCreated(
292 v8_inspector::V8ContextInfo(context, 1, v8_inspector::StringView())); 301 v8_inspector::V8ContextInfo(context, 1, v8_inspector::StringView()));
293 } 302 }
294 303
295 static void Detach(const v8::FunctionCallbackInfo<v8::Value>& args) { 304 static void Detach(const v8::FunctionCallbackInfo<v8::Value>& args) {
296 v8::Isolate* isolate = args.GetIsolate(); 305 v8::Isolate* isolate = args.GetIsolate();
297 v8::Local<v8::Context> context = isolate->GetCurrentContext(); 306 v8::Local<v8::Context> context = isolate->GetCurrentContext();
298 v8_inspector::V8Inspector* inspector = 307 v8_inspector::V8Inspector* inspector =
299 InspectorClientImpl::InspectorFromContext(context); 308 InspectorClientImpl::InspectorFromContext(context);
300 if (!inspector) { 309 if (!inspector) {
301 fprintf(stderr, "Inspector client not found - cannot detach!"); 310 fprintf(stderr, "Inspector client not found - cannot detach!");
302 Exit(); 311 Exit();
303 } 312 }
304 inspector->contextDestroyed(context); 313 inspector->contextDestroyed(context);
305 } 314 }
315
316 static void SetMaxAsyncTaskStacks(
317 const v8::FunctionCallbackInfo<v8::Value>& args) {
318 if (args.Length() != 1 || !args[0]->IsInt32()) {
319 fprintf(stderr, "Internal error: setMaxAsyncTaskStacks(max).");
320 Exit();
321 }
322 v8_inspector::V8Inspector* inspector =
323 InspectorClientImpl::InspectorFromContext(
324 args.GetIsolate()->GetCurrentContext());
325 CHECK(inspector);
326 v8_inspector::SetMaxAsyncTaskStacksForTest(
327 inspector, args[0].As<v8::Int32>()->Value());
328 }
306 }; 329 };
307 330
308 v8::Local<v8::String> ToString(v8::Isolate* isolate, 331 v8::Local<v8::String> ToString(v8::Isolate* isolate,
309 const v8_inspector::StringView& string) { 332 const v8_inspector::StringView& string) {
310 if (string.is8Bit()) 333 if (string.is8Bit())
311 return v8::String::NewFromOneByte(isolate, string.characters8(), 334 return v8::String::NewFromOneByte(isolate, string.characters8(),
312 v8::NewStringType::kNormal, 335 v8::NewStringType::kNormal,
313 static_cast<int>(string.length())) 336 static_cast<int>(string.length()))
314 .ToLocalChecked(); 337 .ToLocalChecked();
315 else 338 else
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 argv[i]); 430 argv[i]);
408 Exit(); 431 Exit();
409 } 432 }
410 frontend_runner.Append(new ExecuteStringTask(chars)); 433 frontend_runner.Append(new ExecuteStringTask(chars));
411 } 434 }
412 435
413 frontend_runner.Join(); 436 frontend_runner.Join();
414 backend_runner.Join(); 437 backend_runner.Join();
415 return 0; 438 return 0;
416 } 439 }
OLDNEW
« no previous file with comments | « test/inspector/debugger/async-stacks-limit-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698