Skip to content

Commit fd74de7

Browse files
committed
[lldb] add settings to control how synthetic symbol names are generated
1 parent 7670af5 commit fd74de7

File tree

5 files changed

+46
-1
lines changed

5 files changed

+46
-1
lines changed

lldb/include/lldb/Core/ModuleList.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,20 @@ static constexpr OptionEnumValueElement g_auto_download_enum_values[] = {
6767
},
6868
};
6969

70+
static constexpr OptionEnumValueElement
71+
g_synthetic_symbols_name_style_values[] = {
72+
{
73+
lldb::eSyntheticSymbolsNameStyleIndex,
74+
"index",
75+
"Function index style",
76+
},
77+
{
78+
lldb::eSyntheticSymbolsNameStyleFileAddress,
79+
"file-address",
80+
"Function file address in module style",
81+
},
82+
};
83+
7084
class ModuleListProperties : public Properties {
7185
mutable llvm::sys::RWMutex m_symlink_paths_mutex;
7286
PathMappingList m_symlink_paths;
@@ -91,6 +105,7 @@ class ModuleListProperties : public Properties {
91105
bool GetLoadSymbolOnDemand();
92106

93107
lldb::SymbolDownload GetSymbolAutoDownload() const;
108+
lldb::SyntheticSymbolsNameStyle GetSyntheticSymbolsNameStyle() const;
94109

95110
PathMappingList GetSymlinkMappings() const;
96111
};

lldb/include/lldb/lldb-enumerations.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,6 +1391,12 @@ enum StopDisassemblyType {
13911391
eStopDisassemblyTypeAlways
13921392
};
13931393

1394+
/// Format to use for unknown symbols.
1395+
enum SyntheticSymbolsNameStyle {
1396+
eSyntheticSymbolsNameStyleIndex = 0,
1397+
eSyntheticSymbolsNameStyleFileAddress = 1,
1398+
};
1399+
13941400
} // namespace lldb
13951401

13961402
#endif // LLDB_LLDB_ENUMERATIONS_H

lldb/source/Core/CoreProperties.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ let Definition = "modulelist" in {
4646
Global,
4747
DefaultFalse,
4848
Desc<"Enable on demand symbol loading in LLDB. LLDB will load debug info on demand for each module based on various conditions (e.g. matched breakpoint, resolved stack frame addresses and matched global variables/function symbols in symbol table) to improve performance. Please refer to docs/use/ondemand.rst for details.">;
49+
def SyntheticSymbolsNameStyle: Property<"synthetic-symbols-name-style", "Enum">,
50+
Global,
51+
DefaultEnumValue<"eSyntheticSymbolsNameStyleIndex">,
52+
EnumValues<"OptionEnumValues(g_synthetic_symbols_name_style_values)">,
53+
Desc<"Determines the way synthetic symbol names are generated for unknown symbols">;
4954
}
5055

5156
let Definition = "debugger" in {

lldb/source/Core/ModuleList.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ SymbolDownload ModuleListProperties::GetSymbolAutoDownload() const {
115115
g_modulelist_properties[idx].default_uint_value));
116116
}
117117

118+
lldb::SyntheticSymbolsNameStyle
119+
ModuleListProperties::GetSyntheticSymbolsNameStyle() const {
120+
const uint32_t idx = ePropertySyntheticSymbolsNameStyle;
121+
return GetPropertyAtIndexAs<lldb::SyntheticSymbolsNameStyle>(
122+
idx, static_cast<lldb::SyntheticSymbolsNameStyle>(
123+
g_modulelist_properties[idx].default_uint_value));
124+
}
125+
118126
FileSpec ModuleListProperties::GetClangModulesCachePath() const {
119127
const uint32_t idx = ePropertyClangModulesCachePath;
120128
return GetPropertyAtIndexAs<FileSpec>(idx, {});

lldb/source/Symbol/Symbol.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,18 @@ void Symbol::SynthesizeNameIfNeeded() const {
639639
// breakpoints on them.
640640
llvm::SmallString<256> name;
641641
llvm::raw_svector_ostream os(name);
642-
os << GetSyntheticSymbolPrefix() << GetID();
642+
os << GetSyntheticSymbolPrefix();
643+
switch (ModuleList::GetGlobalModuleListProperties()
644+
.GetSyntheticSymbolsNameStyle()) {
645+
case eSyntheticSymbolsNameStyleIndex:
646+
os << GetID();
647+
break;
648+
case eSyntheticSymbolsNameStyleFileAddress:
649+
os << "_"
650+
<< llvm::format_hex_no_prefix(
651+
m_addr_range.GetBaseAddress().GetFileAddress(), 0);
652+
break;
653+
}
643654
m_mangled.SetDemangledName(ConstString(os.str()));
644655
}
645656
}

0 commit comments

Comments
 (0)