[Lldb-commits] [PATCH] D108090: [lldb/lua] Supplement Lua bindings for lldb module

2021-10-12 Thread Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG67f94e5a9745: [lldb/lua] Supplement Lua bindings for lldb 
module (authored by Siger Yang sigerye...@gmail.com).

Changed prior to commit:
  https://reviews.llvm.org/D108090?vs=378971=379026#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108090/new/

https://reviews.llvm.org/D108090

Files:
  lldb/CMakeLists.txt
  lldb/bindings/lua/CMakeLists.txt
  lldb/bindings/lua/lua-typemaps.swig
  lldb/bindings/lua/lua-wrapper.swig
  lldb/bindings/lua/lua.swig
  lldb/source/API/liblldb-private.exports
  lldb/source/API/liblldb.exports
  lldb/test/API/lit.site.cfg.py.in
  lldb/test/API/lldbtest.py
  lldb/test/API/lua_api/Makefile
  lldb/test/API/lua_api/TestBreakpointAPI.lua
  lldb/test/API/lua_api/TestComprehensive.lua
  lldb/test/API/lua_api/TestFileHandle.lua
  lldb/test/API/lua_api/TestLuaAPI.py
  lldb/test/API/lua_api/TestProcessAPI.lua
  lldb/test/API/lua_api/lua_lldb_test.lua
  lldb/test/API/lua_api/main.c

Index: lldb/test/API/lua_api/main.c
===
--- /dev/null
+++ lldb/test/API/lua_api/main.c
@@ -0,0 +1,35 @@
+#include 
+
+void BFunction()
+{
+}
+
+void AFunction()
+{
+printf("I am a function.\n");
+}
+
+int main(int argc, const char *argv[])
+{
+int inited = 0xDEADBEEF;
+int sum = 0;
+if(argc > 1)
+{
+for(int i = 0; i < argc; i++)
+{
+puts(argv[i]);
+}
+if(argc > 2)
+{
+return argc;
+}
+}
+AFunction();
+for(int i = 1; i <= 100; i++)
+{
+BFunction();
+sum += i;
+}
+printf("sum = %d\n", sum);
+return 0;
+}
Index: lldb/test/API/lua_api/lua_lldb_test.lua
===
--- /dev/null
+++ lldb/test/API/lua_api/lua_lldb_test.lua
@@ -0,0 +1,155 @@
+-- Make lldb available in global
+lldb = require('lldb')
+
+-- Global assertion functions
+function assertTrue(x)
+if not x then error('assertTrue failure') end
+end
+
+function assertFalse(x)
+if x then error('assertNotNil failure') end
+end
+
+function assertNotNil(x)
+if x == nil then error('assertNotNil failure') end
+end
+
+function assertEquals(x, y)
+if type(x) == 'table' and type(y) == 'table' then
+for k, _ in pairs(x) do
+assertEquals(x[k], y[k])
+end
+elseif type(x) ~= type(y) then
+error('assertEquals failure')
+elseif x ~= y then
+error('assertEquals failure')
+end
+end
+
+function assertStrContains(x, y)
+if not string.find(x, y, 1, true) then
+error('assertStrContains failure')
+end
+end
+
+-- Global helper functions
+function read_file_non_empty_lines(f)
+local lines = {}
+while true do
+local line = f:read('*l')
+if not line then break end
+if line ~= '\n' then table.insert(lines, line) end
+end
+return lines
+end
+
+function split_lines(str)
+local lines = {}
+for line in str:gmatch("[^\r\n]+") do
+table.insert(lines, line)
+end
+return lines
+end
+
+function get_stopped_threads(process, reason)
+local threads = {}
+for i = 0, process:GetNumThreads() - 1 do
+local t = process:GetThreadAtIndex(i)
+if t:IsValid() and t:GetStopReason() == reason then
+table.insert(threads, t)
+end
+end
+return threads
+end
+
+function get_stopped_thread(process, reason)
+local threads = get_stopped_threads(process, reason)
+if #threads ~= 0 then return threads[1]
+else return nil end
+end
+
+-- Test helper
+
+local _M = {}
+local _m = {}
+
+local _mt = { __index = _m }
+
+function _M.create_test(name, exe, output, input)
+print('[lldb/lua] Create test ' .. name)
+exe = exe or os.getenv('TEST_EXE')
+output = output or os.getenv('TEST_OUTPUT')
+input = input or os.getenv('TEST_INPUT')
+lldb.SBDebugger.Initialize()
+local debugger = lldb.SBDebugger.Create()
+-- Ensure that debugger is created
+assertNotNil(debugger)
+assertTrue(debugger:IsValid())
+
+debugger:SetAsync(false)
+
+local lua_language = debugger:GetScriptingLanguage('lua')
+assertNotNil(lua_language)
+debugger:SetScriptLanguage(lua_language)
+
+local test = setmetatable({
+output = output,
+input = input,
+name = name,
+exe = exe,
+debugger = debugger
+}, _mt)
+_G[name] = test
+return test
+end
+
+function _m:create_target(exe)
+local target
+if not exe then exe = self.exe end
+target = self.debugger:CreateTarget(exe)
+-- Ensure that target is created
+assertNotNil(target)
+assertTrue(target:IsValid())
+return target
+end
+
+function _m:handle_command(command, collect)
+if collect == nil then 

