[Lldb-commits] [lldb] [NFC][lldb][windows] refactor switch case braces (PR #197714)

Charles Zablit via lldb-commits lldb-commits at lists.llvm.org
Thu May 14 08:18:27 PDT 2026


https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/197714

>From da251a09c32e453aff34e2bb88cb287c5fe592d4 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Thu, 14 May 2026 16:57:21 +0200
Subject: [PATCH 1/2] [NFC][lldb][windows] refactor switch case braces

---
 .../Windows/Common/NativeProcessWindows.cpp   | 54 +++++++++----------
 1 file changed, 25 insertions(+), 29 deletions(-)

diff --git a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
index 4fdb286c93e1e..cfd6db8248585 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
@@ -496,8 +496,7 @@ NativeProcessWindows::OnDebugException(bool first_chance,
     return ExceptionResult::MaskException;
   }
   case DWORD(STATUS_BREAKPOINT):
-  case STATUS_WX86_BREAKPOINT:
-
+  case STATUS_WX86_BREAKPOINT: {
     if (NativeThreadWindows *stop_thread =
             GetThreadByID(record.GetThreadID())) {
       auto &reg_ctx = stop_thread->GetRegisterContext();
@@ -564,39 +563,36 @@ NativeProcessWindows::OnDebugException(bool first_chance,
       return ExceptionResult::BreakInDebugger;
     }
 
-    {
-      // Any remaining STATUS_BREAKPOINT is a breakpoint instruction in the
-      // program's own code (e.g. `__debugbreak()` or `__builtin_debugtrap()`).
-      // Stop the debugger and let the user decide what to do.
-      std::string desc =
-          formatv("Exception {0:x8} encountered at address {1:x8}",
-                  record.GetExceptionCode(), record.GetExceptionAddress())
-              .str();
-      StopThread(record.GetThreadID(), StopReason::eStopReasonException,
-                 std::move(desc));
-      SetState(eStateStopped, true);
-    }
+    // Any remaining STATUS_BREAKPOINT is a breakpoint instruction in the
+    // program's own code (e.g. `__debugbreak()` or `__builtin_debugtrap()`).
+    // Stop the debugger and let the user decide what to do.
+    std::string desc =
+        formatv("Exception {0:x8} encountered at address {1:x8}",
+                record.GetExceptionCode(), record.GetExceptionAddress())
+            .str();
+    StopThread(record.GetThreadID(), StopReason::eStopReasonException,
+               std::move(desc));
+    SetState(eStateStopped, true);
 
     return ExceptionResult::MaskException;
-  default:
+  }
+  default: {
     LLDB_LOG(log,
              "Debugger thread reported exception {0:x} at address {1:x} "
              "(first_chance={2})",
              record.GetExceptionCode(), record.GetExceptionAddress(),
              first_chance);
 
-    {
-      std::string desc;
-      llvm::raw_string_ostream desc_stream(desc);
-      desc_stream << "Exception "
-                  << llvm::format_hex(record.GetExceptionCode(), 8)
-                  << " encountered at address "
-                  << llvm::format_hex(record.GetExceptionAddress(), 8);
-      StopThread(record.GetThreadID(), StopReason::eStopReasonException,
-                 desc.c_str());
-
-      SetState(eStateStopped, true);
-    }
+    std::string desc;
+    llvm::raw_string_ostream desc_stream(desc);
+    desc_stream << "Exception "
+                << llvm::format_hex(record.GetExceptionCode(), 8)
+                << " encountered at address "
+                << llvm::format_hex(record.GetExceptionAddress(), 8);
+    StopThread(record.GetThreadID(), StopReason::eStopReasonException,
+               desc.c_str());
+
+    SetState(eStateStopped, true);
 
     // For non-breakpoints, give the application a chance to handle the
     // exception first.
@@ -604,9 +600,9 @@ NativeProcessWindows::OnDebugException(bool first_chance,
       result = ExceptionResult::SendToApplication;
     else
       result = ExceptionResult::BreakInDebugger;
-  }
 
-  return result;
+    return result;
+  }
 }
 
 void NativeProcessWindows::OnCreateThread(const HostThread &new_thread) {

>From 16f7fdca341a6c6267d07cd9323739db18068e91 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Thu, 14 May 2026 17:17:49 +0200
Subject: [PATCH 2/2] fixup! [NFC][lldb][windows] refactor switch case braces

---
 .../Plugins/Process/Windows/Common/NativeProcessWindows.cpp      | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
index cfd6db8248585..d0bb2e48f5918 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
@@ -604,6 +604,7 @@ NativeProcessWindows::OnDebugException(bool first_chance,
     return result;
   }
 }
+}
 
 void NativeProcessWindows::OnCreateThread(const HostThread &new_thread) {
   llvm::sys::ScopedLock lock(m_mutex);



More information about the lldb-commits mailing list