Skip to content

Commit b1b0178

Browse files
committed
CallTree: show offsets after a symbol name.
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.
1 parent b144608 commit b1b0178

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/calltree.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,21 @@ using std::min;
3434
using std::ostream;
3535
using std::ostringstream;
3636
using std::pair;
37+
using std::showbase;
3738
using std::string;
3839
using std::vector;
3940

4041
string CallTree::getFunctionName(Addr addr) const
4142
{
4243
if (IN.has_image())
43-
if (const Symbol *Symb = IN.get_image()->find_symbol(addr))
44-
return Symb->getName();
44+
if (const Symbol *Symb = IN.get_image()->find_symbol(addr)) {
45+
ostringstream oss;
46+
oss << Symb->getName();
47+
Addr offset = addr - Symb->addr;
48+
if (offset)
49+
oss << " + " << hex << showbase << addr;
50+
return oss.str();
51+
}
4552
return string();
4653
}
4754

0 commit comments

Comments
 (0)