[Lldb-commits] [PATCH] D108090: [lldb/lua] Supplement Lua bindings for lldb module

2021-10-12 Thread Siger Young via Phabricator via lldb-commits
siger-young updated this revision to Diff 378971.
siger-young added a comment.

Pull and merge conflicts, will soon be merged into main.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108090/new/

https://reviews.llvm.org/D108090

Files:
  lldb/CMakeLists.txt
  lldb/bindings/lua/CMakeLists.txt
  lldb/bindings/lua/lua-typemaps.swig
  lldb/bindings/lua/lua-wrapper.swig
  lldb/bindings/lua/lua.swig
  lldb/source/API/liblldb-private.exports
  lldb/source/API/liblldb.exports
  lldb/test/API/lit.site.cfg.py.in
  lldb/test/API/lldbtest.py
  lldb/test/API/lua_api/Makefile
  lldb/test/API/lua_api/TestBreakpointAPI.lua
  lldb/test/API/lua_api/TestComprehensive.lua
  lldb/test/API/lua_api/TestFileHandle.lua
  lldb/test/API/lua_api/TestLuaAPI.py
  lldb/test/API/lua_api/TestProcessAPI.lua
  lldb/test/API/lua_api/lua_lldb_test.lua
  lldb/test/API/lua_api/main.c

Index: lldb/test/API/lua_api/main.c
===
--- /dev/null
+++ lldb/test/API/lua_api/main.c
@@ -0,0 +1,35 @@
+#include 
+
+void BFunction()
+{
+}
+
+void AFunction()
+{
+printf("I am a function.\n");
+}
+
+int main(int argc, const char *argv[])
+{
+int inited = 0xDEADBEEF;
+int sum = 0;
+if(argc > 1)
+{
+for(int i = 0; i < argc; i++)
+{
+puts(argv[i]);
+}
+if(argc > 2)
+{
+return argc;
+}
+}
+AFunction();
+for(int i = 1; i <= 100; i++)
+{
+BFunction();
+sum += i;
+}
+printf("sum = %d\n", sum);
+return 0;
+}
Index: lldb/test/API/lua_api/lua_lldb_test.lua
===
--- /dev/null
+++ lldb/test/API/lua_api/lua_lldb_test.lua
@@ -0,0 +1,155 @@
+-- Make lldb available in global
+lldb = require('lldb')
+
+-- Global assertion functions
+function assertTrue(x)
+if not x then error('assertTrue failure') end
+end
+
+function assertFalse(x)
+if x then error('assertNotNil failure') end
+end
+
+function assertNotNil(x)
+if x == nil then error('assertNotNil failure') end
+end
+
+function assertEquals(x, y)
+if type(x) == 'table' and type(y) == 'table' then
+for k, _ in pairs(x) do
+assertEquals(x[k], y[k])
+end
+elseif type(x) ~= type(y) then
+error('assertEquals failure')
+elseif x ~= y then
+error('assertEquals failure')
+end
+end
+
+function assertStrContains(x, y)
+if not string.find(x, y, 1, true) then
+error('assertStrContains failure')
+end
+end
+
+-- Global helper functions
+function read_file_non_empty_lines(f)
+local lines = {}
+while true do
+local line = f:read('*l')
+if not line then break end
+if line ~= '\n' then table.insert(lines, line) end
+end
+return lines
+end
+
+function split_lines(str)
+local lines = {}
+for line in str:gmatch("[^\r\n]+") do
+table.insert(lines, line)
+end
+return lines
+end
+
+function get_stopped_threads(process, reason)
+local threads = {}
+for i = 0, process:GetNumThreads() - 1 do
+local t = process:GetThreadAtIndex(i)
+if t:IsValid() and t:GetStopReason() == reason then
+table.insert(threads, t)
+end
+end
+return threads
+end
+
+function get_stopped_thread(process, reason)
+local threads = get_stopped_threads(process, reason)
+if #threads ~= 0 then return threads[1]
+else return nil end
+end
+
+-- Test helper
+
+local _M = {}
+local _m = {}
+
+local _mt = { __index = _m }
+
+function _M.create_test(name, exe, output, input)
+print('[lldb/lua] Create test ' .. name)
+exe = exe or os.getenv('TEST_EXE')
+output = output or os.getenv('TEST_OUTPUT')
+input = input or os.getenv('TEST_INPUT')
+lldb.SBDebugger.Initialize()
+local debugger = lldb.SBDebugger.Create()
+-- Ensure that debugger is created
+assertNotNil(debugger)
+assertTrue(debugger:IsValid())
+
+debugger:SetAsync(false)
+
+local lua_language = debugger:GetScriptingLanguage('lua')
+assertNotNil(lua_language)
+debugger:SetScriptLanguage(lua_language)
+
+local test = setmetatable({
+output = output,
+input = input,
+name = name,
+exe = exe,
+debugger = debugger
+}, _mt)
+_G[name] = test
+return test
+end
+
+function _m:create_target(exe)
+local target
+if not exe then exe = self.exe end
+target = self.debugger:CreateTarget(exe)
+-- Ensure that target is created
+assertNotNil(target)
+assertTrue(target:IsValid())
+return target
+end
+
+function _m:handle_command(command, collect)
+if collect == nil then collect = true end
+if collect then
+local ret = lldb.SBCommandReturnObject()
+local interpreter = self.debugger:GetCommandInterpreter()
+assertTrue(interpreter:IsValid())
+

