当前位置: 首页>>代码示例>>C++>>正文


C++ FrameInjection::getStackFrame方法代码示例

本文整理汇总了C++中FrameInjection::getStackFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ FrameInjection::getStackFrame方法的具体用法?C++ FrameInjection::getStackFrame怎么用?C++ FrameInjection::getStackFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FrameInjection的用法示例。


在下文中一共展示了FrameInjection::getStackFrame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:Tacnix,项目名称:hiphop-php,代码行数:70,代码来源:frame_injection.cpp


注:本文中的FrameInjection::getStackFrame方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。