Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
lldb/source/Core/Debugger.cpp
Show First 20 Lines • Show All 815 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void Debugger::SetAsyncExecution(bool async_execution) { | void Debugger::SetAsyncExecution(bool async_execution) { | ||||
m_command_interpreter_up->SetSynchronous(!async_execution); | m_command_interpreter_up->SetSynchronous(!async_execution); | ||||
} | } | ||||
repro::DataRecorder *Debugger::GetInputRecorder() { return m_input_recorder; } | repro::DataRecorder *Debugger::GetInputRecorder() { return m_input_recorder; } | ||||
void Debugger::SetInputFileHandle(FILE *fh, bool tranfer_ownership, | Status Debugger::SetInputFile(FileSP file_sp, repro::DataRecorder *recorder) { | ||||
repro::DataRecorder *recorder) { | Status error; | ||||
m_input_recorder = recorder; | m_input_recorder = recorder; | ||||
m_input_file_sp = std::make_shared<File>(fh, tranfer_ownership); | if (!file_sp || !file_sp->IsValid()) { | ||||
if (!m_input_file_sp->IsValid()) | |||||
m_input_file_sp = std::make_shared<File>(stdin, false); | m_input_file_sp = std::make_shared<File>(stdin, false); | ||||
error.SetErrorString("invalid file"); | |||||
} else { | |||||
m_input_file_sp = file_sp; | |||||
} | |||||
labath: Could we make it so that the validity of the file_sp argument is checked at the SB level? That… | |||||
// Save away the terminal state if that is relevant, so that we can restore | // Save away the terminal state if that is relevant, so that we can restore | ||||
// it in RestoreInputState. | // it in RestoreInputState. | ||||
SaveInputTerminalState(); | SaveInputTerminalState(); | ||||
return error; | |||||
} | } | ||||
void Debugger::SetOutputFileHandle(FILE *fh, bool tranfer_ownership) { | Status Debugger::SetOutputFile(FileSP file_sp) { | ||||
FileSP file_sp = std::make_shared<File>(fh, tranfer_ownership); | Status error; | ||||
if (!file_sp->IsValid()) | if (!file_sp || !file_sp->IsValid()) { | ||||
file_sp = std::make_shared<File>(stdout, false); | file_sp = std::make_shared<File>(stdout, false); | ||||
error.SetErrorString("invalid file"); | |||||
} | |||||
m_output_stream_sp = std::make_shared<StreamFile>(file_sp); | m_output_stream_sp = std::make_shared<StreamFile>(file_sp); | ||||
return error; | |||||
} | } | ||||
void Debugger::SetErrorFileHandle(FILE *fh, bool tranfer_ownership) { | Status Debugger::SetErrorFile(FileSP file_sp) { | ||||
FileSP file_sp = std::make_shared<File>(fh, tranfer_ownership); | Status error; | ||||
if (!file_sp->IsValid()) | if (!file_sp || !file_sp->IsValid()) { | ||||
file_sp = std::make_shared<File>(stderr, false); | file_sp = std::make_shared<File>(stderr, false); | ||||
error.SetErrorString("invalid file"); | |||||
} | |||||
m_error_stream_sp = std::make_shared<StreamFile>(file_sp); | m_error_stream_sp = std::make_shared<StreamFile>(file_sp); | ||||
return error; | |||||
} | } | ||||
void Debugger::SaveInputTerminalState() { | void Debugger::SaveInputTerminalState() { | ||||
int fd = GetInputFile().GetDescriptor(); | int fd = GetInputFile().GetDescriptor(); | ||||
if (fd != File::kInvalidDescriptor) | if (fd != File::kInvalidDescriptor) | ||||
m_terminal_state.Save(fd, true); | m_terminal_state.Save(fd, true); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 784 Lines • Show Last 20 Lines |
Could we make it so that the validity of the file_sp argument is checked at the SB level? That way you wouldn't need the Status result here. Same goes for stdout and stderr methods.