jingham added inline comments.
================ Comment at: lldb/docs/use/python-reference.rst:586 the module is loaded allowing you to add whatever commands you want into the -current debugger. Note that this function will only be run when using the LLDB -command command script import, it will not get run if anyone imports your -module from another module. If you want to always run code when your module is -loaded from LLDB or when loaded via an import statement in python code you can -test the lldb.debugger object, since you imported the module at the top of the -python ls.py module. This test must be in code that isn't contained inside of -any function or class, just like the standard test for __main__ like all python -modules usually do. Sample code would look like: - -:: - - if __name__ == '__main__': - # Create a new debugger instance in your module if your module - # can be run from the command line. When we run a script from - # the command line, we won't have any debugger object in - # lldb.debugger, so we can just create it if it will be needed - lldb.debugger = lldb.SBDebugger.Create() - elif lldb.debugger: - # Module is being run inside the LLDB interpreter - lldb.debugger.HandleCommand('command script add -f ls.ls ls') - print 'The "ls" python command has been installed and is ready for use.' +current debugger. ---------------- I think it's okay to show the "if __name__ == '__main__': part of this example, but it should be: ``` if __name__ == '__main__': # Create a new debugger instance in your module if your module # can be run from the command line. When we run a script from # the command line, we won't have any debugger object in # lldb.debugger, so we can just create it if it will be needed lldb.debugger = lldb.SBDebugger.Create() # Now do whatever work this module would do when run as a command # Now dispose of the debugger you just made. lldb.SBDebugger.Destroy(debugger) ```That seems useful trick. ================ Comment at: lldb/examples/darwin/heap_find/heap.py:1518 + __name__) + # debugger.HandleCommand('command script add -f %s.heap heap' % package_name) + # debugger.HandleCommand('command script add -f %s.section_ptr_refs section_ptr_refs' % package_name) ---------------- Do you know what these commented-out lines are for? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D117237/new/ https://reviews.llvm.org/D117237 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits