mib created this revision. mib added reviewers: JDevlieghere, bulbazord. mib added a project: LLDB. Herald added a project: All. mib requested review of this revision. Herald added a subscriber: lldb-commits.
This is a follow-up patch to 6f7835f309b9. As explained previously, when running from an IDE, it can happen that the IDE imports some lldb scripts by itself. If the user also tries to import these commands, lldb will show the following message: error: cannot add command: user command exists and force replace not set This message is confusing to the user, because it suggests that the command import failed and that the execution should stop. However, in this case, lldb will continue the execution with the command added previously by the user. To prevent that, this patch updates every first-party lldb-packaged custom commands to override commands that were pre-imported in lldb. Signed-off-by: Med Ismail Bennani <medismail.benn...@gmail.com> Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D140293 Files: lldb/examples/darwin/heap_find/heap.py lldb/examples/python/bsd.py lldb/examples/python/cmdtemplate.py lldb/examples/python/crashlog.py lldb/examples/python/delta.py lldb/examples/python/diagnose_nsstring.py lldb/examples/python/diagnose_unwind.py lldb/examples/python/disassembly_mode.py lldb/examples/python/gdb_disassemble.py lldb/examples/python/gdbremote.py lldb/examples/python/jump.py lldb/examples/python/lldb_module_utils.py lldb/examples/python/memory.py lldb/examples/python/sources.py lldb/examples/python/stacks.py lldb/examples/python/step_and_print.py lldb/examples/python/types.py
Index: lldb/examples/python/types.py =================================================================== --- lldb/examples/python/types.py +++ lldb/examples/python/types.py @@ -351,5 +351,5 @@ def __lldb_init_module(debugger, internal_dict): debugger.HandleCommand( - 'command script add -f types.check_padding_command check_padding') + 'command script add -o -f types.check_padding_command check_padding') print('"check_padding" command installed, use the "--help" option for detailed help') Index: lldb/examples/python/step_and_print.py =================================================================== --- lldb/examples/python/step_and_print.py +++ lldb/examples/python/step_and_print.py @@ -21,4 +21,4 @@ return "Does a step-over then runs frame variable passing the command args to it\n" def __lldb_init_module(debugger, unused): - debugger.HandleCommand("command script add -c step_and_print.StepAndPrint sap") + debugger.HandleCommand("command script add -o -c step_and_print.StepAndPrint sap") Index: lldb/examples/python/stacks.py =================================================================== --- lldb/examples/python/stacks.py +++ lldb/examples/python/stacks.py @@ -64,5 +64,5 @@ def __lldb_init_module(debugger, internal_dict): debugger.HandleCommand( - "command script add -f stacks.stack_frames stack_frames") + "command script add -o -f stacks.stack_frames stack_frames") print("A new command called 'stack_frames' was added, type 'stack_frames --help' for more information.") Index: lldb/examples/python/sources.py =================================================================== --- lldb/examples/python/sources.py +++ lldb/examples/python/sources.py @@ -27,5 +27,5 @@ def __lldb_init_module(debugger, dict): # Add any commands contained in this module to LLDB debugger.HandleCommand( - 'command script add -f sources.info_sources info_sources') + 'command script add -o -f sources.info_sources info_sources') print('The "info_sources" command has been installed, type "help info_sources" or "info_sources --help" for detailed help.') Index: lldb/examples/python/memory.py =================================================================== --- lldb/examples/python/memory.py +++ lldb/examples/python/memory.py @@ -272,5 +272,5 @@ def __lldb_init_module(debugger, internal_dict): memfind_command.__doc__ = create_memfind_options().format_help() debugger.HandleCommand( - 'command script add -f memory.memfind_command memfind') + 'command script add -o -f memory.memfind_command memfind') print('"memfind" command installed, use the "--help" option for detailed help') Index: lldb/examples/python/lldb_module_utils.py =================================================================== --- lldb/examples/python/lldb_module_utils.py +++ lldb/examples/python/lldb_module_utils.py @@ -183,9 +183,9 @@ # Add any commands contained in this module to LLDB debugger.HandleCommand( - 'command script add -c %s.DumpLineTables %s' % (__name__, + 'command script add -o -c %s.DumpLineTables %s' % (__name__, DumpLineTables.command_name)) debugger.HandleCommand( - 'command script add -c %s.DumpFiles %s' % (__name__, DumpFiles.command_name)) + 'command script add -o -c %s.DumpFiles %s' % (__name__, DumpFiles.command_name)) print('The "%s" and "%s" commands have been installed.' % (DumpLineTables.command_name, DumpFiles.command_name)) Index: lldb/examples/python/jump.py =================================================================== --- lldb/examples/python/jump.py +++ lldb/examples/python/jump.py @@ -192,5 +192,5 @@ def __lldb_init_module(debugger, internal_dict): # Module is being run inside the LLDB interpreter jump.__doc__ = usage_string() - debugger.HandleCommand('command script add -f jump.jump jump') + debugger.HandleCommand('command script add -o -f jump.jump jump') print('The "jump" command has been installed, type "help jump" or "jump <ENTER>" for detailed help.') Index: lldb/examples/python/gdbremote.py =================================================================== --- lldb/examples/python/gdbremote.py +++ lldb/examples/python/gdbremote.py @@ -1626,7 +1626,7 @@ # This initializer is being run from LLDB in the embedded command interpreter # Add any commands contained in this module to LLDB debugger.HandleCommand( - 'command script add -f gdbremote.start_gdb_log start_gdb_log') + 'command script add -o -f gdbremote.start_gdb_log start_gdb_log') debugger.HandleCommand( - 'command script add -f gdbremote.stop_gdb_log stop_gdb_log') + 'command script add -o -f gdbremote.stop_gdb_log stop_gdb_log') print('The "start_gdb_log" and "stop_gdb_log" commands are now installed and ready for use, type "start_gdb_log --help" or "stop_gdb_log --help" for more information') Index: lldb/examples/python/gdb_disassemble.py =================================================================== --- lldb/examples/python/gdb_disassemble.py +++ lldb/examples/python/gdb_disassemble.py @@ -23,5 +23,5 @@ # Install the command when the module gets imported def __lldb_init_module(debugger, internal_dict): debugger.HandleCommand( - 'command script add -f gdb_disassemble.disassemble gdb-disassemble') + 'command script add -o -f gdb_disassemble.disassemble gdb-disassemble') print('Installed "gdb-disassemble" command for disassembly') Index: lldb/examples/python/disassembly_mode.py =================================================================== --- lldb/examples/python/disassembly_mode.py +++ lldb/examples/python/disassembly_mode.py @@ -45,4 +45,4 @@ return "Toggles between a disassembly only mode and normal source mode\n" def __lldb_init_module(debugger, unused): - debugger.HandleCommand("command script add -c disassembly_mode.DisassemblyMode toggle-disassembly") + debugger.HandleCommand("command script add -o -c disassembly_mode.DisassemblyMode toggle-disassembly") Index: lldb/examples/python/diagnose_unwind.py =================================================================== --- lldb/examples/python/diagnose_unwind.py +++ lldb/examples/python/diagnose_unwind.py @@ -309,6 +309,6 @@ def __lldb_init_module(debugger, internal_dict): debugger.HandleCommand( - 'command script add -f %s.diagnose_unwind diagnose-unwind' % + 'command script add -o -f %s.diagnose_unwind diagnose-unwind' % __name__) print('The "diagnose-unwind" command has been installed, type "help diagnose-unwind" for detailed help.') Index: lldb/examples/python/diagnose_nsstring.py =================================================================== --- lldb/examples/python/diagnose_nsstring.py +++ lldb/examples/python/diagnose_nsstring.py @@ -175,7 +175,7 @@ def __lldb_init_module(debugger, internal_dict): debugger.HandleCommand( - "command script add -f %s.diagnose_nsstring_Command_Impl diagnose-nsstring" % + "command script add -o -f %s.diagnose_nsstring_Command_Impl diagnose-nsstring" % __name__) print('The "diagnose-nsstring" command has been installed, type "help diagnose-nsstring" for detailed help.') Index: lldb/examples/python/delta.py =================================================================== --- lldb/examples/python/delta.py +++ lldb/examples/python/delta.py @@ -128,5 +128,5 @@ # This initializer is being run from LLDB in the embedded command interpreter # Add any commands contained in this module to LLDB debugger.HandleCommand( - 'command script add -f delta.parse_time_log parse_time_log') + 'command script add -o -f delta.parse_time_log parse_time_log') print('The "parse_time_log" command is now installed and ready for use, type "parse_time_log --help" for more information') Index: lldb/examples/python/crashlog.py =================================================================== --- lldb/examples/python/crashlog.py +++ lldb/examples/python/crashlog.py @@ -1345,8 +1345,8 @@ def __lldb_init_module(debugger, internal_dict): debugger.HandleCommand( - 'command script add -o -c lldb.macosx.crashlog.Symbolicate crashlog') + 'command script add -o -o -c lldb.macosx.crashlog.Symbolicate crashlog') debugger.HandleCommand( - 'command script add -o -f lldb.macosx.crashlog.save_crashlog save_crashlog') + 'command script add -o -o -f lldb.macosx.crashlog.save_crashlog save_crashlog') print('"crashlog" and "save_crashlog" commands have been installed, use ' 'the "--help" options on these commands for detailed help.') Index: lldb/examples/python/cmdtemplate.py =================================================================== --- lldb/examples/python/cmdtemplate.py +++ lldb/examples/python/cmdtemplate.py @@ -24,7 +24,7 @@ parser = cls.create_options() cls.__doc__ = parser.format_help() # Add any commands contained in this module to LLDB - command = 'command script add -c %s.%s %s' % (module_name, + command = 'command script add -o -c %s.%s %s' % (module_name, cls.__name__, cls.program) debugger.HandleCommand(command) Index: lldb/examples/python/bsd.py =================================================================== --- lldb/examples/python/bsd.py +++ lldb/examples/python/bsd.py @@ -558,7 +558,7 @@ # interpreter. # Add any commands contained in this module to LLDB debugger.HandleCommand( - 'command script add -c %s.VerifyDebugMapCommand %s' % ( + 'command script add -o -c %s.VerifyDebugMapCommand %s' % ( __name__, VerifyDebugMapCommand.name)) print('The "%s" command has been installed, type "help %s" for detailed ' 'help.' % (VerifyDebugMapCommand.name, VerifyDebugMapCommand.name)) Index: lldb/examples/darwin/heap_find/heap.py =================================================================== --- lldb/examples/darwin/heap_find/heap.py +++ lldb/examples/darwin/heap_find/heap.py @@ -1503,19 +1503,19 @@ malloc_info.__doc__ = get_malloc_info_options().format_help() objc_refs.__doc__ = get_objc_refs_options().format_help() debugger.HandleCommand( - 'command script add -f %s.ptr_refs ptr_refs' % + 'command script add -o -f %s.ptr_refs ptr_refs' % __name__) debugger.HandleCommand( - 'command script add -f %s.cstr_refs cstr_refs' % + 'command script add -o -f %s.cstr_refs cstr_refs' % __name__) debugger.HandleCommand( - 'command script add -f %s.malloc_info malloc_info' % + 'command script add -o -f %s.malloc_info malloc_info' % __name__) debugger.HandleCommand( - 'command script add -f %s.find_variable find_variable' % + 'command script add -o -f %s.find_variable find_variable' % __name__) - # debugger.HandleCommand('command script add -f %s.section_ptr_refs section_ptr_refs' % package_name) + # debugger.HandleCommand('command script add -o -f %s.section_ptr_refs section_ptr_refs' % package_name) debugger.HandleCommand( - 'command script add -f %s.objc_refs objc_refs' % + 'command script add -o -f %s.objc_refs objc_refs' % __name__) print('"malloc_info", "ptr_refs", "cstr_refs", "find_variable", and "objc_refs" commands have been installed, use the "--help" options on these commands for detailed help.')
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits