aboutsummaryrefslogtreecommitdiff
path: root/scripts/msgpack-gen.lua
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2014-10-22 10:45:54 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2014-10-22 11:26:43 -0300
commitb31a74ad11c8943b795d132c7d3e3c961d048118 (patch)
tree059e5ccf4d4173cc8bc335cd553941ed23e43147 /scripts/msgpack-gen.lua
parent42334463447e884b9a1198be599d734fbe2d1eb7 (diff)
downloadrneovim-b31a74ad11c8943b795d132c7d3e3c961d048118.tar.gz
rneovim-b31a74ad11c8943b795d132c7d3e3c961d048118.tar.bz2
rneovim-b31a74ad11c8943b795d132c7d3e3c961d048118.zip
debug: Improve debugging of msgpack-rpc requests
- Add the api_stringify function to display API objects - Use api_stringify to display request arguments and return values in DLOG statements.
Diffstat (limited to 'scripts/msgpack-gen.lua')
-rw-r--r--scripts/msgpack-gen.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/scripts/msgpack-gen.lua b/scripts/msgpack-gen.lua
index aa3aaf40fa..284956a43c 100644
--- a/scripts/msgpack-gen.lua
+++ b/scripts/msgpack-gen.lua
@@ -164,7 +164,13 @@ for i = 1, #functions do
output:write('static Object handle_'..fn.name..'(uint64_t channel_id, uint64_t request_id, Array args, Error *error)')
output:write('\n{')
- output:write('\n DLOG("Handling msgpack-rpc call to '..fn.name..'(request id: %" PRIu64 ")", request_id);')
+ output:write('\n')
+ output:write('\n#if MIN_LOG_LEVEL <= DEBUG_LOG_LEVEL\n {')
+ output:write('\n char *args_repr = api_stringify(ARRAY_OBJ(args));')
+ output:write('\n DLOG("msgpack-rpc request received(id: %" PRIu64 ", method: '..fn.name..' , arguments: %s)", request_id, args_repr);')
+ output:write('\n free(args_repr);')
+ output:write('\n }\n#endif')
+ output:write('\n')
output:write('\n Object ret = NIL;')
-- Declare/initialize variables that will hold converted arguments
for j = 1, #fn.parameters do
@@ -229,6 +235,7 @@ for i = 1, #functions do
end
-- and check for the error
output:write('\n if (error->set) {')
+ output:write('\n DLOG("msgpack-rpc request failed(id: %" PRIu64 ", method: '..fn.name..' , error: %s)", request_id, error->msg);')
output:write('\n goto cleanup;')
output:write('\n }\n')
else
@@ -238,6 +245,11 @@ for i = 1, #functions do
if fn.return_type ~= 'void' then
output:write('\n ret = '..string.upper(real_type(fn.return_type))..'_OBJ(rv);')
end
+ output:write('\n#if MIN_LOG_LEVEL <= DEBUG_LOG_LEVEL\n {')
+ output:write('\n char *rv_repr = api_stringify(ret);')
+ output:write('\n DLOG("msgpack-rpc request succeeded(id: %" PRIu64 ", method: '..fn.name..' , return value: %s)", request_id, rv_repr);')
+ output:write('\n free(rv_repr);')
+ output:write('\n }\n#endif')
-- Now generate the cleanup label for freeing memory allocated for the
-- arguments
output:write('\n\ncleanup:');