#ifndef V8_DEBUG_DEBUG_COVERAGE_H_
#define V8_DEBUG_DEBUG_COVERAGE_H_
#include <memory>
#include <vector>
#include "src/debug/debug-interface.h"
#include "src/handles/handles.h"
#include "src/objects/objects.h"
namespace v8 {
namespace internal {
class Isolate;
struct CoverageBlock {
CoverageBlock(int s, int e, uint32_t c) : start(s), end(e), count(c) {}
CoverageBlock() : CoverageBlock(kNoSourcePosition, kNoSourcePosition, 0) {}
int start;
int end;
uint32_t count;
};
struct CoverageFunction {
CoverageFunction(int s, int e, uint32_t c, Handle<String> n)
: start(s), end(e), count(c), name(n), has_block_coverage(false) {}
bool HasNonEmptySourceRange() const { return start < end && start >= 0; }
bool HasBlocks() const { return !blocks.empty(); }
int start;
int end;
uint32_t count;
Handle<String> name;
std::vector<CoverageBlock> blocks;
bool has_block_coverage;
};
struct CoverageScript {
explicit CoverageScript(Handle<Script> s) : script(s) {}
Handle<Script> script;
std::vector<CoverageFunction> functions;
};
class Coverage : public std::vector<CoverageScript> {
public:
static std::unique_ptr<Coverage> CollectPrecise(Isolate* isolate);
static std::unique_ptr<Coverage> CollectBestEffort(Isolate* isolate);
static void SelectMode(Isolate* isolate, debug::CoverageMode mode);
private:
static std::unique_ptr<Coverage> Collect(
Isolate* isolate, v8::debug::CoverageMode collectionMode);
Coverage() = default;
};
}
}
#endif