Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lldb] Rename CommandReturnObject::Get.*Data -> Get.*String #112062

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lldb/include/lldb/Interpreter/CommandReturnObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@ class CommandReturnObject {

~CommandReturnObject() = default;

llvm::StringRef GetInlineDiagnosticsData(unsigned indent);
/// Format any inline diagnostics with an indentation of \c indent.
llvm::StringRef GetInlineDiagnosticString(unsigned indent);

llvm::StringRef GetOutputData() {
llvm::StringRef GetOutputString() {
lldb::StreamSP stream_sp(m_out_stream.GetStreamAtIndex(eStreamStringIndex));
if (stream_sp)
return std::static_pointer_cast<StreamString>(stream_sp)->GetString();
return llvm::StringRef();
}

llvm::StringRef GetErrorData();
llvm::StringRef GetErrorString();

Stream &GetOutputStream() {
// Make sure we at least have our normal string stream output stream
Expand Down
8 changes: 4 additions & 4 deletions lldb/source/API/SBCommandReturnObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,27 +85,27 @@ SBCommandReturnObject::operator bool() const {
const char *SBCommandReturnObject::GetOutput() {
LLDB_INSTRUMENT_VA(this);

ConstString output(ref().GetOutputData());
ConstString output(ref().GetOutputString());
return output.AsCString(/*value_if_empty*/ "");
}

const char *SBCommandReturnObject::GetError() {
LLDB_INSTRUMENT_VA(this);

ConstString output(ref().GetErrorData());
ConstString output(ref().GetErrorString());
return output.AsCString(/*value_if_empty*/ "");
}

size_t SBCommandReturnObject::GetOutputSize() {
LLDB_INSTRUMENT_VA(this);

return ref().GetOutputData().size();
return ref().GetOutputString().size();
}

size_t SBCommandReturnObject::GetErrorSize() {
LLDB_INSTRUMENT_VA(this);

return ref().GetErrorData().size();
return ref().GetErrorString().size();
}

size_t SBCommandReturnObject::PutOutput(FILE *fh) {
Expand Down
6 changes: 3 additions & 3 deletions lldb/source/Commands/CommandObjectCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ class CommandObjectPythonFunction : public CommandObjectRaw {
} else {
// Don't change the status if the command already set it...
if (result.GetStatus() == eReturnStatusInvalid) {
if (result.GetOutputData().empty())
if (result.GetOutputString().empty())
result.SetStatus(eReturnStatusSuccessFinishNoResult);
else
result.SetStatus(eReturnStatusSuccessFinishResult);
Expand Down Expand Up @@ -1205,7 +1205,7 @@ class CommandObjectScriptingObjectRaw : public CommandObjectRaw {
} else {
// Don't change the status if the command already set it...
if (result.GetStatus() == eReturnStatusInvalid) {
if (result.GetOutputData().empty())
if (result.GetOutputString().empty())
result.SetStatus(eReturnStatusSuccessFinishNoResult);
else
result.SetStatus(eReturnStatusSuccessFinishResult);
Expand Down Expand Up @@ -2137,7 +2137,7 @@ class CommandObjectScriptingObjectParsed : public CommandObjectParsed {
} else {
// Don't change the status if the command already set it...
if (result.GetStatus() == eReturnStatusInvalid) {
if (result.GetOutputData().empty())
if (result.GetOutputString().empty())
result.SetStatus(eReturnStatusSuccessFinishNoResult);
else
result.SetStatus(eReturnStatusSuccessFinishResult);
Expand Down
5 changes: 3 additions & 2 deletions lldb/source/Core/Debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,9 +784,10 @@ void Debugger::Destroy(DebuggerSP &debugger_sp) {
CommandReturnObject result(debugger_sp->GetUseColor());
cmd_interpreter.SaveTranscript(result);
if (result.Succeeded())
(*debugger_sp->GetAsyncOutputStream()) << result.GetOutputData() << '\n';
(*debugger_sp->GetAsyncOutputStream())
<< result.GetOutputString() << '\n';
else
(*debugger_sp->GetAsyncErrorStream()) << result.GetErrorData() << '\n';
(*debugger_sp->GetAsyncErrorStream()) << result.GetErrorString() << '\n';
}

debugger_sp->Clear();
Expand Down
18 changes: 9 additions & 9 deletions lldb/source/Interpreter/CommandInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2094,11 +2094,11 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
// used instead of `GetSaveTrasncript()`. This is because the latter will
// fail when the command is "settings set interpreter.save-transcript true".
if (transcript_item) {
m_transcript_stream << result.GetOutputData();
m_transcript_stream << result.GetErrorData();
m_transcript_stream << result.GetOutputString();
m_transcript_stream << result.GetErrorString();

transcript_item->AddStringItem("output", result.GetOutputData());
transcript_item->AddStringItem("error", result.GetErrorData());
transcript_item->AddStringItem("output", result.GetOutputString());
transcript_item->AddStringItem("error", result.GetErrorString());
transcript_item->AddFloatItem("durationInSeconds",
execute_time.get().count());
}
Expand Down Expand Up @@ -2632,11 +2632,11 @@ void CommandInterpreter::HandleCommands(const StringList &commands,

if (options.GetPrintResults()) {
if (tmp_result.Succeeded())
result.AppendMessage(tmp_result.GetOutputData());
result.AppendMessage(tmp_result.GetOutputString());
}

if (!success || !tmp_result.Succeeded()) {
llvm::StringRef error_msg = tmp_result.GetErrorData();
llvm::StringRef error_msg = tmp_result.GetErrorString();
if (error_msg.empty())
error_msg = "<unknown error>.\n";
if (options.GetStopOnError()) {
Expand Down Expand Up @@ -3192,7 +3192,7 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
unsigned prompt_len = m_debugger.GetPrompt().size();
if (auto indent = result.GetDiagnosticIndent()) {
llvm::StringRef diags =
result.GetInlineDiagnosticsData(prompt_len + *indent);
result.GetInlineDiagnosticString(prompt_len + *indent);
PrintCommandOutput(io_handler, diags, true);
}
}
Expand All @@ -3201,13 +3201,13 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
GetProcessOutput();

if (!result.GetImmediateOutputStream()) {
llvm::StringRef output = result.GetOutputData();
llvm::StringRef output = result.GetOutputString();
PrintCommandOutput(io_handler, output, true);
}

// Now emit the command error text from the command we just executed.
if (!result.GetImmediateErrorStream()) {
llvm::StringRef error = result.GetErrorData();
llvm::StringRef error = result.GetErrorString();
PrintCommandOutput(io_handler, error, false);
}
}
Expand Down
5 changes: 3 additions & 2 deletions lldb/source/Interpreter/CommandReturnObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ void CommandReturnObject::SetError(llvm::Error error) {
}
}

llvm::StringRef CommandReturnObject::GetInlineDiagnosticsData(unsigned indent) {
llvm::StringRef
CommandReturnObject::GetInlineDiagnosticString(unsigned indent) {
RenderDiagnosticDetails(m_diag_stream, indent, true, m_diagnostics);
// Duplex the diagnostics to the secondary stream (but not inlined).
if (auto stream_sp = m_err_stream.GetStreamAtIndex(eStreamStringIndex))
Expand All @@ -134,7 +135,7 @@ llvm::StringRef CommandReturnObject::GetInlineDiagnosticsData(unsigned indent) {
return m_diag_stream.GetString();
}

llvm::StringRef CommandReturnObject::GetErrorData() {
llvm::StringRef CommandReturnObject::GetErrorString() {
// Diagnostics haven't been fetched; render them now (not inlined).
if (!m_diagnostics.empty()) {
RenderDiagnosticDetails(GetErrorStream(), std::nullopt, false,
Expand Down
4 changes: 2 additions & 2 deletions lldb/tools/lldb-test/lldb-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ int opts::breakpoint::evaluateBreakpoints(Debugger &Dbg) {
CommandReturnObject Result(/*colors*/ false);
if (!Dbg.GetCommandInterpreter().HandleCommand(
Command.c_str(), /*add_to_history*/ eLazyBoolNo, Result)) {
P.formatLine("Failed: {0}", Result.GetErrorData());
P.formatLine("Failed: {0}", Result.GetErrorString());
HadErrors = 1;
continue;
}
Expand Down Expand Up @@ -1161,7 +1161,7 @@ int opts::irmemorymap::evaluateMemoryMapCommands(Debugger &Dbg) {
return CI.HandleCommand(Cmd, eLazyBoolNo, Result);
};
if (!IssueCmd("b main") || !IssueCmd("run")) {
outs() << formatv("Failed: {0}\n", Result.GetErrorData());
outs() << formatv("Failed: {0}\n", Result.GetErrorString());
exit(1);
}

Expand Down
Loading