[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
Mon Aug 16 04:44:36 PDT 2021


tammela added inline comments.


================
Comment at: lldb/bindings/lua/lua-typemaps.swig:198
+      size_t size = lua_rawlen(L, $input);
+      $1 = (char **)malloc((size + 1) * sizeof(char *));
+      int i = 0, j = 0;
----------------
This seems it could leak.
Are you sure it doesn't? If so add a comment here explaining where it's freed.


================
Comment at: lldb/bindings/lua/lua-typemaps.swig:221
+   luaL_Stream *p = (luaL_Stream *)luaL_checkudata(L, $input, LUA_FILEHANDLE);
+   FileSP file_sp;
+   file_sp = std::make_shared<NativeFile>(p->f, false);
----------------





================
Comment at: lldb/bindings/lua/lua-typemaps.swig:222
+   FileSP file_sp;
+   file_sp = std::make_shared<NativeFile>(p->f, false);
+   if (!file_sp->IsValid())
----------------



================
Comment at: lldb/bindings/lua/lua-typemaps.swig:229
+%typecheck(SWIG_TYPECHECK_POINTER) lldb::FileSP {
+   $1 = lua_isuserdata(L, $input) ? 1 : 0;
+}
----------------



================
Comment at: lldb/bindings/lua/lua-typemaps.swig:249
+
+%typemap(in) (uint64_t* array, size_t array_len),
+             (uint32_t* array, size_t array_len),
----------------
The raw variants here are overkill, you can the use normal ones


================
Comment at: lldb/bindings/lua/lua-typemaps.swig:256
+      $2 = lua_rawlen(L, $input);
+      $1 = ($1_ltype)malloc(($2) * sizeof($*1_type));
+      int i = 0, j = 0;
----------------
Leaking?


================
Comment at: lldb/bindings/lua/lua-typemaps.swig:266
+      $2 = 0;
+   }
+}
----------------
else Lua error?


================
Comment at: lldb/bindings/lua/lua-typemaps.swig:284
+//===----------------------------------------------------------------------===//
\ No newline at end of file

----------------
Please fix this


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