mirror of https://github.com/axmolengine/axmol.git
fix coded debugger support
This commit is contained in:
parent
94757e7adb
commit
23781f7b92
|
@ -93,7 +93,6 @@ void startScript(string strDebugArg)
|
|||
if (!strDebugArg.empty())
|
||||
{
|
||||
// open debugger.lua module
|
||||
luaopen_debugger(engine->getLuaStack()->getLuaState());
|
||||
engine->executeString(strDebugArg.c_str());
|
||||
}
|
||||
cocos2d::log("debug args = %s", strDebugArg.c_str());
|
||||
|
@ -1221,7 +1220,8 @@ void initRuntime()
|
|||
auto engine = LuaEngine::getInstance();
|
||||
ScriptEngineManager::getInstance()->setScriptEngine(engine);
|
||||
register_runtime_override_function(engine->getLuaStack()->getLuaState());
|
||||
|
||||
luaopen_lua_debugger(engine->getLuaStack()->getLuaState());
|
||||
|
||||
static ConsoleCustomCommand *g_customCommand;
|
||||
g_customCommand = new ConsoleCustomCommand();
|
||||
g_customCommand->init();
|
||||
|
|
|
@ -74,7 +74,7 @@ static const char *lua_m_debugger =
|
|||
"-- * Break-on-error feature (break if an error is thrown and there is no pcall in stack to handle it).\n"
|
||||
"-- * Use new 5.2 facilities to provide informations about function (arguments names, vararg, ...)\n"
|
||||
"-- * Allow to see ... content for vararg functions (5.2 only)\n"
|
||||
"-- * Inspect LuaJIT C data (http://lua-users.org/lists/lua-l/2011-02/msg01012.html)-- /!\ This file is auto-generated. Do not alter manually /!\\n"
|
||||
"-- * Inspect LuaJIT C data (http://lua-users.org/lists/lua-l/2011-02/msg01012.html)-- /!\\ This file is auto-generated. Do not alter manually /!\\\n"
|
||||
"\n"
|
||||
"--------------------------------------------------------------------------------\n"
|
||||
"-- Submodules body\n"
|
||||
|
@ -101,7 +101,7 @@ static const char *lua_m_debugger =
|
|||
"function b64_wrap(src)\n"
|
||||
" local t = {}\n"
|
||||
" local b64_src = mime.b64(src)\n"
|
||||
" for i=1, #b64_src, 76 do t[#t+1] = b64_src:sub(i, i+75)..\"\r\n\" end\n"
|
||||
" for i=1, #b64_src, 76 do t[#t+1] = b64_src:sub(i, i+75)..\"\\r\\n\" end\n"
|
||||
" return table.concat(t)\n"
|
||||
"end\n"
|
||||
"\n"
|
||||
|
@ -134,7 +134,7 @@ static const char *lua_m_debugger =
|
|||
" b64 = function(data)\n"
|
||||
" t = {}\n"
|
||||
" local b64_data = apr.base64_encode(data)\n"
|
||||
" for i=1, #b64_data, 76 do t[#t+1] = b64_data:sub(i, i+75)..\"\r\n\" end\n"
|
||||
" for i=1, #b64_data, 76 do t[#t+1] = b64_data:sub(i, i+75)..\"\\r\\n\" end\n"
|
||||
" return table.concat(t)\n"
|
||||
" end,\n"
|
||||
"\n"
|
||||
|
@ -752,7 +752,7 @@ static const char *lua_m_debugger =
|
|||
" local file, err = io.open(path)\n"
|
||||
" if not file then dbgp.error(100, err, { success = 0 }) end\n"
|
||||
" -- Try to identify compiled files\n"
|
||||
" if file:read(1) == \"\033\" then dbgp.error(100, args.f..\" is bytecode\", { success = 0 }) end\n"
|
||||
" if file:read(1) == \"\\033\" then dbgp.error(100, args.f..\" is bytecode\", { success = 0 }) end\n"
|
||||
" file:seek(\"set\", 0)\n"
|
||||
"\n"
|
||||
"\n"
|
||||
|
@ -765,11 +765,11 @@ static const char *lua_m_debugger =
|
|||
" elseif currentline >= endline then break end\n"
|
||||
" end\n"
|
||||
" file:close()\n"
|
||||
" srclines[#srclines + 1] = \"\" -- to add a trailing \n\n"
|
||||
" srclines[#srclines + 1] = \"\" -- to add a trailing \\n\n"
|
||||
"\n"
|
||||
" dbgp.send_xml(self.skt, { tag = \"response\",\n"
|
||||
" attr = { command = \"source\", transaction_id = args.i, success = 1},\n"
|
||||
" util.b64(table.concat(srclines, \"\n\")) })\n"
|
||||
" util.b64(table.concat(srclines, \"\\n\")) })\n"
|
||||
"end\n"
|
||||
"\n"
|
||||
"-- Factory for both stdout and stderr commands, change file descriptor in io\n"
|
||||
|
@ -864,13 +864,13 @@ static const char *lua_m_debugger =
|
|||
"\n"
|
||||
" -- debug only !!\n"
|
||||
" __tostring = function(self)\n"
|
||||
" local buf = { \"Locals: \n\" }\n"
|
||||
" local buf = { \"Locals: \\n\" }\n"
|
||||
" for k,v in pairs(self[LOCAL][STORE]) do\n"
|
||||
" buf[#buf+1] = \"\t\"..tostring(k)..\"(\"..tostring(v)..\")=\"..tostring(self[LOCAL][k])..\"\n\"\n"
|
||||
" buf[#buf+1] = \"\\t\"..tostring(k)..\"(\"..tostring(v)..\")=\"..tostring(self[LOCAL][k])..\"\\n\"\n"
|
||||
" end\n"
|
||||
" buf[#buf+1] = \"Upvalues: \n\"\n"
|
||||
" buf[#buf+1] = \"Upvalues: \\n\"\n"
|
||||
" for k,v in pairs(self[UPVAL][STORE]) do\n"
|
||||
" buf[#buf+1] = \"\t\"..tostring(k)..\"(\"..tostring(v)..\")=\"..tostring(self[UPVAL][k])..\"\n\"\n"
|
||||
" buf[#buf+1] = \"\\t\"..tostring(k)..\"(\"..tostring(v)..\")=\"..tostring(self[UPVAL][k])..\"\\n\"\n"
|
||||
" end\n"
|
||||
" return table.concat(buf)\n"
|
||||
" end,\n"
|
||||
|
@ -1040,7 +1040,7 @@ static const char *lua_m_debugger =
|
|||
" while true do\n"
|
||||
" local byte, err = skt:receive(1)\n"
|
||||
" if not byte then return nil, err end\n"
|
||||
" if byte == \"\000\" then break end\n"
|
||||
" if byte == \"\\000\" then break end\n"
|
||||
" size[#size+1] = byte\n"
|
||||
" end\n"
|
||||
" return tconcat(size)\n"
|
||||
|
@ -1109,9 +1109,9 @@ static const char *lua_m_debugger =
|
|||
" if not resp.attr then resp.attr = {} end\n"
|
||||
" resp.attr.xmlns = \"urn:debugger_protocol_v1\"\n"
|
||||
"\n"
|
||||
" local data = '<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n'..M.lom2str(resp)\n"
|
||||
" local data = '<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\\n'..M.lom2str(resp)\n"
|
||||
" util.log(\"DEBUG\", \"Send \" .. data)\n"
|
||||
" skt:send(tostring(#data)..\"\000\"..data..\"\000\")\n"
|
||||
" skt:send(tostring(#data)..\"\\000\"..data..\"\\000\")\n"
|
||||
"end\n"
|
||||
"\n"
|
||||
"--- Return an XML tag describing a debugger error, with an optional message\n"
|
||||
|
@ -1326,8 +1326,8 @@ static const char *lua_m_debugger =
|
|||
"end\n"
|
||||
"\n"
|
||||
"M.inspectors.string = function(name, value, parent, fullname)\n"
|
||||
" -- escape linebreaks as \n and not as \<0x0A> like %q does\n"
|
||||
" return M.property(name, \"string\", sformat(\"%q\", value):gsub(\"\\\n\", \"\\n\"), parent, fullname)\n"
|
||||
" -- escape linebreaks as \\n and not as \\<0x0A> like %q does\n"
|
||||
" return M.property(name, \"string\", sformat(\"%q\", value):gsub(\"\\\\\\n\", \"\\\\n\"), parent, fullname)\n"
|
||||
"end\n"
|
||||
"\n"
|
||||
"M.inspectors[\"function\"] = function(name, value, parent, fullname)\n"
|
||||
|
@ -1337,7 +1337,7 @@ static const char *lua_m_debugger =
|
|||
" -- try to create a fancy representation if possible\n"
|
||||
" local repr = info.nparams and fancy_func_repr(value, info) or tostring(value)\n"
|
||||
" if info.source:sub(1,1) == \"@\" then\n"
|
||||
" repr = repr .. \"\n\" .. platform.get_uri(\"@\" .. info.source) .. \"\n\" .. tostring(info.linedefined)\n"
|
||||
" repr = repr .. \"\\n\" .. platform.get_uri(\"@\" .. info.source) .. \"\\n\" .. tostring(info.linedefined)\n"
|
||||
" end\n"
|
||||
" prop = M.property(name, \"function (Lua)\", repr, parent, fullname)\n"
|
||||
" else\n"
|
||||
|
@ -2296,13 +2296,13 @@ static const char *lua_m_debugger =
|
|||
" M.to_path = function (parsed_url) return url.unescape(parsed_url.path) end\n"
|
||||
" else\n"
|
||||
" -- Implementations for Windows, see UNIX versions for documentation.\n"
|
||||
" M.path_sep = \"\\\"\n"
|
||||
" M.path_sep = \"\\\\\"\n"
|
||||
" M.is_path_absolute = function (path) return path:match(\"^%a:/\") end\n"
|
||||
" M.to_file_uri = function (path) return url.build{scheme=\"file\",authority=\"\", path=\"/\"..path} end\n"
|
||||
" M.to_path = function (parsed_url) return url.unescape(parsed_url.path):gsub(\"^/\", \"\") end\n"
|
||||
"\n"
|
||||
" local unixnormalize = M.normalize\n"
|
||||
" M.normalize = function(path) return unixnormalize(path:gsub(\"\\\",\"/\"):lower()) end\n"
|
||||
" M.normalize = function(path) return unixnormalize(path:gsub(\"\\\\\",\"/\"):lower()) end\n"
|
||||
"\n"
|
||||
" -- determine base dir\n"
|
||||
" local function getworkingdirectory()\n"
|
||||
|
@ -2507,7 +2507,7 @@ static const char *lua_m_debugger =
|
|||
"function M.log(level, msg, ...)\n"
|
||||
" if (LEVELS[level] or -1) > LOG_LEVEL then return end\n"
|
||||
" if select(\"#\", ...) > 0 then msg = msg:format(...) end\n"
|
||||
" io.base.stderr:write(string.format(\"DEBUGGER\t%s\t%s\n\", level, msg))\n"
|
||||
" io.base.stderr:write(string.format(\"DEBUGGER\\t%s\\t%s\\n\", level, msg))\n"
|
||||
"end\n"
|
||||
"\n"
|
||||
"return M\n"
|
||||
|
@ -2906,7 +2906,7 @@ static const char *lua_m_debugger =
|
|||
"-- for i=1, select(\"#\", ...) do\n"
|
||||
"-- buf[i] = tostring(buf[i])\n"
|
||||
"-- end\n"
|
||||
"-- io.stdout:write(table.concat(buf, \"\t\") .. \"\n\")\n"
|
||||
"-- io.stdout:write(table.concat(buf, \"\\t\") .. \"\\n\")\n"
|
||||
"-- end\n"
|
||||
"\n"
|
||||
"-- Actually change standard output file but still return the \"fake\" stdout\n"
|
||||
|
@ -2922,7 +2922,7 @@ static const char *lua_m_debugger =
|
|||
" write = function(self, ...)\n"
|
||||
" local buf = {...}\n"
|
||||
" for i=1, select(\"#\", ...) do buf[i] = tostring(buf[i]) end\n"
|
||||
" buf = table.concat(buf):gsub(\"\n\", \"\r\n\")\n"
|
||||
" buf = table.concat(buf):gsub(\"\\n\", \"\\r\\n\")\n"
|
||||
" dbgp.send_xml(self.skt, { tag = \"stream\", attr = { type=self.mode }, util.b64(buf) } )\n"
|
||||
" end,\n"
|
||||
" flush = dummy,\n"
|
||||
|
@ -3489,7 +3489,7 @@ static luaL_Reg lua_debugger_modules[] = {
|
|||
{NULL, NULL}
|
||||
};
|
||||
|
||||
void luaopen_debugger(lua_State* L)
|
||||
void luaopen_lua_debugger(lua_State* L)
|
||||
{
|
||||
luaL_Reg* lib = lua_debugger_modules;
|
||||
lua_getglobal(L, "package");
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* lua_debugger.h.h */
|
||||
|
||||
#ifndef __LUA_MODULES_6138519995EA0D10EABE8E26B195D5DB_H_
|
||||
#define __LUA_MODULES_6138519995EA0D10EABE8E26B195D5DB_H_
|
||||
#ifndef __LUA_MODULES_865AA78CBE5B66EE51A8CB6690FEE443_H_
|
||||
#define __LUA_MODULES_865AA78CBE5B66EE51A8CB6690FEE443_H_
|
||||
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
|
@ -10,7 +10,7 @@ extern "C" {
|
|||
|
||||
#include "lua.h"
|
||||
|
||||
void luaopen_debugger(lua_State* L);
|
||||
void luaopen_lua_debugger(lua_State* L);
|
||||
|
||||
/*
|
||||
int luaopen_lua_m_debugger(lua_State* L);
|
||||
|
@ -20,4 +20,4 @@ int luaopen_lua_m_debugger(lua_State* L);
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif /* __LUA_MODULES_6138519995EA0D10EABE8E26B195D5DB_H_ */
|
||||
#endif /* __LUA_MODULES_865AA78CBE5B66EE51A8CB6690FEE443_H_ */
|
||||
|
|
Loading…
Reference in New Issue