[Lldb-commits] [lldb] r370802 - [lldb][NFC] Remove unused overload of File::Read

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 3 11:11:15 PDT 2019


Author: teemperor
Date: Tue Sep  3 11:11:14 2019
New Revision: 370802

URL: http://llvm.org/viewvc/llvm-project?rev=370802&view=rev
Log:
[lldb][NFC] Remove unused overload of File::Read

Summary: It's neither used or tested here and in swift-lldb, so let's get rid of it.

Reviewers: #lldb, davide

Reviewed By: #lldb, davide

Subscribers: davide, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D67116

Modified:
    lldb/trunk/include/lldb/Host/File.h
    lldb/trunk/source/Host/common/File.cpp

Modified: lldb/trunk/include/lldb/Host/File.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/File.h?rev=370802&r1=370801&r2=370802&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/File.h (original)
+++ lldb/trunk/include/lldb/Host/File.h Tue Sep  3 11:11:14 2019
@@ -252,36 +252,6 @@ public:
   ///     failure.
   Status Read(void *dst, size_t &num_bytes, off_t &offset);
 
-  /// Read bytes from a file from the specified file offset.
-  ///
-  /// NOTE: This function is thread safe in that clients manager their
-  /// own file position markers and reads on other threads won't mess up the
-  /// current read.
-  ///
-  /// \param[in,out] num_bytes
-  ///     The number of bytes to read form the current file position
-  ///     which gets modified with the number of bytes that were read.
-  ///
-  /// \param[in,out] offset
-  ///     The offset within the file from which to read \a num_bytes
-  ///     bytes. This offset gets incremented by the number of bytes
-  ///     that were read.
-  ///
-  /// \param[in] null_terminate
-  ///     Ensure that the data that is read is terminated with a NULL
-  ///     character so that the data can be used as a C string.
-  ///
-  /// \param[out] data_buffer_sp
-  ///     A data buffer to create and fill in that will contain any
-  ///     data that is read from the file. This buffer will be reset
-  ///     if an error occurs.
-  ///
-  /// \return
-  ///     An error object that indicates success or the reason for
-  ///     failure.
-  Status Read(size_t &num_bytes, off_t &offset, bool null_terminate,
-              lldb::DataBufferSP &data_buffer_sp);
-
   /// Write bytes to a file at the specified file offset.
   ///
   /// NOTE: This function is thread safe in that clients manager their

Modified: lldb/trunk/source/Host/common/File.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/File.cpp?rev=370802&r1=370801&r2=370802&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/File.cpp (original)
+++ lldb/trunk/source/Host/common/File.cpp Tue Sep  3 11:11:14 2019
@@ -513,50 +513,6 @@ Status File::Read(void *buf, size_t &num
   return error;
 }
 
-Status File::Read(size_t &num_bytes, off_t &offset, bool null_terminate,
-                  DataBufferSP &data_buffer_sp) {
-  Status error;
-
-  if (num_bytes > 0) {
-    int fd = GetDescriptor();
-    if (fd != kInvalidDescriptor) {
-      struct stat file_stats;
-      if (::fstat(fd, &file_stats) == 0) {
-        if (file_stats.st_size > offset) {
-          const size_t bytes_left = file_stats.st_size - offset;
-          if (num_bytes > bytes_left)
-            num_bytes = bytes_left;
-
-          size_t num_bytes_plus_nul_char = num_bytes + (null_terminate ? 1 : 0);
-          std::unique_ptr<DataBufferHeap> data_heap_up;
-          data_heap_up.reset(new DataBufferHeap());
-          data_heap_up->SetByteSize(num_bytes_plus_nul_char);
-
-          if (data_heap_up) {
-            error = Read(data_heap_up->GetBytes(), num_bytes, offset);
-            if (error.Success()) {
-              // Make sure we read exactly what we asked for and if we got
-              // less, adjust the array
-              if (num_bytes_plus_nul_char < data_heap_up->GetByteSize())
-                data_heap_up->SetByteSize(num_bytes_plus_nul_char);
-              data_buffer_sp.reset(data_heap_up.release());
-              return error;
-            }
-          }
-        } else
-          error.SetErrorString("file is empty");
-      } else
-        error.SetErrorToErrno();
-    } else
-      error.SetErrorString("invalid file handle");
-  } else
-    error.SetErrorString("invalid file handle");
-
-  num_bytes = 0;
-  data_buffer_sp.reset();
-  return error;
-}
-
 Status File::Write(const void *buf, size_t &num_bytes, off_t &offset) {
   Status error;
 




More information about the lldb-commits mailing list