TODO(metzman): replace std::string with std::string_view for better performance. Need to figure our how to use string_view on Windows.
| 137 | // TODO(metzman): replace std::string with std::string_view for |
| 138 | // better performance. Need to figure our how to use string_view on Windows. |
| 139 | static bool ParseDFTLine(const std::string &Line, size_t *FunctionNum, |
| 140 | std::string *DFTString) { |
| 141 | if (!Line.empty() && Line[0] != 'F') |
| 142 | return false; // Ignore coverage. |
| 143 | size_t SpacePos = Line.find(' '); |
| 144 | if (SpacePos == std::string::npos) |
| 145 | return ParseError("no space in the trace line", Line); |
| 146 | if (Line.empty() || Line[0] != 'F') |
| 147 | return ParseError("the trace line doesn't start with 'F'", Line); |
| 148 | *FunctionNum = std::atol(Line.c_str() + 1); |
| 149 | const char *Beg = Line.c_str() + SpacePos + 1; |
| 150 | const char *End = Line.c_str() + Line.size(); |
| 151 | assert(Beg < End); |
| 152 | size_t Len = End - Beg; |
| 153 | for (size_t I = 0; I < Len; I++) { |
| 154 | if (Beg[I] != '0' && Beg[I] != '1') |
| 155 | return ParseError("the trace should contain only 0 or 1", Line); |
| 156 | } |
| 157 | *DFTString = Beg; |
| 158 | return true; |
| 159 | } |
| 160 | |
| 161 | bool DataFlowTrace::Init(const std::string &DirPath, std::string *FocusFunction, |
| 162 | std::vector<SizedFile> &CorporaFiles, Random &Rand) { |