summaryrefslogtreecommitdiff
path: root/lldb/test/Shell/ScriptInterpreter/Lua
AgeCommit message (Collapse)Author
2024-10-31[lldb] Remove lldb-repro utilityJonas Devlieghere
Remove lldb-repro which was used to run the test suite against a reproducer. The corresponding functionality has been removed from LLDB so there's no need for the tool anymore.
2023-08-31[lldb] Fix test failure for breakpoint_function_callback.testMed Ismail Bennani
This should fix the test failure in breakpoint_function_callback.test since SBStructuredData can now display the content of SBStructuredData. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-06-07[lldb] Disable variable watchpoints when going out of scopeMed Ismail Bennani
If we use a variable watchpoint with a condition using a scope variable, if we go out-of-scope, the watpoint remains active which can the expression evaluator to fail to parse the watchpoint condition (because of the missing varible bindings). This was discovered after `watchpoint_callback.test` started failing on the green dragon bot. This patch should address that issue by setting an internal breakpoint on the return addresss of the current frame when creating a variable watchpoint. The breakpoint has a callback that will disable the watchpoint if the the breakpoint execution context matches the watchpoint execution context. This is only enabled for local variables. This patch also re-enables the failing test following e1086384e584. rdar://109574319 Differential Revision: https://reviews.llvm.org/D151366 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-05-26Revert "[lldb] Disable variable watchpoints when going out of scope"Jason Molenda
Reverting https://reviews.llvm.org/D151366 until Ismail has a chance to look at the ubuntu CI test failures and can reland. This reverts commit 7c847ac4bd1bd8a89c7fbb4581328fa8cb0498f1.
2023-05-25[lldb] Disable variable watchpoints when going out of scopeMed Ismail Bennani
If we use a variable watchpoint with a condition using a scope variable, if we go out-of-scope, the watpoint remains active which can the expression evaluator to fail to parse the watchpoint condition (because of the missing varible bindings). This was discovered after `watchpoint_callback.test` started failing on the green dragon bot. This patch should address that issue by setting an internal breakpoint on the return addresss of the current frame when creating a variable watchpoint. The breakpoint has a callback that will disable the watchpoint if the the breakpoint execution context matches the watchpoint execution context. This is only enabled for local variables. This patch also re-enables the failing test following e1086384e584. rdar://109574319 Differential Revision: https://reviews.llvm.org/D151366 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-05-24[lldb] Disable `watchpoint_callback.test` temporarily on darwinMed Ismail Bennani
This test started failing on the green-dragon bot, but after some investigation, it doesn't have anything to do with Lua. If we use a variable watchpoint with a condition using a scope variable, if we go out-of-scope, the watpoint remains active which can the expression evaluator to fail to parse the watchpoint condition (because of the missing varible bindings). For now, we should disable this test until we come up with a fix for it. rdar://109574319 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2022-02-07[lldb] Fix Lua/watchpoint_callback.test on Apple SiliconJonas Devlieghere
As Pavel pointed out, on Apple Silicon "b main" stops at a point after the variable has already been initialized. This patch updates the test case to avoids that. I've also split the test into separate files so its easier to reproduce the individual scenarios without having to build any shared state.
2021-07-09[lldb] Drop REQUIRES where redundant because of lit.local.cfgJonas Devlieghere
2021-07-07[lldb/lua] Add scripted watchpoints for LuaSiger Yang
Add support for Lua scripted watchpoints, with basic tests. Differential Revision: https://reviews.llvm.org/D105034
2021-06-08[lldb] Don't print script output twice in HandleCommandJonas Devlieghere
When executing a script command in HandleCommand(s) we currently print its output twice You can see this issue in action when adding a breakpoint command: (lldb) b main Breakpoint 1: where = main.out`main + 13 at main.cpp:2:3, address = 0x0000000100003fad (lldb) break command add 1 -o "script print(\"Hey!\")" (lldb) r Process 76041 launched: '/tmp/main.out' (x86_64) Hey! (lldb) script print("Hey!") Hey! Process 76041 stopped The issue is caused by HandleCommands using a temporary CommandReturnObject and one of the commands (`script` in this case) setting an immediate output stream. This causes the result to be printed twice: once directly to the immediate output stream and once when printing the result of HandleCommands. This patch fixes the issue by introducing a new option to suppress immediate output for temporary CommandReturnObjects. Differential revision: https://reviews.llvm.org/D103349
2021-04-20[lldb] Simplify check for nill value in breakpoint_function_callback.testJonas Devlieghere
2021-04-19[lldb] Update breakpoint_function_callback.test for different error messageJonas Devlieghere
Adjust for the Lua error message printed by Lua 5.4.3.
2021-02-03[lldb] Check for both Lua 5.3 and 5.4 error messages in the tests.Jonas Devlieghere
2021-01-25[lldb/Lua] add support for Lua function breakpointPedro Tammela
Adds support for running a Lua function when a breakpoint is hit. Example: breakpoint command add -s lua -F abc The above runs the Lua function 'abc' passing 2 arguments. 'frame', 'bp_loc' and 'extra_args'. A third parameter 'extra_args' is only present when there is structured data declared in the command line. Example: breakpoint command add -s lua -F abc -k foo -v bar Differential Revision: https://reviews.llvm.org/D93649
2021-01-07[lldb/Lua] add support for multiline scripted breakpointsPedro Tammela
1 - Partial Statements The interpreter loop runs every line it receives, so partial Lua statements are not being handled properly. This is a problem for multiline breakpoint scripts since the interpreter loop, for this particular case, is just an abstraction to a partially parsed function body declaration. This patch addresses this issue and as a side effect improves the general Lua interpreter loop as well. It's now possible to write partial statements in the 'script' command. Example: (lldb) script >>> do ..> local a = 123 ..> print(a) ..> end 123 The technique implemented is the same as the one employed by Lua's own REPL implementation. Partial statements always errors out with the '<eof>' tag in the error message. 2 - CheckSyntax in Lua.h In order to support (1), we need an API for just checking the syntax of string buffers. 3 - Multiline scripted breakpoints Finally, with all the base features implemented this feature is straightforward. The interpreter loop behaves exactly the same, the difference is that it will aggregate all Lua statements into the body of the breakpoint function. An explicit 'quit' statement is needed to exit the interpreter loop. Example: (lldb) breakpoint command add -s lua Enter your Lua command(s). Type 'quit' to end. The commands are compiled as the body of the following Lua function function (frame, bp_loc, ...) end ..> print(456) ..> a = 123 ..> quit Differential Revision: https://reviews.llvm.org/D93481
2020-12-20[lldb] [test] Update test status for NetBSDMichał Górny
2020-12-07[LLDB] fix error message for one-line breakpoint scriptsPedro Tammela
LLDB is ignoring compilation errors for one-line breakpoint scripts. This patch fixes the issues and now the error message of the ScriptInterpreter is shown to the user. I had to remove a new-line character for the Lua interpreter since it was duplicated. Differential Revision: https://reviews.llvm.org/D92729
2020-11-30[LLDB/Lua] add support for one-liner breakpoint callbackPedro Tammela
These callbacks are set using the following: breakpoint command add -s lua -o "print('hello world!')" The user supplied script is executed as: function (frame, bp_loc, ...) <body> end So the local variables 'frame', 'bp_loc' and vararg are all accessible. Any global variables declared will persist in the Lua interpreter. A user should never hold 'frame' and 'bp_loc' in a global variable as these userdatas are context dependent. Differential Revision: https://reviews.llvm.org/D91508
2020-11-05[LLDB-lua] modify Lua's 'print' to respect 'io.stdout'Pedro Tammela
This patch changes the implementation of Lua's `print()` function to respect `io.stdout`. The original implementation uses `lua_writestring()` internally, which is hardcoded to `stdout`. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D90787
2020-09-15[lldb] Add -l/--language option to script commandJonas Devlieghere
Make it possible to run the script command with a different language than currently selected. $ ./bin/lldb -l python (lldb) script -l lua >>> io.stdout:write("Hello, World!\n") Hello, World! When passing the language option and a raw command, you need to separate the flag from the script code with --. $ ./bin/lldb -l python (lldb) script -l lua -- io.stdout:write("Hello, World!\n") Hello, World! Differential revision: https://reviews.llvm.org/D86996
2020-06-25[lldb/Lua] Redirect Lua stdout/stderr to the CommandReturnObjectJonas Devlieghere
Redirect the output of stdout and stderr to the CommandReturnObject for one line commands. Differential revision: https://reviews.llvm.org/D82412
2020-06-23[lldb/Lua] Use the debugger's output and error file for Lua's I/O library.Jonas Devlieghere
Add support for changing the stdout and stderr file in Lua's I/O library and hook it up with the debugger's output and error file respectively for the interactive Lua interpreter. https://reviews.llvm.org/D82273
2020-06-22[lldb/Lua] Recognize "quit" as a way to exit the script interpreter.Jonas Devlieghere
Add a way to quit the interactive script interpreter from a shell tests. Currently, the only way (that I know) to exit the interactive Lua interpreter is to send a EOF with CTRL-D. I noticed that the embedded Python script interpreter accepts quit (while the regular python interpreter doesn't). I've added a special case to the Lua interpreter to do the same. Differential revision: https://reviews.llvm.org/D82272
2020-01-27[lldb/Test] Use lit.local.cfg to mark whole directory as (un)supported.Jonas Devlieghere
Mark the whole Python or Lua test directory as unsupported when the corresponding language is not available.
2020-01-22[lldb/Test] Skip script interpreter tests reading from stdin for lldb-reproJonas Devlieghere
The reproducers currently only shadow the command interpreter. It would be possible to make it work for the Lua interpreter which uses the IOHandlerEditline under the hood, but the Python one runs a REPL in Python itself so there's no (straightforward) way to shadow that. Given that we already capture any API calls, this isn't super high on my list of priorities.
2020-01-10[lldb/Lua] Support loading Lua modulesJonas Devlieghere
Implements the command script import command for Lua. Differential revision: https://reviews.llvm.org/D71825
2020-01-10[lldb/lua] Make convenience_variables.test compatible with lua-5.1Pavel Labath
2020-01-09[lldb/Lua] Make lldb.debugger et al available to LuaJonas Devlieghere
The Python script interpreter makes the current debugger, target, process, thread and frame available to interactive scripting sessions through convenience variables. This patch does the same for Lua. Differential revision: https://reviews.llvm.org/D71801
2019-12-23[lldb/lua] Fix bindings.test for lua-5.1Pavel Labath
string.format("%s", true) only works since lua-5.2. Make the print statement more portable.
2019-12-21[lldb/ScriptInterpreter] Fix stale/bogus error messagesJonas Devlieghere
Fix the nonsensical error messages for when breakpoint and watchpoint callbacks are not supported.
2019-12-21[Lldb/Lua] Persist Lua state across script interpreter calls.Jonas Devlieghere
Don't create a new lua state on every operation. Share a single state across the lifetime of the script interpreter. Add simple locking to prevent two threads from modifying the state concurrently.
2019-12-21[Lldb/Lua] Generate Lua BindingsJonas Devlieghere
This patch uses SWIG to generate the Lua bindings for the SB API. It covers most of the API, but some methods require a type map similar to Python. Discussion on the mailing list: http://lists.llvm.org/pipermail/lldb-dev/2019-December/015812.html Differential revision: https://reviews.llvm.org/D71235
2019-12-20[lldb/Lua] Implement a Simple Lua Script Interpreter PrototypeJonas Devlieghere
This implements a very elementary Lua script interpreter. It supports running a single command as well as running interactively. It uses editline if available. It's still missing a bunch of stuff though. Some things that I intentionally ingored for now are that I/O isn't properly hooked up (so every print goes to stdout) and the non-editline support which is not handling a bunch of corner cases. The latter is a matter of reusing existing code in the Python interpreter. Discussion on the mailing list: http://lists.llvm.org/pipermail/lldb-dev/2019-December/015812.html Differential revision: https://reviews.llvm.org/D71234