Skip to content

Commit c275080

Browse files
[lldb] Rename CommandReturnObject::Get.*Data -> Get.*String (#112062)
In a later commit, I want to add a method to access diagnostics as actual structured data, which will make these function names rather confusing.
1 parent e866e6b commit c275080

File tree

7 files changed

+28
-25
lines changed

7 files changed

+28
-25
lines changed

lldb/include/lldb/Interpreter/CommandReturnObject.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,17 @@ class CommandReturnObject {
3030

3131
~CommandReturnObject() = default;
3232

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

35-
llvm::StringRef GetOutputData() {
36+
llvm::StringRef GetOutputString() {
3637
lldb::StreamSP stream_sp(m_out_stream.GetStreamAtIndex(eStreamStringIndex));
3738
if (stream_sp)
3839
return std::static_pointer_cast<StreamString>(stream_sp)->GetString();
3940
return llvm::StringRef();
4041
}
4142

42-
llvm::StringRef GetErrorData();
43+
llvm::StringRef GetErrorString();
4344

4445
Stream &GetOutputStream() {
4546
// Make sure we at least have our normal string stream output stream

lldb/source/API/SBCommandReturnObject.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,27 +85,27 @@ SBCommandReturnObject::operator bool() const {
8585
const char *SBCommandReturnObject::GetOutput() {
8686
LLDB_INSTRUMENT_VA(this);
8787

88-
ConstString output(ref().GetOutputData());
88+
ConstString output(ref().GetOutputString());
8989
return output.AsCString(/*value_if_empty*/ "");
9090
}
9191

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

95-
ConstString output(ref().GetErrorData());
95+
ConstString output(ref().GetErrorString());
9696
return output.AsCString(/*value_if_empty*/ "");
9797
}
9898

9999
size_t SBCommandReturnObject::GetOutputSize() {
100100
LLDB_INSTRUMENT_VA(this);
101101

102-
return ref().GetOutputData().size();
102+
return ref().GetOutputString().size();
103103
}
104104

105105
size_t SBCommandReturnObject::GetErrorSize() {
106106
LLDB_INSTRUMENT_VA(this);
107107

108-
return ref().GetErrorData().size();
108+
return ref().GetErrorString().size();
109109
}
110110

111111
size_t SBCommandReturnObject::PutOutput(FILE *fh) {

lldb/source/Commands/CommandObjectCommands.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ class CommandObjectPythonFunction : public CommandObjectRaw {
10991099
} else {
11001100
// Don't change the status if the command already set it...
11011101
if (result.GetStatus() == eReturnStatusInvalid) {
1102-
if (result.GetOutputData().empty())
1102+
if (result.GetOutputString().empty())
11031103
result.SetStatus(eReturnStatusSuccessFinishNoResult);
11041104
else
11051105
result.SetStatus(eReturnStatusSuccessFinishResult);
@@ -1205,7 +1205,7 @@ class CommandObjectScriptingObjectRaw : public CommandObjectRaw {
12051205
} else {
12061206
// Don't change the status if the command already set it...
12071207
if (result.GetStatus() == eReturnStatusInvalid) {
1208-
if (result.GetOutputData().empty())
1208+
if (result.GetOutputString().empty())
12091209
result.SetStatus(eReturnStatusSuccessFinishNoResult);
12101210
else
12111211
result.SetStatus(eReturnStatusSuccessFinishResult);
@@ -2137,7 +2137,7 @@ class CommandObjectScriptingObjectParsed : public CommandObjectParsed {
21372137
} else {
21382138
// Don't change the status if the command already set it...
21392139
if (result.GetStatus() == eReturnStatusInvalid) {
2140-
if (result.GetOutputData().empty())
2140+
if (result.GetOutputString().empty())
21412141
result.SetStatus(eReturnStatusSuccessFinishNoResult);
21422142
else
21432143
result.SetStatus(eReturnStatusSuccessFinishResult);

lldb/source/Core/Debugger.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,9 +784,10 @@ void Debugger::Destroy(DebuggerSP &debugger_sp) {
784784
CommandReturnObject result(debugger_sp->GetUseColor());
785785
cmd_interpreter.SaveTranscript(result);
786786
if (result.Succeeded())
787-
(*debugger_sp->GetAsyncOutputStream()) << result.GetOutputData() << '\n';
787+
(*debugger_sp->GetAsyncOutputStream())
788+
<< result.GetOutputString() << '\n';
788789
else
789-
(*debugger_sp->GetAsyncErrorStream()) << result.GetErrorData() << '\n';
790+
(*debugger_sp->GetAsyncErrorStream()) << result.GetErrorString() << '\n';
790791
}
791792

792793
debugger_sp->Clear();

lldb/source/Interpreter/CommandInterpreter.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,11 +2094,11 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
20942094
// used instead of `GetSaveTrasncript()`. This is because the latter will
20952095
// fail when the command is "settings set interpreter.save-transcript true".
20962096
if (transcript_item) {
2097-
m_transcript_stream << result.GetOutputData();
2098-
m_transcript_stream << result.GetErrorData();
2097+
m_transcript_stream << result.GetOutputString();
2098+
m_transcript_stream << result.GetErrorString();
20992099

2100-
transcript_item->AddStringItem("output", result.GetOutputData());
2101-
transcript_item->AddStringItem("error", result.GetErrorData());
2100+
transcript_item->AddStringItem("output", result.GetOutputString());
2101+
transcript_item->AddStringItem("error", result.GetErrorString());
21022102
transcript_item->AddFloatItem("durationInSeconds",
21032103
execute_time.get().count());
21042104
}
@@ -2632,11 +2632,11 @@ void CommandInterpreter::HandleCommands(const StringList &commands,
26322632

26332633
if (options.GetPrintResults()) {
26342634
if (tmp_result.Succeeded())
2635-
result.AppendMessage(tmp_result.GetOutputData());
2635+
result.AppendMessage(tmp_result.GetOutputString());
26362636
}
26372637

26382638
if (!success || !tmp_result.Succeeded()) {
2639-
llvm::StringRef error_msg = tmp_result.GetErrorData();
2639+
llvm::StringRef error_msg = tmp_result.GetErrorString();
26402640
if (error_msg.empty())
26412641
error_msg = "<unknown error>.\n";
26422642
if (options.GetStopOnError()) {
@@ -3192,7 +3192,7 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
31923192
unsigned prompt_len = m_debugger.GetPrompt().size();
31933193
if (auto indent = result.GetDiagnosticIndent()) {
31943194
llvm::StringRef diags =
3195-
result.GetInlineDiagnosticsData(prompt_len + *indent);
3195+
result.GetInlineDiagnosticString(prompt_len + *indent);
31963196
PrintCommandOutput(io_handler, diags, true);
31973197
}
31983198
}
@@ -3201,13 +3201,13 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
32013201
GetProcessOutput();
32023202

32033203
if (!result.GetImmediateOutputStream()) {
3204-
llvm::StringRef output = result.GetOutputData();
3204+
llvm::StringRef output = result.GetOutputString();
32053205
PrintCommandOutput(io_handler, output, true);
32063206
}
32073207

32083208
// Now emit the command error text from the command we just executed.
32093209
if (!result.GetImmediateErrorStream()) {
3210-
llvm::StringRef error = result.GetErrorData();
3210+
llvm::StringRef error = result.GetErrorString();
32113211
PrintCommandOutput(io_handler, error, false);
32123212
}
32133213
}

lldb/source/Interpreter/CommandReturnObject.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ void CommandReturnObject::SetError(llvm::Error error) {
123123
}
124124
}
125125

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

137-
llvm::StringRef CommandReturnObject::GetErrorData() {
138+
llvm::StringRef CommandReturnObject::GetErrorString() {
138139
// Diagnostics haven't been fetched; render them now (not inlined).
139140
if (!m_diagnostics.empty()) {
140141
RenderDiagnosticDetails(GetErrorStream(), std::nullopt, false,

lldb/tools/lldb-test/lldb-test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ int opts::breakpoint::evaluateBreakpoints(Debugger &Dbg) {
439439
CommandReturnObject Result(/*colors*/ false);
440440
if (!Dbg.GetCommandInterpreter().HandleCommand(
441441
Command.c_str(), /*add_to_history*/ eLazyBoolNo, Result)) {
442-
P.formatLine("Failed: {0}", Result.GetErrorData());
442+
P.formatLine("Failed: {0}", Result.GetErrorString());
443443
HadErrors = 1;
444444
continue;
445445
}
@@ -1161,7 +1161,7 @@ int opts::irmemorymap::evaluateMemoryMapCommands(Debugger &Dbg) {
11611161
return CI.HandleCommand(Cmd, eLazyBoolNo, Result);
11621162
};
11631163
if (!IssueCmd("b main") || !IssueCmd("run")) {
1164-
outs() << formatv("Failed: {0}\n", Result.GetErrorData());
1164+
outs() << formatv("Failed: {0}\n", Result.GetErrorString());
11651165
exit(1);
11661166
}
11671167

0 commit comments

Comments
 (0)