[Lldb-commits] [PATCH] D108090: [lldb/lua] Supplement Lua bindings for lldb module
Pedro Tammela via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Sat Sep 4 14:29:01 PDT 2021
tammela added a comment.
Trying to run the tests in my system failed with the following:
================
Comment at: lldb/CMakeLists.txt:60-68
+ execute_process(
+ COMMAND ${Lua_EXECUTABLE}
+ -e "for w in string.gmatch(package.cpath, ';?([^;]+);?') do \
+ if string.match(w, '%?%.so') then print(string.sub(w, 1, #w - 4)) break end end"
+ OUTPUT_VARIABLE LLDB_LUA_DEFAULT_INSTALL_PATH
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ file(TO_CMAKE_PATH ${LLDB_LUA_DEFAULT_INSTALL_PATH} LLDB_LUA_DEFAULT_INSTALL_PATH)
----------------
This is broken if the user specifies another INSTALL_PREFIX, as it forces it to `/usr/local/lib/lua/5.3`.
I think a safe option is to always set to `lib/lua/5.3`, so install prefixes can be concatenated freely.
================
Comment at: lldb/CMakeLists.txt:116
+if (LLDB_ENABLE_LUA)
+ set(lldb_lua_target_dir "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${CMAKE_INSTALL_LIBDIR}/lua")
+ get_target_property(lldb_lua_bindings_dir swig_wrapper_lua BINARY_DIR)
----------------
I think we are missing the Framework build here.
LLDB_BUILD_FRAMEWORK is a Darwin specific variable, so you will most likely need one to test this.
I can help if you don't have access to a Darwin device.
================
Comment at: lldb/bindings/lua/lua-typemaps.swig:195-213
+%typemap(in) char ** {
+ if (lua_istable(L, $input)) {
+ size_t size = lua_rawlen(L, $input);
+ $1 = (char **)malloc((size + 1) * sizeof(char *));
+ int i = 0, j = 0;
+ while (i++ < size) {
+ lua_rawgeti(L, $input, i);
----------------
Add comment here saying that the raw calls will restrict the table to be a sequence of strings.
Please add it in other functions as well.
================
Comment at: lldb/bindings/lua/lua-typemaps.swig:219-221
+%typecheck(SWIG_TYPECHECK_STRING_ARRAY) char ** {
+ $1 = (lua_istable(L, $input) || lua_isnil(L, $input));
+}
----------------
This is not being generated by SWIG for some reason.
I think it's more readable to just have an else clause that raises an error on line 212.
================
Comment at: lldb/bindings/lua/lua-typemaps.swig:275
+ $2 = 0;
+ }
+}
----------------
Else clause here for raising an error for types that are not supported
================
Comment at: lldb/bindings/lua/lua-typemaps.swig:278
+
+%typemap(in) (uint64_t* array, size_t array_len),
+ (uint32_t* array, size_t array_len),
----------------
This bug was not caught by the tests, perhaps we need to expand it more?
This would certainly generate a NULL pointer de-reference as the argument would always be NULL, since it's replacing the above code with just `free()`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108090/new/
https://reviews.llvm.org/D108090
More information about the lldb-commits
mailing list