Exemplo n.º 1
0
int cmd_loadluafile(struct ldb_context *lctx, const char *filepath) {
    char abspath[PATH_MAX_SIZE];
    sprintf(abspath, "%s/%s", lctx->src_dir, filepath);
    if(access(abspath, F_OK) == -1) {
        printf("load %s failed,errno:%d\n", abspath, errno);
        return -1;
    }
    strcpy(lctx->lprog->abspath, abspath);
    lctx->lprog->L = luaL_newstate();

    lua_pushstring(lctx->lprog->L, REGISTRY_TAG);
    lua_pushlightuserdata(lctx->lprog->L, (void*)lctx);
    lua_settable(lctx->lprog->L, LUA_REGISTRYINDEX);

    int mask = lua_gethookmask(lctx->lprog->L);
    lua_sethook(lctx->lprog->L, line_hook, LUA_MASKLINE | mask, 0);
    return 0;
}
Exemplo n.º 2
0
static int db_gethook (lua_State *L) {
  int arg;
  lua_State *L1 = getthread(L, &arg);
  char buff[5];
  int mask = lua_gethookmask(L1);
  lua_Hook hook = lua_gethook(L1);
  if (hook != NULL && hook != hookf)  /* external hook? */
    lua_pushliteral(L, "external hook");
  else {
    gethooktable(L);
    lua_pushthread(L1); lua_xmove(L1, L, 1);
    lua_rawget(L, -2);   /* get hook */
    lua_remove(L, -2);  /* remove hook table */
  }
  lua_pushstring(L, unmakemask(mask, buff));
  lua_pushinteger(L, lua_gethookcount(L1));
  return 3;
}
Exemplo n.º 3
0
static int db_gethook (lua_State *L) {
  int arg;
  lua_State *L1 = getthread(L, &arg);
  char buff[5];
  int mask = lua_gethookmask(L1);
  lua_Hook hook = lua_gethook(L1);
  if (hook == NULL)  /* no hook? */
    lua_pushnil(L);
  else if (hook != hookf)  /* external hook? */
    lua_pushliteral(L, "external hook");
  else {  /* hook table must exist */
    lua_rawgetp(L, LUA_REGISTRYINDEX, &HOOKKEY);
    lua_pushthread(L1); lua_xmove(L1, L, 1);
    lua_rawget(L, -2);   /* 1st result = hooktable[L1] */
    lua_remove(L, -2);  /* remove hook table */
  }
  lua_pushstring(L, unmakemask(mask, buff));  /* 2nd result = mask */
  lua_pushinteger(L, lua_gethookcount(L1));  /* 3rd result = count */
  return 3;
}
Exemplo n.º 4
0
int LuaDebug::GetHookMask() const
{
	return lua_gethookmask(L());
}