Exemplo n.º 1
0
    static void s_hook_lua_call(lua_State* L, lua_Debug* debug)
    {
        (void)L;
        auto key = s_key(debug);
        auto iter = s_calls.find(key);
        if (iter != s_calls.end() && iter->first == key)
        {
            iter->second.count++;
            iter->second.last_clock = clock();
        }
        else
        {
            if (!s_watchKeys.empty() && s_watchKeys.count(key) == 0)
            {
                return;
            }

            CallInfo info;
            info.count = 1;
            info.source = debug->source;
            info.line = debug->linedefined;
            if (debug->name)
            {
                info.name = debug->name;
            }
            info.total_clock = 0;
            info.last_clock = clock();
            s_calls.insert(iter, std::make_pair(key, info));
        }
    }
Exemplo n.º 2
0
int IsSKeyOK(long key)
{
  long skey = key >> SKEY_LSHIFT ;
  long first_key = key & ~(SKEY_MASK << SKEY_LSHIFT) ;

  if ( s_key( first_key ) != skey ) return( 0 ) ;
 
   return( 1 ) ;
}
Exemplo n.º 3
0
 static void s_hook_lua_return(lua_State* L, lua_Debug* debug)
 {
     (void)L;
     auto key = s_key(debug);
     auto iter = s_calls.find(key);
     if (iter != s_calls.end() && iter->first == key)
     {
         auto& info = iter->second;
         auto this_clock = clock() - info.last_clock;
         info.total_clock += this_clock;
         info.last_clock = 0;
     }
 }
Exemplo n.º 4
0
 static int watch_funs(lua_State* L)
 {
     s_watchKeys.clear();
     luaL_checktype(L, 1, LUA_TTABLE);
     int n = (int)lua_rawlen(L, 1);
     for (int i = 1; i <= n; i++)
     {
         lua_rawgeti(L, 1, i);
         if (lua_isfunction(L, -1))
         {
             lua_Debug debug;
             lua_getinfo(L, ">Sn", &debug);
             auto key = s_key(&debug);
             s_watchKeys.insert(key);
         }
         else
         {
             lua_pop(L, 1);
         }
     }
     return 1;
 }
Exemplo n.º 5
0
string Vehicle::key() {
    string s_key(1, marking());
    return s_key + ": " + name();
}