mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-23 13:50:11 +00:00
[lldb] Add actionable feedback when overwriting a command fails (#76030)
If adding a user commands fails because a command with the same name already exists, we only say that "force replace is not set" without telling the user _how_ to set it. There are two ways to do so; this commit changes the error message to mention both.
This commit is contained in:
parent
e6d2bb0ed8
commit
cf0be7b492
@ -1160,7 +1160,11 @@ Status CommandInterpreter::AddUserCommand(llvm::StringRef name,
|
||||
|
||||
if (UserCommandExists(name)) {
|
||||
if (!can_replace) {
|
||||
result.SetErrorString("user command exists and force replace not set");
|
||||
result.SetErrorStringWithFormatv(
|
||||
"user command \"{0}\" already exists and force replace was not set "
|
||||
"by --overwrite or 'settings set interpreter.require-overwrite "
|
||||
"false'",
|
||||
name);
|
||||
return result;
|
||||
}
|
||||
if (cmd_sp->IsMultiwordObject()) {
|
||||
|
@ -161,6 +161,19 @@ class CmdPythonTestCase(TestBase):
|
||||
)
|
||||
self.expect("my_command", substrs=["a.out"])
|
||||
|
||||
# Test that without --overwrite we are not allowed to redefine the command.
|
||||
self.expect(
|
||||
"command script add my_command --class welcome.TargetnameCommand",
|
||||
substrs=[
|
||||
(
|
||||
'user command "my_command" already exists and force replace was'
|
||||
" not set by --overwrite or 'settings set"
|
||||
" interpreter.require-overwrite false'"
|
||||
),
|
||||
],
|
||||
error=True,
|
||||
)
|
||||
|
||||
self.runCmd("command script clear")
|
||||
|
||||
self.expect(
|
||||
|
Loading…
Reference in New Issue
Block a user