summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
diff options
context:
space:
mode:
authorLawrence D'Anna <lawrence_danna@apple.com>2019-09-26 17:54:59 +0000
committerLawrence D'Anna <lawrence_danna@apple.com>2019-09-26 17:54:59 +0000
commit2fce1137c7c227f40edbb657c484797addba38ca (patch)
tree1aca86d16d377f546f54a9b2c4782e51f113008c /lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
parent875d20bcde2e2b1990f3a4bdfc800959e8a72ed6 (diff)
downloadbcm5719-llvm-2fce1137c7c227f40edbb657c484797addba38ca.tar.gz
bcm5719-llvm-2fce1137c7c227f40edbb657c484797addba38ca.zip
Convert FileSystem::Open() to return Expected<FileUP>
Summary: This patch converts FileSystem::Open from this prototype: Status Open(File &File, const FileSpec &file_spec, ...); to this one: llvm::Expected<std::unique_ptr<File>> Open(const FileSpec &file_spec, ...); This is beneficial on its own, as llvm::Expected is a more modern and recommended error type than Status. It is also a necessary step towards https://reviews.llvm.org/D67891, and further developments for lldb_private::File. Reviewers: JDevlieghere, jasonmolenda, labath Reviewed By: labath Subscribers: mgorny, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D67996 llvm-svn: 373003
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp')
-rw-r--r--lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 577d80f03cd..2fad73c702a 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -6271,22 +6271,23 @@ bool ObjectFileMachO::SaveCore(const lldb::ProcessSP &process_sp,
buffer.PutHex32(segment.flags);
}
- File core_file;
std::string core_file_path(outfile.GetPath());
- error = FileSystem::Instance().Open(core_file, outfile,
- File::eOpenOptionWrite |
- File::eOpenOptionTruncate |
- File::eOpenOptionCanCreate);
- if (error.Success()) {
+ auto core_file = FileSystem::Instance().Open(
+ outfile, File::eOpenOptionWrite | File::eOpenOptionTruncate |
+ File::eOpenOptionCanCreate);
+ if (!core_file) {
+ error = core_file.takeError();
+ } else {
// Read 1 page at a time
uint8_t bytes[0x1000];
// Write the mach header and load commands out to the core file
size_t bytes_written = buffer.GetString().size();
- error = core_file.Write(buffer.GetString().data(), bytes_written);
+ error = core_file.get()->Write(buffer.GetString().data(),
+ bytes_written);
if (error.Success()) {
// Now write the file data for all memory segments in the process
for (const auto &segment : segment_load_commands) {
- if (core_file.SeekFromStart(segment.fileoff) == -1) {
+ if (core_file.get()->SeekFromStart(segment.fileoff) == -1) {
error.SetErrorStringWithFormat(
"unable to seek to offset 0x%" PRIx64 " in '%s'",
segment.fileoff, core_file_path.c_str());
@@ -6311,7 +6312,7 @@ bool ObjectFileMachO::SaveCore(const lldb::ProcessSP &process_sp,
if (bytes_read == bytes_to_read) {
size_t bytes_written = bytes_read;
- error = core_file.Write(bytes, bytes_written);
+ error = core_file.get()->Write(bytes, bytes_written);
bytes_left -= bytes_read;
addr += bytes_read;
} else {
@@ -6319,7 +6320,7 @@ bool ObjectFileMachO::SaveCore(const lldb::ProcessSP &process_sp,
// be zero filled
memset(bytes, 0, bytes_to_read);
size_t bytes_written = bytes_to_read;
- error = core_file.Write(bytes, bytes_written);
+ error = core_file.get()->Write(bytes, bytes_written);
bytes_left -= bytes_to_read;
addr += bytes_to_read;
}
OpenPOWER on IntegriCloud