<div dir="ltr">Hi Enrico, have there been any tests exercising any of the language plugin stuff yet?  Hard to follow every CL that goes in, so just trying to catch up.</div><br><div class="gmail_quote"><div dir="ltr">On Wed, Nov 18, 2015 at 5:14 PM Enrico Granata via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org">lldb-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: enrico<br>
Date: Wed Nov 18 19:11:53 2015<br>
New Revision: 253531<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=253531&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=253531&view=rev</a><br>
Log:<br>
Allow the language plugins a say in how the function name is rendered as part of frame formatting<br>
<br>
Modified:<br>
    lldb/trunk/include/lldb/Target/Language.h<br>
    lldb/trunk/source/Core/FormatEntity.cpp<br>
    lldb/trunk/source/Target/Language.cpp<br>
<br>
Modified: lldb/trunk/include/lldb/Target/Language.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Language.h?rev=253531&r1=253530&r2=253531&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Language.h?rev=253531&r1=253530&r2=253531&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/include/lldb/Target/Language.h (original)<br>
+++ lldb/trunk/include/lldb/Target/Language.h Wed Nov 18 19:11:53 2015<br>
@@ -32,7 +32,6 @@ class Language :<br>
 public PluginInterface<br>
 {<br>
 public:<br>
-<br>
     class TypeScavenger<br>
     {<br>
     public:<br>
@@ -67,6 +66,13 @@ public:<br>
                    const char *key,<br>
                    ResultSet &results) = 0;<br>
     };<br>
+<br>
+    enum class FunctionNameRepresentation<br>
+    {<br>
+        eName,<br>
+        eNameWithArgs,<br>
+        eNameWithNoArgs<br>
+    };<br>
<br>
     ~Language() override;<br>
<br>
@@ -134,6 +140,11 @@ public:<br>
     virtual bool<br>
     IsUninitializedReference (ValueObject& valobj);<br>
<br>
+    virtual bool<br>
+    GetFunctionDisplayName (const SymbolContext *sc,<br>
+                            FunctionNameRepresentation representation,<br>
+                            Stream& s);<br>
+<br>
     // These are accessors for general information about the Languages lldb knows about:<br>
<br>
     static lldb::LanguageType<br>
