Skip to content

Commit 4c9e125

Browse files
committed
[lldb] Update custom commands to always be overrriden
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. Differential Revision: https://reviews.llvm.org/D140293 Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent 29a5758 commit 4c9e125

16 files changed

+23
-23
lines changed

lldb/examples/darwin/heap_find/heap.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,19 +1503,19 @@ def __lldb_init_module(debugger, internal_dict):
15031503
malloc_info.__doc__ = get_malloc_info_options().format_help()
15041504
objc_refs.__doc__ = get_objc_refs_options().format_help()
15051505
debugger.HandleCommand(
1506-
'command script add -f %s.ptr_refs ptr_refs' %
1506+
'command script add -o -f %s.ptr_refs ptr_refs' %
15071507
__name__)
15081508
debugger.HandleCommand(
1509-
'command script add -f %s.cstr_refs cstr_refs' %
1509+
'command script add -o -f %s.cstr_refs cstr_refs' %
15101510
__name__)
15111511
debugger.HandleCommand(
1512-
'command script add -f %s.malloc_info malloc_info' %
1512+
'command script add -o -f %s.malloc_info malloc_info' %
15131513
__name__)
15141514
debugger.HandleCommand(
1515-
'command script add -f %s.find_variable find_variable' %
1515+
'command script add -o -f %s.find_variable find_variable' %
15161516
__name__)
1517-
# debugger.HandleCommand('command script add -f %s.section_ptr_refs section_ptr_refs' % package_name)
1517+
# debugger.HandleCommand('command script add -o -f %s.section_ptr_refs section_ptr_refs' % package_name)
15181518
debugger.HandleCommand(
1519-
'command script add -f %s.objc_refs objc_refs' %
1519+
'command script add -o -f %s.objc_refs objc_refs' %
15201520
__name__)
15211521
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/examples/python/bsd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ def __lldb_init_module(debugger, dict):
558558
# interpreter.
559559
# Add any commands contained in this module to LLDB
560560
debugger.HandleCommand(
561-
'command script add -c %s.VerifyDebugMapCommand %s' % (
561+
'command script add -o -c %s.VerifyDebugMapCommand %s' % (
562562
__name__, VerifyDebugMapCommand.name))
563563
print('The "%s" command has been installed, type "help %s" for detailed '
564564
'help.' % (VerifyDebugMapCommand.name, VerifyDebugMapCommand.name))

lldb/examples/python/cmdtemplate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def register_lldb_command(cls, debugger, module_name):
2424
parser = cls.create_options()
2525
cls.__doc__ = parser.format_help()
2626
# Add any commands contained in this module to LLDB
27-
command = 'command script add -c %s.%s %s' % (module_name,
27+
command = 'command script add -o -c %s.%s %s' % (module_name,
2828
cls.__name__,
2929
cls.program)
3030
debugger.HandleCommand(command)

lldb/examples/python/delta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,5 @@ def __lldb_init_module(debugger, internal_dict):
128128
# This initializer is being run from LLDB in the embedded command interpreter
129129
# Add any commands contained in this module to LLDB
130130
debugger.HandleCommand(
131-
'command script add -f delta.parse_time_log parse_time_log')
131+
'command script add -o -f delta.parse_time_log parse_time_log')
132132
print('The "parse_time_log" command is now installed and ready for use, type "parse_time_log --help" for more information')

lldb/examples/python/diagnose_nsstring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def diagnose_nsstring_Command_Impl(debugger, command, result, internal_dict):
175175

176176
def __lldb_init_module(debugger, internal_dict):
177177
debugger.HandleCommand(
178-
"command script add -f %s.diagnose_nsstring_Command_Impl diagnose-nsstring" %
178+
"command script add -o -f %s.diagnose_nsstring_Command_Impl diagnose-nsstring" %
179179
__name__)
180180
print('The "diagnose-nsstring" command has been installed, type "help diagnose-nsstring" for detailed help.')
181181

lldb/examples/python/diagnose_unwind.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,6 @@ def create_diagnose_unwind_options():
309309

310310
def __lldb_init_module(debugger, internal_dict):
311311
debugger.HandleCommand(
312-
'command script add -f %s.diagnose_unwind diagnose-unwind' %
312+
'command script add -o -f %s.diagnose_unwind diagnose-unwind' %
313313
__name__)
314314
print('The "diagnose-unwind" command has been installed, type "help diagnose-unwind" for detailed help.')

lldb/examples/python/disassembly_mode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ def get_short_help(self):
4545
return "Toggles between a disassembly only mode and normal source mode\n"
4646

4747
def __lldb_init_module(debugger, unused):
48-
debugger.HandleCommand("command script add -c disassembly_mode.DisassemblyMode toggle-disassembly")
48+
debugger.HandleCommand("command script add -o -c disassembly_mode.DisassemblyMode toggle-disassembly")

lldb/examples/python/gdb_disassemble.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ def disassemble(debugger, command, result, dict):
2323
# Install the command when the module gets imported
2424
def __lldb_init_module(debugger, internal_dict):
2525
debugger.HandleCommand(
26-
'command script add -f gdb_disassemble.disassemble gdb-disassemble')
26+
'command script add -o -f gdb_disassemble.disassemble gdb-disassemble')
2727
print('Installed "gdb-disassemble" command for disassembly')

lldb/examples/python/gdbremote.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,7 +1626,7 @@ def __lldb_init_module(debugger, internal_dict):
16261626
# This initializer is being run from LLDB in the embedded command interpreter
16271627
# Add any commands contained in this module to LLDB
16281628
debugger.HandleCommand(
1629-
'command script add -f gdbremote.start_gdb_log start_gdb_log')
1629+
'command script add -o -f gdbremote.start_gdb_log start_gdb_log')
16301630
debugger.HandleCommand(
1631-
'command script add -f gdbremote.stop_gdb_log stop_gdb_log')
1631+
'command script add -o -f gdbremote.stop_gdb_log stop_gdb_log')
16321632
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')

lldb/examples/python/jump.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,5 @@ def jump(debugger, command, result, internal_dict):
192192
def __lldb_init_module(debugger, internal_dict):
193193
# Module is being run inside the LLDB interpreter
194194
jump.__doc__ = usage_string()
195-
debugger.HandleCommand('command script add -f jump.jump jump')
195+
debugger.HandleCommand('command script add -o -f jump.jump jump')
196196
print('The "jump" command has been installed, type "help jump" or "jump <ENTER>" for detailed help.')

0 commit comments

Comments
 (0)