Skip to content

Commit 788bd86

Browse files
author
git apple-llvm automerger
committed
Merge commit '5f4b40c90a51' from llvm.org/main into next
2 parents e47d15a + 5f4b40c commit 788bd86

File tree

5 files changed

+59
-12
lines changed

5 files changed

+59
-12
lines changed

lldb/include/lldb/Core/ModuleList.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,26 @@ class UUID;
4747
class VariableList;
4848
struct ModuleFunctionSearchOptions;
4949

50+
static constexpr OptionEnumValueElement g_auto_download_enum_values[] = {
51+
{
52+
lldb::eSymbolDownloadOff,
53+
"off",
54+
"Disable automatically downloading symbols.",
55+
},
56+
{
57+
lldb::eSymbolDownloadBackground,
58+
"background",
59+
"Download symbols in the background for images as they appear in the "
60+
"backtrace.",
61+
},
62+
{
63+
lldb::eSymbolDownloadForeground,
64+
"foreground",
65+
"Download symbols in the foreground for images as they appear in the "
66+
"backtrace.",
67+
},
68+
};
69+
5070
class ModuleListProperties : public Properties {
5171
mutable llvm::sys::RWMutex m_symlink_paths_mutex;
5272
PathMappingList m_symlink_paths;
@@ -78,7 +98,6 @@ class ModuleListProperties : public Properties {
7898
bool SetClangModulesCachePath(const FileSpec &path);
7999
bool GetEnableExternalLookup() const;
80100
bool SetEnableExternalLookup(bool new_value);
81-
bool GetEnableBackgroundLookup() const;
82101
bool GetEnableLLDBIndexCache() const;
83102
bool SetEnableLLDBIndexCache(bool new_value);
84103
uint64_t GetLLDBIndexCacheMaxByteSize();
@@ -89,6 +108,8 @@ class ModuleListProperties : public Properties {
89108

90109
bool GetLoadSymbolOnDemand();
91110

111+
lldb::SymbolDownload GetSymbolAutoDownload() const;
112+
92113
PathMappingList GetSymlinkMappings() const;
93114
};
94115

lldb/include/lldb/lldb-enumerations.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,12 @@ enum class ChildCacheState {
13441344
///< re-use what we computed the last time we called Update.
13451345
};
13461346

1347+
enum SymbolDownload {
1348+
eSymbolDownloadOff = 0,
1349+
eSymbolDownloadBackground = 1,
1350+
eSymbolDownloadForeground = 2,
1351+
};
1352+
13471353
} // namespace lldb
13481354

13491355
#endif // LLDB_LLDB_ENUMERATIONS_H

lldb/source/Core/CoreProperties.td

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ let Definition = "modulelist" in {
88
def EnableBackgroundLookup: Property<"enable-background-lookup", "Boolean">,
99
Global,
1010
DefaultFalse,
11-
Desc<"On macOS, enable calling dsymForUUID (or an equivalent script/binary) in the background to locate symbol files that weren't found.">;
11+
Desc<"Alias for backward compatibility: when enabled this is the equivalent to 'symbols.download background'.">;
12+
def AutoDownload: Property<"auto-download", "Enum">,
13+
Global,
14+
DefaultEnumValue<"eSymbolDownloadOff">,
15+
EnumValues<"OptionEnumValues(g_auto_download_enum_values)">,
16+
Desc<"On macOS, automatically download symbols with dsymForUUID (or an equivalent script/binary) for relevant images in the debug session.">;
1217
def ClangModulesCachePath: Property<"clang-modules-cache-path", "FileSpec">,
1318
Global,
1419
DefaultStringValue<"">,

lldb/source/Core/ModuleList.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,15 @@ bool ModuleListProperties::SetEnableExternalLookup(bool new_value) {
136136
return SetPropertyAtIndex(ePropertyEnableExternalLookup, new_value);
137137
}
138138

139-
bool ModuleListProperties::GetEnableBackgroundLookup() const {
140-
const uint32_t idx = ePropertyEnableBackgroundLookup;
141-
return GetPropertyAtIndexAs<bool>(
142-
idx, g_modulelist_properties[idx].default_uint_value != 0);
139+
SymbolDownload ModuleListProperties::GetSymbolAutoDownload() const {
140+
// Backward compatibility alias.
141+
if (GetPropertyAtIndexAs<bool>(ePropertyEnableBackgroundLookup, false))
142+
return eSymbolDownloadBackground;
143+
144+
const uint32_t idx = ePropertyAutoDownload;
145+
return GetPropertyAtIndexAs<lldb::SymbolDownload>(
146+
idx, static_cast<lldb::SymbolDownload>(
147+
g_modulelist_properties[idx].default_uint_value));
143148
}
144149

145150
FileSpec ModuleListProperties::GetClangModulesCachePath() const {

lldb/source/Symbol/SymbolLocator.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "lldb/Core/Debugger.h"
1212
#include "lldb/Core/PluginManager.h"
13+
#include "lldb/Host/Host.h"
1314

1415
#include "llvm/ADT/SmallSet.h"
1516
#include "llvm/Support/ThreadPool.h"
@@ -18,12 +19,10 @@ using namespace lldb;
1819
using namespace lldb_private;
1920

2021
void SymbolLocator::DownloadSymbolFileAsync(const UUID &uuid) {
21-
if (!ModuleList::GetGlobalModuleListProperties().GetEnableBackgroundLookup())
22-
return;
23-
2422
static llvm::SmallSet<UUID, 8> g_seen_uuids;
2523
static std::mutex g_mutex;
26-
Debugger::GetThreadPool().async([=]() {
24+
25+
auto lookup = [=]() {
2726
{
2827
std::lock_guard<std::mutex> guard(g_mutex);
2928
if (g_seen_uuids.count(uuid))
@@ -36,12 +35,23 @@ void SymbolLocator::DownloadSymbolFileAsync(const UUID &uuid) {
3635
module_spec.GetUUID() = uuid;
3736
if (!PluginManager::DownloadObjectAndSymbolFile(module_spec, error,
3837
/*force_lookup=*/true,
39-
/*copy_executable=*/false))
38+
/*copy_executable=*/true))
4039
return;
4140

4241
if (error.Fail())
4342
return;
4443

4544
Debugger::ReportSymbolChange(module_spec);
46-
});
45+
};
46+
47+
switch (ModuleList::GetGlobalModuleListProperties().GetSymbolAutoDownload()) {
48+
case eSymbolDownloadOff:
49+
break;
50+
case eSymbolDownloadBackground:
51+
Debugger::GetThreadPool().async(lookup);
52+
break;
53+
case eSymbolDownloadForeground:
54+
lookup();
55+
break;
56+
};
4757
}

0 commit comments

Comments
 (0)