Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion profile_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void AutoFDOProfileReader::ReadNameTable() {
}
uint32_t name_vector_size = gcov_read_unsigned();
for (uint32_t i = 0; i < name_vector_size; i++) {
const char *name = gcov_read_string();
std::string name = gcov_read_string();
uint32_t file_index =
absl::GetFlag(FLAGS_gcov_version) >= 3 ? gcov_read_unsigned() : -1;
names_.emplace_back(name, file_index);
Expand Down
8 changes: 6 additions & 2 deletions profile_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,17 @@ class SourceProfileWriter: public SymbolTraverser {

virtual void VisitTopSymbol(const std::string &name, const Symbol *node) {
gcov_write_counter(node->head_count);
gcov_write_unsigned(GetStringIndex(Symbol::Name(name.c_str())));
unsigned NameIdx = GetStringIndex(Symbol::Name(name.c_str()));
CHECK(NameIdx != 0 && "name index 0 should never be present as a top-level symbol!");
gcov_write_unsigned(NameIdx);
}

virtual void VisitCallsite(const Callsite &callsite) {
uint64_t value = callsite.location;
gcov_write_unsigned(SourceInfo::GenerateCompressedOffset(value));
gcov_write_unsigned(GetStringIndex(Symbol::Name(callsite.callee_name)));
unsigned NameIdx = GetStringIndex(Symbol::Name(callsite.callee_name));
CHECK(NameIdx != 0 && "name index 0 should never be present as a callee!");
gcov_write_unsigned(NameIdx);
}

private:
Expand Down
3 changes: 2 additions & 1 deletion symbol_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ class Symbol {
~Symbol();

static std::string Name(const char *name) {
return (name && strlen(name) > 0) ? name : "noname";
CHECK(name && strlen(name) > 0 && "Empty string should never occur in profile!");
return name;
}

std::string name() const { return Name(info.func_name); }
Expand Down
Loading