|
LLDB mainline
|
POSIX implementation of NativeFile. More...
#include "lldb/Host/posix/FilePosix.h"
Public Member Functions | |
| NativeFilePosix ()=default | |
| NativeFilePosix (FILE *fh, OpenOptions options, bool transfer_ownership) | |
| NativeFilePosix (int fd, OpenOptions options, bool transfer_ownership) | |
| Status | GetFileSpec (FileSpec &file_spec) const override |
| Get the file specification for this file, if possible. | |
| WaitableHandle | GetWaitableHandle () override |
| Get a handle that can be used for OS polling interfaces, such as WaitForMultipleObjects, select, or epoll. | |
| Status | Sync () override |
| Sync to disk. | |
| Status | Read (void *dst, size_t &num_bytes, off_t &offset) override |
| Read bytes from a file from the specified file offset. | |
| Status | Write (const void *src, size_t &num_bytes, off_t &offset) override |
| Write bytes to a file at the specified file offset. | |
| bool | isA (const void *classID) const override |
| Status | Read (void *buf, size_t &num_bytes) override |
| Read bytes from a file from the current file position into buf. | |
| Status | Write (const void *buf, size_t &num_bytes) override |
| Write bytes from buf to a file at the current file position. | |
| Public Member Functions inherited from lldb_private::NativeFileBase | |
| bool | IsValid () const override |
| IsValid. | |
| Status | Close () override |
| Flush any buffers and release any resources owned by the file. | |
| int | GetDescriptor () const override |
| Get underlying OS file descriptor for this file, or kInvalidDescriptor. | |
| FILE * | GetStream () override |
| Get the underlying libc stream for this file, or NULL. | |
| off_t | SeekFromStart (off_t offset, Status *error_ptr=nullptr) override |
| Seek to an offset relative to the beginning of the file. | |
| off_t | SeekFromCurrent (off_t offset, Status *error_ptr=nullptr) override |
| Seek to an offset relative to the current file position. | |
| off_t | SeekFromEnd (off_t offset, Status *error_ptr=nullptr) override |
| Seek to an offset relative to the end of the file. | |
| Status | Flush () override |
| Flush the current stream. | |
| size_t | PrintfVarArg (const char *format, va_list args) override |
| Output printf formatted output to the stream. | |
| llvm::Expected< OpenOptions > | GetOptions () const override |
| Return the OpenOptions for this file. | |
| Public Member Functions inherited from lldb_private::File | |
| File () | |
| size_t | Printf (const char *format,...) __attribute__((format(printf |
| Output printf formatted output to the stream. | |
| llvm::Expected< const char * > | GetOpenMode () const |
| uint32_t | GetPermissions (Status &error) const |
| Get the permissions for a this file. | |
| bool | GetIsInteractive () |
| Return true if this file is interactive. | |
| bool | GetIsRealTerminal () |
| Return true if this file from a real terminal. | |
| bool | GetIsTerminalWithColors () |
| Return true if this file is a terminal which supports colors. | |
| operator bool () const | |
| bool | operator! () const |
| Public Member Functions inherited from lldb_private::IOObject | |
| IOObject (FDType type) | |
| virtual | ~IOObject () |
| FDType | GetFdType () const |
Static Public Member Functions | |
| static bool | classof (const File *file) |
| Static Public Member Functions inherited from lldb_private::NativeFileBase | |
| static bool | classof (const File *file) |
| Static Public Member Functions inherited from lldb_private::File | |
| static mode_t | ConvertOpenOptionsForPOSIXOpen (OpenOptions open_options) |
| static llvm::Expected< OpenOptions > | GetOptionsFromMode (llvm::StringRef mode) |
| static bool | DescriptorIsValid (int descriptor) |
| static llvm::Expected< const char * > | GetStreamOpenModeFromOptions (OpenOptions options) |
| static bool | classof (const File *file) |
Static Public Attributes | |
| static char | ID = 0 |
| Static Public Attributes inherited from lldb_private::NativeFileBase | |
| static char | ID = 0 |
| Static Public Attributes inherited from lldb_private::File | |
| static int | kInvalidDescriptor = -1 |
| static FILE * | kInvalidStream = nullptr |
| static constexpr OpenOptions | OpenOptionsModeMask |
| static char | ID = 0 |
| Static Public Attributes inherited from lldb_private::IOObject | |
| static const WaitableHandle | kInvalidHandleValue = -1 |
Protected Member Functions | |
| void | CalculateInteractiveAndTerminal () override |
| Refresh the cached interactive / terminal / color flags by inspecting the underlying descriptor. | |
| Protected Member Functions inherited from lldb_private::NativeFileBase | |
| NativeFileBase () | |
| NativeFileBase (FILE *fh, OpenOptions options, bool transfer_ownership) | |
| NativeFileBase (int fd, OpenOptions options, bool transfer_ownership) | |
| ~NativeFileBase () override | |
| bool | DescriptorIsValidUnlocked () const |
| bool | StreamIsValidUnlocked () const |
| ValueGuard | DescriptorIsValid () const |
| ValueGuard | StreamIsValid () const |
| virtual int | Fileno (FILE *fh) const |
| Map a stream to its underlying file descriptor. | |
| virtual int | Dup (int fd) const |
| Duplicate a file descriptor. | |
| virtual bool | TryWriteStreamUnlocked (const void *buf, size_t &num_bytes, Status &error) |
| Hook for stream writes that bypass the default fwrite path. | |
Private Member Functions | |
| NativeFilePosix (const NativeFilePosix &)=delete | |
| const NativeFilePosix & | operator= (const NativeFilePosix &)=delete |
POSIX implementation of NativeFile.
Definition at line 18 of file FilePosix.h.
|
default |
References lldb_private::NativeFileBase::Read(), and lldb_private::NativeFileBase::Write().
Referenced by NativeFilePosix(), and operator=().
| NativeFilePosix::NativeFilePosix | ( | FILE * | fh, |
| OpenOptions | options, | ||
| bool | transfer_ownership ) |
Definition at line 32 of file FilePosix.cpp.
References lldb_private::File::ConvertOpenOptionsForPOSIXOpen(), and lldb_private::NativeFileBase::NativeFileBase().
| NativeFilePosix::NativeFilePosix | ( | int | fd, |
| OpenOptions | options, | ||
| bool | transfer_ownership ) |
Definition at line 56 of file FilePosix.cpp.
References lldb_private::NativeFileBase::NativeFileBase().
|
privatedelete |
References NativeFilePosix().
|
overrideprotectedvirtual |
Refresh the cached interactive / terminal / color flags by inspecting the underlying descriptor.
The default implementation leaves the flags set to "no"; concrete subclasses override this with the appropriate platform-specific terminal probing.
Reimplemented from lldb_private::File.
Definition at line 76 of file FilePosix.cpp.
References lldb_private::File::DescriptorIsValid(), lldb_private::eLazyBoolNo, lldb_private::eLazyBoolYes, lldb_private::NativeFileBase::GetDescriptor(), lldb_private::File::m_is_interactive, lldb_private::File::m_is_real_terminal, and lldb_private::File::m_supports_colors.
Definition at line 41 of file FilePosix.h.
References ID, and lldb_private::File::isA().
Get the file specification for this file, if possible.
| [out] | file_spec | the file specification. |
Reimplemented from lldb_private::NativeFileBase.
Definition at line 99 of file FilePosix.cpp.
References lldb_private::FileSpec::Clear(), error(), lldb_private::Status::FromErrno(), lldb_private::Status::FromErrorString(), lldb_private::NativeFileBase::GetDescriptor(), lldb_private::NativeFileBase::IsValid(), PATH_MAX, and lldb_private::FileSpec::SetFile().
|
overridevirtual |
Get a handle that can be used for OS polling interfaces, such as WaitForMultipleObjects, select, or epoll.
This may return IOObject::kInvalidHandleValue if none is available. This will generally be the same as the file descriptor, this function is not interchangeable with GetDescriptor(). A WaitableHandle must only be used for polling, not actual I/O.
Reimplemented from lldb_private::NativeFileBase.
Definition at line 60 of file FilePosix.cpp.
References lldb_private::NativeFileBase::GetDescriptor().
|
inlineoverridevirtual |
Reimplemented from lldb_private::NativeFileBase.
Reimplemented in lldb_private::SerialPort.
Definition at line 38 of file FilePosix.h.
References ID, and lldb_private::NativeFileBase::isA().
Referenced by lldb_private::SerialPort::isA().
|
privatedelete |
References NativeFilePosix().
|
overridevirtual |
Read bytes from a file from the current file position into buf.
NOTE: This function is NOT thread safe. Use the read function that takes an "off_t &offset" to ensure correct operation in multi- threaded environments.
| [in,out] | num_bytes | Pass in the size of buf. Read will pass out the number of bytes read. Zero bytes read with no error indicates EOF. |
Reimplemented from lldb_private::NativeFileBase.
|
overridevirtual |
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.
| [in] | dst | A buffer where to put the bytes that are read. |
| [in,out] | num_bytes | The number of bytes to read from the current file position which gets modified with the number of bytes that were read. |
| [in,out] | offset | The offset within the file from which to read num_bytes bytes. This offset gets incremented by the number of bytes that were read. |
Implements lldb_private::NativeFileBase.
Definition at line 135 of file FilePosix.cpp.
References error(), lldb_private::Status::FromErrno(), lldb_private::Status::FromErrorString(), lldb_private::NativeFileBase::GetDescriptor(), lldb_private::File::kInvalidDescriptor, and Read().
Referenced by lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_vFile_pRead(), and Read().
|
overridevirtual |
Sync to disk.
Implements lldb_private::NativeFileBase.
Definition at line 65 of file FilePosix.cpp.
References lldb_private::NativeFileBase::DescriptorIsValid(), error(), lldb_private::Status::FromErrno(), lldb_private::Status::FromErrorString(), and lldb_private::NativeFileBase::m_descriptor.
|
overridevirtual |
Write bytes from buf to a file at the current file position.
NOTE: This function is NOT thread safe. Use the write function that takes an "off_t &offset" to ensure correct operation in multi- threaded environments.
| [in,out] | num_bytes | Pass in the size of buf. Write will pass out the number of bytes written. Write will attempt write the full number of bytes and will not return early except on error. |
Reimplemented from lldb_private::NativeFileBase.
|
overridevirtual |
Write bytes to a file at the specified file offset.
NOTE: This function is thread safe in that clients manager their own file position markers, though clients will need to implement their own locking externally to avoid multiple people writing to the file at the same time.
| [in] | src | A buffer containing the bytes to write. |
| [in,out] | num_bytes | The number of bytes to write to the file at offset offset. num_bytes gets modified with the number of bytes that were read. |
| [in,out] | offset | The offset within the file at which to write num_bytes bytes. This offset gets incremented by the number of bytes that were written. |
Implements lldb_private::NativeFileBase.
Definition at line 186 of file FilePosix.cpp.
References error(), lldb_private::Status::FromErrno(), lldb_private::Status::FromErrorString(), lldb_private::NativeFileBase::GetDescriptor(), lldb_private::File::kInvalidDescriptor, lldb_private::NativeFileBase::m_descriptor, and Write().
Referenced by lldb_private::ClangUtilityFunction::ClangUtilityFunction(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_vFile_pWrite(), lldb_private::ClangExpressionParser::ParseInternal(), and Write().
|
static |
Definition at line 37 of file FilePosix.h.