Skip to content

Commit 7d33929

Browse files
Merge pull request swiftlang#7922 from felipepiovezan/felipe/cherry-pick-actionable-feedback
[cherry-pick][lldb] Add actionable feedback when overwriting a command fails (llvm#76030)
2 parents 1312409 + ca53fea commit 7d33929

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lldb/source/Interpreter/CommandInterpreter.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,11 @@ Status CommandInterpreter::AddUserCommand(llvm::StringRef name,
11671167

11681168
if (UserCommandExists(name)) {
11691169
if (!can_replace) {
1170-
result.SetErrorString("user command exists and force replace not set");
1170+
result.SetErrorStringWithFormatv(
1171+
"user command \"{0}\" already exists and force replace was not set "
1172+
"by --overwrite or 'settings set interpreter.require-overwrite "
1173+
"false'",
1174+
name);
11711175
return result;
11721176
}
11731177
if (cmd_sp->IsMultiwordObject()) {

lldb/test/API/commands/command/script/TestCommandScript.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,19 @@ def cleanup():
161161
)
162162
self.expect("my_command", substrs=["a.out"])
163163

164+
# Test that without --overwrite we are not allowed to redefine the command.
165+
self.expect(
166+
"command script add my_command --class welcome.TargetnameCommand",
167+
substrs=[
168+
(
169+
'user command "my_command" already exists and force replace was'
170+
" not set by --overwrite or 'settings set"
171+
" interpreter.require-overwrite false'"
172+
),
173+
],
174+
error=True,
175+
)
176+
164177
self.runCmd("command script clear")
165178

166179
self.expect(

0 commit comments

Comments
 (0)