| 267 | } |
| 268 | |
| 269 | void FlameGraph::printCpool(Writer& out) { |
| 270 | out << "'all'"; |
| 271 | |
| 272 | std::string prev; |
| 273 | u32 index = 0; |
| 274 | for (std::map<std::string, u32>::const_iterator it = _cpool.begin(); it != _cpool.end(); ++it) { |
| 275 | if (_name_order[it->second]) { |
| 276 | _name_order[it->second] = ++index; |
| 277 | |
| 278 | size_t prefix_len = StringUtils::getCommonPrefix(prev, it->first); |
| 279 | prev = it->first; |
| 280 | |
| 281 | if (prefix_len > 95) prefix_len = 95; |
| 282 | std::string s(1, (char)(prefix_len + ' ')); |
| 283 | s.append(it->first, prefix_len, std::string::npos); |
| 284 | |
| 285 | StringUtils::replace(s, '\\', "\\\\", 2); |
| 286 | StringUtils::replace(s, '\'', "\\'", 2); |
| 287 | out << ",\n'"; |
| 288 | out.write(s.data(), s.size()); |
| 289 | out << "'"; |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | // Release cpool memory, since frame names are never used beyond this point |
| 294 | _cpool = std::map<std::string, u32>(); |
| 295 | } |
| 296 | |
| 297 | const char* FlameGraph::printTill(Writer& out, const char* data, const char* till) { |
| 298 | const char* pos = strstr(data, till); |