| 92 | } |
| 93 | |
| 94 | void print(FILE* f, int indent = 0, int start = 0) const { |
| 95 | char** strings = backtrace_symbols(callers_, numCallers_); |
| 96 | if (strings) { |
| 97 | start += skip_; |
| 98 | if (start < 0) { |
| 99 | start = 0; |
| 100 | } |
| 101 | for (int n = start; n < numCallers_; ++n) { |
| 102 | fprintf(f, "%*s#%-2d %s\n", indent, "", n, strings[n]); |
| 103 | } |
| 104 | free(strings); |
| 105 | } else { |
| 106 | fprintf(f, "%*s<failed to determine symbols>\n", indent, ""); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | int getDepth() const { return numCallers_ - skip_; } |
| 111 |
no outgoing calls