Exemple #1
0
void ExitOnError(AMX *amx, int error)
{
  if (error != AMX_ERR_NONE) {
    #if defined AMXDBG
      FILE *fp;
      AMX_DBG amxdbg;
      long line;
      const char *filename;
    #endif

    printf("Run time error %d: \"%s\" on address %ld\n",
           error, aux_StrError(error), (long)amx->cip);

    /* optionally use the debug library to find the line number (if debug info.
     * is available)
     */
    #if defined AMXDBG
      /* load the debug info. */
      if ((fp=fopen(g_filename,"rb")) != NULL && dbg_LoadInfo(&amxdbg,fp) == AMX_ERR_NONE) {
        dbg_LookupFile(&amxdbg, amx->cip, &filename);
        dbg_LookupLine(&amxdbg, amx->cip, &line);
        printf("File: %s, line: %ld\n", filename, line);
        dbg_FreeInfo(&amxdbg);
        fclose(fp);
      } /* if */
    #endif
    exit(1);
  } /* if */
}
Exemple #2
0
bool Debugger::GetTraceInfo(trace_info_t *pTraceInfo, long &line, const char *&function, const char *&file)
{
    cell addr = pTraceInfo->cip;

    dbg_LookupFunction(m_pAmxDbg, addr, &function);
    dbg_LookupLine(m_pAmxDbg, addr, &line);
    dbg_LookupFile(m_pAmxDbg, addr, &file);

    return true;
}
Exemple #3
0
void Debugger::StepI()
{
    assert(m_Top >= 0 && m_Top < (int)m_pCalls.size());

#if defined BINLOG_ENABLED
    if (g_binlog_level & 32)
    {
        CPluginMngr::CPlugin *pl = g_plugins.findPluginFast(m_pAmx);
        if (pl)
        {
            long line;
            dbg_LookupLine(m_pAmxDbg, m_pAmx->cip, &line);
            g_BinLog.WriteOp(BinLog_SetLine, pl->getId(), (int)(line + 1));
        }
    }
#endif

    m_pCalls[m_Top]->StepI(m_pAmx->frm, m_pAmx->cip);
}
long DebugInfo::LookupLine(Address address) const {
  long line = 0;
  last_error_ = dbg_LookupLine(amxdbg_, address, &line);
  return line;
}