<br>
Modified: lldb/trunk/source/Core/FormatEntity.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatEntity.cpp?rev=253531&r1=253530&r2=253531&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatEntity.cpp?rev=253531&r1=253530&r2=253531&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Core/FormatEntity.cpp (original)<br>
+++ lldb/trunk/source/Core/FormatEntity.cpp Wed Nov 18 19:11:53 2015<br>
@@ -1653,201 +1653,264 @@ FormatEntity::Format (const Entry &entry<br>
<br>
         case Entry::Type::FunctionName:<br>
             {<br>
-                const char *name = NULL;<br>
+                Language *language_plugin = nullptr;<br>
+                bool language_plugin_handled = false;<br>
+                StreamString ss;<br>
                 if (sc->function)<br>
-                    name = sc->function->GetName().AsCString (NULL);<br>
+                    language_plugin = Language::FindPlugin(sc->function->GetLanguage());<br>
                 else if (sc->symbol)<br>
-                    name = sc->symbol->GetName().AsCString (NULL);<br>
-                if (name)<br>
+                    language_plugin = Language::FindPlugin(sc->symbol->GetLanguage());<br>
+                if (language_plugin)<br>
                 {<br>
-                    s.PutCString(name);<br>
-<br>
-                    if (sc->block)<br>
+                    language_plugin_handled = language_plugin->GetFunctionDisplayName(sc,<br>
+                                                                                      Language::FunctionNameRepresentation::eName,<br>
+                                                                                      ss);<br>
+                }<br>
+                if (language_plugin_handled)<br>
+                {<br>
+                    s.PutCString(ss.GetData());<br>
+                    return true;<br>
+                }<br>
+                else<br>
+                {<br>
+                    const char *name = NULL;<br>
+                    if (sc->function)<br>
+                        name = sc->function->GetName().AsCString (NULL);<br>
+                    else if (sc->symbol)<br>
+                        name = sc->symbol->GetName().AsCString (NULL);<br>
+                    if (name)<br>
                     {<br>
-                        Block *inline_block = sc->block->GetContainingInlinedBlock ();<br>
-                        if (inline_block)<br>
+                        s.PutCString(name);<br>
+<br>
+                        if (sc->block)<br>
                         {<br>
-                            const InlineFunctionInfo *inline_info = sc->block->GetInlinedFunctionInfo();<br>
-                            if (inline_info)<br>
+                            Block *inline_block = sc->block->GetContainingInlinedBlock ();<br>
+                            if (inline_block)<br>
                             {<br>
-                                s.PutCString(" [inlined] ");<br>
-                                inline_info->GetName(sc->function->GetLanguage()).Dump(&s);<br>
+                                const InlineFunctionInfo *inline_info = sc->block->GetInlinedFunctionInfo();<br>
+                                if (inline_info)<br>
+                                {<br>
+                                    s.PutCString(" [inlined] ");<br>
+                                    inline_info->GetName(sc->function->GetLanguage()).Dump(&s);<br>
+                                }<br>
                             }<br>
                         }<br>
+                        return true;<br>
                     }<br>
-                    return true;<br>
                 }<br>
             }<br>
             return false;<br>
<br>
         case Entry::Type::FunctionNameNoArgs:<br>
             {<br>
-                ConstString name;<br>
+                Language *language_plugin = nullptr;<br>
+                bool language_plugin_handled = false;<br>
+                StreamString ss;<br>
                 if (sc->function)<br>
-                    name = sc->function->GetNameNoArguments();<br>
+                    language_plugin = Language::FindPlugin(sc->function->GetLanguage());<br>
                 else if (sc->symbol)<br>
-                    name = sc->symbol->GetNameNoArguments();<br>
-                if (name)<br>
+                    language_plugin = Language::FindPlugin(sc->symbol->GetLanguage());<br>
+                if (language_plugin)<br>
                 {<br>
-                    s.PutCString(name.GetCString());<br>
+                    language_plugin_handled = language_plugin->GetFunctionDisplayName(sc,<br>
+                                                                                      Language::FunctionNameRepresentation::eNameWithNoArgs,<br>
+                                                                                      ss);<br>
+                }<br>
+                if (language_plugin_handled)<br>
+                {<br>
+                    s.PutCString(ss.GetData());<br>
                     return true;<br>
                 }<br>
+                else<br>
+                {<br>
+                    ConstString name;<br>
+                    if (sc->function)<br>
+                        name = sc->function->GetNameNoArguments();<br>
+                    else if (sc->symbol)<br>
+                        name = sc->symbol->GetNameNoArguments();<br>
+                    if (name)<br>
+                    {<br>
+                        s.PutCString(name.GetCString());<br>
+                        return true;<br>
+                    }<br>
+                }<br>
             }<br>
             return false;<br>
<br>
         case Entry::Type::FunctionNameWithArgs:<br>
             {<br>
-                // Print the function name with arguments in it<br>
+                Language *language_plugin = nullptr;<br>
+                bool language_plugin_handled = false;<br>
+                StreamString ss;<br>
                 if (sc->function)<br>
+                    language_plugin = Language::FindPlugin(sc->function->GetLanguage());<br>
+                else if (sc->symbol)<br>
+                    language_plugin = Language::FindPlugin(sc->symbol->GetLanguage());<br>
+                if (language_plugin)<br>
                 {<br>
-                    ExecutionContextScope *exe_scope = exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL;<br>
-                    const char *cstr = sc->function->GetName().AsCString (NULL);<br>
-                    if (cstr)<br>
+                    language_plugin_handled = language_plugin->GetFunctionDisplayName(sc,<br>
+                                                                                      Language::FunctionNameRepresentation::eNameWithArgs,<br>
+                                                                                      ss);<br>
+                }<br>
+                if (language_plugin_handled)<br>
+                {<br>
+                    s.PutCString(ss.GetData());<br>
+                    return true;<br>
+                }<br>
+                else<br>
+                {<br>
+                    // Print the function name with arguments in it<br>
+                    if (sc->function)<br>
                     {<br>
-                        const InlineFunctionInfo *inline_info = NULL;<br>
-                        VariableListSP variable_list_sp;<br>
-                        bool get_function_vars = true;<br>
-                        if (sc->block)<br>
+                        ExecutionContextScope *exe_scope = exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL;<br>
+                        const char *cstr = sc->function->GetName().AsCString (NULL);<br>
+                        if (cstr)<br>
                         {<br>
-                            Block *inline_block = sc->block->GetContainingInlinedBlock ();<br>
-<br>
-                            if (inline_block)<br>
+                            const InlineFunctionInfo *inline_info = NULL;<br>
+                            VariableListSP variable_list_sp;<br>
+                            bool get_function_vars = true;<br>
+                            if (sc->block)<br>
                             {<br>
-                                get_function_vars = false;<br>
-                                inline_info = sc->block->GetInlinedFunctionInfo();<br>
-                                if (inline_info)<br>
-                                    variable_list_sp = inline_block->GetBlockVariableList (true);<br>
-                            }<br>
-                        }<br>
-<br>
-                        if (get_function_vars)<br>
-                        {<br>
-                            variable_list_sp = sc->function->GetBlock(true).GetBlockVariableList (true);<br>
-                        }<br>
-<br>
-                        if (inline_info)<br>
-                        {<br>
-                            s.PutCString (cstr);<br>
-                            s.PutCString (" [inlined] ");<br>
-                            cstr = inline_info->GetName(sc->function->GetLanguage()).GetCString();<br>
-                        }<br>
-<br>
-                        VariableList args;<br>
-                        if (variable_list_sp)<br>
-                            variable_list_sp->AppendVariablesWithScope(eValueTypeVariableArgument, args);<br>
-                        if (args.GetSize() > 0)<br>
-                        {<br>
-                            const char *open_paren = strchr (cstr, '(');<br>
-                            const char *close_paren = nullptr;<br>
-                            const char *generic = strchr(cstr, '<');<br>
-                            // if before the arguments list begins there is a template sign<br>
-                            // then scan to the end of the generic args before you try to find<br>
-                            // the arguments list<br>
-                            if (generic && open_paren && generic < open_paren)<br>
-                            {<br>
-                                int generic_depth = 1;<br>
-                                ++generic;<br>
-                                for (;<br>
-                                     *generic && generic_depth > 0;<br>
-                                     generic++)<br>
-                                {<br>
-                                    if (*generic == '<')<br>
-                                        generic_depth++;<br>
-                                    if (*generic == '>')<br>
-                                        generic_depth--;<br>
+                                Block *inline_block = sc->block->GetContainingInlinedBlock ();<br>
+<br>
+                                if (inline_block)<br>
+                                {<br>
+                                    get_function_vars = false;<br>
+                                    inline_info = sc->block->GetInlinedFunctionInfo();<br>
+                                    if (inline_info)<br>
+                                        variable_list_sp = inline_block->GetBlockVariableList (true);<br>
                                 }<br>
-                                if (*generic)<br>
-                                    open_paren = strchr(generic, '(');<br>
-                                else<br>
-                                    open_paren = nullptr;<br>
                             }<br>
-                            if (open_paren)<br>
+<br>
+                            if (get_function_vars)<br>
                             {<br>
-                                if (IsToken (open_paren, "(anonymous namespace)"))<br>
-                                {<br>
-                                    open_paren = strchr (open_paren + strlen("(anonymous namespace)"), '(');<br>
-                                    if (open_paren)<br>
-                                        close_paren = strchr (open_paren, ')');<br>
-                                }<br>
-                                else<br>
-                                    close_paren = strchr (open_paren, ')');<br>
+                                variable_list_sp = sc->function->GetBlock(true).GetBlockVariableList (true);<br>
                             }<br>
-<br>
-                            if (open_paren)<br>
-                                s.Write(cstr, open_paren - cstr + 1);<br>
-                            else<br>
+<br>
+                            if (inline_info)<br>
                             {<br>
                                 s.PutCString (cstr);<br>
-                                s.PutChar ('(');<br>
+                                s.PutCString (" [inlined] ");<br>
+                                cstr = inline_info->GetName(sc->function->GetLanguage()).GetCString();<br>
                             }<br>
-                            const size_t num_args = args.GetSize();<br>
-                            for (size_t arg_idx = 0; arg_idx < num_args; ++arg_idx)<br>
+<br>
+                            VariableList args;<br>
+                            if (variable_list_sp)<br>
+                                variable_list_sp->AppendVariablesWithScope(eValueTypeVariableArgument, args);<br>
+                            if (args.GetSize() > 0)<br>
                             {<br>
-                                std::string buffer;<br>
-<br>
-                                VariableSP var_sp (args.GetVariableAtIndex (arg_idx));<br>
-                                ValueObjectSP var_value_sp (ValueObjectVariable::Create (exe_scope, var_sp));<br>
-                                StreamString ss;<br>
-                                const char *var_representation = nullptr;<br>
-                                const char *var_name = var_value_sp->GetName().GetCString();<br>
-                                if (var_value_sp->GetCompilerType().IsValid())<br>
-                                {<br>
-                                    if (var_value_sp && exe_scope->CalculateTarget())<br>
-                                        var_value_sp = var_value_sp->GetQualifiedRepresentationIfAvailable(exe_scope->CalculateTarget()->TargetProperties::GetPreferDynamicValue(),<br>
-                                                                                                           exe_scope->CalculateTarget()->TargetProperties::GetEnableSyntheticValue());<br>
-                                    if (var_value_sp->GetCompilerType().IsAggregateType() &&<br>
-                                        DataVisualization::ShouldPrintAsOneLiner(*var_value_sp.get()))<br>
+                                const char *open_paren = strchr (cstr, '(');<br>
+                                const char *close_paren = nullptr;<br>
+                                const char *generic = strchr(cstr, '<');<br>
+                                // if before the arguments list begins there is a template sign<br>
+                                // then scan to the end of the generic args before you try to find<br>
+                                // the arguments list<br>
+                                if (generic && open_paren && generic < open_paren)<br>
+                                {<br>
+                                    int generic_depth = 1;<br>
+                                    ++generic;<br>
+                                    for (;<br>
+                                         *generic && generic_depth > 0;<br>
+                                         generic++)<br>
+                                    {<br>
+                                        if (*generic == '<')<br>
+                                            generic_depth++;<br>
+                                        if (*generic == '>')<br>
+                                            generic_depth--;<br>
+                                    }<br>
+                                    if (*generic)<br>
+                                        open_paren = strchr(generic, '(');<br>
+                                    else<br>
+                                        open_paren = nullptr;<br>
+                                }<br>
+                                if (open_paren)<br>
+                                {<br>
+                                    if (IsToken (open_paren, "(anonymous namespace)"))<br>
                                     {<br>
-                                        static StringSummaryFormat format(TypeSummaryImpl::Flags()<br>
-                                                                          .SetHideItemNames(false)<br>
-                                                                          .SetShowMembersOneLiner(true),<br>
-                                                                          "");<br>
-                                        format.FormatObject(var_value_sp.get(), buffer, TypeSummaryOptions());<br>
-                                        var_representation = buffer.c_str();<br>
+                                        open_paren = strchr (open_paren + strlen("(anonymous namespace)"), '(');<br>
+                                        if (open_paren)<br>
+                                            close_paren = strchr (open_paren, ')');<br>
                                     }<br>
                                     else<br>
-                                        var_value_sp->DumpPrintableRepresentation(ss,<br>
-                                                                                  ValueObject::ValueObjectRepresentationStyle::eValueObjectRepresentationStyleSummary,<br>
-                                                                                  eFormatDefault,<br>
-                                                                                  ValueObject::PrintableRepresentationSpecialCases::ePrintableRepresentationSpecialCasesAllow,<br>
-                                                                                  false);<br>
+                                        close_paren = strchr (open_paren, ')');<br>
                                 }<br>
<br>
-                                if (ss.GetData() && ss.GetSize())<br>
-                                    var_representation = ss.GetData();<br>
-                                if (arg_idx > 0)<br>
-                                    s.PutCString (", ");<br>
-                                if (var_value_sp->GetError().Success())<br>
+                                if (open_paren)<br>
+                                    s.Write(cstr, open_paren - cstr + 1);<br>
+                                else<br>
                                 {<br>
-                                    if (var_representation)<br>
-                                        s.Printf ("%s=%s", var_name, var_representation);<br>
+                                    s.PutCString (cstr);<br>
+                                    s.PutChar ('(');<br>
+                                }<br>
+                                const size_t num_args = args.GetSize();<br>
+                                for (size_t arg_idx = 0; arg_idx < num_args; ++arg_idx)<br>
+                                {<br>
+                                    std::string buffer;<br>
+<br>
+                                    VariableSP var_sp (args.GetVariableAtIndex (arg_idx));<br>
+                                    ValueObjectSP var_value_sp (ValueObjectVariable::Create (exe_scope, var_sp));<br>
+                                    StreamString ss;<br>
+                                    const char *var_representation = nullptr;<br>
+                                    const char *var_name = var_value_sp->GetName().GetCString();<br>
+                                    if (var_value_sp->GetCompilerType().IsValid())<br>
+                                    {<br>
+                                        if (var_value_sp && exe_scope->CalculateTarget())<br>
+                                            var_value_sp = var_value_sp->GetQualifiedRepresentationIfAvailable(exe_scope->CalculateTarget()->TargetProperties::GetPreferDynamicValue(),<br>
+                                                                                                               exe_scope->CalculateTarget()->TargetProperties::GetEnableSyntheticValue());<br>
+                                        if (var_value_sp->GetCompilerType().IsAggregateType() &&<br>
+                                            DataVisualization::ShouldPrintAsOneLiner(*var_value_sp.get()))<br>
+                                        {<br>
+                                            static StringSummaryFormat format(TypeSummaryImpl::Flags()<br>
+                                                                              .SetHideItemNames(false)<br>
+                                                                              .SetShowMembersOneLiner(true),<br>
+                                                                              "");<br>
+                                            format.FormatObject(var_value_sp.get(), buffer, TypeSummaryOptions());<br>
+                                            var_representation = buffer.c_str();<br>
+                                        }<br>
+                                        else<br>
+                                            var_value_sp->DumpPrintableRepresentation(ss,<br>
+                                                                                      ValueObject::ValueObjectRepresentationStyle::eValueObjectRepresentationStyleSummary,<br>
+                                                                                      eFormatDefault,<br>
+                                                                                      ValueObject::PrintableRepresentationSpecialCases::ePrintableRepresentationSpecialCasesAllow,<br>
+                                                                                      false);<br>
+                                    }<br>
+<br>
+                                    if (ss.GetData() && ss.GetSize())<br>
+                                        var_representation = ss.GetData();<br>
+                                    if (arg_idx > 0)<br>
+                                        s.PutCString (", ");<br>
+                                    if (var_value_sp->GetError().Success())<br>
+                                    {<br>
+                                        if (var_representation)<br>
+                                            s.Printf ("%s=%s", var_name, var_representation);<br>
+                                        else<br>
+                                            s.Printf ("%s=%s at %s", var_name, var_value_sp->GetTypeName().GetCString(), var_value_sp->GetLocationAsCString());<br>
+                                    }<br>
                                     else<br>
-                                        s.Printf ("%s=%s at %s", var_name, var_value_sp->GetTypeName().GetCString(), var_value_sp->GetLocationAsCString());<br>
+                                        s.Printf ("%s=<unavailable>", var_name);<br>
                                 }<br>
+<br>
+                                if (close_paren)<br>
+                                    s.PutCString (close_paren);<br>
                                 else<br>
-                                    s.Printf ("%s=<unavailable>", var_name);<br>
+                                    s.PutChar(')');<br>
+<br>
                             }<br>
-<br>
-                            if (close_paren)<br>
-                                s.PutCString (close_paren);<br>
                             else<br>
-                                s.PutChar(')');<br>
-<br>
+                            {<br>
+                                s.PutCString(cstr);<br>
+                            }<br>
+                            return true;<br>
                         }<br>
-                        else<br>
+                    }<br>
+                    else if (sc->symbol)<br>
+                    {<br>
+                        const char *cstr = sc->symbol->GetName().AsCString (NULL);<br>
+                        if (cstr)<br>
                         {<br>
                             s.PutCString(cstr);<br>
+                            return true;<br>
                         }<br>
-                        return true;<br>
-                    }<br>
-                }<br>
-                else if (sc->symbol)<br>
-                {<br>
-                    const char *cstr = sc->symbol->GetName().AsCString (NULL);<br>
-                    if (cstr)<br>
-                    {<br>
-                        s.PutCString(cstr);<br>
-                        return true;<br>
                     }<br>
                 }<br>
             }<br>
<br>
Modified: lldb/trunk/source/Target/Language.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Language.cpp?rev=253531&r1=253530&r2=253531&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Language.cpp?rev=253531&r1=253530&r2=253531&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Target/Language.cpp (original)<br>
+++ lldb/trunk/source/Target/Language.cpp Wed Nov 18 19:11:53 2015<br>
@@ -370,6 +370,14 @@ Language::IsUninitializedReference (Valu<br>
     return false;<br>
 }<br>
<br>
+bool<br>
+Language::GetFunctionDisplayName (const SymbolContext *sc,<br>
+                                  FunctionNameRepresentation representation,<br>
+                                  Stream& s)<br>
+{<br>
+    return false;<br>
+}<br>
+<br>
 //----------------------------------------------------------------------<br>
 // Constructor<br>
 //----------------------------------------------------------------------<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br>
</blockquote></div>