mstorsjo created this revision.
mstorsjo added reviewers: labath, alvinhochun, DavidSpickett.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: LLDB.

This adds a testcase for
4d123783957e547009e55346bf3a8ae43a88fa14 
<https://reviews.llvm.org/rG4d123783957e547009e55346bf3a8ae43a88fa14> / D128201 
<https://reviews.llvm.org/D128201>. Before that commit,
lldb would crash here, while now lldb manages to stop after the
exception.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128410

Files:
  lldb/test/Shell/Process/Windows/wndproc_exception.cpp


Index: lldb/test/Shell/Process/Windows/wndproc_exception.cpp
===================================================================
--- /dev/null
+++ lldb/test/Shell/Process/Windows/wndproc_exception.cpp
@@ -0,0 +1,54 @@
+// clang-format off
+
+// Check that lldb doesn't crash when there's a nested exception.
+
+// REQUIRES: system-windows
+// RUN: %clangxx_host -o %t.exe -luser32 -v -- %s
+// RUN: %lldb -f %t.exe -o "run"
+
+#include <windows.h>
+
+static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
+                                   LPARAM lParam) {
+  switch (uMsg) {
+  case WM_DESTROY:
+    PostQuitMessage(0);
+    return 0;
+
+  case WM_PAINT:
+    *(volatile int *)nullptr = 1;
+    return 0;
+  }
+  return DefWindowProcA(hwnd, uMsg, wParam, lParam);
+}
+
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR 
pCmdLine,
+                   int nCmdShow) {
+  const char CLASS_NAME[] = "Crash Window Class";
+
+  WNDCLASSA wc = {};
+
+  wc.lpfnWndProc = WindowProc;
+  wc.hInstance = hInstance;
+  wc.lpszClassName = CLASS_NAME;
+
+  RegisterClassA(&wc);
+
+  HWND hwnd = CreateWindowExA(0, CLASS_NAME, "Crash", WS_OVERLAPPEDWINDOW,
+                              CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+                              CW_USEDEFAULT,
+                              NULL, NULL, hInstance, NULL);
+
+  if (hwnd == NULL)
+    return 0;
+
+  ShowWindow(hwnd, nCmdShow);
+
+  MSG msg = {};
+  while (GetMessageA(&msg, NULL, 0, 0) > 0) {
+    TranslateMessage(&msg);
+    DispatchMessageA(&msg);
+  }
+
+  return 0;
+}


Index: lldb/test/Shell/Process/Windows/wndproc_exception.cpp
===================================================================
--- /dev/null
+++ lldb/test/Shell/Process/Windows/wndproc_exception.cpp
@@ -0,0 +1,54 @@
+// clang-format off
+
+// Check that lldb doesn't crash when there's a nested exception.
+
+// REQUIRES: system-windows
+// RUN: %clangxx_host -o %t.exe -luser32 -v -- %s
+// RUN: %lldb -f %t.exe -o "run"
+
+#include <windows.h>
+
+static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
+                                   LPARAM lParam) {
+  switch (uMsg) {
+  case WM_DESTROY:
+    PostQuitMessage(0);
+    return 0;
+
+  case WM_PAINT:
+    *(volatile int *)nullptr = 1;
+    return 0;
+  }
+  return DefWindowProcA(hwnd, uMsg, wParam, lParam);
+}
+
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine,
+                   int nCmdShow) {
+  const char CLASS_NAME[] = "Crash Window Class";
+
+  WNDCLASSA wc = {};
+
+  wc.lpfnWndProc = WindowProc;
+  wc.hInstance = hInstance;
+  wc.lpszClassName = CLASS_NAME;
+
+  RegisterClassA(&wc);
+
+  HWND hwnd = CreateWindowExA(0, CLASS_NAME, "Crash", WS_OVERLAPPEDWINDOW,
+                              CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+                              CW_USEDEFAULT,
+                              NULL, NULL, hInstance, NULL);
+
+  if (hwnd == NULL)
+    return 0;
+
+  ShowWindow(hwnd, nCmdShow);
+
+  MSG msg = {};
+  while (GetMessageA(&msg, NULL, 0, 0) > 0) {
+    TranslateMessage(&msg);
+    DispatchMessageA(&msg);
+  }
+
+  return 0;
+}
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to