// Format stack as GDBMI static StackFrames getStackTrace(CIDebugControl *debugControl, CIDebugSymbols *debugSymbols, unsigned maxFrames, bool *incomplete, std::string *errorMessage) { if (maxFrames) { *incomplete = false; } else { *incomplete = true; return StackFrames(); } // Ask for one more frame to find out whether it is a complete listing. const unsigned askedFrames = maxFrames + 1; DEBUG_STACK_FRAME *frames = new DEBUG_STACK_FRAME[askedFrames]; ULONG frameCount = 0; const HRESULT hr = debugControl->GetStackTrace(0, 0, 0, frames, askedFrames, &frameCount); if (FAILED(hr)) { delete [] frames; *errorMessage = msgDebugEngineComFailed("GetStackTrace", hr); return StackFrames(); } if (askedFrames == frameCount) { --frameCount; *incomplete = true; } StackFrames rc(frameCount, StackFrame()); for (ULONG f = 0; f < frameCount; ++f) getFrame(debugSymbols, frames[f], &(rc[f])); delete [] frames; return rc; }
// Format stack as GDBMI static StackFrames getStackTrace(CIDebugControl *debugControl, CIDebugSymbols *debugSymbols, unsigned maxFrames, std::string *errorMessage) { if (!maxFrames) return StackFrames(); DEBUG_STACK_FRAME *frames = new DEBUG_STACK_FRAME[maxFrames]; ULONG frameCount = 0; const HRESULT hr = debugControl->GetStackTrace(0, 0, 0, frames, maxFrames, &frameCount); if (FAILED(hr)) { delete [] frames; *errorMessage = msgDebugEngineComFailed("GetStackTrace", hr); return StackFrames(); } StackFrames rc(frameCount, StackFrame()); for (ULONG f = 0; f < frameCount; ++f) getFrame(debugSymbols, frames[f], &(rc[f])); delete [] frames; return rc; }