1 /*
2 * Copyright (C) 2018 Kernkonzept GmbH.
3 * Author: Steffen Liebergeld <steffen.liebergeld@kernkonzept.com>
4 *
5 * This file is distributed under the terms of the GNU General Public
6 * License, version 2. Please see the COPYING-GPL-2 file for details.
7 */
8
9 /*
10 * This file implements support for the L4Re::Debug protocol.
11 *
12 * This is an example ned config that makes moe print its debug information:
13 * local L4 = require("L4")
14 *
15 * L4.cast("L4Re::Debug_obj", L4.Env.user_factory):debug(0)
16 */
17 #include <lua.h>
18 #include <lualib.h>
19 #include "lua.h"
20
21 #include <l4/re/debug>
22
23 #include "lua_cap.h"
24
25 namespace Lua { namespace {
26
27 static int
__debug(lua_State * l)28 __debug(lua_State *l)
29 {
30 Cap *_debug_obj = check_cap(l, 1);
31 l4_umword_t n = luaL_checkinteger(l, 2);
32 L4::Cap<L4Re::Debug_obj> debug_obj = _debug_obj->cap<L4Re::Debug_obj>().get();
33 unsigned long ret = debug_obj->debug(n);
34 lua_pushinteger(l, ret);
35 return 1;
36 }
37
38 struct Debug_obj_model
39 {
40 static void
register_methodsLua::__anon49d803040111::Debug_obj_model41 register_methods(lua_State *l)
42 {
43 static const luaL_Reg l4_cap_class[] =
44 {
45 { "debug", __debug },
46 { NULL, NULL }
47 };
48 luaL_setfuncs(l, l4_cap_class, 0);
49 Cap::add_class_metatable(l);
50 }
51 };
52
53 static Lua::Cap_type_lib<L4Re::Debug_obj, Debug_obj_model> __lib;
54
55 }}
56