[Lldb-commits] [lldb] 2cc1198 - [lldb] Fix typo in the description of breakpoint options

2021-08-21 Thread Sylvestre Ledru via lldb-commits

Author: Kirill Shmakov
Date: 2021-08-21T12:24:29+02:00
New Revision: 2cc1198e36d042f9a5cd8d66773d7e85d1d0c62f

URL: 
https://github.com/llvm/llvm-project/commit/2cc1198e36d042f9a5cd8d66773d7e85d1d0c62f
DIFF: 
https://github.com/llvm/llvm-project/commit/2cc1198e36d042f9a5cd8d66773d7e85d1d0c62f.diff

LOG: [lldb] Fix typo in the description of breakpoint options

Added: 


Modified: 
lldb/source/Commands/Options.td

Removed: 




diff  --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index b78fb37f56c47..56f7720636e8a 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -151,10 +151,10 @@ let Command = "breakpoint set" in {
   def breakpoint_set_selector : Option<"selector", "S">, Group<5>,
 Arg<"Selector">, Required,
 Desc<"Set the breakpoint by ObjC selector name. Can be repeated multiple "
-"times tomake one breakpoint for multiple Selectors.">;
+"times to make one breakpoint for multiple Selectors.">;
   def breakpoint_set_method : Option<"method", "M">, Group<6>, Arg<"Method">,
 Required, Desc<"Set the breakpoint by C++ method names.  Can be repeated "
-"multiple times tomake one breakpoint for multiple methods.">;
+"multiple times to make one breakpoint for multiple methods.">;
   def breakpoint_set_func_regex : Option<"func-regex", "r">, Group<7>,
 Arg<"RegularExpression">, Required, Desc<"Set the breakpoint by function "
 "name, evaluating a regular-expression to find the function name(s).">;



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


[Lldb-commits] [PATCH] D108510: [lldb] Allow to register frame recognizers applied beyond the first instruction

2021-08-21 Thread Roman Podoliaka via Phabricator via lldb-commits
malor created this revision.
malor added reviewers: jingham, mib.
malor added a project: LLDB.
Herald added subscribers: dang, JDevlieghere.
malor requested review of this revision.
Herald added a subscriber: lldb-commits.

It is currently possible to register a frame recognizer, but it will be applied 
if and only if the frame's PC points to the very first instruction of the 
specified function, which limits usability of this feature.

The implementation already supports changing this behaviour by passing an 
additional flag, but it's not possible to set it via the command interface. Fix 
that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108510

Files:
  lldb/source/Commands/CommandObjectFrame.cpp
  lldb/source/Commands/Options.td
  lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py

Index: lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py
===
--- lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py
+++ lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py
@@ -205,6 +205,64 @@
 self.expect("frame recognizer info 0",
 substrs=['frame 0 is recognized by recognizer.MyFrameRecognizer'])
 
+@skipUnlessDarwin
+def test_frame_recognizer_not_only_first_instruction(self):
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+# Clear internal & plugins recognizers that get initialized at launch.
+self.runCmd("frame recognizer clear")
+
+self.runCmd("command script import " + os.path.join(self.getSourceDir(), "recognizer.py"))
+
+self.expect("frame recognizer list",
+substrs=['no matching results found.'])
+
+# Create a target.
+target, process, thread, _ = lldbutil.run_to_name_breakpoint(self, "foo",
+ exe_name = exe)
+
+# Move the PC one instruction further.
+self.runCmd("next")
+
+# Add a frame recognizer in that target.
+self.runCmd("frame recognizer add -l recognizer.MyFrameRecognizer -s a.out -n foo -n bar")
+
+# It's not applied to foo(), because frame's PC is not at the first instruction of the function.
+self.expect("frame recognizer info 0",
+substrs=['frame 0 not recognized by any recognizer'])
+
+# Add a frame recognizer with --first-instruction-only=true.
+self.runCmd("frame recognizer clear")
+
+self.runCmd("frame recognizer add -l recognizer.MyFrameRecognizer -s a.out -n foo -n bar --first-instruction-only=true")
+
+# It's not applied to foo(), because frame's PC is not at the first instruction of the function.
+self.expect("frame recognizer info 0",
+substrs=['frame 0 not recognized by any recognizer'])
+
+# Now add a frame recognizer with --first-instruction-only=false.
+self.runCmd("frame recognizer clear")
+
+self.runCmd("frame recognizer add -l recognizer.MyFrameRecognizer -s a.out -n foo -n bar --first-instruction-only=false")
+
+# This time it should recognize the frame.
+self.expect("frame recognizer info 0",
+substrs=['frame 0 is recognized by recognizer.MyFrameRecognizer'])
+
+opts = lldb.SBVariablesOptions()
+opts.SetIncludeRecognizedArguments(True)
+frame = thread.GetSelectedFrame()
+variables = frame.GetVariables(opts)
+
+self.assertEqual(variables.GetSize(), 2)
+self.assertEqual(variables.GetValueAtIndex(0).name, "a")
+self.assertEqual(variables.GetValueAtIndex(0).signed, 42)
+self.assertEqual(variables.GetValueAtIndex(0).GetValueType(), lldb.eValueTypeVariableArgument)
+self.assertEqual(variables.GetValueAtIndex(1).name, "b")
+self.assertEqual(variables.GetValueAtIndex(1).signed, 56)
+self.assertEqual(variables.GetValueAtIndex(1).GetValueType(), lldb.eValueTypeVariableArgument)
+
 @no_debug_info_test
 def test_frame_recognizer_delete_invalid_arg(self):
 self.expect("frame recognizer delete a", error=True,
@@ -226,3 +284,12 @@
 substrs=["error: '-1' is not a valid frame index."])
 self.expect("frame recognizer info 4294967297", error=True,
 substrs=["error: '4294967297' is not a valid frame index."])
+
+@no_debug_info_test
+def test_frame_recognizer_add_invalid_arg(self):
+self.expect("frame recognizer add -f", error=True,
+substrs=["error: last option requires an argument"])
+self.expect("frame recognizer add -f -1", error=True,
+substrs=["error: invalid boolean value '-1' passed for -f option"])
+self.expect("frame recognizer add -f foo", error=True,
+substrs=["error: invalid boolean value 'foo' passed for -f option"])
Index: lldb/source/Commands/Optio

[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] D108515: [lldb/lua] Force Lua version to be 5.3

2021-08-21 Thread Siger Young via Phabricator via lldb-commits
siger-young created this revision.
siger-young added reviewers: tammela, JDevlieghere.
Herald added a subscriber: mgorny.
siger-young requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Due to CMake cache, find_package in FindLuaAndSwig.cmake
will be ignored. This commit adds EXACT and REQUIRED flags
to it and removes find_package in Lua ScriptInterpreter.

Signed-off-by: Siger Yang 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108515

Files:
  lldb/cmake/modules/FindLuaAndSwig.cmake
  lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt


Index: lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
+++ lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
@@ -1,5 +1,3 @@
-find_package(Lua REQUIRED)
-
 add_lldb_library(lldbPluginScriptInterpreterLua PLUGIN
   Lua.cpp
   ScriptInterpreterLua.cpp
Index: lldb/cmake/modules/FindLuaAndSwig.cmake
===
--- lldb/cmake/modules/FindLuaAndSwig.cmake
+++ lldb/cmake/modules/FindLuaAndSwig.cmake
@@ -9,7 +9,7 @@
 else()
   find_package(SWIG 3.0)
   if (SWIG_FOUND)
-find_package(Lua 5.3)
+find_package(Lua 5.3 EXACT REQUIRED)
 if(LUA_FOUND AND SWIG_FOUND)
   mark_as_advanced(
 LUA_LIBRARIES


Index: lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
+++ lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
@@ -1,5 +1,3 @@
-find_package(Lua REQUIRED)
-
 add_lldb_library(lldbPluginScriptInterpreterLua PLUGIN
   Lua.cpp
   ScriptInterpreterLua.cpp
Index: lldb/cmake/modules/FindLuaAndSwig.cmake
===
--- lldb/cmake/modules/FindLuaAndSwig.cmake
+++ lldb/cmake/modules/FindLuaAndSwig.cmake
@@ -9,7 +9,7 @@
 else()
   find_package(SWIG 3.0)
   if (SWIG_FOUND)
-find_package(Lua 5.3)
+find_package(Lua 5.3 EXACT REQUIRED)
 if(LUA_FOUND AND SWIG_FOUND)
   mark_as_advanced(
 LUA_LIBRARIES
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits