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

Side by Side Diff: src/debug/debug.cc

Issue 2465553003: [inspector] added Debugger.getPossibleBreakpoints method (Closed)
Patch Set: it works Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #include "src/debug/debug.h" 5 #include "src/debug/debug.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 } 1345 }
1346 1346
1347 // Update PCs on the stack to point to recompiled code. 1347 // Update PCs on the stack to point to recompiled code.
1348 RedirectActiveFunctions redirect_visitor(*shared); 1348 RedirectActiveFunctions redirect_visitor(*shared);
1349 redirect_visitor.VisitThread(isolate_, isolate_->thread_local_top()); 1349 redirect_visitor.VisitThread(isolate_, isolate_->thread_local_top());
1350 isolate_->thread_manager()->IterateArchivedThreads(&redirect_visitor); 1350 isolate_->thread_manager()->IterateArchivedThreads(&redirect_visitor);
1351 1351
1352 return true; 1352 return true;
1353 } 1353 }
1354 1354
1355 bool Debug::FindBreakablePositions(Handle<DebugInfo> debug_info,
1356 int start_position, int end_position,
1357 BreakPositionAlignment alignment,
1358 std::vector<int>& offsets) {
1359 int statement_position;
1360 int position;
1361 if (debug_info->HasDebugCode()) {
1362 CodeBreakIterator it(debug_info, ALL_BREAK_LOCATIONS);
1363 it.SkipToPosition(start_position, alignment);
1364 while (!it.Done() && it.position() < end_position &&
1365 it.position() >= start_position) {
1366 statement_position = it.statement_position();
1367 position = it.position();
1368 offsets.push_back(alignment == STATEMENT_ALIGNED ? statement_position
1369 : position);
1370 it.Next();
1371 }
1372 } else {
1373 DCHECK(debug_info->HasDebugBytecodeArray());
1374 BytecodeArrayBreakIterator it(debug_info, ALL_BREAK_LOCATIONS);
Yang 2016/11/02 13:51:15 This is just duplicate code. Can we either use vir
kozy 2016/11/03 01:15:02 Done.
1375 it.SkipToPosition(start_position, alignment);
1376 while (!it.Done() && it.position() < end_position &&
1377 it.position() >= start_position) {
1378 statement_position = it.statement_position();
1379 position = it.position();
1380 offsets.push_back(alignment == STATEMENT_ALIGNED ? statement_position
1381 : position);
1382 it.Next();
1383 }
1384 }
1385 return true;
1386 }
1387
1388 bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position,
1389 int end_position,
1390 std::vector<int>& offsets) {
1391 for (int iteration = 0;; iteration++) {
1392 std::vector<int> current;
1393 if (!script->shared_function_infos()->IsWeakFixedArray()) break;
1394 WeakFixedArray::Iterator iterator(script->shared_function_infos());
1395 SharedFunctionInfo* candidate;
1396 bool should_restart = false;
1397 while ((candidate = iterator.Next<SharedFunctionInfo>())) {
1398 if (!candidate) break;
Yang 2016/11/02 13:51:15 this seems redundant.
kozy 2016/11/03 01:15:02 Removed.
1399 if (candidate->end_position() < start_position ||
1400 candidate->start_position() >= end_position)
1401 continue;
1402 if (candidate->HasDebugCode()) {
1403 Handle<SharedFunctionInfo> shared_handle(candidate);
1404 if (!shared_handle->IsSubjectToDebugging()) continue;
1405 if (!shared_handle->HasDebugInfo()) {
1406 AllowHeapAllocation allow_before_return;
Yang 2016/11/02 13:51:15 This is not safe. Once GC happens, the weak fixed
kozy 2016/11/03 01:15:02 Thank you! Done.
1407 CreateDebugInfo(shared_handle);
1408 }
1409 Handle<DebugInfo> debug_info(shared_handle->GetDebugInfo());
1410 if (!FindBreakablePositions(debug_info, start_position, end_position,
1411 STATEMENT_ALIGNED, current))
1412 return false;
1413 continue;
1414 }
1415 if (candidate->allows_lazy_compilation()) {
1416 HandleScope scope(isolate_);
1417 AllowHeapAllocation allow_before_return;
1418 if (!Compiler::CompileDebugCode(handle(candidate))) {
1419 return false;
1420 } else {
1421 should_restart = true;
1422 }
1423 break;
1424 }
1425 }
1426 if (should_restart) continue;
1427 offsets.swap(current);
1428 return true;
1429 }
1430 return true;
1431 }
1432
1355 void Debug::RecordAsyncFunction(Handle<JSGeneratorObject> generator_object) { 1433 void Debug::RecordAsyncFunction(Handle<JSGeneratorObject> generator_object) {
1356 if (last_step_action() <= StepOut) return; 1434 if (last_step_action() <= StepOut) return;
1357 if (!IsAsyncFunction(generator_object->function()->shared()->kind())) return; 1435 if (!IsAsyncFunction(generator_object->function()->shared()->kind())) return;
1358 DCHECK(!has_suspended_generator()); 1436 DCHECK(!has_suspended_generator());
1359 thread_local_.suspended_generator_ = *generator_object; 1437 thread_local_.suspended_generator_ = *generator_object;
1360 ClearStepping(); 1438 ClearStepping();
1361 } 1439 }
1362 1440
1363 class SharedFunctionInfoFinder { 1441 class SharedFunctionInfoFinder {
1364 public: 1442 public:
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after
2561 } 2639 }
2562 2640
2563 2641
2564 void LockingCommandMessageQueue::Clear() { 2642 void LockingCommandMessageQueue::Clear() {
2565 base::LockGuard<base::Mutex> lock_guard(&mutex_); 2643 base::LockGuard<base::Mutex> lock_guard(&mutex_);
2566 queue_.Clear(); 2644 queue_.Clear();
2567 } 2645 }
2568 2646
2569 } // namespace internal 2647 } // namespace internal
2570 } // namespace v8 2648 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/debug.h ('k') | src/debug/debug-interface.h » ('j') | src/debug/debug-interface.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698