The function called periodically to ensure Lua doesn't run amok.
| 5915 | |
| 5916 | // The function called periodically to ensure Lua doesn't run amok. |
| 5917 | FCEU_MAYBE_UNUSED |
| 5918 | static void FCEU_LuaHookFunction(lua_State *L, lua_Debug *dbg) { |
| 5919 | |
| 5920 | if (numTries-- == 0) { |
| 5921 | |
| 5922 | int kill = 0; |
| 5923 | |
| 5924 | #ifdef __WIN_DRIVER__ |
| 5925 | // Uh oh |
| 5926 | //StopSound(); //mbg merge 7/23/08 |
| 5927 | int ret = MessageBox(hAppWnd, "The Lua script running has been running a long time. It may have gone crazy. Kill it?\n\n(No = don't check anymore either)", "Lua Script Gone Nuts?", MB_YESNO); |
| 5928 | |
| 5929 | if (ret == IDYES) { |
| 5930 | kill = 1; |
| 5931 | } |
| 5932 | |
| 5933 | #else |
| 5934 | if ( LuaKillMessageBox() ) |
| 5935 | { |
| 5936 | kill = 1; |
| 5937 | } |
| 5938 | //fprintf(stderr, "The Lua script running has been running a long time.\nIt may have gone crazy. Kill it? (I won't ask again if you say No)\n"); |
| 5939 | //char buffer[64]; |
| 5940 | //while (TRUE) { |
| 5941 | // fprintf(stderr, "(y/n): "); |
| 5942 | // fgets(buffer, sizeof(buffer), stdin); |
| 5943 | // if (buffer[0] == 'y' || buffer[0] == 'Y') { |
| 5944 | // kill = 1; |
| 5945 | // break; |
| 5946 | // } |
| 5947 | |
| 5948 | // if (buffer[0] == 'n' || buffer[0] == 'N') |
| 5949 | // break; |
| 5950 | //} |
| 5951 | #endif |
| 5952 | |
| 5953 | if (kill) { |
| 5954 | luaL_error(L, "Killed by user request."); |
| 5955 | FCEU_LuaOnStop(); |
| 5956 | } |
| 5957 | |
| 5958 | // else, kill the debug hook. |
| 5959 | lua_sethook(L, NULL, 0, 0); |
| 5960 | } |
| 5961 | |
| 5962 | |
| 5963 | } |
| 5964 | |
| 5965 | static void emu_exec_count_hook(lua_State *L, lua_Debug *dbg) { |
| 5966 | luaL_error(L, "exec_count timeout"); |
nothing calls this directly
no test coverage detected