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

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

Issue 2728563002: [inspector] added type of break location into getPossibleBreakpoints output (Closed)
Patch Set: fixed compilation Created 3 years, 9 months 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 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 RedirectActiveFunctions redirect_visitor(*shared); 1308 RedirectActiveFunctions redirect_visitor(*shared);
1309 redirect_visitor.VisitThread(isolate_, isolate_->thread_local_top()); 1309 redirect_visitor.VisitThread(isolate_, isolate_->thread_local_top());
1310 isolate_->thread_manager()->IterateArchivedThreads(&redirect_visitor); 1310 isolate_->thread_manager()->IterateArchivedThreads(&redirect_visitor);
1311 1311
1312 return true; 1312 return true;
1313 } 1313 }
1314 1314
1315 namespace { 1315 namespace {
1316 template <typename Iterator> 1316 template <typename Iterator>
1317 void GetBreakablePositions(Iterator* it, int start_position, int end_position, 1317 void GetBreakablePositions(Iterator* it, int start_position, int end_position,
1318 BreakPositionAlignment alignment, 1318 std::vector<BreakLocation>* locations) {
1319 std::set<int>* positions) { 1319 it->SkipToPosition(start_position, BREAK_POSITION_ALIGNED);
1320 it->SkipToPosition(start_position, alignment);
1321 while (!it->Done() && it->position() < end_position && 1320 while (!it->Done() && it->position() < end_position &&
1322 it->position() >= start_position) { 1321 it->position() >= start_position) {
1323 positions->insert(alignment == STATEMENT_ALIGNED ? it->statement_position() 1322 locations->push_back(it->GetBreakLocation());
1324 : it->position());
1325 it->Next(); 1323 it->Next();
1326 } 1324 }
1327 } 1325 }
1328 1326
1329 void FindBreakablePositions(Handle<DebugInfo> debug_info, int start_position, 1327 void FindBreakablePositions(Handle<DebugInfo> debug_info, int start_position,
1330 int end_position, BreakPositionAlignment alignment, 1328 int end_position,
1331 std::set<int>* positions) { 1329 std::vector<BreakLocation>* locations) {
1332 if (debug_info->HasDebugCode()) { 1330 if (debug_info->HasDebugCode()) {
1333 CodeBreakIterator it(debug_info); 1331 CodeBreakIterator it(debug_info);
1334 GetBreakablePositions(&it, start_position, end_position, alignment, 1332 GetBreakablePositions(&it, start_position, end_position, locations);
1335 positions);
1336 } else { 1333 } else {
1337 DCHECK(debug_info->HasDebugBytecodeArray()); 1334 DCHECK(debug_info->HasDebugBytecodeArray());
1338 BytecodeArrayBreakIterator it(debug_info); 1335 BytecodeArrayBreakIterator it(debug_info);
1339 GetBreakablePositions(&it, start_position, end_position, alignment, 1336 GetBreakablePositions(&it, start_position, end_position, locations);
1340 positions);
1341 } 1337 }
1342 } 1338 }
1343 } // namespace 1339 } // namespace
1344 1340
1345 bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position, 1341 bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position,
1346 int end_position, bool restrict_to_function, 1342 int end_position, bool restrict_to_function,
1347 std::set<int>* positions) { 1343 std::vector<BreakLocation>* locations) {
1348 if (restrict_to_function) { 1344 if (restrict_to_function) {
1349 Handle<Object> result = 1345 Handle<Object> result =
1350 FindSharedFunctionInfoInScript(script, start_position); 1346 FindSharedFunctionInfoInScript(script, start_position);
1351 if (result->IsUndefined(isolate_)) return false; 1347 if (result->IsUndefined(isolate_)) return false;
1352 1348
1353 // Make sure the function has set up the debug info. 1349 // Make sure the function has set up the debug info.
1354 Handle<SharedFunctionInfo> shared = 1350 Handle<SharedFunctionInfo> shared =
1355 Handle<SharedFunctionInfo>::cast(result); 1351 Handle<SharedFunctionInfo>::cast(result);
1356 if (!EnsureDebugInfo(shared)) return false; 1352 if (!EnsureDebugInfo(shared)) return false;
1357 1353
1358 Handle<DebugInfo> debug_info(shared->GetDebugInfo()); 1354 Handle<DebugInfo> debug_info(shared->GetDebugInfo());
1359 FindBreakablePositions(debug_info, start_position, end_position, 1355 FindBreakablePositions(debug_info, start_position, end_position, locations);
1360 BREAK_POSITION_ALIGNED, positions);
1361 return true; 1356 return true;
1362 } 1357 }
1363 1358
1364 while (true) { 1359 while (true) {
1365 HandleScope scope(isolate_); 1360 HandleScope scope(isolate_);
1366 List<Handle<SharedFunctionInfo>> candidates; 1361 List<Handle<SharedFunctionInfo>> candidates;
1367 SharedFunctionInfo::ScriptIterator iterator(script); 1362 SharedFunctionInfo::ScriptIterator iterator(script);
1368 for (SharedFunctionInfo* info = iterator.Next(); info != nullptr; 1363 for (SharedFunctionInfo* info = iterator.Next(); info != nullptr;
1369 info = iterator.Next()) { 1364 info = iterator.Next()) {
1370 if (info->end_position() < start_position || 1365 if (info->end_position() < start_position ||
(...skipping 17 matching lines...) Expand all
1388 } 1383 }
1389 } 1384 }
1390 if (!EnsureDebugInfo(candidates[i])) return false; 1385 if (!EnsureDebugInfo(candidates[i])) return false;
1391 } 1386 }
1392 if (was_compiled) continue; 1387 if (was_compiled) continue;
1393 1388
1394 for (int i = 0; i < candidates.length(); ++i) { 1389 for (int i = 0; i < candidates.length(); ++i) {
1395 CHECK(candidates[i]->HasDebugInfo()); 1390 CHECK(candidates[i]->HasDebugInfo());
1396 Handle<DebugInfo> debug_info(candidates[i]->GetDebugInfo()); 1391 Handle<DebugInfo> debug_info(candidates[i]->GetDebugInfo());
1397 FindBreakablePositions(debug_info, start_position, end_position, 1392 FindBreakablePositions(debug_info, start_position, end_position,
1398 BREAK_POSITION_ALIGNED, positions); 1393 locations);
1399 } 1394 }
1400 return true; 1395 return true;
1401 } 1396 }
1402 UNREACHABLE(); 1397 UNREACHABLE();
1403 return false; 1398 return false;
1404 } 1399 }
1405 1400
1406 void Debug::RecordGenerator(Handle<JSGeneratorObject> generator_object) { 1401 void Debug::RecordGenerator(Handle<JSGeneratorObject> generator_object) {
1407 if (last_step_action() <= StepOut) return; 1402 if (last_step_action() <= StepOut) return;
1408 1403
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
2426 isolate_->Throw(*isolate_->factory()->NewEvalError( 2421 isolate_->Throw(*isolate_->factory()->NewEvalError(
2427 MessageTemplate::kNoSideEffectDebugEvaluate)); 2422 MessageTemplate::kNoSideEffectDebugEvaluate));
2428 } 2423 }
2429 isolate_->set_needs_side_effect_check(old_needs_side_effect_check_); 2424 isolate_->set_needs_side_effect_check(old_needs_side_effect_check_);
2430 isolate_->debug()->UpdateHookOnFunctionCall(); 2425 isolate_->debug()->UpdateHookOnFunctionCall();
2431 isolate_->debug()->side_effect_check_failed_ = false; 2426 isolate_->debug()->side_effect_check_failed_ = false;
2432 } 2427 }
2433 2428
2434 } // namespace internal 2429 } // namespace internal
2435 } // namespace v8 2430 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698