[Lldb-commits] [lldb] r264356 - Make it possible for language plugins to provide additional custom help for 'type lookup'

Enrico Granata via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 24 16:06:42 PDT 2016


Author: enrico
Date: Thu Mar 24 18:06:42 2016
New Revision: 264356

URL: http://llvm.org/viewvc/llvm-project?rev=264356&view=rev
Log:
Make it possible for language plugins to provide additional custom help for 'type lookup'


Modified:
    lldb/trunk/include/lldb/Target/Language.h
    lldb/trunk/source/Commands/CommandObjectType.cpp
    lldb/trunk/source/Target/Language.cpp

Modified: lldb/trunk/include/lldb/Target/Language.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Language.h?rev=264356&r1=264355&r2=264356&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Language.h (original)
+++ lldb/trunk/include/lldb/Target/Language.h Thu Mar 24 18:06:42 2016
@@ -113,6 +113,9 @@ public:
     virtual std::unique_ptr<TypeScavenger>
     GetTypeScavenger ();
     
+    virtual const char*
+    GetLanguageSpecificTypeLookupHelp ();
+    
     // if an individual data formatter can apply to several types and cross a language boundary
     // it makes sense for individual languages to want to customize the printing of values of that
     // type by appending proper prefix/suffix information in language-specific ways

Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=264356&r1=264355&r2=264356&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Thu Mar 24 18:06:42 2016
@@ -3265,8 +3265,8 @@ public:
     CommandObjectTypeLookup (CommandInterpreter &interpreter) :
     CommandObjectRaw (interpreter,
                       "type lookup",
-                      "Lookup a type by name in the select target.",
-                      "type lookup <typename>",
+                      "Lookup types and declarations in the current target, following language-specific naming conventions.",
+                      "type lookup <type-specifier>",
                       eCommandRequiresTarget),
     m_option_group(interpreter),
     m_command_options()
@@ -3283,6 +3283,32 @@ public:
         return &m_option_group;
     }
     
+    const char*
+    GetHelpLong () override
+    {
+        if (m_cmd_help_long.empty())
+        {
+            StreamString stream;
+            // FIXME: hardcoding languages is not good
+            lldb::LanguageType languages[] = {eLanguageTypeObjC,eLanguageTypeC_plus_plus};
+            
+            for(const auto lang_type : languages)
+            {
+                if (auto language = Language::FindPlugin(lang_type))
+                {
+                    if (const char* help = language->GetLanguageSpecificTypeLookupHelp())
+                    {
+                        stream.Printf("%s\n", help);
+                    }
+                }
+            }
+            
+            if (stream.GetData())
+                m_cmd_help_long.assign(stream.GetString());
+        }
+        return this->CommandObject::GetHelpLong();
+    }
+    
     bool
     DoExecute (const char *raw_command_line, CommandReturnObject &result) override
     {

Modified: lldb/trunk/source/Target/Language.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Language.cpp?rev=264356&r1=264355&r2=264356&view=diff
==============================================================================
--- lldb/trunk/source/Target/Language.cpp (original)
+++ lldb/trunk/source/Target/Language.cpp Thu Mar 24 18:06:42 2016
@@ -368,6 +368,12 @@ Language::GetTypeScavenger ()
     return nullptr;
 }
 
+const char*
+Language::GetLanguageSpecificTypeLookupHelp ()
+{
+    return nullptr;
+}
+
 size_t
 Language::TypeScavenger::Find (ExecutionContextScope *exe_scope,
                                const char *key,




More information about the lldb-commits mailing list