Skip to content

Commit

Permalink
CallTree: show offsets after a symbol name.
Browse files Browse the repository at this point in the history
tarmac-profile indexes its records by the first address it sees being
executed within a function. So if a trace file starts in mid-function,
and the same function is called again later, there will be one record
for calls to the start of the function, and a separate one for the
case where we started in the middle. But they were both listed in the
output with the same symbol name, confusingly.

Now, when an address is translated into a symbol name, it gets an
offset suffix like '+ 0x1234' if the address turns out not to be the
very start of the function. This is already how symbols are annotated
in the GUI browsers.

This affects both tarmac-calltree and tarmac-profile, because both use
the internal CallTree class.
  • Loading branch information
statham-arm committed Jun 28, 2024
1 parent b144608 commit b1b0178
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/calltree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,21 @@ using std::min;
using std::ostream;
using std::ostringstream;
using std::pair;
using std::showbase;
using std::string;
using std::vector;

string CallTree::getFunctionName(Addr addr) const
{
if (IN.has_image())
if (const Symbol *Symb = IN.get_image()->find_symbol(addr))
return Symb->getName();
if (const Symbol *Symb = IN.get_image()->find_symbol(addr)) {
ostringstream oss;
oss << Symb->getName();
Addr offset = addr - Symb->addr;
if (offset)
oss << " + " << hex << showbase << addr;
return oss.str();
}
return string();
}

Expand Down

0 comments on commit b1b0178

Please sign in to comment.