Skip to content

Commit

Permalink
Introduce a FormattersMatchData class which contains all the informat…
Browse files Browse the repository at this point in the history
…ion that data formatters need in one place, and also allows for lazy computation of expensive chunks of information if need be

This is a NFC commit that is essentially plumbing the new currency through the system



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@249366 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Enrico Granata committed Oct 6, 2015
1 parent d5ca1bc commit 4d1c5cb
Show file tree
Hide file tree
Showing 9 changed files with 236 additions and 195 deletions.
30 changes: 30 additions & 0 deletions include/lldb/DataFormatters/FormatClasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,36 @@ class FormattersMatchCandidate
};

typedef std::vector<FormattersMatchCandidate> FormattersMatchVector;
typedef std::vector<lldb::LanguageType> CandidateLanguagesVector;

class FormattersMatchData
{
public:
FormattersMatchData (ValueObject&,
lldb::DynamicValueType);

FormattersMatchVector
GetMatchesVector ();

ConstString
GetTypeForCache ();

CandidateLanguagesVector
GetCandidateLanguages ();

ValueObject&
GetValueObject ();

lldb::DynamicValueType
GetDynamicValueType ();

private:
ValueObject& m_valobj;
lldb::DynamicValueType m_dynamic_value_type;
std::pair<FormattersMatchVector,bool> m_formatters_match_vector;
ConstString m_type_for_cache;
CandidateLanguagesVector m_candidate_languages;
};

class TypeNameSpecifierImpl
{
Expand Down
10 changes: 6 additions & 4 deletions include/lldb/DataFormatters/FormatManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,16 @@ class FormatManager : public IFormatChangeListener
ConstString m_vectortypes_category_name;

lldb::TypeFormatImplSP
GetHardcodedFormat (ValueObject&,lldb::DynamicValueType);
GetHardcodedFormat (FormattersMatchData&);

lldb::TypeSummaryImplSP
GetHardcodedSummaryFormat (ValueObject&,lldb::DynamicValueType);
GetHardcodedSummaryFormat (FormattersMatchData&);

lldb::SyntheticChildrenSP
GetHardcodedSyntheticChildren (ValueObject&,lldb::DynamicValueType);
GetHardcodedSyntheticChildren (FormattersMatchData&);

lldb::TypeValidatorImplSP
GetHardcodedValidator (ValueObject&,lldb::DynamicValueType);
GetHardcodedValidator (FormattersMatchData&);

TypeCategoryMap&
GetCategories ()
Expand All @@ -338,6 +338,8 @@ class FormatManager : public IFormatChangeListener

void
LoadVectorFormatters ();

friend class FormattersMatchData;
};

} // namespace lldb_private
Expand Down
36 changes: 12 additions & 24 deletions include/lldb/DataFormatters/LanguageCategory.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,51 +31,39 @@ class LanguageCategory
LanguageCategory (lldb::LanguageType lang_type);

