| 46 | }; |
| 47 | |
| 48 | _Unwind_Reason_Code unwindCallback(struct _Unwind_Context* context, void* arg) { |
| 49 | BacktraceState* state = reinterpret_cast<BacktraceState*>(arg); |
| 50 | auto absoluteProgramCounter = |
| 51 | reinterpret_cast<InstructionPointer>(_Unwind_GetIP(context)); |
| 52 | |
| 53 | if (state->skip > 0) { |
| 54 | --state->skip; |
| 55 | return _URC_NO_REASON; |
| 56 | } |
| 57 | |
| 58 | if (state->stackTrace.size() == state->stackTrace.capacity()) { |
| 59 | return _URC_END_OF_STACK; |
| 60 | } |
| 61 | |
| 62 | state->stackTrace.push_back(absoluteProgramCounter); |
| 63 | |
| 64 | return _URC_NO_REASON; |
| 65 | } |
| 66 | |
| 67 | void captureBacktrace(size_t skip, vector<InstructionPointer>& stackTrace) { |
| 68 | // Beware of a bug on some platforms, which makes the trace loop until the |