本文整理汇总了C++中StackTrace::AddFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ StackTrace::AddFrame方法的具体用法?C++ StackTrace::AddFrame怎么用?C++ StackTrace::AddFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StackTrace
的用法示例。
在下文中一共展示了StackTrace::AddFrame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cpuStateReference
status_t
Architecture::CreateStackTrace(Team* team,
ImageDebugInfoProvider* imageInfoProvider, CpuState* cpuState,
StackTrace*& _stackTrace, int32 maxStackDepth, bool useExistingTrace)
{
BReference<CpuState> cpuStateReference(cpuState);
StackTrace* stackTrace = NULL;
ObjectDeleter<StackTrace> stackTraceDeleter;
StackFrame* frame = NULL;
if (useExistingTrace)
stackTrace = _stackTrace;
else {
// create the object
stackTrace = new(std::nothrow) StackTrace;
if (stackTrace == NULL)
return B_NO_MEMORY;
stackTraceDeleter.SetTo(stackTrace);
}
// if we're passed an already existing partial stack trace,
// attempt to continue building it from where it left off.
if (stackTrace->CountFrames() > 0) {
frame = stackTrace->FrameAt(stackTrace->CountFrames() - 1);
cpuState = frame->GetCpuState();
}
while (cpuState != NULL) {
// get the instruction pointer
target_addr_t instructionPointer = cpuState->InstructionPointer();
if (instructionPointer == 0)
break;
// get the image for the instruction pointer
AutoLocker<Team> teamLocker(team);
Image* image = team->ImageByAddress(instructionPointer);
BReference<Image> imageReference(image);
teamLocker.Unlock();
// get the image debug info
ImageDebugInfo* imageDebugInfo = NULL;
if (image != NULL)
imageInfoProvider->GetImageDebugInfo(image, imageDebugInfo);
BReference<ImageDebugInfo> imageDebugInfoReference(imageDebugInfo,
true);
// get the function
teamLocker.Lock();
FunctionInstance* function = NULL;
FunctionDebugInfo* functionDebugInfo = NULL;
if (imageDebugInfo != NULL) {
function = imageDebugInfo->FunctionAtAddress(instructionPointer);
if (function != NULL)
functionDebugInfo = function->GetFunctionDebugInfo();
}
BReference<FunctionInstance> functionReference(function);
teamLocker.Unlock();
// If the CPU state's instruction pointer is actually the return address
// of the next frame, we let the architecture fix that.
if (frame != NULL
&& frame->ReturnAddress() == cpuState->InstructionPointer()) {
UpdateStackFrameCpuState(frame, image,
functionDebugInfo, cpuState);
}
// create the frame using the debug info
StackFrame* previousFrame = NULL;
CpuState* previousCpuState = NULL;
if (function != NULL) {
status_t error = functionDebugInfo->GetSpecificImageDebugInfo()
->CreateFrame(image, function, cpuState, previousFrame,
previousCpuState);
if (error != B_OK && error != B_UNSUPPORTED)
break;
}
// If we have no frame yet, let the architecture create it.
if (previousFrame == NULL) {
status_t error = CreateStackFrame(image, functionDebugInfo,
cpuState, frame == NULL, previousFrame, previousCpuState);
if (error != B_OK)
break;
}
cpuStateReference.SetTo(previousCpuState, true);
previousFrame->SetImage(image);
previousFrame->SetFunction(function);
if (!stackTrace->AddFrame(previousFrame)) {
delete previousFrame;
return B_NO_MEMORY;
}
frame = previousFrame;
cpuState = previousCpuState;
if (--maxStackDepth == 0)
break;
//.........这里部分代码省略.........