Skip to content

[lldb] Move dynamic type cache to common ABI runtime - #212014

Merged
Nerixyz merged 1 commit into
mainfrom
users/nerixyz/lldb-common-abi-runtime-followup-2
Aug 8, 2026
Merged

[lldb] Move dynamic type cache to common ABI runtime#212014
Nerixyz merged 1 commit into
mainfrom
users/nerixyz/lldb-common-abi-runtime-followup-2

Conversation

@Nerixyz

@Nerixyz Nerixyz commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Both the Itanium and the MS ABI want some cache for dynamic types. This moves the functionality from the Itanium ABI to the base class.

@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-lldb

Author: Nerixyz (Nerixyz)

Changes

Both the Itanium and the MS ABI want some cache for dynamic types. This moves the functionality from the Itanium ABI to the base class.


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

4 Files Affected:

  • (modified) lldb/source/Plugins/LanguageRuntime/CPlusPlus/CommonABIRuntime.cpp (+16)
  • (modified) lldb/source/Plugins/LanguageRuntime/CPlusPlus/CommonABIRuntime.h (+11)
  • (modified) lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.cpp (-16)
  • (modified) lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.h (-9)
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CommonABIRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CommonABIRuntime.cpp
index 91db30ddcc1b4..a8ed0e810b700 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CommonABIRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CommonABIRuntime.cpp
@@ -95,3 +95,19 @@ CommonABIRuntime::LookupTypeByName(llvm::StringRef type_name,
            type_name);
   return {};
 }
+
+TypeAndOrName
+CommonABIRuntime::GetDynamicTypeInfo(const lldb_private::Address &vtable_addr) {
+  std::lock_guard<std::mutex> locker(m_mutex);
+  DynamicTypeCache::const_iterator pos = m_dynamic_type_map.find(vtable_addr);
+  if (pos == m_dynamic_type_map.end())
+    return TypeAndOrName();
+
+  return pos->second;
+}
+
+void CommonABIRuntime::SetDynamicTypeInfo(
+    const lldb_private::Address &vtable_addr, const TypeAndOrName &type_info) {
+  std::lock_guard<std::mutex> locker(m_mutex);
+  m_dynamic_type_map[vtable_addr] = type_info;
+}
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CommonABIRuntime.h b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CommonABIRuntime.h
index 8af61ec2c2c6d..7fc8248c3e192 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CommonABIRuntime.h
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CommonABIRuntime.h
@@ -11,6 +11,7 @@
 
 #include "lldb/Target/Process.h"
 
+#include <map>
 #include <mutex>
 
 namespace lldb_private {
@@ -25,9 +26,19 @@ class CommonABIRuntime {
   lldb::TypeSP LookupTypeByName(llvm::StringRef type_name,
                                 lldb::ModuleSP preferred_module) const;
 
+  TypeAndOrName GetDynamicTypeInfo(const lldb_private::Address &vtable_addr);
+
+  void SetDynamicTypeInfo(const lldb_private::Address &vtable_addr,
+                          const TypeAndOrName &type_info);
+
 protected:
   Process *m_process;
   std::mutex m_mutex;
+
+private:
+  using DynamicTypeCache = std::map<Address, TypeAndOrName>;
+
+  DynamicTypeCache m_dynamic_type_map;
 };
 
 } // namespace lldb_private
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.cpp
index e139ee1623f4b..db1c2a62681d3 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.cpp
@@ -251,19 +251,3 @@ ItaniumABIRuntime::GetExceptionObjectForThread(ThreadSP thread_sp) {
 
   return exception;
 }
-
-TypeAndOrName ItaniumABIRuntime::GetDynamicTypeInfo(
-    const lldb_private::Address &vtable_addr) {
-  std::lock_guard<std::mutex> locker(m_mutex);
-  DynamicTypeCache::const_iterator pos = m_dynamic_type_map.find(vtable_addr);
-  if (pos == m_dynamic_type_map.end())
-    return TypeAndOrName();
-  else
-    return pos->second;
-}
-
-void ItaniumABIRuntime::SetDynamicTypeInfo(
-    const lldb_private::Address &vtable_addr, const TypeAndOrName &type_info) {
-  std::lock_guard<std::mutex> locker(m_mutex);
-  m_dynamic_type_map[vtable_addr] = type_info;
-}
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.h b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.h
index db2dae6a2cfa9..7c4cf019ee975 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.h
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.h
@@ -42,15 +42,6 @@ class ItaniumABIRuntime : public CommonABIRuntime {
 private:
   TypeAndOrName GetTypeInfo(ValueObject &in_value,
                             const LanguageRuntime::VTableInfo &vtable_info);
-
-  TypeAndOrName GetDynamicTypeInfo(const lldb_private::Address &vtable_addr);
-
-  void SetDynamicTypeInfo(const lldb_private::Address &vtable_addr,
-                          const TypeAndOrName &type_info);
-
-  using DynamicTypeCache = std::map<Address, TypeAndOrName>;
-
-  DynamicTypeCache m_dynamic_type_map;
 };
 
 } // namespace lldb_private

@Nerixyz
Nerixyz force-pushed the users/nerixyz/lldb-common-abi-runtime-followup-2 branch from b89f8d4 to d2eeec4 Compare July 25, 2026 11:21
Base automatically changed from users/nerixyz/lldb-common-abi-runtime-followup to main August 7, 2026 17:31
@Nerixyz
Nerixyz force-pushed the users/nerixyz/lldb-common-abi-runtime-followup-2 branch from d2eeec4 to 3de3c57 Compare August 7, 2026 17:31
@Nerixyz
Nerixyz merged commit e4b9301 into main Aug 8, 2026
12 checks passed
@Nerixyz
Nerixyz deleted the users/nerixyz/lldb-common-abi-runtime-followup-2 branch August 8, 2026 09:09
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.

2 participants