Allow the language plugins a say in how the function name is rendered as part of frame formatting

llvm-svn: 253531
This commit is contained in:
Enrico Granata 2015-11-19 01:11:53 +00:00
parent 4029426b17
commit d4129b47d0
3 changed files with 226 additions and 144 deletions

View File

@ -32,7 +32,6 @@ class Language :
public PluginInterface
{
public:
class TypeScavenger
{
public:
@ -68,6 +67,13 @@ public:
ResultSet &results) = 0;
};
enum class FunctionNameRepresentation
{
eName,
eNameWithArgs,
eNameWithNoArgs
};
~Language() override;
static Language*
@ -134,6 +140,11 @@ public:
virtual bool
IsUninitializedReference (ValueObject& valobj);
virtual bool
GetFunctionDisplayName (const SymbolContext *sc,
FunctionNameRepresentation representation,
Stream& s);
// These are accessors for general information about the Languages lldb knows about:
static lldb::LanguageType

View File

@ -1652,6 +1652,26 @@ FormatEntity::Format (const Entry &entry,
return initial_function;
case Entry::Type::FunctionName:
{
Language *language_plugin = nullptr;
bool language_plugin_handled = false;
StreamString ss;
if (sc->function)
language_plugin = Language::FindPlugin(sc->function->GetLanguage());
else if (sc->symbol)
language_plugin = Language::FindPlugin(sc->symbol->GetLanguage());
if (language_plugin)
{
language_plugin_handled = language_plugin->GetFunctionDisplayName(sc,
Language::FunctionNameRepresentation::eName,
ss);
}
if (language_plugin_handled)
{
s.PutCString(ss.GetData());
return true;
}
else
{
const char *name = NULL;
if (sc->function)
@ -1678,9 +1698,30 @@ FormatEntity::Format (const Entry &entry,
return true;
}
}
}
return false;
case Entry::Type::FunctionNameNoArgs:
{
Language *language_plugin = nullptr;
bool language_plugin_handled = false;
StreamString ss;
if (sc->function)
language_plugin = Language::FindPlugin(sc->function->GetLanguage());
else if (sc->symbol)
language_plugin = Language::FindPlugin(sc->symbol->GetLanguage());
if (language_plugin)
{
language_plugin_handled = language_plugin->GetFunctionDisplayName(sc,
Language::FunctionNameRepresentation::eNameWithNoArgs,
ss);
}
if (language_plugin_handled)
{
s.PutCString(ss.GetData());
return true;
}
else
{
ConstString name;
if (sc->function)
@ -1693,9 +1734,30 @@ FormatEntity::Format (const Entry &entry,
return true;
}
}
}
return false;
case Entry::Type::FunctionNameWithArgs:
{
Language *language_plugin = nullptr;
bool language_plugin_handled = false;
StreamString ss;
if (sc->function)
language_plugin = Language::FindPlugin(sc->function->GetLanguage());
else if (sc->symbol)
language_plugin = Language::FindPlugin(sc->symbol->GetLanguage());
if (language_plugin)
{
language_plugin_handled = language_plugin->GetFunctionDisplayName(sc,
Language::FunctionNameRepresentation::eNameWithArgs,
ss);
}
if (language_plugin_handled)
{
s.PutCString(ss.GetData());
return true;
}
else
{
// Print the function name with arguments in it
if (sc->function)
@ -1851,6 +1913,7 @@ FormatEntity::Format (const Entry &entry,
}
}
}
}
return false;
case Entry::Type::FunctionAddrOffset:

View File

@ -370,6 +370,14 @@ Language::IsUninitializedReference (ValueObject& valobj)
return false;
}
bool
Language::GetFunctionDisplayName (const SymbolContext *sc,
FunctionNameRepresentation representation,
Stream& s)
{
return false;
}
//----------------------------------------------------------------------
// Constructor
//----------------------------------------------------------------------