@@ -68,7 +68,7 @@ void SwiftLanguage::Initialize() {
68
68
static ConstString g_SwiftStringStorageClass (" _TtCs15__StringStorage" );
69
69
static ConstString g_NSArrayClass1 (" _TtCs22__SwiftDeferredNSArray" );
70
70
PluginManager::RegisterPlugin (GetPluginNameStatic (), " Swift Language" ,
71
- CreateInstance);
71
+ CreateInstance, &DebuggerInitialize );
72
72
73
73
lldb_private::formatters::NSString_Additionals::GetAdditionalSummaries ()
74
74
.emplace(
@@ -1900,6 +1900,144 @@ SwiftLanguage::GetDemangledFunctionNameWithoutArguments(Mangled mangled) const {
1900
1900
return mangled_name;
1901
1901
}
1902
1902
1903
+ static std::optional<llvm::StringRef>
1904
+ GetDemangledBasename (const SymbolContext &sc) {
1905
+ return std::nullopt;
1906
+ }
1907
+
1908
+ static std::optional<llvm::StringRef>
1909
+ GetDemangledFunctionPrefix (const SymbolContext &sc) {
1910
+ return std::nullopt;
1911
+ }
1912
+
1913
+ static std::optional<llvm::StringRef>
1914
+ GetDemangledFunctionSuffix (const SymbolContext &sc) {
1915
+ return std::nullopt;
1916
+ }
1917
+
1918
+ static bool PrintDemangledArgumentList (Stream &s, const SymbolContext &sc) {
1919
+ return false ;
1920
+ }
1921
+
1922
+ static VariableListSP GetFunctionVariableList (const SymbolContext &sc) {
1923
+ assert (sc.function );
1924
+
1925
+ if (sc.block )
1926
+ if (Block *inline_block = sc.block ->GetContainingInlinedBlock ())
1927
+ return inline_block->GetBlockVariableList (true );
1928
+
1929
+ return sc.function ->GetBlock (true ).GetBlockVariableList (true );
1930
+ }
1931
+
1932
+ bool SwiftLanguage::HandleFrameFormatVariable (const SymbolContext &sc,
1933
+ const ExecutionContext *exe_ctx,
1934
+ FormatEntity::Entry::Type type,
1935
+ Stream &s) {
1936
+ switch (type) {
1937
+ case FormatEntity::Entry::Type::FunctionBasename: {
1938
+ std::optional<llvm::StringRef> name = GetDemangledBasename (sc);
1939
+ if (!name)
1940
+ return false ;
1941
+
1942
+ s << *name;
1943
+
1944
+ return true ;
1945
+ }
1946
+ case FormatEntity::Entry::Type::FunctionFormattedArguments: {
1947
+ // This ensures we print the arguments even when no debug-info is available.
1948
+ //
1949
+ // FIXME: we should have a Entry::Type::FunctionArguments and
1950
+ // use it in the plugin.cplusplus.display.function-name-format
1951
+ // once we have a "fallback operator" in the frame-format language.
1952
+ if (!sc.function && sc.symbol )
1953
+ return PrintDemangledArgumentList (s, sc);
1954
+ std::string display_name = SwiftLanguageRuntime::DemangleSymbolAsString (
1955
+ sc.function ->GetMangled ().GetMangledName ().GetStringRef (),
1956
+ SwiftLanguageRuntime::eSimplified, &sc, exe_ctx);
1957
+ if (display_name.empty ())
1958
+ return false ;
1959
+
1960
+ VariableList args;
1961
+ if (auto variable_list_sp = GetFunctionVariableList (sc))
1962
+ variable_list_sp->AppendVariablesWithScope (eValueTypeVariableArgument,
1963
+ args);
1964
+
1965
+ s << GetFunctionDisplayArgs (sc, args, exe_ctx);
1966
+ return true ;
1967
+ }
1968
+ case FormatEntity::Entry::Type::FunctionPrefix: {
1969
+ std::optional<llvm::StringRef> prefix = GetDemangledFunctionPrefix (sc);
1970
+ if (!prefix)
1971
+ return false ;
1972
+
1973
+ s << *prefix;
1974
+
1975
+ return true ;
1976
+ }
1977
+ case FormatEntity::Entry::Type::FunctionSuffix: {
1978
+ std::optional<llvm::StringRef> suffix = GetDemangledFunctionSuffix (sc);
1979
+ if (!suffix)
1980
+ return false ;
1981
+
1982
+ s << *suffix;
1983
+
1984
+ return true ;
1985
+ }
1986
+
1987
+ case FormatEntity::Entry::Type::FunctionScope:
1988
+ case FormatEntity::Entry::Type::FunctionTemplateArguments:
1989
+ case FormatEntity::Entry::Type::FunctionReturnRight:
1990
+ case FormatEntity::Entry::Type::FunctionReturnLeft:
1991
+ case FormatEntity::Entry::Type::FunctionQualifiers:
1992
+ default :
1993
+ return true ;
1994
+ }
1995
+ }
1996
+
1997
+ #define LLDB_PROPERTIES_language_swift
1998
+ #include " LanguageSwiftProperties.inc"
1999
+
2000
+ enum {
2001
+ #define LLDB_PROPERTIES_language_swift
2002
+ #include " LanguageSwiftPropertiesEnum.inc"
2003
+ };
2004
+
2005
+ namespace {
2006
+ class PluginProperties : public Properties {
2007
+ public:
2008
+ static llvm::StringRef GetSettingName () { return " display" ; }
2009
+
2010
+ PluginProperties () {
2011
+ m_collection_sp = std::make_shared<OptionValueProperties>(GetSettingName ());
2012
+ m_collection_sp->Initialize (g_language_swift_properties);
2013
+ }
2014
+
2015
+ FormatEntity::Entry GetFunctionNameFormat () const {
2016
+ return GetPropertyAtIndexAs<const FormatEntity::Entry>(
2017
+ ePropertyFunctionNameFormat, {});
2018
+ }
2019
+ };
2020
+ } // namespace
2021
+
2022
+ static PluginProperties &GetGlobalPluginProperties () {
2023
+ static PluginProperties g_settings;
2024
+ return g_settings;
2025
+ }
2026
+
2027
+ FormatEntity::Entry SwiftLanguage::GetFunctionNameFormat () const {
2028
+ return GetGlobalPluginProperties ().GetFunctionNameFormat ();
2029
+ }
2030
+
2031
+ void SwiftLanguage::DebuggerInitialize (Debugger &debugger) {
2032
+ if (!PluginManager::GetSettingForSwiftLanguagePlugin (
2033
+ debugger, PluginProperties::GetSettingName ())) {
2034
+ PluginManager::CreateSettingForSwiftLanguagePlugin (
2035
+ debugger, GetGlobalPluginProperties ().GetValueProperties (),
2036
+ " Properties for the Swift language plug-in." ,
2037
+ /* is_global_property=*/ true );
2038
+ }
2039
+ }
2040
+
1903
2041
namespace {
1904
2042
using namespace swift ::Demangle;
1905
2043
struct AsyncInfo {
0 commit comments