本文整理汇总了C++中FrameInjection::getFileName方法的典型用法代码示例。如果您正苦于以下问题:C++ FrameInjection::getFileName方法的具体用法?C++ FrameInjection::getFileName怎么用?C++ FrameInjection::getFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrameInjection
的用法示例。
在下文中一共展示了FrameInjection::getFileName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetContainingFileName
String FrameInjection::GetContainingFileName(bool skip /* = false */) {
FrameInjection *t = ThreadInfo::s_threadInfo->m_top;
if (t && skip) {
t = t->m_prev;
}
if (t) {
return t->getFileName();
}
return "";
}
示例2: GetBacktrace
Array FrameInjection::GetBacktrace(bool skip /* = false */,
bool withSelf /* = false */,
bool withThis /* = true */) {
Array bt = Array::Create();
FrameInjection *t = ThreadInfo::s_threadInfo->m_top;
if (skip && t) {
t = t->m_prev;
}
// This is used by onError with extended exceptions
if (withSelf && t) {
String filename = t->getFileName();
// If the top frame is not an extension function,
// add it to the trace
if (filename != "") {
Array frame = Array::Create();
frame.set(s_file, filename, true);
frame.set(s_line, t->m_line, true);
bt.append(frame);
}
}
while (t) {
Array frame = Array::Create();
if (t->m_prev) {
String file = t->m_prev->getFileName();
if (!file.empty() && t->m_prev->m_line) {
frame.set(s_file, file, true);
frame.set(s_line, t->m_prev->m_line, true);
}
} else if (t->m_flags & PseudoMain) {
// Stop at top, don't include top file
break;
}
if (t->m_flags & PseudoMain) {
frame.set(s_function, "include", true);
frame.set(s_args, Array::Create(t->getFileName()), true);
} else {
const char *c = strstr(t->m_name, "::");
if (c) {
frame.set(s_function, String(c + 2), true);
frame.set(s_class, t->m_class->copy(), true);
if (!t->m_object.isNull()) {
if (withThis) {
frame.set(s_object, t->m_object, true);
}
frame.set(s_type, "->", true);
} else {
frame.set(s_type, "::", true);
}
} else {
frame.set(s_function, t->m_name, true);
}
Array args = t->getArgs();
if (!args.isNull()) {
frame.set(s_args, args, true);
} else {
frame.set(s_args, Array::Create(), true);
}
}
bt.append(frame);
t = t->m_prev;
}
return bt;
}
示例3: GetBacktrace
Array FrameInjection::GetBacktrace(bool skip /* = false */,
bool withSelf /* = false */,
bool withThis /* = true */) {
Array bt = Array::Create();
FrameInjection *t = ThreadInfo::s_threadInfo->m_top;
if (skip && t) {
t = t->m_prev;
}
// This is used by onError with extended exceptions
if (withSelf && t) {
String filename = t->getFileName();
// If the top frame is not an extension function, and has actually been
// entered (i.e. has a real line number) add it to the trace
if (filename != "" && t->m_line != 0) {
Array frame = Array::Create();
frame.set(s_file, filename, true);
frame.set(s_line, t->m_line, true);
bt.append(frame);
}
}
Array sbt = bt;
FrameInjection *st = t;
while (t && (RuntimeOption::InjectedStackTraceLimit < 0 ||
bt.size() < RuntimeOption::InjectedStackTraceLimit)) {
Array frame = t->getStackFrame(withSelf, withThis);
if (frame.isNull()) return bt;
bt.append(frame);
t = t->m_prev;
}
if (!t) return bt;
// The stack depth has exceeded the limit. Re-construct bt to include the
// top and bottom frames. This is considered more useful in cases such as
// infinite recursion.
ASSERT(bt.size() == RuntimeOption::InjectedStackTraceLimit);
int half = RuntimeOption::InjectedStackTraceLimit / 2;
// start over, get the top half
bt = sbt;
t = st;
while (t && bt.size() < half) {
Array frame = t->getStackFrame(withSelf, withThis);
if (frame.isNull()) assert(false);
bt.append(frame);
t = t->m_prev;
}
// then the bottom half
std::vector<FrameInjection *> remainingFrames;
while (t) {
if (!t->m_prev && (t->m_flags & PseudoMain)) break;
remainingFrames.push_back(t);
t = t->m_prev;
}
int remaining = remainingFrames.size();
int omitted = remaining - half;
assert(omitted >= 0);
if (omitted > 0) {
std::string tmp("(...) ");
tmp += boost::lexical_cast<std::string>(omitted) +
" omitted frame" + ((omitted > 1) ? "s" : "");
Array frame;
frame.set(s_function, tmp);
bt.append(frame);
}
for (int i = omitted; i < remaining; i++) {
Array frame = remainingFrames[i]->getStackFrame(withSelf, withThis);
if (frame.isNull()) assert(false);
bt.append(frame);
}
return bt;
}