Extending LLDB to More Scripting Languages Jonas Devlieghere, Apple
C++ API
Scripting Bridge API
Scripting Bridge API SBThread SBDebugger SBBreakpoint SBTarget SBFrame SBSymbol SBValue SBProcess SBFunction
Python
Python #!/usr/bin/python $ lldb (lldb) script import lldb >>> frame = lldb.frame dbg = lldb.SBDebugger.Create() >>> print(frame.IsInlined()) target = dbg.CreateTarget("a.out") False target.BreakpointCreateByName("foo") (lldb) command script import foo.py process = target.LaunchSimple(...) (lldb) foo I'm a Python script!
Another Scripting Language
Another Scripting Language
Script Interpreter • Execute a single line of code (lldb) script >>> io.stdout:write("Hello, World!\n") Hello, World! • Run an interactive interpreter (lldb) command script import foo.lua (lldb) foo • Load a module I'm a Lua script!
SWIG
SWIG • • Lua • Python C# • • Racket • R D • • OCaml • Ruby Go • • Octave • Scilab Guile • • Perl • Tcl/Tk Java • • PHP JavaScript
Language Bindings
Language Bindings (lldb) script --language python (lldb) script --language lua >>> frame = lldb.frame >>> frame = lldb.frame >>> print(frame.IsInlined()) >>> print(frame:IsInlined()) False false
Future Work • Breakpoint/Watchpoint callbacks • Lua Type Summaries
Conclusion • Designed for multiple scripting languages • Stable SB API • Generated language bindings
Recommend
More recommend