[Lldb-commits] [PATCH] D108090: [lldb/lua] Supplement Lua bindings for lldb module

2021-10-03 Thread Pedro Tammela via Phabricator via lldb-commits
tammela accepted this revision.
tammela added a comment.

LGTM.

You will have to rebase to main.

Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108090/new/

https://reviews.llvm.org/D108090

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D108090: [lldb/lua] Supplement Lua bindings for lldb module

2021-09-27 Thread Siger Young via Phabricator via lldb-commits
siger-young updated this revision to Diff 375240.
siger-young added a comment.

Add assertion functions and error status detection to remove "luaunit"


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108090/new/

https://reviews.llvm.org/D108090

Files:
  lldb/CMakeLists.txt
  lldb/bindings/lua/CMakeLists.txt
  lldb/bindings/lua/lua-typemaps.swig
  lldb/bindings/lua/lua-wrapper.swig
  lldb/bindings/lua/lua.swig
  lldb/source/API/liblldb-private.exports
  lldb/source/API/liblldb.exports
  lldb/test/API/lit.site.cfg.py.in
  lldb/test/API/lldbtest.py
  lldb/test/API/lua_api/Makefile
  lldb/test/API/lua_api/TestBreakpointAPI.lua
  lldb/test/API/lua_api/TestComprehensive.lua
  lldb/test/API/lua_api/TestFileHandle.lua
  lldb/test/API/lua_api/TestLuaAPI.py
  lldb/test/API/lua_api/TestProcessAPI.lua
  lldb/test/API/lua_api/lua_lldb_test.lua
  lldb/test/API/lua_api/main.c

Index: lldb/test/API/lua_api/main.c
===
--- /dev/null
+++ lldb/test/API/lua_api/main.c
@@ -0,0 +1,35 @@
+#include 
+
+void BFunction()
+{
+}
+
+void AFunction()
+{
+printf("I am a function.\n");
+}
+
+int main(int argc, const char *argv[])
+{
+int inited = 0xDEADBEEF;
+int sum = 0;
+if(argc > 1)
+{
+for(int i = 0; i < argc; i++)
+{
+puts(argv[i]);
+}
+if(argc > 2)
+{
+return argc;
+}
+}
+AFunction();
+for(int i = 1; i <= 100; i++)
+{
+BFunction();
+sum += i;
+}
+printf("sum = %d\n", sum);
+return 0;
+}
Index: lldb/test/API/lua_api/lua_lldb_test.lua
===
--- /dev/null
+++ lldb/test/API/lua_api/lua_lldb_test.lua
@@ -0,0 +1,155 @@
+-- Make lldb available in global
+lldb = require('lldb')
+
+-- Global assertion functions
+function assertTrue(x)
+if not x then error('assertTrue failure') end
+end
+
+function assertFalse(x)
+if x then error('assertNotNil failure') end
+end
+
+function assertNotNil(x)
+if x == nil then error('assertNotNil failure') end
+end
+
+function assertEquals(x, y)
+if type(x) == 'table' and type(y) == 'table' then
+for k, _ in pairs(x) do
+assertEquals(x[k], y[k])
+end
+elseif type(x) ~= type(y) then
+error('assertEquals failure')
+elseif x ~= y then
+error('assertEquals failure')
+end
+end
+
+function assertStrContains(x, y)
+if not string.find(x, y, 1, true) then
+error('assertStrContains failure')
+end
+end
+
+-- Global helper functions
+function read_file_non_empty_lines(f)
+local lines = {}
+while true do
+local line = f:read('*l')
+if not line then break end
+if line ~= '\n' then table.insert(lines, line) end
+end
+return lines
+end
+
+function split_lines(str)
+local lines = {}
+for line in str:gmatch("[^\r\n]+") do
+table.insert(lines, line)
+end
+return lines
+end
+
+function get_stopped_threads(process, reason)
+local threads = {}
+for i = 0, process:GetNumThreads() - 1 do
+local t = process:GetThreadAtIndex(i)
+if t:IsValid() and t:GetStopReason() == reason then
+table.insert(threads, t)
+end
+end
+return threads
+end
+
+function get_stopped_thread(process, reason)
+local threads = get_stopped_threads(process, reason)
+if #threads ~= 0 then return threads[1]
+else return nil end
+end
+
+-- Test helper
+
+local _M = {}
+local _m = {}
+
+local _mt = { __index = _m }
+
+function _M.create_test(name, exe, output, input)
+print('[lldb/lua] Create test ' .. name)
+exe = exe or os.getenv('TEST_EXE')
+output = output or os.getenv('TEST_OUTPUT')
+input = input or os.getenv('TEST_INPUT')
+lldb.SBDebugger.Initialize()
+local debugger = lldb.SBDebugger.Create()
+-- Ensure that debugger is created
+assertNotNil(debugger)
+assertTrue(debugger:IsValid())
+
+debugger:SetAsync(false)
+
+local lua_language = debugger:GetScriptingLanguage('lua')
+assertNotNil(lua_language)
+debugger:SetScriptLanguage(lua_language)
+
+local test = setmetatable({
+output = output,
+input = input,
+name = name,
+exe = exe,
+debugger = debugger
+}, _mt)
+_G[name] = test
+return test
+end
+
+function _m:create_target(exe)
+local target
+if not exe then exe = self.exe end
+target = self.debugger:CreateTarget(exe)
+-- Ensure that target is created
+assertNotNil(target)
+assertTrue(target:IsValid())
+return target
+end
+
+function _m:handle_command(command, collect)
+if collect == nil then collect = true end
+if collect then
+local ret = lldb.SBCommandReturnObject()
+local interpreter = self.debugger:GetCommandInterpreter()
+assertTrue(interpreter:IsValid())
+

