xbolva00 updated this revision to Diff 163820.
xbolva00 added a comment.

- Addressed review comments


https://reviews.llvm.org/D51615

Files:
  source/Core/Debugger.cpp


Index: source/Core/Debugger.cpp
===================================================================
--- source/Core/Debugger.cpp
+++ source/Core/Debugger.cpp
@@ -50,8 +50,15 @@
 
 #if defined(_WIN32)
 #include "lldb/Host/windows/PosixApi.h" // for PATH_MAX
+#include "windows.h"
+
+#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
+// See https://docs.microsoft.com/en-us/windows/console/setconsolemode
+#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
 #endif
 
+#endif
+
 #include "llvm/ADT/None.h"      // for None
 #include "llvm/ADT/STLExtras.h" // for make_unique
 #include "llvm/ADT/StringRef.h"
@@ -804,6 +811,17 @@
   // Turn off use-color if we don't write to a terminal with color support.
   if (!m_output_file_sp->GetFile().GetIsTerminalWithColors())
     SetUseColor(false);
+
+#if defined(_WIN32)
+  // Enabling use of ANSI color codes because LLDB is using them to highlight
+  // text.
+  HANDLE console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
+  DWORD console_mode;
+  GetConsoleMode(console_handle, &console_mode);
+  console_mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
+  bool ansi_colors_supported = SetConsoleMode(console_handle, console_mode);
+  SetUseColor(ansi_colors_supported);
+#endif
 }
 
 Debugger::~Debugger() { Clear(); }


Index: source/Core/Debugger.cpp
===================================================================
--- source/Core/Debugger.cpp
+++ source/Core/Debugger.cpp
@@ -50,8 +50,15 @@
 
 #if defined(_WIN32)
 #include "lldb/Host/windows/PosixApi.h" // for PATH_MAX
+#include "windows.h"
+
+#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
+// See https://docs.microsoft.com/en-us/windows/console/setconsolemode
+#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
 #endif
 
+#endif
+
 #include "llvm/ADT/None.h"      // for None
 #include "llvm/ADT/STLExtras.h" // for make_unique
 #include "llvm/ADT/StringRef.h"
@@ -804,6 +811,17 @@
   // Turn off use-color if we don't write to a terminal with color support.
   if (!m_output_file_sp->GetFile().GetIsTerminalWithColors())
     SetUseColor(false);
+
+#if defined(_WIN32)
+  // Enabling use of ANSI color codes because LLDB is using them to highlight
+  // text.
+  HANDLE console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
+  DWORD console_mode;
+  GetConsoleMode(console_handle, &console_mode);
+  console_mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
+  bool ansi_colors_supported = SetConsoleMode(console_handle, console_mode);
+  SetUseColor(ansi_colors_supported);
+#endif
 }
 
 Debugger::~Debugger() { Clear(); }
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to