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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: src/debug/debug.cc
diff --git a/src/debug/debug.cc b/src/debug/debug.cc
index 711f54d9ff2c043f0ea3f55c20da6485fc9caa14..2744501c3b7089ee497e1cc4e15bb5abcc861f62 100644
--- a/src/debug/debug.cc
+++ b/src/debug/debug.cc
@@ -1352,6 +1352,84 @@ bool Debug::PrepareFunctionForBreakPoints(Handle<SharedFunctionInfo> shared) {
return true;
}
+bool Debug::FindBreakablePositions(Handle<DebugInfo> debug_info,
+ int start_position, int end_position,
+ BreakPositionAlignment alignment,
+ std::vector<int>& offsets) {
+ int statement_position;
+ int position;
+ if (debug_info->HasDebugCode()) {
+ CodeBreakIterator it(debug_info, ALL_BREAK_LOCATIONS);
+ it.SkipToPosition(start_position, alignment);
+ while (!it.Done() && it.position() < end_position &&
+ it.position() >= start_position) {
+ statement_position = it.statement_position();
+ position = it.position();
+ offsets.push_back(alignment == STATEMENT_ALIGNED ? statement_position
+ : position);
+ it.Next();
+ }
+ } else {
+ DCHECK(debug_info->HasDebugBytecodeArray());
+ 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.
+ it.SkipToPosition(start_position, alignment);
+ while (!it.Done() && it.position() < end_position &&
+ it.position() >= start_position) {
+ statement_position = it.statement_position();
+ position = it.position();
+ offsets.push_back(alignment == STATEMENT_ALIGNED ? statement_position
+ : position);
+ it.Next();
+ }
+ }
+ return true;
+}
+
+bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position,
+ int end_position,
+ std::vector<int>& offsets) {
+ for (int iteration = 0;; iteration++) {
+ std::vector<int> current;
+ if (!script->shared_function_infos()->IsWeakFixedArray()) break;
+ WeakFixedArray::Iterator iterator(script->shared_function_infos());
+ SharedFunctionInfo* candidate;
+ bool should_restart = false;
+ while ((candidate = iterator.Next<SharedFunctionInfo>())) {
+ if (!candidate) break;
Yang 2016/11/02 13:51:15 this seems redundant.
kozy 2016/11/03 01:15:02 Removed.
+ if (candidate->end_position() < start_position ||
+ candidate->start_position() >= end_position)
+ continue;
+ if (candidate->HasDebugCode()) {
+ Handle<SharedFunctionInfo> shared_handle(candidate);
+ if (!shared_handle->IsSubjectToDebugging()) continue;
+ if (!shared_handle->HasDebugInfo()) {
+ 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.
+ CreateDebugInfo(shared_handle);
+ }
+ Handle<DebugInfo> debug_info(shared_handle->GetDebugInfo());
+ if (!FindBreakablePositions(debug_info, start_position, end_position,
+ STATEMENT_ALIGNED, current))
+ return false;
+ continue;
+ }
+ if (candidate->allows_lazy_compilation()) {
+ HandleScope scope(isolate_);
+ AllowHeapAllocation allow_before_return;
+ if (!Compiler::CompileDebugCode(handle(candidate))) {
+ return false;
+ } else {
+ should_restart = true;
+ }
+ break;
+ }
+ }
+ if (should_restart) continue;
+ offsets.swap(current);
+ return true;
+ }
+ return true;
+}
+
void Debug::RecordAsyncFunction(Handle<JSGeneratorObject> generator_object) {
if (last_step_action() <= StepOut) return;
if (!IsAsyncFunction(generator_object->function()->shared()->kind())) return;
« 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