Skip to content

Conversation

@Nerixyz
Copy link
Contributor

@Nerixyz Nerixyz commented Dec 15, 2025

Because PDB doesn't know about templates, we need to get to T of std::atomic<T> differently. The type includes the value_type typedef, which is always equal to T. The native PDB plugin includes this since #169248.

Then we can run the std::atomic test with (native) PDB.

@Nerixyz Nerixyz requested a review from Michael137 December 15, 2025 18:47
@llvmbot llvmbot added the lldb label Dec 15, 2025
@llvmbot
Copy link
Member

llvmbot commented Dec 15, 2025

@llvm/pr-subscribers-lldb

Author: nerix (Nerixyz)

Changes

Because PDB doesn't know about templates, we need to get to T of std::atomic&lt;T&gt; differently. The type includes the value_type typedef, which is always equal to T. The native PDB plugin includes this since #169248.

Then we can run the std::atomic test with (native) PDB.


Full diff: https://github.com/llvm/llvm-project/pull/172349.diff

2 Files Affected:

  • (modified) lldb/source/Plugins/Language/CPlusPlus/MsvcStlAtomic.cpp (+11-2)
  • (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/TestDataFormatterStdAtomic.py (+2)
diff --git a/lldb/source/Plugins/Language/CPlusPlus/MsvcStlAtomic.cpp b/lldb/source/Plugins/Language/CPlusPlus/MsvcStlAtomic.cpp
index 020ba10166231..0e5464448c686 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/MsvcStlAtomic.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/MsvcStlAtomic.cpp
@@ -64,10 +64,19 @@ lldb_private::formatters::MsvcStlAtomicSyntheticFrontEnd::Update() {
   if (!storage_sp)
     return lldb::ChildCacheState::eRefetch;
 
-  m_element_type = m_backend.GetCompilerType().GetTypeTemplateArgument(0);
-  if (!m_element_type)
+  CompilerType backend_type = m_backend.GetCompilerType();
+  if (!backend_type)
     return lldb::ChildCacheState::eRefetch;
 
+  m_element_type = backend_type.GetTypeTemplateArgument(0);
+  if (!m_element_type) {
+    // PDB doesn't have info about templates, so use value_type which equals T.
+    m_element_type = backend_type.GetDirectNestedTypeWithName("value_type");
+
+    if (!m_element_type)
+      return lldb::ChildCacheState::eRefetch;
+  }
+
   m_storage = storage_sp.get();
   return lldb::ChildCacheState::eRefetch;
 }
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/TestDataFormatterStdAtomic.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/TestDataFormatterStdAtomic.py
index bdf12ca3b86db..67c2c359c9afb 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/TestDataFormatterStdAtomic.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/TestDataFormatterStdAtomic.py
@@ -10,6 +10,8 @@
 
 
 class StdAtomicTestCase(TestBase):
+    TEST_WITH_PDB_DEBUG_INFO = True
+
     def get_variable(self, name):
         var = self.frame().FindVariable(name)
         var.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)

@Nerixyz Nerixyz merged commit eaf6d9a into llvm:main Dec 16, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants