// Handle a continue cmd, or setup stepping.
void DebuggerProxy::processFlowControl(CmdInterrupt &cmd) {
  TRACE(2, "DebuggerProxy::processFlowControl\n");
  switch (m_flow->getType()) {
    case DebuggerCommand::KindOfContinue:
      if (!m_flow->decCount()) {
        m_flow.reset();
      }
      break;
    case DebuggerCommand::KindOfStep:
      {
        // allows the breakpoint to be hit again when returns
        // from function call
        BreakPointInfoPtr bp = getBreakPointAtCmd(cmd);
        if (bp) {
          bp->setBreakable(getRealStackDepth());
        }
        break;
      }
    case DebuggerCommand::KindOfOut:
    case DebuggerCommand::KindOfNext:
      m_flow->setStackDepth(getStackDepth());
      m_flow->setVMDepth(g_vmContext->m_nesting);
      m_flow->setFileLine(cmd.getFileLine());
      break;
    default:
      assert(false);
      break;
  }
}
// Determine if an outstanding flow control cmd has run it's course and we
// should stop execution.
bool DebuggerProxy::breakByFlowControl(CmdInterrupt &cmd) {
  TRACE(2, "DebuggerProxy::breakByFlowControl\n");
  switch (m_flow->getType()) {
    case DebuggerCommand::KindOfStep: {
      if (!m_flow->decCount()) {
        // if the line changes and the stack depth is the same
        // pop the breakpoint depth stack
        m_flow.reset();
        return true;
      }
      break;
    }
    case DebuggerCommand::KindOfNext: {
      int currentVMDepth = g_vmContext->m_nesting;
      int currentStackDepth = getStackDepth();

      if (currentVMDepth <= m_flow->getVMDepth() &&
          currentStackDepth <= m_flow->getStackDepth() &&
          m_flow->getFileLine() != cmd.getFileLine()) {
            if (!m_flow->decCount()) {
              m_flow.reset();
              return true;
            }
      }

      break;
    }
    case DebuggerCommand::KindOfOut: {
      int currentVMDepth = g_vmContext->m_nesting;
      int currentStackDepth = getStackDepth();
      if (currentVMDepth < m_flow->getVMDepth()) {
        // Cut corner here, just break when cross VM boundary no matter how
        // many levels we want to go out of
        m_flow.reset();
        return true;
      } else if (m_flow->getStackDepth() - currentStackDepth >=
                 m_flow->getCount()) {
        m_flow.reset();
        return true;
      }
      break;
    }
    default:
      break;
  }
  return false;
}
Beispiel #3
0
void CDebugHelper::printBacktrace(lua_State* pState)
{
    int depth = getStackDepth(pState);
    for (int i = 0; i < depth; ++i)
    {
        printFrame(pState, i);
    }
}
Beispiel #4
0
void CDebugHelper::returnHook(lua_State* pState, lua_Debug* ar)
{
    if(ar->event != LUA_HOOKRET)
    {
        return;
    }

    int curStackDepth = getStackDepth(pState);
    if(m_curStackDepth < curStackDepth)
    {
        return;
    }

    printLine(pState);
    return run(pState);
}
Beispiel #5
0
void CDebugHelper::setNextHook(lua_State* pState)
{
    m_hook = &CDebugHelper::nextHook;
    m_curStackDepth = getStackDepth(pState);
}
Beispiel #6
0
void CDebugHelper::setReturnHook(lua_State* pState)
{
    m_hook = &CDebugHelper::returnHook;
    m_curStackDepth = getStackDepth(pState);
}