diff options
author | Adrian Prantl <aprantl@apple.com> | 2024-10-14 16:29:26 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-14 16:29:26 -0700 |
commit | 9eddc8b9bf4e4e0b01e2ecc90a71c4b3b4e9c8af (patch) | |
tree | c5525898a47401b0e6ebb6d4cc8b72569fd5d953 /lldb/source/Interpreter/CommandInterpreter.cpp | |
parent | fc08ad6610c66856f48559e543eb7be317e908e7 (diff) | |
download | llvm-9eddc8b9bf4e4e0b01e2ecc90a71c4b3b4e9c8af.zip llvm-9eddc8b9bf4e4e0b01e2ecc90a71c4b3b4e9c8af.tar.gz llvm-9eddc8b9bf4e4e0b01e2ecc90a71c4b3b4e9c8af.tar.bz2 |
[lldb] Expose structured command diagnostics via the SBAPI. (#112109)
This allows IDEs to render LLDB expression diagnostics to their liking
without relying on characterprecise ASCII art from LLDB. It is exposed
as a versioned SBStructuredData object, since it is expected that this
may need to be tweaked based on actual usage.
Diffstat (limited to 'lldb/source/Interpreter/CommandInterpreter.cpp')
-rw-r--r-- | lldb/source/Interpreter/CommandInterpreter.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 19bb420..bfac3f4 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -2636,20 +2636,18 @@ void CommandInterpreter::HandleCommands(const StringList &commands, } if (!success || !tmp_result.Succeeded()) { - llvm::StringRef error_msg = tmp_result.GetErrorString(); + std::string error_msg = tmp_result.GetErrorString(); if (error_msg.empty()) error_msg = "<unknown error>.\n"; if (options.GetStopOnError()) { - result.AppendErrorWithFormat( - "Aborting reading of commands after command #%" PRIu64 - ": '%s' failed with %s", - (uint64_t)idx, cmd, error_msg.str().c_str()); + result.AppendErrorWithFormatv("Aborting reading of commands after " + "command #{0}: '{1}' failed with {2}", + (uint64_t)idx, cmd, error_msg); m_debugger.SetAsyncExecution(old_async_execution); return; } else if (options.GetPrintResults()) { - result.AppendMessageWithFormat( - "Command #%" PRIu64 " '%s' failed with %s", (uint64_t)idx + 1, cmd, - error_msg.str().c_str()); + result.AppendMessageWithFormatv("Command #{0} '{1}' failed with {2}", + (uint64_t)idx + 1, cmd, error_msg); } } @@ -3187,11 +3185,12 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler, io_handler.GetFlags().Test(eHandleCommandFlagPrintResult)) || io_handler.GetFlags().Test(eHandleCommandFlagPrintErrors)) { // Display any inline diagnostics first. - if (!result.GetImmediateErrorStream() && - GetDebugger().GetShowInlineDiagnostics()) { + const bool inline_diagnostics = !result.GetImmediateErrorStream() && + GetDebugger().GetShowInlineDiagnostics(); + if (inline_diagnostics) { unsigned prompt_len = m_debugger.GetPrompt().size(); if (auto indent = result.GetDiagnosticIndent()) { - llvm::StringRef diags = + std::string diags = result.GetInlineDiagnosticString(prompt_len + *indent); PrintCommandOutput(io_handler, diags, true); } @@ -3207,7 +3206,7 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler, // Now emit the command error text from the command we just executed. if (!result.GetImmediateErrorStream()) { - llvm::StringRef error = result.GetErrorString(); + std::string error = result.GetErrorString(!inline_diagnostics); PrintCommandOutput(io_handler, error, false); } } |