bool
Get (ValueObject& valobj,
lldb::DynamicValueType dynamic,
FormattersMatchVector matches,
Get (FormattersMatchData& match_data,
lldb::TypeFormatImplSP& format_sp);

bool
Get (ValueObject& valobj,
lldb::DynamicValueType dynamic,
FormattersMatchVector matches,
Get (FormattersMatchData& match_data,
lldb::TypeSummaryImplSP& format_sp);

bool
Get (ValueObject& valobj,
lldb::DynamicValueType dynamic,
FormattersMatchVector matches,
Get (FormattersMatchData& match_data,
lldb::SyntheticChildrenSP& format_sp);

bool
Get (ValueObject& valobj,
lldb::DynamicValueType dynamic,
FormattersMatchVector matches,
Get (FormattersMatchData& match_data,
lldb::TypeValidatorImplSP& format_sp);

bool
GetHardcoded (ValueObject& valobj,
lldb::DynamicValueType use_dynamic,
FormatManager& fmt_mgr,
GetHardcoded (FormatManager& fmt_mgr,
FormattersMatchData& match_data,
lldb::TypeFormatImplSP& format_sp);

bool
GetHardcoded (ValueObject& valobj,
lldb::DynamicValueType use_dynamic,
FormatManager& fmt_mgr,
GetHardcoded (FormatManager& fmt_mgr,
FormattersMatchData& match_data,
lldb::TypeSummaryImplSP& format_sp);

bool
GetHardcoded (ValueObject& valobj,
lldb::DynamicValueType use_dynamic,
FormatManager& fmt_mgr,
GetHardcoded (FormatManager& fmt_mgr,
FormattersMatchData& match_data,
lldb::SyntheticChildrenSP& format_sp);

bool
GetHardcoded (ValueObject& valobj,
lldb::DynamicValueType use_dynamic,
FormatManager& fmt_mgr,
GetHardcoded (FormatManager& fmt_mgr,
FormattersMatchData& match_data,
lldb::TypeValidatorImplSP& format_sp);

lldb::TypeCategoryImplSP
Expand Down
16 changes: 4 additions & 12 deletions include/lldb/DataFormatters/TypeCategoryMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,26 +101,18 @@ namespace lldb_private {
}

lldb::TypeFormatImplSP
GetFormat (ValueObject& valobj,
lldb::DynamicValueType use_dynamic,
FormattersMatchVector matches);
GetFormat (FormattersMatchData& match_data);

lldb::TypeSummaryImplSP
GetSummaryFormat (ValueObject& valobj,
lldb::DynamicValueType use_dynamic,
FormattersMatchVector matches);
GetSummaryFormat (FormattersMatchData& match_data);

#ifndef LLDB_DISABLE_PYTHON
lldb::SyntheticChildrenSP
GetSyntheticChildren (ValueObject& valobj,
lldb::DynamicValueType use_dynamic,
FormattersMatchVector matches);
GetSyntheticChildren (FormattersMatchData& match_data);
#endif

lldb::TypeValidatorImplSP
GetValidator (ValueObject& valobj,
lldb::DynamicValueType use_dynamic,
FormattersMatchVector matches);
GetValidator (FormattersMatchData& match_data);

private:

Expand Down
12 changes: 7 additions & 5 deletions lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0610"
version = "1.8">
version = "1.3">
<BuildAction
parallelizeBuildables = "NO"
buildImplicitDependencies = "YES">
Expand All @@ -23,10 +23,10 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
Expand Down Expand Up @@ -80,14 +80,16 @@
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "DebugClang"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
customWorkingDirectory = "/Volumes/work/gclayton/Documents/devb/attach"
buildConfiguration = "DebugClang"
ignoresPersistentStateOnLaunch = "YES"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
Expand Down Expand Up @@ -143,10 +145,10 @@
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
ignoresPersistentStateOnLaunch = "YES"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
Expand Down
47 changes: 47 additions & 0 deletions source/DataFormatters/FormatClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include "lldb/DataFormatters/FormatClasses.h"

#include "lldb/DataFormatters/FormatManager.h"

// C Includes

// C++ Includes
Expand All @@ -20,3 +22,48 @@
using namespace lldb;
using namespace lldb_private;

FormattersMatchData::FormattersMatchData (ValueObject& valobj, lldb::DynamicValueType use_dynamic) :
m_valobj(valobj),
m_dynamic_value_type(use_dynamic),
m_formatters_match_vector({},false),
m_type_for_cache(),
m_candidate_languages()
{
m_type_for_cache = FormatManager::GetTypeForCache(valobj, use_dynamic);
m_candidate_languages = FormatManager::GetCandidateLanguages(valobj);
}

FormattersMatchVector
FormattersMatchData::GetMatchesVector ()
{
if (!m_formatters_match_vector.second)
{
m_formatters_match_vector.second = true;
m_formatters_match_vector.first = FormatManager::GetPossibleMatches(m_valobj, m_dynamic_value_type);
}
return m_formatters_match_vector.first;
}

ConstString
FormattersMatchData::GetTypeForCache ()
{
return m_type_for_cache;
}

CandidateLanguagesVector
FormattersMatchData::GetCandidateLanguages ()
{
return m_candidate_languages;
}

ValueObject&
FormattersMatchData::GetValueObject ()
{
return m_valobj;
}

lldb::DynamicValueType
FormattersMatchData::GetDynamicValueType ()
{
return m_dynamic_value_type;
}
Loading

0 comments on commit 4d1c5cb

Please sign in to comment.