[Lldb-commits] [PATCH] D108090: [lldb/lua] Supplement Lua bindings for lldb module

2021-09-27 Thread Siger Young via Phabricator via lldb-commits
siger-young added inline comments.



Comment at: lldb/test/API/lua_api/lua_lldb_test.lua:3
+EXPORT_ASSERT_TO_GLOBALS = true
+require('luaunit')
+

tammela wrote:
> siger-young wrote:
> > tammela wrote:
> > > Could we not use an external dependency?
> > > For instance in my setup it fails because it couldn't find this library.
> > Does it make sense to directly copy "luaunit.lua" to the Lua test dir?
> You don't seem to have a hard dependency on it.
> Couldn't you just replicate what you are interested? Instead of bringing in a 
> full blown unit testing framework...
Oh sorry, I didn't notice the comments here.

I will remove the dependency of "luaunit" soon.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108090/new/

https://reviews.llvm.org/D108090

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D108090: [lldb/lua] Supplement Lua bindings for lldb module

2021-09-27 Thread Pedro Tammela via Phabricator via lldb-commits
tammela added inline comments.



Comment at: lldb/test/API/lua_api/lua_lldb_test.lua:3
+EXPORT_ASSERT_TO_GLOBALS = true
+require('luaunit')
+

siger-young wrote:
> tammela wrote:
> > Could we not use an external dependency?
> > For instance in my setup it fails because it couldn't find this library.
> Does it make sense to directly copy "luaunit.lua" to the Lua test dir?
You don't seem to have a hard dependency on it.
Couldn't you just replicate what you are interested? Instead of bringing in a 
full blown unit testing framework...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108090/new/

https://reviews.llvm.org/D108090

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D108090: [lldb/lua] Supplement Lua bindings for lldb module

2021-09-27 Thread Siger Young via Phabricator via lldb-commits
siger-young added inline comments.



Comment at: lldb/test/API/lua_api/lua_lldb_test.lua:3
+EXPORT_ASSERT_TO_GLOBALS = true
+require('luaunit')
+

tammela wrote:
> Could we not use an external dependency?
> For instance in my setup it fails because it couldn't find this library.
Does it make sense to directly copy "luaunit.lua" to the Lua test dir?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108090/new/

https://reviews.llvm.org/D108090

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D108090: [lldb/lua] Supplement Lua bindings for lldb module

2021-09-26 Thread Pedro Tammela via Phabricator via lldb-commits
tammela added a comment.

Just one last thing and I think we are done!

Thanks for your work.




Comment at: lldb/test/API/lua_api/lua_lldb_test.lua:3
+EXPORT_ASSERT_TO_GLOBALS = true
+require('luaunit')
+

Could we not use an external dependency?
For instance in my setup it fails because it couldn't find this library.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108090/new/

https://reviews.llvm.org/D108090

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D108090: [lldb/lua] Supplement Lua bindings for lldb module

2021-09-26 Thread Siger Young via Phabricator via lldb-commits
siger-young updated this revision to Diff 375103.
siger-young added a comment.

Rebase commits.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108090/new/

https://reviews.llvm.org/D108090

Files:
  lldb/CMakeLists.txt
  lldb/bindings/lua/CMakeLists.txt
  lldb/bindings/lua/lua-typemaps.swig
  lldb/bindings/lua/lua-wrapper.swig
  lldb/bindings/lua/lua.swig
  lldb/source/API/liblldb-private.exports
  lldb/source/API/liblldb.exports
  lldb/test/API/lit.site.cfg.py.in
  lldb/test/API/lldbtest.py
  lldb/test/API/lua_api/Makefile
  lldb/test/API/lua_api/TestBreakpointAPI.lua
  lldb/test/API/lua_api/TestComprehensive.lua
  lldb/test/API/lua_api/TestFileHandle.lua
  lldb/test/API/lua_api/TestLuaAPI.py
  lldb/test/API/lua_api/TestProcessAPI.lua
  lldb/test/API/lua_api/lua_lldb_test.lua
  lldb/test/API/lua_api/main.c

