Author: Charles Zablit
Date: 2026-06-02T14:12:26+01:00
New Revision: 6180a4899ff913e0a0e2338e4d019b683f8f06da

URL: 
https://github.com/llvm/llvm-project/commit/6180a4899ff913e0a0e2338e4d019b683f8f06da
DIFF: 
https://github.com/llvm/llvm-project/commit/6180a4899ff913e0a0e2338e4d019b683f8f06da.diff

LOG: [lldb][Windows] Register MSVCRTCFrameRecognizer from 
DynamicLoaderWindowsDYLD (#201097)

Added: 
    lldb/source/Plugins/DynamicLoader/Windows-DYLD/MSVCRTCFrameRecognizer.cpp
    lldb/source/Plugins/DynamicLoader/Windows-DYLD/MSVCRTCFrameRecognizer.h

Modified: 
    lldb/source/Plugins/DynamicLoader/Windows-DYLD/CMakeLists.txt
    lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
    lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt
    lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp

Removed: 
    lldb/source/Plugins/Process/Windows/Common/MSVCRTCFrameRecognizer.cpp
    lldb/source/Plugins/Process/Windows/Common/MSVCRTCFrameRecognizer.h


################################################################################
diff  --git a/lldb/source/Plugins/DynamicLoader/Windows-DYLD/CMakeLists.txt 
b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/CMakeLists.txt
index 4c2145714081c..9f000d4ea654a 100644
--- a/lldb/source/Plugins/DynamicLoader/Windows-DYLD/CMakeLists.txt
+++ b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/CMakeLists.txt
@@ -1,10 +1,13 @@
 add_lldb_library(lldbPluginDynamicLoaderWindowsDYLD PLUGIN
   DynamicLoaderWindowsDYLD.cpp
+  MSVCRTCFrameRecognizer.cpp
 
   LINK_COMPONENTS
     Support
     TargetParser
   LINK_LIBS
     lldbCore
+    lldbSymbol
     lldbTarget
+    lldbValueObject
   )

diff  --git 
a/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
index b0ea55c96f48f..2d6e97b067c30 100644
--- 
a/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
+++ 
b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
@@ -8,6 +8,7 @@
 
 #include "DynamicLoaderWindowsDYLD.h"
 
+#include "MSVCRTCFrameRecognizer.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Target/ExecutionContext.h"
@@ -137,6 +138,8 @@ void DynamicLoaderWindowsDYLD::DidAttach() {
   Log *log = GetLog(LLDBLog::DynamicLoader);
   LLDB_LOGF(log, "DynamicLoaderWindowsDYLD::%s()", __FUNCTION__);
 
+  RegisterMSVCRTCFrameRecognizer(m_process->GetTarget());
+
   ModuleSP executable = GetTargetExecutable();
 
   if (!executable)
@@ -167,6 +170,8 @@ void DynamicLoaderWindowsDYLD::DidLaunch() {
   Log *log = GetLog(LLDBLog::DynamicLoader);
   LLDB_LOGF(log, "DynamicLoaderWindowsDYLD::%s()", __FUNCTION__);
 
+  RegisterMSVCRTCFrameRecognizer(m_process->GetTarget());
+
   ModuleSP executable = GetTargetExecutable();
   if (!executable)
     return;

diff  --git 
a/lldb/source/Plugins/Process/Windows/Common/MSVCRTCFrameRecognizer.cpp 
b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/MSVCRTCFrameRecognizer.cpp
similarity index 81%
rename from 
lldb/source/Plugins/Process/Windows/Common/MSVCRTCFrameRecognizer.cpp
rename to 
lldb/source/Plugins/DynamicLoader/Windows-DYLD/MSVCRTCFrameRecognizer.cpp
index da05cd79fbe62..c1438ae7e76bb 100644
--- a/lldb/source/Plugins/Process/Windows/Common/MSVCRTCFrameRecognizer.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/MSVCRTCFrameRecognizer.cpp
@@ -21,8 +21,8 @@ using namespace lldb_private;
 
 namespace lldb_private {
 
-void RegisterMSVCRTCFrameRecognizer(ProcessWindows &process) {
-  process.GetTarget().GetFrameRecognizerManager().AddRecognizer(
+void RegisterMSVCRTCFrameRecognizer(Target &target) {
+  target.GetFrameRecognizerManager().AddRecognizer(
       std::make_shared<MSVCRTCFrameRecognizer>(), ConstString(""),
       {ConstString("failwithmessage")}, Mangled::ePreferDemangled,
       /*first_instruction_only=*/false);
@@ -33,13 +33,6 @@ MSVCRTCFrameRecognizer::RecognizeFrame(lldb::StackFrameSP 
frame_sp) {
   // failwithmessage calls __debugbreak() which lands at frame 0.
   if (frame_sp->GetFrameIndex() != 0)
     return RecognizedStackFrameSP();
-  // Only fire on EXCEPTION_BREAKPOINT (0x80000003), not on other exceptions
-  // that might incidentally have failwithmessage somewhere in the call stack.
-  auto *pw =
-      static_cast<ProcessWindows *>(frame_sp->GetThread()->GetProcess().get());
-  auto exc_code = pw->GetActiveExceptionCode();
-  if (!exc_code || *exc_code != EXCEPTION_BREAKPOINT)
-    return RecognizedStackFrameSP();
 
   const char *fn_name = frame_sp->GetFunctionName();
   if (!fn_name)

diff  --git 
a/lldb/source/Plugins/Process/Windows/Common/MSVCRTCFrameRecognizer.h 
b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/MSVCRTCFrameRecognizer.h
similarity index 82%
rename from lldb/source/Plugins/Process/Windows/Common/MSVCRTCFrameRecognizer.h
rename to 
lldb/source/Plugins/DynamicLoader/Windows-DYLD/MSVCRTCFrameRecognizer.h
index 51a451cb94f90..79dcad049b11a 100644
--- a/lldb/source/Plugins/Process/Windows/Common/MSVCRTCFrameRecognizer.h
+++ b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/MSVCRTCFrameRecognizer.h
@@ -6,16 +6,17 @@
 //
 
//===----------------------------------------------------------------------===//
 
-#ifndef LLDB_PLUGINS_PROCESS_WINDOWS_MSVCRTCFRAMERECOGNIZER_H
-#define LLDB_PLUGINS_PROCESS_WINDOWS_MSVCRTCFRAMERECOGNIZER_H
+#ifndef LLDB_PLUGINS_DYNAMICLOADER_WINDOWS_MSVCRTCFRAMERECOGNIZER_H
+#define LLDB_PLUGINS_DYNAMICLOADER_WINDOWS_MSVCRTCFRAMERECOGNIZER_H
 
-#include "ProcessWindows.h"
 #include "lldb/Target/StackFrameRecognizer.h"
 
 namespace lldb_private {
 
+class Target;
+
 /// Registers the MSVC run-time check failure frame recognizer with the target.
-void RegisterMSVCRTCFrameRecognizer(ProcessWindows &process);
+void RegisterMSVCRTCFrameRecognizer(Target &target);
 
 /// Recognized stack frame for an MSVC _RTC failure. Carries the human-readable
 /// stop description extracted from failwithmessage's \c msg parameter.
@@ -38,4 +39,4 @@ class MSVCRTCFrameRecognizer : public StackFrameRecognizer {
 
 } // namespace lldb_private
 
-#endif // LLDB_PLUGINS_PROCESS_WINDOWS_MSVCRTCFRAMERECOGNIZER_H
+#endif // LLDB_PLUGINS_DYNAMICLOADER_WINDOWS_MSVCRTCFRAMERECOGNIZER_H

diff  --git a/lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt 
b/lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt
index edb0532ea01c7..9854b79fbb8d6 100644
--- a/lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt
@@ -2,7 +2,6 @@
 add_lldb_library(lldbPluginProcessWindowsCommon PLUGIN
   DebuggerThread.cpp
   LocalDebugDelegate.cpp
-  MSVCRTCFrameRecognizer.cpp
   NativeProcessWindows.cpp
   NativeRegisterContextWindows.cpp
   NativeRegisterContextWindows_arm.cpp

diff  --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp 
b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
index 42b3d713a737c..9a273463792ce 100644
--- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -45,7 +45,6 @@
 #include "ExceptionRecord.h"
 #include "ForwardDecl.h"
 #include "LocalDebugDelegate.h"
-#include "MSVCRTCFrameRecognizer.h"
 #include "ProcessWindowsLog.h"
 #include "TargetThreadWindows.h"
 
@@ -305,8 +304,6 @@ void ProcessWindows::DidLaunch() {
 void ProcessWindows::DidAttach(ArchSpec &arch_spec) {
   llvm::sys::ScopedLock lock(m_mutex);
 
-  RegisterMSVCRTCFrameRecognizer(*this);
-
   // The initial stop won't broadcast the state change event, so account for
   // that here.
   if (m_session_data && GetPrivateState() == eStateStopped &&


        
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to