[Lldb-commits] [lldb] [windows][lldb] implement system logging on Windows (PR #150213)
Michael Buch via lldb-commits
lldb-commits at lists.llvm.org
Wed Jul 23 08:04:07 PDT 2025
================
@@ -302,3 +304,64 @@ Environment Host::GetEnvironment() {
}
return env;
}
+
+/// Manages the lifecycle of a Windows Event's Source.
+/// The destructor will call DeregisterEventSource.
+/// This class is meant to be used with \ref llvm::ManagedStatic.
+class WindowsEventLog {
+public:
+ WindowsEventLog() : handle(RegisterEventSource(nullptr, L"lldb")) {}
+
+ ~WindowsEventLog() {
+ if (handle)
+ DeregisterEventSource(handle);
+ }
+
+ HANDLE GetHandle() const { return handle; }
+
+private:
+ HANDLE handle;
+};
+
+static llvm::ManagedStatic<WindowsEventLog> event_log;
+
+static LPCWSTR AnsiToUtf16(const std::string &ansi) {
+ if (ansi.empty())
+ return nullptr;
+ const int unicode_length =
+ MultiByteToWideChar(CP_ACP, 0, ansi.c_str(), -1, nullptr, 0);
+ WCHAR *unicode = new WCHAR[unicode_length];
----------------
Michael137 wrote:
That way we don't need to worry about deleting it
https://github.com/llvm/llvm-project/pull/150213
More information about the lldb-commits
mailing list