Index: lldb/test/API/lua_api/main.c
===
--- /dev/null
+++ lldb/test/API/lua_api/main.c
@@ -0,0 +1,35 @@
+#include 
+
+void BFunction()
+{
+}
+
+void AFunction()
+{
+printf("I am a function.\n");
+}
+
+int main(int argc, const char *argv[])
+{
+int inited = 0xDEADBEEF;
+int sum = 0;
+if(argc > 1)
+{
+for(int i = 0; i < argc; i++)
+{
+puts(argv[i]);
+}
+if(argc > 2)
+{
+return argc;
+}
+}
+AFunction();
+for(int i = 1; i <= 100; i++)
+{
+BFunction();
+sum += i;
+}
+printf("sum = %d\n", sum);
+return 0;
+}
Index: lldb/test/API/lua_api/lua_lldb_test.lua
===
--- /dev/null
+++ lldb/test/API/lua_api/lua_lldb_test.lua
@@ -0,0 +1,107 @@
+-- Import all functions of luaunit
+EXPORT_ASSERT_TO_GLOBALS = true
+require('luaunit')
+
+-- Make lldb available in global
+lldb = require('lldb')
+
+-- Global helper functions
+function read_file_non_empty_lines(f)
+local lines = {}
+while true do
+local line = f:read('*l')
+if not line then break end
+if line ~= '\n' then table.insert(lines, line) end
+end
+return lines
+end
+
+function split_lines(str)
+local lines = {}
+for line in str:gmatch("[^\r\n]+") do
+table.insert(lines, line)
+end
+return lines
+end
+
+function get_stopped_threads(process, reason)
+local threads = {}
+for i = 0, process:GetNumThreads() - 1 do
+local t = process:GetThreadAtIndex(i)
+if t:IsValid() and t:GetStopReason() == reason then
+table.insert(threads, t)
+end
+end
+return threads
+end
+
+function get_stopped_thread(process, reason)
+local threads = get_stopped_threads(process, reason)
+if #threads ~= 0 then return threads[1]
+else return nil end
+end
+
+-- Test helper
+
+local _M = {}
+local _m = {}
+
+local _mt = { __index = _m }
+
+function _M.create_test(name, exe, output, input)
+print('[lldb/lua] Doing test ' .. name)
+exe = exe or os.getenv('TEST_EXE')
+output = output or os.getenv('TEST_OUTPUT')
+input = input or os.getenv('TEST_INPUT')
+lldb.SBDebugger.Initialize()
+local debugger = lldb.SBDebugger.Create()
+-- Ensure that debugger is created
+assertNotNil(debugger)
+assertTrue(debugger:IsValid())
+
+debugger:SetAsync(false)
+
+local lua_language = debugger:GetScriptingLanguage('lua')
+assertNotNil(lua_language)
+debugger:SetScriptLanguage(lua_language)
+
+local test = setmetatable({
+output = output,
+input = input,
+name = name,
+exe = exe,
+debugger = debugger
+}, _mt)
+_G[name] = test
+return test
+end
+
+function _m:create_target(exe)
+local target
+if not exe then exe = self.exe end
+target = self.debugger:CreateTarget(exe)
+-- Ensure that target is created
+assertNotNil(target)
+assertTrue(target:IsValid())
+return target
+end
+
+function _m:handle_command(command, collect)
+if collect == nil then collect = true end
+if collect then
+local ret = lldb.SBCommandReturnObject()
+local interpreter = self.debugger:GetCommandInterpreter()
+assertTrue(interpreter:IsValid())
+interpreter:HandleCommand(command, ret)
+self.debugger:GetOutputFile():Flush()
+self.debugger:GetErrorFile():Flush()
+assertTrue(ret:Succeeded())
+return ret:GetOutput()
+else
+self.debugger:HandleCommand(command)
+self.debugger:GetOutputFile():Flush()
+self.debugger:GetErrorFile():Flush()
+end
+end
+
+return _M
Index: lldb/test/API/lua_api/TestProcessAPI.lua
===
--- /dev/null
+++ lldb/test/API/lua_api/TestProcessAPI.lua
@@ -0,0 +1,59 @@
+_T = require('lua_lldb_test').create_test('TestProcessAPI')
+
+function _T:TestProcessLaunchSimple()
+local target = self:create_target()
+

[Lldb-commits] [PATCH] D108090: [lldb/lua] Supplement Lua bindings for lldb module

2021-09-26 Thread Siger Young via Phabricator via lldb-commits
siger-young updated this revision to Diff 375100.
siger-young added a comment.

Fix typo in SBData test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108090/new/

https://reviews.llvm.org/D108090

Files:
  lldb/test/API/lua_api/TestComprehensive.lua


Index: lldb/test/API/lua_api/TestComprehensive.lua
===
--- lldb/test/API/lua_api/TestComprehensive.lua
+++ lldb/test/API/lua_api/TestComprehensive.lua
@@ -71,7 +71,7 @@
 assertTrue(error:Success())
 local data_le = 
lldb.SBData.CreateDataFromUInt32Array(lldb.eByteOrderLittle, 1, {0xDEADBEEF})
 local data_be = lldb.SBData.CreateDataFromUInt32Array(lldb.eByteOrderBig, 
1, {0xDEADBEEF})
-assertTrue(data_le:GetUnsignedInt32(error, 0) == 0xDCADBEEF or 
data_be:GetUnsignedInt32(error, 0) == 0xDCADBEEF)
+assertTrue(data_le:GetUnsignedInt32(error, 0) == 0xDEADBEEF or 
data_be:GetUnsignedInt32(error, 0) == 0xDEADBEEF)
 assertTrue(raw_data == "\xEF\xBE\xAD\xDE" or raw_data == 
"\xDE\xAD\xBE\xEF")
 end
 


