[Lldb-commits] [lldb] r257812 - Enable the use of modules in the expression parser by default.

Sean Callanan via lldb-commits lldb-commits at lists.llvm.org
Thu Jan 14 13:46:09 PST 2016


Author: spyffe
Date: Thu Jan 14 15:46:09 2016
New Revision: 257812

URL: http://llvm.org/viewvc/llvm-project?rev=257812&view=rev
Log:
Enable the use of modules in the expression parser by default.

If your program refers to modules (as indicated in DWARF) we will now try to
load these modules and give you access to their types in expressions.  This used
to be gated by a setting ("settings set target.auto-import-clang-modules true")
but that setting defaulted to false.  Now it defaults to true -- but you can
disable it by toggling the setting to false.

Modified:
    lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp?rev=257812&r1=257811&r2=257812&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp Thu Jan 14 15:46:09 2016
@@ -627,7 +627,9 @@ ClangModulesDeclVendor::Create(Target &t
     
     std::vector<std::string> compiler_invocation_arguments =
     {
+        "clang",
         "-fmodules",
+        "-fimplicit-module-maps",
         "-fcxx-modules",
         "-fsyntax-only",
         "-femit-all-decls",

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=257812&r1=257811&r2=257812&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Jan 14 15:46:09 2016
@@ -1091,9 +1091,42 @@ SymbolFileDWARF::ParseImportedModules (c
         if (ClangModulesDeclVendor::LanguageSupportsClangModules(sc.comp_unit->GetLanguage()))
         {
             UpdateExternalModuleListIfNeeded();
-            for (const auto &pair : m_external_type_modules)
+            
+            if (sc.comp_unit)
             {
-                imported_modules.push_back(pair.first);
+                DWARFCompileUnit *dwarf_cu = GetDWARFCompileUnit (sc.comp_unit);
+                
+                const DWARFDIE die = dwarf_cu->GetCompileUnitDIEOnly();
+                
+                if (die)
+                {
+                    for (DWARFDIE child_die = die.GetFirstChild();
+                         child_die;
+                         child_die = child_die.GetSibling())
+                    {
+                        if (child_die.Tag() == DW_TAG_imported_declaration)
+                        {
+                            if (DWARFDIE module_die = child_die.GetReferencedDIE(DW_AT_import))
+                            {
+                                if (module_die.Tag() == DW_TAG_module)
+                                {
+                                    if (const char *name = module_die.GetAttributeValueAsString(DW_AT_name, nullptr))
+                                    {
+                                        ConstString const_name(name);
+                                        imported_modules.push_back(const_name);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            else
+            {
+                for (const auto &pair : m_external_type_modules)
+                {
+                    imported_modules.push_back(pair.first);
+                }
             }
         }
     }

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=257812&r1=257811&r2=257812&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Thu Jan 14 15:46:09 2016
@@ -3389,7 +3389,7 @@ g_properties[] =
     { "exec-search-paths"                  , OptionValue::eTypeFileSpecList, false, 0                       , nullptr, nullptr, "Executable search paths to use when locating executable files whose paths don't match the local file system." },
     { "debug-file-search-paths"            , OptionValue::eTypeFileSpecList, false, 0                       , nullptr, nullptr, "List of directories to be searched when locating debug symbol files." },
     { "clang-module-search-paths"          , OptionValue::eTypeFileSpecList, false, 0                       , nullptr, nullptr, "List of directories to be searched when locating modules for Clang." },
-    { "auto-import-clang-modules"          , OptionValue::eTypeBoolean   , false, false                     , nullptr, nullptr, "Automatically load Clang modules referred to by the program." },
+    { "auto-import-clang-modules"          , OptionValue::eTypeBoolean   , false, true                      , nullptr, nullptr, "Automatically load Clang modules referred to by the program." },
     { "max-children-count"                 , OptionValue::eTypeSInt64    , false, 256                       , nullptr, nullptr, "Maximum number of children to expand in any level of depth." },
     { "max-string-summary-length"          , OptionValue::eTypeSInt64    , false, 1024                      , nullptr, nullptr, "Maximum number of characters to show when using %s in summary strings." },
     { "max-memory-read-size"               , OptionValue::eTypeSInt64    , false, 1024                      , nullptr, nullptr, "Maximum number of bytes that 'memory read' will fetch before --force must be specified." },




More information about the lldb-commits mailing list