diff mbox series

Lua: improve stackdump() for tables and functions

Message ID 20171006105957.32569-1-christian.storm@siemens.com
State Accepted
Headers show
Series Lua: improve stackdump() for tables and functions | expand

Commit Message

Storm, Christian Oct. 6, 2017, 10:59 a.m. UTC
Improve LUAstackDump() to prettier-print tables and functions.

Signed-off-by: Christian Storm <christian.storm@siemens.com>
---
 corelib/lua_interface.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c
index f94512e..14f9251 100644
--- a/corelib/lua_interface.c
+++ b/corelib/lua_interface.c
@@ -65,6 +65,10 @@  void LUAstackDump(lua_State *L)
 				TRACE("(%d) [bool  ] %s", i, (lua_toboolean(L, i) ? "true" : "false"));
 				break;
 			}
+			case LUA_TFUNCTION: {
+				TRACE("(%d) [func  ] %s()", i, lua_tostring(L, i));
+				break;
+			}
 			case LUA_TNUMBER: {
 				TRACE("(%d) [number] %g", i, lua_tonumber(L, i));
 				break;
@@ -84,6 +88,14 @@  void LUAstackDump(lua_State *L)
 								lua_tostring(L, -1),
 								lua_tostring(L, -2));
 							break;
+						case LUA_TFUNCTION:
+							TRACE("(%d) [table ] %s()", i,
+								lua_tostring(L, -1));
+							break;
+						case LUA_TTABLE:
+							TRACE("(%d) [table ] %s <table>", i,
+								lua_tostring(L, -1));
+							break;
 						case LUA_TBOOLEAN:
 							TRACE("(%d) [table ] %s = %s", i,
 								lua_tostring(L, -1),