Source code from DUCTAPE's pdbtree utility that displays the static call graph:
static void printFuncTree(const pdbRoutine *r, int level) {
r->flag(ACTIVE);
pdbRoutine::callvec c = r->callees( ); (1)
for (pdbRoutine::callvec::iterator it=c.begin( ); it!=c.end( ); ++it) { (2)
const pdbRoutine *rr = (*it)->call( );
if ( level != 0 || rr->callees( ).size( ) ) {
cout << setw((level-1)*5) << "";
if ( level ) cout << "`--> ";
cout << rr->fullName( ); (3)
if ( (*it)->isVirtual( ) ) cout << " (VIRTUAL)";
if ( rr->flag() == ACTIVE ) {
cout << " ..." << endl;
} else {
cout << endl;
printFuncTree(rr, level+1); (4)
}
}
}
r->flag(INACTIVE);
}