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 */ }
bool DebugInfo::Load(const std::string &filename) { std::FILE* fp = std::fopen(filename.c_str(), "rb"); if (fp != 0) { AMX_DBG amxdbg; last_error_ = dbg_LoadInfo(&amxdbg, fp); if (last_error_ == AMX_ERR_NONE) { amxdbg_ = new AMX_DBG(amxdbg); return true; } fclose(fp); } return false; }