[Lldb-commits] [lldb] [llvm] [lldb][windows] use Windows APIs to print to the console (PR #149493)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Fri Jul 25 02:56:56 PDT 2025


================
@@ -247,6 +248,28 @@ uint32_t File::GetPermissions(Status &error) const {
   return file_stats.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
 }
 
+NativeFile::NativeFile()
+    : m_descriptor(kInvalidDescriptor), m_stream(kInvalidStream) {}
+
+NativeFile::NativeFile(FILE *fh, bool transfer_ownership)
+    : m_descriptor(kInvalidDescriptor), m_own_descriptor(false), m_stream(fh),
+      m_options(), m_own_stream(transfer_ownership) {
+#ifdef _WIN32
+  int fd = _fileno(fh);
+  is_windows_console =
+      ::GetFileType((HANDLE)::_get_osfhandle(fd)) == FILE_TYPE_CHAR;
+#endif
+}
+
+NativeFile::NativeFile(int fd, OpenOptions options, bool transfer_ownership)
+    : m_descriptor(fd), m_own_descriptor(transfer_ownership),
+      m_stream(kInvalidStream), m_options(options), m_own_stream(false) {
+#ifdef _WIN32
+  is_windows_console =
+      ::GetFileType((HANDLE)::_get_osfhandle(fd)) == FILE_TYPE_CHAR;
+#endif
+}
----------------
labath wrote:

That isn't quite equivalent as the implementation (for better or worse), remembers whether it was constructed with a FD or a FILE* and then uses the appropriate method to implement read/write operations. 

https://github.com/llvm/llvm-project/pull/149493


More information about the lldb-commits mailing list