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

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

Issue 2465553003: [inspector] added Debugger.getPossibleBreakpoints method (Closed)
Patch Set: addressed comments 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
« no previous file with comments | « src/debug/debug.h ('k') | src/debug/debug-interface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 namespace {
1356 template <typename Iterator>
1357 void GetBreakablePositions(Iterator* it, int start_position, int end_position,
1358 BreakPositionAlignment alignment,
1359 std::set<int>* positions) {
1360 it->SkipToPosition(start_position, alignment);
1361 while (!it->Done() && it->position() < end_position &&
1362 it->position() >= start_position) {
1363 positions->insert(alignment == STATEMENT_ALIGNED ? it->statement_position()
1364 : it->position());
1365 it->Next();
1366 }
1367 }
1368
1369 void FindBreakablePositions(Handle<DebugInfo> debug_info, int start_position,
1370 int end_position, BreakPositionAlignment alignment,
1371 std::set<int>* positions) {
1372 if (debug_info->HasDebugCode()) {
1373 CodeBreakIterator it(debug_info, ALL_BREAK_LOCATIONS);
1374 GetBreakablePositions(&it, start_position, end_position, alignment,
1375 positions);
1376 } else {
1377 DCHECK(debug_info->HasDebugBytecodeArray());
1378 BytecodeArrayBreakIterator it(debug_info, ALL_BREAK_LOCATIONS);
1379 GetBreakablePositions(&it, start_position, end_position, alignment,
1380 positions);
1381 }
1382 }
1383 } // namespace
1384
1385 bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position,
1386 int end_position, std::set<int>* positions) {
1387 while (true) {
1388 if (!script->shared_function_infos()->IsWeakFixedArray()) return false;
1389
1390 WeakFixedArray* infos =
1391 WeakFixedArray::cast(script->shared_function_infos());
1392 HandleScope scope(isolate_);
1393 List<Handle<SharedFunctionInfo>> candidates;
1394 {
1395 WeakFixedArray::Iterator iterator(infos);
1396 SharedFunctionInfo* info;
1397 while ((info = iterator.Next<SharedFunctionInfo>())) {
1398 if (info->end_position() < start_position ||
1399 info->start_position() >= end_position) {
1400 continue;
1401 }
1402 if (!info->IsSubjectToDebugging()) continue;
1403 if (!info->HasDebugCode() && !info->allows_lazy_compilation()) continue;
1404 candidates.Add(i::handle(info));
1405 }
1406 }
1407
1408 bool was_compiled = false;
1409 for (int i = 0; i < candidates.length(); ++i) {
1410 if (!candidates[i]->HasDebugCode()) {
1411 if (!Compiler::CompileDebugCode(candidates[i])) {
1412 return false;
1413 } else {
1414 was_compiled = true;
1415 }
1416 }
1417 if (!candidates[i]->HasDebugInfo()) CreateDebugInfo(candidates[i]);
1418 }
1419 if (was_compiled) continue;
1420
1421 for (int i = 0; i < candidates.length(); ++i) {
1422 CHECK(candidates[i]->HasDebugInfo());
1423 Handle<DebugInfo> debug_info(candidates[i]->GetDebugInfo());
1424 FindBreakablePositions(debug_info, start_position, end_position,
1425 STATEMENT_ALIGNED, positions);
1426 }
1427 return true;
1428 }
1429 UNREACHABLE();
1430 return false;
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 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after
2563 } 2641 }
2564 2642
2565 2643
2566 void LockingCommandMessageQueue::Clear() { 2644 void LockingCommandMessageQueue::Clear() {
2567 base::LockGuard<base::Mutex> lock_guard(&mutex_); 2645 base::LockGuard<base::Mutex> lock_guard(&mutex_);
2568 queue_.Clear(); 2646 queue_.Clear();
2569 } 2647 }
2570 2648
2571 } // namespace internal 2649 } // namespace internal
2572 } // namespace v8 2650 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/debug.h ('k') | src/debug/debug-interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698