MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / InstructionCountHook

Function InstructionCountHook

lua/sp.c:2011–2062  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2009}
2010
2011static void InstructionCountHook(lua_State *lua, lua_Debug *debug)
2012{
2013 SP sp = getsp(lua);
2014 if (sp) {
2015 lua_pop(lua, 1);
2016 if ((sp->max_num_instructions > 0) &&
2017 (sp->num_instructions > sp->max_num_instructions)) {
2018 lua_end_all_step(sp->clnt, sp);
2019 luabb_error(
2020 lua, NULL,
2021 "Exceeded instruction quota (%d). Set db:setmaxinstructions()",
2022 sp->max_num_instructions);
2023 }
2024 sp->num_instructions++;
2025
2026 if (gbl_break_all_lua) {
2027 lua_getstack(lua, 1, debug);
2028 lua_getinfo(lua, "nSl", debug);
2029 char sp_info[128];
2030 lua_getstack(lua, 1, debug);
2031 lua_getinfo(lua, "nSl", debug);
2032 if (sp->spversion.version_num) {
2033 sprintf(sp_info, "%s:%d:%d", sp->spname,
2034 sp->spversion.version_num, debug->currentline);
2035 } else {
2036 sprintf(sp_info, "%s:%s:%d", sp->spname,
2037 sp->spversion.version_str, debug->currentline);
2038 }
2039 if (strcasecmp(sp_info, gbl_break_spname) == 0) {
2040 gbl_break_lua = pthread_self();
2041 }
2042 }
2043
2044 if (gbl_break_lua && pthread_equal(gbl_break_lua, pthread_self())) {
2045 if (debug_clnt) {
2046 char *err = NULL;
2047 load_debugging_information(sp, &err);
2048 }
2049 }
2050
2051 if (gbl_epoch_time) {
2052 if ((gbl_epoch_time - sp->clnt->last_check_time) > 5) {
2053 sp->clnt->last_check_time = gbl_epoch_time;
2054 if (!gbl_notimeouts) {
2055 if (peer_dropped_connection(sp->clnt)) {
2056 luaL_error(lua, "Socket Connection DROPPED");
2057 }
2058 }
2059 }
2060 }
2061 }
2062}
2063
2064static int luabb_carray_bind_real(Lua L, int lua_idx, sqlite3_stmt *stmt, int sql_idx)
2065{

Callers

nothing calls this directly

Calls 7

lua_end_all_stepFunction · 0.85
luabb_errorFunction · 0.85
lua_getstackFunction · 0.85
lua_getinfoFunction · 0.85
peer_dropped_connectionFunction · 0.85
luaL_errorFunction · 0.85

Tested by

no test coverage detected