[Lldb-commits] [lldb] 0b339c0 - [lldb] Inform every language runtime of the modified modules
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Fri Jul 24 12:13:10 PDT 2020
Author: Jonas Devlieghere
Date: 2020-07-24T12:10:45-07:00
New Revision: 0b339c069266b7a4f3c82f80067d74620cbe19c4
URL: https://github.com/llvm/llvm-project/commit/0b339c069266b7a4f3c82f80067d74620cbe19c4
DIFF: https://github.com/llvm/llvm-project/commit/0b339c069266b7a4f3c82f80067d74620cbe19c4.diff
LOG: [lldb] Inform every language runtime of the modified modules
When a process is notified that modules got loaded, currently only
existing language runtimes are given a chance to deal with that. This
means that if the runtime for a given language wasn't needed before it
won't be informed of the module chance.
This is wrong because the module change might be what triggers the need
for a certain runtime. Instead, we should give the language runtime for
every supported language a chance to deal with the modified modules.
Differential revision: https://reviews.llvm.org/D84475
Added:
Modified:
lldb/source/Target/Process.cpp
Removed:
################################################################################
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index b7694ec43f34..3776a90e546a 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -5757,41 +5757,25 @@ addr_t Process::ResolveIndirectFunction(const Address *address, Status &error) {
}
void Process::ModulesDidLoad(ModuleList &module_list) {
+ // Inform the system runtime of the modified modules.
SystemRuntime *sys_runtime = GetSystemRuntime();
- if (sys_runtime) {
+ if (sys_runtime)
sys_runtime->ModulesDidLoad(module_list);
- }
GetJITLoaders().ModulesDidLoad(module_list);
- // Give runtimes a chance to be created.
+ // Give the instrumentation runtimes a chance to be created before informing
+ // them of the modified modules.
InstrumentationRuntime::ModulesDidLoad(module_list, this,
m_instrumentation_runtimes);
+ for (auto &runtime : m_instrumentation_runtimes)
+ runtime.second->ModulesDidLoad(module_list);
- // Tell runtimes about new modules.
- for (auto pos = m_instrumentation_runtimes.begin();
- pos != m_instrumentation_runtimes.end(); ++pos) {
- InstrumentationRuntimeSP runtime = pos->second;
- runtime->ModulesDidLoad(module_list);
- }
-
- // Let any language runtimes we have already created know about the modules
- // that loaded.
-
- // Iterate over a copy of this language runtime list in case the language
- // runtime ModulesDidLoad somehow causes the language runtime to be
- // unloaded.
- {
- std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
- LanguageRuntimeCollection language_runtimes(m_language_runtimes);
- for (const auto &pair : language_runtimes) {
- // We must check language_runtime_sp to make sure it is not nullptr as we
- // might cache the fact that we didn't have a language runtime for a
- // language.
- LanguageRuntimeSP language_runtime_sp = pair.second;
- if (language_runtime_sp)
- language_runtime_sp->ModulesDidLoad(module_list);
- }
+ // Give the language runtimes a chance to be created before informing them of
+ // the modified modules.
+ for (const lldb::LanguageType lang_type : Language::GetSupportedLanguages()) {
+ if (LanguageRuntime *runtime = GetLanguageRuntime(lang_type))
+ runtime->ModulesDidLoad(module_list);
}
// If we don't have an operating system plug-in, try to load one since
@@ -5799,7 +5783,7 @@ void Process::ModulesDidLoad(ModuleList &module_list) {
if (!m_os_up)
LoadOperatingSystemPlugin(false);
- // Give structured-data plugins a chance to see the modified modules.
+ // Inform the structured-data plugins of the modified modules.
for (auto pair : m_structured_data_plugin_map) {
if (pair.second)
pair.second->ModulesDidLoad(*this, module_list);
More information about the lldb-commits
mailing list