Index: lldb/test/API/lua_api/TestComprehensive.lua
===
--- lldb/test/API/lua_api/TestComprehensive.lua
+++ lldb/test/API/lua_api/TestComprehensive.lua
@@ -71,7 +71,7 @@
 assertTrue(error:Success())
 local data_le = lldb.SBData.CreateDataFromUInt32Array(lldb.eByteOrderLittle, 1, {0xDEADBEEF})
 local data_be = lldb.SBData.CreateDataFromUInt32Array(lldb.eByteOrderBig, 1, {0xDEADBEEF})
-assertTrue(data_le:GetUnsignedInt32(error, 0) == 0xDCADBEEF or data_be:GetUnsignedInt32(error, 0) == 0xDCADBEEF)
+assertTrue(data_le:GetUnsignedInt32(error, 0) == 0xDEADBEEF or data_be:GetUnsignedInt32(error, 0) == 0xDEADBEEF)
 assertTrue(raw_data == "\xEF\xBE\xAD\xDE" or raw_data == "\xDE\xAD\xBE\xEF")
 end
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D108090: [lldb/lua] Supplement Lua bindings for lldb module

2021-09-26 Thread Siger Young via Phabricator via lldb-commits
siger-young updated this revision to Diff 375081.
siger-young added a comment.

This update mainly fixed problematic typemaps and adding necessary comments.

Together, it forced Lua installation path as "PREFIX/lib/lua/5.3" and removed 
"lit.util" in tests.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108090/new/

https://reviews.llvm.org/D108090

Files:
  lldb/CMakeLists.txt
  lldb/bindings/lua/CMakeLists.txt
  lldb/bindings/lua/lua-typemaps.swig
  lldb/test/API/lua_api/TestComprehensive.lua
  lldb/test/API/lua_api/TestLuaAPI.py

Index: lldb/test/API/lua_api/TestLuaAPI.py
===
--- lldb/test/API/lua_api/TestLuaAPI.py
+++ lldb/test/API/lua_api/TestLuaAPI.py
@@ -5,8 +5,129 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
-import lit.util
+import subprocess
 
+def to_string(b):
+"""Return the parameter as type 'str', possibly encoding it.
+
+In Python2, the 'str' type is the same as 'bytes'. In Python3, the
+'str' type is (essentially) Python2's 'unicode' type, and 'bytes' is
+distinct.
+
+"""
+if isinstance(b, str):
+# In Python2, this branch is taken for types 'str' and 'bytes'.
+# In Python3, this branch is taken only for 'str'.
+return b
+if isinstance(b, bytes):
+# In Python2, this branch is never taken ('bytes' is handled as 'str').
+# In Python3, this is true only for 'bytes'.
+try:
+return b.decode('utf-8')
+except UnicodeDecodeError:
+# If the value is not valid Unicode, return the default
+# repr-line encoding.
+return str(b)
+
+# By this point, here's what we *don't* have:
+#
+#  - In Python2:
+#- 'str' or 'bytes' (1st branch above)
+#  - In Python3:
+#- 'str' (1st branch above)
+#- 'bytes' (2nd branch above)
+#
+# The last type we might expect is the Python2 'unicode' type. There is no
+# 'unicode' type in Python3 (all the Python3 cases were already handled). In
+# order to get a 'str' object, we need to encode the 'unicode' object.
+try:
+return b.encode('utf-8')
+except AttributeError:
+raise TypeError('not sure how to convert %s to %s' % (type(b), str))
+
+class ExecuteCommandTimeoutException(Exception):
+def __init__(self, msg, out, err, exitCode):
+assert isinstance(msg, str)
+assert isinstance(out, str)
+assert isinstance(err, str)
+assert isinstance(exitCode, int)
+self.msg = msg
+self.out = out
+self.err = err
+self.exitCode = exitCode
+
+
+# Close extra file handles on UNIX (on Windows this cannot be done while
+# also redirecting input).
+kUseCloseFDs = not (platform.system() == 'Windows')
+
+
+def executeCommand(command, cwd=None, env=None, input=None, timeout=0):
+"""Execute command ``command`` (list of arguments or string) with.
+
+* working directory ``cwd`` (str), use None to use the current
+working directory
+* environment ``env`` (dict), use None for none
+* Input to the command ``input`` (str), use string to pass
+no input.
+* Max execution time ``timeout`` (int) seconds. Use 0 for no timeout.
+
+Returns a tuple (out, err, exitCode) where
+* ``out`` (str) is the standard output of running the command
+* ``err`` (str) is the standard error of running the command
+* ``exitCode`` (int) is the exitCode of running the command
+
+If the timeout is hit an ``ExecuteCommandTimeoutException``
+is raised.
+
+"""
+if input is not None:
+input = to_bytes(input)
+p = subprocess.Popen(command, cwd=cwd,
+stdin=subprocess.PIPE,
+stdout=subprocess.PIPE,
+stderr=subprocess.PIPE,
+env=env, close_fds=kUseCloseFDs)
+timerObject = None
+# FIXME: Because of the way nested function scopes work in Python 2.x we
+# need to use a reference to a mutable object rather than a plain
+# bool. In Python 3 we could use the "nonlocal" keyword but we need
+# to support Python 2 as well.
+hitTimeOut = [False]
+try:
+if timeout > 0:
+def killProcess():
+# We may be invoking a shell so we need to kill the
+# process and all its children.
+hitTimeOut[0] = True
+killProcessAndChildren(p.pid)
+
+timerObject = threading.Timer(timeout, killProcess)
+timerObject.start()
+
+out, err = p.communicate(input=input)
+exitCode = p.wait()
+finally:
+if timerObject != None:
+timerObject.cancel()
+
+# Ensure the resulting output is always of string type.
+out = to_string(out)
+err = to_string(err)
+
+if hitTimeOut[0]:
+  

