Skip to content
Open
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
8 changes: 4 additions & 4 deletions llvm_profile_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ class LLVMSourceProfileWriter : public SymbolTraverser {
}

protected:
void WriteSourceLocation(uint32 start_line, uint32 offset) {
void WriteSourceLocation(uint32 offset) {
if (offset & 0xffff) {
fprintf(outf_, "%u.%u: ", (offset >> 16) + start_line, offset & 0xffff);
fprintf(outf_, "%u.%u: ", offset >> 16, offset & 0xffff);
} else {
fprintf(outf_, "%u: ", (offset >> 16) + start_line);
fprintf(outf_, "%u: ", offset >> 16);
}
}

Expand Down Expand Up @@ -78,7 +78,7 @@ class LLVMSourceProfileWriter : public SymbolTraverser {
for (const auto &pos : positions) {
PositionCountMap::const_iterator ret = node->pos_counts.find(pos);
DCHECK(ret != node->pos_counts.end());
WriteSourceLocation(node->info.start_line, pos);
WriteSourceLocation(pos);
fprintf(outf_, "%llu", ret->second.count);

// If there is a call at this location, emit the possible
Expand Down
1 change: 1 addition & 0 deletions symbol_map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ void SymbolMap::AddSourceCount(const string &symbol_name,
return;
}
Symbol *symbol = TraverseInlineStack(symbol_name, src, count);
symbol->info.start_line = src[0].start_line;
if (op == MAX) {
if (count > symbol->pos_counts[src[0].Offset()].count) {
symbol->pos_counts[src[0].Offset()].count = count;
Expand Down
37 changes: 25 additions & 12 deletions symbolize/addr2line_inlinestack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ bool InlineStackHandler::StartSplitCompilationUnit(uint64 offset,
return true;
}

const SubprogramInfo *
InlineStackHandler::FindSubprogramInfo(uint64 abstract_origin) const {
for (SubprogramsByOffsetMap *sbo : subprograms_by_offset_maps_) {
//printf(" %lld\n", kv.first);
auto I = sbo->find(abstract_origin);
if (I != sbo->end())
return I->second;
}
return nullptr;
}

void InlineStackHandler::CleanupUnusedSubprograms() {
SubprogramsByOffsetMap* subprograms_by_offset =
subprograms_by_offset_maps_.back();
Expand Down Expand Up @@ -181,7 +192,7 @@ void InlineStackHandler::EndDIE(uint64 offset) {
subprogram_stack_.pop_back();
}
if (die == DW_TAG_compile_unit && sampled_functions_ != NULL) {
CleanupUnusedSubprograms();
//CleanupUnusedSubprograms();
}
}

Expand Down Expand Up @@ -247,9 +258,14 @@ void InlineStackHandler::ProcessAttributeUnsigned(
subprogram_stack_.back()->set_callsite_discr(data);
break;
case DW_AT_abstract_origin:
CHECK(form == DW_FORM_ref4);
subprogram_stack_.back()->set_abstract_origin(
compilation_unit_offset_ + data);
CHECK(form == DW_FORM_ref4 ||
form == DW_FORM_ref_addr);
if (form == DW_FORM_ref4) {
subprogram_stack_.back()->set_abstract_origin(
compilation_unit_offset_ + data);
} else {
subprogram_stack_.back()->set_abstract_origin(data);
}
break;
case DW_AT_specification:
CHECK(form == DW_FORM_ref4);
Expand Down Expand Up @@ -547,7 +563,7 @@ const SubprogramInfo *InlineStackHandler::GetDeclaration(
} else {
uint64 abstract_origin = declaration->abstract_origin();
if (abstract_origin)
declaration = subprograms_by_offset->find(abstract_origin)->second;
declaration = FindSubprogramInfo(abstract_origin);
else
break;
}
Expand All @@ -557,13 +573,10 @@ const SubprogramInfo *InlineStackHandler::GetDeclaration(

const SubprogramInfo *InlineStackHandler::GetAbstractOrigin(
const SubprogramInfo *subprog) const {
const int cu_index = subprog->cu_index();
CHECK(cu_index < subprograms_by_offset_maps_.size());
SubprogramsByOffsetMap* subprograms_by_offset =
subprograms_by_offset_maps_[cu_index];
if (subprog->abstract_origin())
return subprograms_by_offset->find(subprog->abstract_origin())->second;
else
if (subprog->abstract_origin()) {
const SubprogramInfo *info = FindSubprogramInfo(subprog->abstract_origin());
return info;
} else
return subprog;
}

Expand Down
1 change: 1 addition & 0 deletions symbolize/addr2line_inlinestack.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class InlineStackHandler: public Dwarf2Handler {

// Cleans up memory consumed by subprograms that are not used.
void CleanupUnusedSubprograms();
const SubprogramInfo *FindSubprogramInfo(uint64 abstract_origin) const;

void PopulateSubprogramsByAddress();

Expand Down
11 changes: 4 additions & 7 deletions symbolize/dwarf2reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,11 @@ const char* CompilationUnit::SkipAttribute(const char* start,
break;
case DW_FORM_ref_addr:
// DWARF2 and 3 differ on whether ref_addr is address size or
// offset size.
if (header_.version == 2) {
return start + reader_->AddressSize();
} else {
return start + reader_->OffsetSize();
}
// offset size according to respective standard.
// BUT, per http://wiki.dwarfstd.org/index.php?title=DWARF_FAQ#How_big_is_a_DW_FORM_ref_addr.3F
// it is a bug in DWARF2 standard, so they are both offset.
return start + reader_->OffsetSize();
break;

case DW_FORM_block1:
return start + 1 + reader_->ReadOneByte(start);
break;
Expand Down