Go to the documentation of this file.
9 #ifndef LLDB_HOST_FILE_H
10 #define LLDB_HOST_FILE_H
17 #include "llvm/ADT/BitmaskEnum.h"
22 #include <sys/types.h>
71 static llvm::Expected<const char *>
89 Status Read(
void *buf,
size_t &num_bytes)
override;
104 Status Write(
const void *buf,
size_t &num_bytes)
override;
239 virtual Status Read(
void *dst,
size_t &num_bytes, off_t &offset);
264 virtual Status Write(
const void *src,
size_t &num_bytes, off_t &offset);
293 size_t Printf(
const char *format, ...) __attribute__((format(printf, 2, 3)));
305 virtual
size_t PrintfVarArg(const
char *format, va_list args);
322 return opts.takeError();
362 virtual bool isA(
const void *classID)
const {
return classID == &
ID; }
395 Status Read(
void *buf,
size_t &num_bytes)
override;
396 Status Write(
const void *buf,
size_t &num_bytes)
override;
405 Status Read(
void *dst,
size_t &num_bytes, off_t &offset)
override;
406 Status Write(
const void *src,
size_t &num_bytes, off_t &offset)
override;
409 size_t PrintfVarArg(
const char *format, va_list args)
override;
410 llvm::Expected<OpenOptions>
GetOptions()
const override;
413 virtual bool isA(
const void *classID)
const override {
440 llvm::Optional<unsigned int>
BaudRate = llvm::None;
441 llvm::Optional<Terminal::Parity>
Parity = llvm::None;
443 llvm::Optional<unsigned int>
StopBits = llvm::None;
448 static llvm::Expected<Options>
OptionsFromURL(llvm::StringRef urlqs);
450 static llvm::Expected<std::unique_ptr<SerialPort>>
452 bool transfer_ownership);
461 virtual bool isA(
const void *classID)
const override {
468 bool transfer_ownership);
478 #endif // LLDB_HOST_FILE_H
virtual bool isA(const void *classID) const
Status Sync() override
Sync to disk.
virtual Status Sync()
Sync to disk.
WaitableHandle GetWaitableHandle() override
Get a handle that can be used for OS polling interfaces, such as WaitForMultipleObjects,...
static mode_t ConvertOpenOptionsForPOSIXOpen(OpenOptions open_options)
llvm::Optional< Terminal::ParityCheck > ParityCheck
virtual bool isA(const void *classID) const override
uint32_t GetPermissions(Status &error) const
Get the permissions for a this file.
FILE * GetStream() override
Get the underlying libc stream for this file, or NULL.
Status Read(void *buf, size_t &num_bytes) override
Read bytes from a file from the current file position into buf.
static llvm::Expected< std::unique_ptr< SerialPort > > Create(int fd, OpenOptions options, Options serial_options, bool transfer_ownership)
bool GetIsInteractive()
Return true if this file is interactive.
off_t SeekFromStart(off_t offset, Status *error_ptr=nullptr) override
Seek to an offset relative to the beginning of the file.
bool StreamIsValid() const
bool DescriptorIsValid() const
Status Flush() override
Flush the current stream.
bool GetIsRealTerminal()
Return true if this file from a real terminal.
const File & operator=(const File &)=delete
std::mutex offset_access_mutex
NativeFile(FILE *fh, bool transfer_ownership)
NativeFile(int fd, OpenOptions options, bool transfer_ownership)
@ eOpenOptionCanCreateNewOnly
llvm::Optional< unsigned int > BaudRate
virtual Status GetFileSpec(FileSpec &file_spec) const
Get the file specification for this file, if possible.
static bool classof(const File *file)
Status Close() override
Flush any buffers and release any resources owned by the file.
Status Close() override
Flush any buffers and release any resources owned by the file.
static llvm::Expected< const char * > GetStreamOpenModeFromOptions(OpenOptions options)
LazyBool m_supports_colors
bool IsValid() const override
IsValid.
virtual Status Flush()
Flush the current stream.
static llvm::raw_ostream & error(Stream &strm)
static bool DescriptorIsValid(int descriptor)
llvm::Optional< Terminal::Parity > Parity
const SerialPort & operator=(const SerialPort &)=delete
virtual off_t SeekFromStart(off_t offset, Status *error_ptr=nullptr)
Seek to an offset relative to the beginning of the file.
const NativeFile & operator=(const NativeFile &)=delete
off_t SeekFromCurrent(off_t offset, Status *error_ptr=nullptr) override
Seek to an offset relative to the current file position.
void CalculateInteractiveAndTerminal()
virtual llvm::Expected< OpenOptions > GetOptions() const
Return the OpenOptions for this file.
LazyBool m_is_real_terminal
llvm::Expected< OpenOptions > GetOptions() const override
Return the OpenOptions for this file.
@ LLVM_MARK_AS_BITMASK_ENUM
LazyBool m_is_interactive
static llvm::Expected< Options > OptionsFromURL(llvm::StringRef urlqs)
SerialPort(int fd, OpenOptions options, Options serial_options, bool transfer_ownership)
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE()
@ eOpenOptionDontFollowSymlinks
size_t virtual size_t PrintfVarArg(const char *format, va_list args)
Output printf formatted output to the stream.
virtual bool isA(const void *classID) const override
size_t PrintfVarArg(const char *format, va_list args) override
Output printf formatted output to the stream.
Status Close() override
Flush any buffers and release any resources owned by the file.
static int kInvalidDescriptor
llvm::Optional< unsigned int > StopBits
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
bool IsValid() const override
IsValid.
Status GetFileSpec(FileSpec &file_spec) const override
Get the file specification for this file, if possible.
static bool classof(const File *file)
virtual int GetDescriptor() const
Get underlying OS file descriptor for this file, or kInvalidDescriptor.
static llvm::Expected< OpenOptions > GetOptionsFromMode(llvm::StringRef mode)
llvm::Expected< const char * > GetOpenMode() const
A class that represents a running process on the host machine.
Status Read(void *buf, size_t &num_bytes) override
Read bytes from a file from the current file position into buf.
int GetDescriptor() const override
Get underlying OS file descriptor for this file, or kInvalidDescriptor.
Status Write(const void *buf, size_t &num_bytes) override
Write bytes from buf to a file at the current file position.
Status Write(const void *buf, size_t &num_bytes) override
Write bytes from buf to a file at the current file position.
virtual FILE * GetStream()
Get the underlying libc stream for this file, or NULL.
bool GetIsTerminalWithColors()
Return true if this file is a terminal which supports colors.
WaitableHandle GetWaitableHandle() override
Get a handle that can be used for OS polling interfaces, such as WaitForMultipleObjects,...
virtual off_t SeekFromEnd(off_t offset, Status *error_ptr=nullptr)
Seek to an offset relative to the end of the file.
static bool classof(const File *file)
virtual off_t SeekFromCurrent(off_t offset, Status *error_ptr=nullptr)
Seek to an offset relative to the current file position.
static FILE * kInvalidStream
off_t SeekFromEnd(off_t offset, Status *error_ptr=nullptr) override
Seek to an offset relative to the end of the file.
bool IsValid() const override
IsValid.