[Lldb-commits] [PATCH] D108090: [lldb/lua] Supplement Lua bindings for lldb module

2021-09-20 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere requested changes to this revision.
JDevlieghere added inline comments.
This revision now requires changes to proceed.



Comment at: lldb/CMakeLists.txt:55-60
+   # FIXME: Lua 5.3 is hardcoded but it should support 5.3+!
+   find_program(Lua_EXECUTABLE lua5.3)
+   if (NOT Lua_EXECUTABLE)
+  message(FATAL_ERROR "Lua executable not found")
+   else ()
+  execute_process(

`FindLuaAndSwig.cmake` is responsible for finding Lua. If `LLDB_ENABLE_LUA` is 
set, then you can assume Lua is available. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108090/new/

https://reviews.llvm.org/D108090

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D108090: [lldb/lua] Supplement Lua bindings for lldb module

2021-09-17 Thread Pedro Tammela via Phabricator via lldb-commits
tammela added a comment.

Hi Siger,

We are almost there.
I encourage you to continue working on this patch.

I have been busy the past weeks, but I will try to review ASAP once you address 
my comments.




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));
+}

siger-young wrote:
> tammela wrote:
> > 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.
> I tried commenting and uncommenting these lines then diff, found that the 
> typecheck is actually generated on those overloaded functions. 
> `SBTarget::Launch` no longer works after commenting in my cases:
> ```
> lua5.3: test.lua:27: Wrong arguments for overloaded function 'SBTarget_Launch'
>   Possible C/C++ prototypes are:
> lldb::SBTarget::Launch(lldb::SBListener &,char const **,char const 
> **,char const *,char const *,char const *,char const 
> *,uint32_t,bool,lldb::SBError &)
> lldb::SBTarget::Launch(lldb::SBLaunchInfo &,lldb::SBError &)
> ```
> 
> It seems that SWIG uses "SWIG_isptrtype" to decide arg matches "char**", so 
> this typecheck is necessary.
> 
> For those functions with just one definition (i.e. not overloaded), this 
> typecheck does nothing on them, so it will be `typemap(in)`'s responsibility 
> to check arg types.
I see, Thanks.
That was indeed a good way to see what SWIG is generating :).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108090/new/

https://reviews.llvm.org/D108090

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D108090: [lldb/lua] Supplement Lua bindings for lldb module

2021-09-09 Thread Siger Young via Phabricator via lldb-commits
siger-young added inline comments.



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));
+}

tammela wrote:
> 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.
I tried commenting and uncommenting these lines then diff, found that the 
typecheck is actually generated on those overloaded functions. 
`SBTarget::Launch` no longer works after commenting in my cases:
```
lua5.3: test.lua:27: Wrong arguments for overloaded function 'SBTarget_Launch'
  Possible C/C++ prototypes are:
lldb::SBTarget::Launch(lldb::SBListener &,char const **,char const **,char 
const *,char const *,char const *,char const *,uint32_t,bool,lldb::SBError &)
lldb::SBTarget::Launch(lldb::SBLaunchInfo &,lldb::SBError &)
```

It seems that SWIG uses "SWIG_isptrtype" to decide arg matches "char**", so 
this typecheck is necessary.

For those functions with just one definition (i.e. not overloaded), this 
typecheck does nothing on them, so it will be `typemap(in)`'s responsibility to 
check arg types.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108090/new/

https://reviews.llvm.org/D108090

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D108090: [lldb/lua] Supplement Lua bindings for lldb module

2021-09-04 Thread Pedro Tammela via Phabricator via lldb-commits
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

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D108090: [lldb/lua] Supplement Lua bindings for lldb module

2021-08-21 Thread Siger Young via Phabricator via lldb-commits
siger-young updated this revision to Diff 367971.
siger-young added a comment.

This update adds some tests for Lua LLDB module.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108090/new/

https://reviews.llvm.org/D108090

Files:
  lldb/CMakeLists.txt
  lldb/bindings/lua/CMakeLists.txt
  lldb/bindings/lua/lua-typemaps.swig
  lldb/bindings/lua/lua-wrapper.swig
  lldb/bindings/lua/lua.swig
  lldb/source/API/liblldb-private.exports
  lldb/source/API/liblldb.exports
  lldb/test/API/lit.site.cfg.py.in
  lldb/test/API/lldbtest.py
  lldb/test/API/lua_api/Makefile
  lldb/test/API/lua_api/TestBreakpointAPI.lua
  lldb/test/API/lua_api/TestComprehensive.lua
  lldb/test/API/lua_api/TestFileHandle.lua
  lldb/test/API/lua_api/TestLuaAPI.py
  lldb/test/API/lua_api/TestProcessAPI.lua
  lldb/test/API/lua_api/lua_lldb_test.lua
  lldb/test/API/lua_api/main.c

