[Lldb-commits] [lldb] [lldb][Windows] Support OutputDebugString (PR #196395)
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Fri May 8 06:35:53 PDT 2026
================
@@ -0,0 +1,57 @@
+// REQUIRES: target-windows
+// RUN: %build --compiler=clang-cl -o %t.exe -- %s
+// RUN: %lldb -f %t.exe -o "log enable windows process" -o r -o q | FileCheck %s
+
+#include <Windows.h>
+#include <string>
+
+int main() {
+ OutputDebugStringA("My string\nnext line\nBut this doesn't have trailing newline|");
+ OutputDebugStringW(L"OutputDebugStringW with some emojis 🦎🐊🐢🐍\n");
+ OutputDebugStringW(L"Another W1\n");
+ OutputDebugStringW(L"Another W2\n");
+ OutputDebugStringA("Some A1\n");
+ OutputDebugStringA("Some A2\n");
+ OutputDebugStringA("Some A3\n");
+
+ std::wstring maxW((1 << 19) - 4, L'A');
+ maxW.push_back(L'B');
+ maxW.push_back(L'\n');
+ OutputDebugStringW(maxW.c_str());
+
+ Sleep(100);
----------------
DavidSpickett wrote:
Could you explain how the timing works? I suppose there is some delay between the program calling OutputDebugStringW and LLDB picking up the debug event?
So if you have:
```
OutputDebugStringW(message A);
A:
OutputDebugStringW(message B);
B:
```
If LLDB decides to read messages at A, it will only see message A, but if the event comes in later it will see message A and message B. The timing of the event is up to Windows so by waiting we expect that it will generate the event in that time.
Would it be possible to do this without the sleeps? If you were to `CHECK` instead of `CHECK-NEXT`. What do you lose if you are not so strict?
Though if the larger messages push the others out of the limited message buffer (if it is in fact limited) then this idea does not work. You have to read out all the small messages as you currently do, then send the large ones.
https://github.com/llvm/llvm-project/pull/196395
More information about the lldb-commits
mailing list