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

Unified Diff: src/api.cc

Issue 2696163002: [debugger] implement inspector-facing API for code coverage. (Closed)
Patch Set: one more shared export Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/d8.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 9e242382c3fec54e159b723aa51c516dc8cee6f1..955e0832ed73317ff32242d9675d51416d5bc0ff 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -35,6 +35,7 @@
#include "src/contexts.h"
#include "src/conversions-inl.h"
#include "src/counters.h"
+#include "src/debug/debug-coverage.h"
#include "src/debug/debug.h"
#include "src/deoptimizer.h"
#include "src/execution.h"
@@ -9501,6 +9502,52 @@ Local<String> CpuProfileNode::GetFunctionName() const {
}
}
+debug::Coverage::Range::Range(i::CoverageRange* range,
+ Local<debug::Script> script)
+ : range_(range), script_(script) {
+ i::Handle<i::Script> i_script = v8::Utils::OpenHandle(*script);
+ i::Script::PositionInfo start;
+ i::Script::PositionInfo end;
+ i::Script::GetPositionInfo(i_script, range->start, &start,
+ i::Script::WITH_OFFSET);
+ i::Script::GetPositionInfo(i_script, range->end, &end,
+ i::Script::WITH_OFFSET);
+ start_ = Location(start.line, start.column);
+ end_ = Location(end.line, end.column);
+}
+
+uint32_t debug::Coverage::Range::Count() { return range_->count; }
+
+size_t debug::Coverage::Range::NestedCount() { return range_->inner.size(); }
+
+debug::Coverage::Range debug::Coverage::Range::GetNested(size_t i) {
+ return Range(&range_->inner[i], script_);
+}
+
+MaybeLocal<String> debug::Coverage::Range::Name() {
+ return ToApiHandle<String>(range_->name);
+}
+
+debug::Coverage::~Coverage() { delete coverage_; }
+
+size_t debug::Coverage::ScriptCount() { return coverage_->size(); }
+
+Local<debug::Script> debug::Coverage::GetScript(size_t i) {
+ return ToApiHandle<debug::Script>(coverage_->at(i).script);
+}
+
+debug::Coverage::Range debug::Coverage::GetRange(size_t i) {
+ return Range(&coverage_->at(i).toplevel, GetScript(i));
+}
+
+debug::Coverage debug::Coverage::Collect(Isolate* isolate) {
+ return Coverage(i::Coverage::Collect(reinterpret_cast<i::Isolate*>(isolate)));
+}
+
+void debug::Coverage::TogglePrecise(Isolate* isolate, bool enable) {
+ i::Coverage::TogglePrecise(reinterpret_cast<i::Isolate*>(isolate), enable);
+}
+
const char* CpuProfileNode::GetFunctionNameStr() const {
const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
return node->entry()->name();
« no previous file with comments | « no previous file | src/d8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698