aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Interpreter/CommandInterpreter.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2024-10-11 09:08:52 -0700
committerGitHub <noreply@github.com>2024-10-11 09:08:52 -0700
commit089227feaf0efb5e540783a5542655e25669e7d8 (patch)
treefa1f1cbc27629c0c62a4b2952533fc72796b3a78 /lldb/source/Interpreter/CommandInterpreter.cpp
parent5b25c31351ad1b10a3819411379b3258869c1e1b (diff)
downloadllvm-089227feaf0efb5e540783a5542655e25669e7d8.zip
llvm-089227feaf0efb5e540783a5542655e25669e7d8.tar.gz
llvm-089227feaf0efb5e540783a5542655e25669e7d8.tar.bz2
Support inline diagnostics in CommandReturnObject (#110901)
and implement them for dwim-print (a.k.a. `p`) as an example. The next step will be to expose them as structured data in SBCommandReturnObject.
Diffstat (limited to 'lldb/source/Interpreter/CommandInterpreter.cpp')
-rw-r--r--lldb/source/Interpreter/CommandInterpreter.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 8d3a82e..b4a8233 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -2069,7 +2069,7 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
remainder.c_str());
// To test whether or not transcript should be saved, `transcript_item` is
- // used instead of `GetSaveTrasncript()`. This is because the latter will
+ // used instead of `GetSaveTranscript()`. This is because the latter will
// fail when the command is "settings set interpreter.save-transcript true".
if (transcript_item) {
transcript_item->AddStringItem("commandName", cmd_obj->GetCommandName());
@@ -2078,6 +2078,12 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
ElapsedTime elapsed(execute_time);
cmd_obj->SetOriginalCommandString(real_original_command_string);
+ // Set the indent to the position of the command in the command line.
+ pos = real_original_command_string.rfind(remainder);
+ std::optional<uint16_t> indent;
+ if (pos != std::string::npos)
+ indent = pos;
+ result.SetDiagnosticIndent(indent);
cmd_obj->Execute(remainder.c_str(), result);
}
@@ -3180,7 +3186,18 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
if ((result.Succeeded() &&
io_handler.GetFlags().Test(eHandleCommandFlagPrintResult)) ||
io_handler.GetFlags().Test(eHandleCommandFlagPrintErrors)) {
- // Display any STDOUT/STDERR _prior_ to emitting the command result text
+ // Display any inline diagnostics first.
+ if (!result.GetImmediateErrorStream() &&
+ GetDebugger().GetShowInlineDiagnostics()) {
+ unsigned prompt_len = m_debugger.GetPrompt().size();
+ if (auto indent = result.GetDiagnosticIndent()) {
+ llvm::StringRef diags =
+ result.GetInlineDiagnosticsData(prompt_len + *indent);
+ PrintCommandOutput(io_handler, diags, true);
+ }
+ }
+
+ // Display any STDOUT/STDERR _prior_ to emitting the command result text.
GetProcessOutput();
if (!result.GetImmediateOutputStream()) {
@@ -3188,7 +3205,7 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
PrintCommandOutput(io_handler, output, true);
}
- // Now emit the command error text from the command we just executed
+ // Now emit the command error text from the command we just executed.
if (!result.GetImmediateErrorStream()) {
llvm::StringRef error = result.GetErrorData();
PrintCommandOutput(io_handler, error, false);