Fixed the "expression" command when it comes to using it with the new GDB format
command suffix:
(lldb) expression/x 3+3
Since "expression" is a raw command that has options, we need to make sure the
command gets its options properly terminated with a "--".
Also fixed an issue where if you try to use the GDB command suffix on a
command that doesn't support the "--gdb-format" command, it will report an
appropriate error.
For the fix above, you can query an lldb_private::Options object to see if it
supports a long option by name.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@143266 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Interpreter/CommandInterpreter.cpp b/source/Interpreter/CommandInterpreter.cpp
index fb5fc4c..0b9e4db 100644
--- a/source/Interpreter/CommandInterpreter.cpp
+++ b/source/Interpreter/CommandInterpreter.cpp
@@ -1359,8 +1359,30 @@
{
case '/':
// GDB format suffixes
- revised_command_line.Printf (" --gdb-format=%s", suffix.c_str() + 1);
+ {
+ Options *command_options = cmd_obj->GetOptions();
+ if (command_options && command_options->SupportsLongOption("gdb-format"))
+ {
+ revised_command_line.Printf (" --gdb-format=%s", suffix.c_str() + 1);
+ if (wants_raw_input && command_string.find ("-- ") == std::string::npos)
+ revised_command_line.Printf (" --");
+ }
+ else
+ {
+ result.AppendErrorWithFormat ("the '%s' command doesn't support the --gdb-format option\n",
+ cmd_obj->GetCommandName());
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ }
break;
+
+ default:
+ result.AppendErrorWithFormat ("unknown command shorthand suffix: '%s'\n",
+ suffix.c_str());
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+
}
}
}