本文整理汇总了C++中CallFrame::callerFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ CallFrame::callerFrame方法的具体用法?C++ CallFrame::callerFrame怎么用?C++ CallFrame::callerFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CallFrame
的用法示例。
在下文中一共展示了CallFrame::callerFrame方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT
StackVisitor::StackVisitor(CallFrame* startFrame, VM* vm)
{
m_frame.m_index = 0;
m_frame.m_isWasmFrame = false;
CallFrame* topFrame;
if (startFrame) {
ASSERT(vm);
ASSERT(!vm->topCallFrame || reinterpret_cast<void*>(vm->topCallFrame) != vm->topEntryFrame);
m_frame.m_entryFrame = vm->topEntryFrame;
topFrame = vm->topCallFrame;
if (topFrame && topFrame->isStackOverflowFrame()) {
topFrame = topFrame->callerFrame(m_frame.m_entryFrame);
m_topEntryFrameIsEmpty = (m_frame.m_entryFrame != vm->topEntryFrame);
if (startFrame == vm->topCallFrame)
startFrame = topFrame;
}
} else {
m_frame.m_entryFrame = 0;
topFrame = 0;
}
m_frame.m_callerIsEntryFrame = false;
readFrame(topFrame);
// Find the frame the caller wants to start unwinding from.
while (m_frame.callFrame() && m_frame.callFrame() != startFrame)
gotoNextFrame();
}
示例2: JSContextCreateBacktrace
JSStringRef JSContextCreateBacktrace(JSContextRef ctx, unsigned maxStackSize)
{
ExecState* exec = toJS(ctx);
JSLock lock(exec);
unsigned count = 0;
UStringBuilder builder;
CallFrame* callFrame = exec;
UString functionName;
if (exec->callee()) {
if (asObject(exec->callee())->inherits(&InternalFunction::s_info)) {
functionName = asInternalFunction(exec->callee())->name(exec);
builder.append("#0 ");
builder.append(functionName);
builder.append("() ");
count++;
}
}
while (true) {
ASSERT(callFrame);
int signedLineNumber;
intptr_t sourceID;
UString urlString;
JSValue function;
UString levelStr = UString::number(count);
exec->interpreter()->retrieveLastCaller(callFrame, signedLineNumber, sourceID, urlString, function);
if (function)
functionName = asFunction(function)->name(exec);
else {
// Caller is unknown, but if frame is empty we should still add the frame, because
// something called us, and gave us arguments.
if (count)
break;
}
unsigned lineNumber = signedLineNumber >= 0 ? signedLineNumber : 0;
if (!builder.isEmpty())
builder.append("\n");
builder.append("#");
builder.append(levelStr);
builder.append(" ");
builder.append(functionName);
builder.append("() at ");
builder.append(urlString);
builder.append(":");
builder.append(UString::number(lineNumber));
if (!function || ++count == maxStackSize)
break;
callFrame = callFrame->callerFrame();
}
return OpaqueJSString::create(builder.toUString()).leakRef();
}
示例3: fillFrames
void ScriptCallStack::fillFrames()
{
if (m_filled || !m_caller)
return;
/*
AJValue function = m_exec->interpreter()->retrieveCaller(m_exec, m_caller);
while (!function.isNull()) {
InternalFunction* internal = asInternalFunction(function);
m_frames.append(ScriptCallFrame(internal->name(m_exec), UString(), 0, ArgList(), 0));
function = m_exec->interpreter()->retrieveCaller(m_exec, internal);
}*/
CallFrame* callFrame = m_exec->callerFrame();
while(callFrame) {
UString functionName;
int tmpLineNO;
intptr_t sourceID;
UString urlString;
AJValue function;
m_exec->interpreter()->retrieveLastCaller(callFrame, tmpLineNO, sourceID, urlString, function);
if (function) {
functionName = asInternalFunction(function)->name(m_exec);
} else {
if (!m_frames.isEmpty())
break;
}
unsigned lineNO = tmpLineNO >= 0 ? tmpLineNO : 0;
m_frames.append(ScriptCallFrame(functionName, urlString, lineNO, ArgList(), 0));
if (!function)
break;
callFrame = callFrame->callerFrame();
}
m_filled = true;
}
示例4: initialize
void ScriptCallStack::initialize()
{
if (!m_caller || m_initialized)
return;
int signedLineNumber;
intptr_t sourceID;
UString urlString;
JSValue function;
// callFrame must exist if m_caller is not null.
CallFrame* callFrame = m_exec->callerFrame();
while (true) {
ASSERT(callFrame);
m_exec->interpreter()->retrieveLastCaller(callFrame, signedLineNumber, sourceID, urlString, function);
if (!function)
break;
JSFunction* jsFunction = asFunction(function);
unsigned lineNumber = signedLineNumber >= 0 ? signedLineNumber : 0;
m_frames.append(ScriptCallFrame(jsFunction->name(m_exec), urlString, lineNumber, m_exec, 0));
callFrame = callFrame->callerFrame();
}
m_initialized = true;
}
示例5: update
void ShadowChicken::update(VM&, ExecState* exec)
{
if (verbose) {
dataLog("Running update on: ", *this, "\n");
WTFReportBacktrace();
}
const unsigned logCursorIndex = m_logCursor - m_log;
// We need to figure out how to reconcile the current machine stack with our shadow stack. We do
// that by figuring out how much of the shadow stack to pop. We apply three different rules. The
// precise rule relies on the log. The log contains caller frames, which means that we know
// where we bottomed out after making any call. If we bottomed out but made no calls then 'exec'
// will tell us. That's why "highestPointSinceLastTime" will go no lower than exec. The third
// rule, based on comparing to the current real stack, is executed in a later loop.
CallFrame* highestPointSinceLastTime = exec;
for (unsigned i = logCursorIndex; i--;) {
Packet packet = m_log[i];
if (packet.isPrologue()) {
CallFrame* watermark;
if (i && m_log[i - 1].isTail())
watermark = packet.frame;
else
watermark = packet.callerFrame;
highestPointSinceLastTime = std::max(highestPointSinceLastTime, watermark);
}
}
if (verbose)
dataLog(" Highest point since last time: ", RawPointer(highestPointSinceLastTime), "\n");
while (!m_stack.isEmpty() && m_stack.last().frame < highestPointSinceLastTime)
m_stack.removeLast();
if (verbose)
dataLog(" Revised stack: ", listDump(m_stack), "\n");
// It's possible that the top of stack is now tail-deleted. The stack no longer contains any
// frames below the log's high watermark. That means that we just need to look for the first
// occurence of a tail packet for the current stack top.
if (!m_stack.isEmpty()) {
ASSERT(!m_stack.last().isTailDeleted);
for (unsigned i = 0; i < logCursorIndex; ++i) {
Packet& packet = m_log[i];
if (packet.isTail() && packet.frame == m_stack.last().frame) {
m_stack.last().isTailDeleted = true;
break;
}
}
}
if (verbose)
dataLog(" Revised stack: ", listDump(m_stack), "\n");
// The log-based and exec-based rules require that ShadowChicken was enabled. The point of
// ShadowChicken is to give sensible-looking results even if we had not logged. This means that
// we need to reconcile the shadow stack and the real stack by actually looking at the real
// stack. This reconciliation allows the shadow stack to have extra tail-deleted frames, but it
// forbids it from diverging from the real stack on normal frames.
if (!m_stack.isEmpty()) {
Vector<Frame> stackRightNow;
StackVisitor::visit(
exec, [&] (StackVisitor& visitor) -> StackVisitor::Status {
if (visitor->isInlinedFrame())
return StackVisitor::Continue;
bool isTailDeleted = false;
stackRightNow.append(Frame(visitor->callee(), visitor->callFrame(), isTailDeleted));
return StackVisitor::Continue;
});
stackRightNow.reverse();
if (verbose)
dataLog(" Stack right now: ", listDump(stackRightNow), "\n");
unsigned shadowIndex = 0;
unsigned rightNowIndex = 0;
while (shadowIndex < m_stack.size() && rightNowIndex < stackRightNow.size()) {
if (m_stack[shadowIndex].isTailDeleted) {
shadowIndex++;
continue;
}
if (m_stack[shadowIndex] == stackRightNow[rightNowIndex]) {
shadowIndex++;
rightNowIndex++;
continue;
}
break;
}
m_stack.resize(shadowIndex);
if (verbose)
dataLog(" Revised stack: ", listDump(m_stack), "\n");
}
// It's possible that the top stack frame is actually lower than highestPointSinceLastTime.
// Account for that here.
highestPointSinceLastTime = nullptr;
for (unsigned i = m_stack.size(); i--;) {
if (!m_stack[i].isTailDeleted) {
highestPointSinceLastTime = m_stack[i].frame;
//.........这里部分代码省略.........
示例6: addErrorInfo
JSObject* addErrorInfo(ExecState* exec, JSObject* error, int line, const SourceCode& source)
{
JSGlobalData* globalData = &exec->globalData();
addErrorInfo(globalData, error, line, source);
UStringBuilder stackString;
JSArray* stackArray = constructEmptyArray(exec);
CallFrame* frame = exec;
stackString.append(error->toString(exec));
bool functionKnown;
ReturnAddressPtr pc;
while (!frame->hasHostCallFrameFlag()) {
CodeBlock* codeBlock = frame->codeBlock();
JSObject* arrayItem = constructEmptyObject(exec);
stackString.append("\n at ");
JSObject* callee = frame->callee();
UString functionName;
if (callee && callee->inherits(&JSFunction::s_info)) {
functionName = asFunction(callee)->calculatedDisplayName(exec);
functionKnown = !functionName.isEmpty();
} else {
functionKnown = false;
}
if (functionKnown) {
stackString.append(functionName);
stackString.append(" (");
arrayItem->putWithAttributes(
globalData, Identifier(globalData, functionPropertyName),
jsString(globalData, functionName), ReadOnly | DontDelete
);
}
UString sourceURL = codeBlock->ownerExecutable()->sourceURL();
arrayItem->putWithAttributes(
globalData, Identifier(globalData, sourceURLPropertyName),
jsString(globalData, sourceURL), ReadOnly | DontDelete
);
stackString.append(sourceURL);
stackString.append(":");
if (frame != exec) {
line = codeBlock->lineNumberForBytecodeOffset(codeBlock->bytecodeOffset(pc));
}
arrayItem->putWithAttributes(
globalData, Identifier(globalData, linePropertyName),
jsNumber(line), ReadOnly | DontDelete
);
stackString.append(UString::number(line));
if (functionKnown) {
stackString.append(")");
}
stackArray->push(exec, JSValue(arrayItem));
pc = frame->returnPC();
frame = frame->callerFrame();
}
error->putWithAttributes(
globalData, Identifier(globalData, stackPropertyName),
jsString(globalData, stackString.toUString()), ReadOnly | DontDelete
);
error->putWithAttributes(
globalData, Identifier(globalData, "stackArray"),
stackArray, ReadOnly | DontDelete
);
return error;
}