Files
clang-p2996/lldb/test/Shell/ScriptInterpreter/Lua/breakpoint_function_callback.test
Pedro Tammela 532e4203c5 [lldb/Lua] add support for Lua function breakpoint
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-25 23:40:57 +00:00

24 lines
628 B
Plaintext

# REQUIRES: lua
# RUN: echo "int main() { return 0; }" | %clang_host -x c - -o %t
# RUN: %lldb -s %s --script-language lua %t 2>&1 | FileCheck %s
b main
script
function abc(a, b, c, ...)
print(c)
if c then print(c:GetValueForKey("foo"):GetStringValue(32)) end
end
quit
breakpoint command add -s lua -F abc
r
# CHECK: nil
breakpoint command add -s lua -F abc -k foo -v 123pizza!
r
# CHECK: <userdata of type 'lldb::SBStructuredData *' at {{0x[[:xdigit:]]+}}>
# CHECK: 123pizza!
breakpoint command add -s lua -o "abc(frame, bp_loc, ...)"
r
# CHECK: nil
breakpoint command add -s lua -F typo
r
# CHECK: attempt to call a nil value