|
LLDB mainline
|
Windows implementation of NativeFile. More...
#include "lldb/Host/windows/FileWindows.h"
Public Member Functions | |
| NativeFileWindows ()=default | |
| NativeFileWindows (FILE *fh, OpenOptions options, bool transfer_ownership) | |
| NativeFileWindows (int fd, OpenOptions options, bool transfer_ownership) | |
| 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. | |
| Status | GetFileSpec (FileSpec &file_spec) const override |
| Get the file specification for this file, if possible. | |
| 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. | |
| int | Fileno (FILE *fh) const override |
| Map a stream to its underlying file descriptor. | |
| int | Dup (int fd) const override |
| Duplicate a file descriptor. | |
| bool | TryWriteStreamUnlocked (const void *buf, size_t &num_bytes, Status &error) override |
| Hook for stream writes that bypass the default fwrite path. | |
| 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 |
Private Member Functions | |
| NativeFileWindows (const NativeFileWindows &)=delete | |
| const NativeFileWindows & | operator= (const NativeFileWindows &)=delete |
Private Attributes | |
| bool | m_is_windows_console = false |
| Set when this file wraps stdin/stdout/stderr connected to a console; triggers the raw_fd_ostream path for correct non-ASCII output. | |
Windows implementation of NativeFile.
Definition at line 18 of file FileWindows.h.
|
default |
References lldb_private::NativeFileBase::Read(), and lldb_private::NativeFileBase::Write().
Referenced by NativeFileWindows(), and operator=().
| NativeFileWindows::NativeFileWindows | ( | FILE * | fh, |
| OpenOptions | options, | ||
| bool | transfer_ownership ) |
Definition at line 23 of file FileWindows.cpp.
References m_is_windows_console, and lldb_private::NativeFileBase::NativeFileBase().
| NativeFileWindows::NativeFileWindows | ( | int | fd, |
| OpenOptions | options, | ||
| bool | transfer_ownership ) |
Definition at line 37 of file FileWindows.cpp.
References m_is_windows_console, and lldb_private::NativeFileBase::NativeFileBase().
|
privatedelete |
References NativeFileWindows().
|
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 51 of file FileWindows.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 40 of file FileWindows.h.
References ID, and lldb_private::File::isA().
|
overrideprotectedvirtual |
Duplicate a file descriptor.
Reimplemented from lldb_private::NativeFileBase.
Definition at line 72 of file FileWindows.cpp.
|
overrideprotectedvirtual |
Map a stream to its underlying file descriptor.
Reimplemented from lldb_private::NativeFileBase.
Definition at line 70 of file FileWindows.cpp.
|
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 74 of file FileWindows.cpp.
References lldb_private::NativeFileBase::GetDescriptor().
|
inlineoverridevirtual |
Reimplemented from lldb_private::NativeFileBase.
Definition at line 37 of file FileWindows.h.
References ID, and lldb_private::NativeFileBase::isA().
|
privatedelete |
References NativeFileWindows().
|
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 101 of file FileWindows.cpp.
References error(), lldb_private::Status::FromErrorString(), lldb_private::NativeFileBase::GetDescriptor(), lldb_private::File::kInvalidDescriptor, lldb_private::NativeFileBase::m_descriptor, lldb_private::NativeFileBase::offset_access_mutex, lldb_private::NativeFileBase::Read(), and lldb_private::NativeFileBase::SeekFromStart().
|
overridevirtual |
Sync to disk.
Implements lldb_private::NativeFileBase.
Definition at line 78 of file FileWindows.cpp.
References lldb_private::NativeFileBase::DescriptorIsValid(), error(), lldb_private::Status::FromErrorString(), and lldb_private::NativeFileBase::m_descriptor.
|
overrideprotectedvirtual |
Hook for stream writes that bypass the default fwrite path.
Returns true if the bytes were consumed.
Reimplemented from lldb_private::NativeFileBase.
Definition at line 89 of file FileWindows.cpp.
References error(), m_is_windows_console, and lldb_private::NativeFileBase::m_stream.
|
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 121 of file FileWindows.cpp.
References error(), lldb_private::Status::FromErrorString(), lldb_private::NativeFileBase::GetDescriptor(), lldb_private::File::kInvalidDescriptor, lldb_private::NativeFileBase::m_descriptor, lldb_private::NativeFileBase::offset_access_mutex, lldb_private::NativeFileBase::SeekFromStart(), and lldb_private::NativeFileBase::Write().
|
static |
Definition at line 36 of file FileWindows.h.
|
private |
Set when this file wraps stdin/stdout/stderr connected to a console; triggers the raw_fd_ostream path for correct non-ASCII output.
Definition at line 54 of file FileWindows.h.
Referenced by NativeFileWindows(), NativeFileWindows(), and TryWriteStreamUnlocked().