Index: lldb/test/API/lua_api/main.c
===
--- /dev/null
+++ lldb/test/API/lua_api/main.c
@@ -0,0 +1,35 @@
+#include 
+
+void BFunction()
+{
+}
+
+void AFunction()
+{
+printf("I am a function.\n");
+}
+
+int main(int argc, const char *argv[])
+{
+int inited = 0xDEADBEEF;
+int sum = 0;
+if(argc > 1)
+{
+for(int i = 0; i < argc; i++)
+{
+puts(argv[i]);
+}
+if(argc > 2)
+{
+return argc;
+}
+}
+AFunction();
+for(int i = 1; i <= 100; i++)
+{
+BFunction();
+sum += i;
+}
+printf("sum = %d\n", sum);
+return 0;
+}
Index: lldb/test/API/lua_api/lua_lldb_test.lua
===
--- /dev/null
+++ lldb/test/API/lua_api/lua_lldb_test.lua
@@ -0,0 +1,107 @@
+-- Import all functions of luaunit
+EXPORT_ASSERT_TO_GLOBALS = true
+require('luaunit')
+
+-- Make lldb available in global
+lldb = require('lldb')
+
+-- Global helper functions
+function read_file_non_empty_lines(f)
+local lines = {}
+while true do
+local line = f:read('*l')
+if not line then break end
+if line ~= '\n' then table.insert(lines, line) end
+end
+return lines
+end
+
+function split_lines(str)
+local lines = {}
+for line in str:gmatch("[^\r\n]+") do
+table.insert(lines, line)
+end
+return lines
+end
+
+function get_stopped_threads(process, reason)
+local threads = {}
+for i = 0, process:GetNumThreads() - 1 do
+local t = process:GetThreadAtIndex(i)
+if t:IsValid() and t:GetStopReason() == reason then
+table.insert(threads, t)
+end
+end
+return threads
+end
+
+function get_stopped_thread(process, reason)
+local threads = get_stopped_threads(process, reason)
+if #threads ~= 0 then return threads[1]
+else return nil end
+end
+
+-- Test helper
+
+local _M = {}
+local _m = {}
+
+local _mt = { __index = _m }
+
+function _M.create_test(name, exe, output, input)
+print('[lldb/lua] Doing test ' .. name)
+exe = exe or os.getenv('TEST_EXE')
+output = output or os.getenv('TEST_OUTPUT')
+input = input or os.getenv('TEST_INPUT')
+lldb.SBDebugger.Initialize()
+local debugger = lldb.SBDebugger.Create()
+-- Ensure that debugger is created
+assertNotNil(debugger)
+assertTrue(debugger:IsValid())
+
+debugger:SetAsync(false)
+
+local lua_language = debugger:GetScriptingLanguage('lua')
+assertNotNil(lua_language)
+debugger:SetScriptLanguage(lua_language)
+
+local test = setmetatable({
+output = output,
+input = input,
+name = name,
+exe = exe,
+debugger = debugger
+}, _mt)
+_G[name] = test
+return test
+end
+
+function _m:create_target(exe)
+local target
+if not exe then exe = self.exe end
+target = self.debugger:CreateTarget(exe)
+-- Ensure that target is created
+assertNotNil(target)
+assertTrue(target:IsValid())
+return target
+end
+
+function _m:handle_command(command, collect)
+if collect == nil then collect = true end
+if collect then
+local ret = lldb.SBCommandReturnObject()
+local interpreter = self.debugger:GetCommandInterpreter()
+assertTrue(interpreter:IsValid())
+interpreter:HandleCommand(command, ret)
+self.debugger:GetOutputFile():Flush()
+self.debugger:GetErrorFile():Flush()
+assertTrue(ret:Succeeded())
+return ret:GetOutput()
+else
+self.debugger:HandleCommand(command)
+self.debugger:GetOutputFile():Flush()
+self.debugger:GetErrorFile():Flush()
+end
+end
+
+return _M
Index: lldb/test/API/lua_api/TestProcessAPI.lua
===
--- /dev/null
+++ lldb/test/API/lua_api/TestProcessAPI.lua
@@ -0,0 +1,59 @@
+_T = require('lua_lldb_test').create_test('TestProcessAPI')
+
+function _T:TestProcessLaunchSimple()
+local target 

[Lldb-commits] [PATCH] D108090: [lldb/lua] Supplement Lua bindings for lldb module

2021-08-16 Thread Pedro Tammela via Phabricator via lldb-commits
tammela requested changes to this revision.
tammela added a comment.
This revision now requires changes to proceed.

Missing test cases!
Either a script that test it all, individual unit tests or a combination of 
both.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108090/new/

https://reviews.llvm.org/D108090

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D108090: [lldb/lua] Supplement Lua bindings for lldb module

2021-08-16 Thread Pedro Tammela via Phabricator via lldb-commits
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(p->f, false);







Comment at: lldb/bindings/lua/lua-typemaps.swig:222
+   FileSP file_sp;
+   file_sp = std::make_shared(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

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits