mirror of
https://github.com/intel/llvm.git
synced 2026-01-20 01:58:44 +08:00
Move the functions that FormatManager uses to actually load formatters into their own file
These are useful helpers over the low-level API of the FormattersContainer, and since we're actually going to start moving formatters into plugins, it makes sense to simplify things llvm-svn: 246612
This commit is contained in:
76
lldb/include/lldb/DataFormatters/FormattersHelpers.h
Normal file
76
lldb/include/lldb/DataFormatters/FormattersHelpers.h
Normal file
@@ -0,0 +1,76 @@
|
||||
//===-- FormattersHelpers.h --------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef lldb_FormattersHelpers_h_
|
||||
#define lldb_FormattersHelpers_h_
|
||||
|
||||
// C Includes
|
||||
// C++ Includes
|
||||
// Other libraries and framework includes
|
||||
// Project includes
|
||||
#include "lldb/lldb-forward.h"
|
||||
#include "lldb/lldb-enumerations.h"
|
||||
|
||||
#include "lldb/DataFormatters/TypeCategory.h"
|
||||
#include "lldb/DataFormatters/TypeFormat.h"
|
||||
#include "lldb/DataFormatters/TypeSummary.h"
|
||||
#include "lldb/DataFormatters/TypeSynthetic.h"
|
||||
|
||||
namespace lldb_private {
|
||||
namespace formatters {
|
||||
void
|
||||
AddFormat (TypeCategoryImpl::SharedPointer category_sp,
|
||||
lldb::Format format,
|
||||
ConstString type_name,
|
||||
TypeFormatImpl::Flags flags,
|
||||
bool regex = false);
|
||||
|
||||
void
|
||||
AddStringSummary(TypeCategoryImpl::SharedPointer category_sp,
|
||||
const char* string,
|
||||
ConstString type_name,
|
||||
TypeSummaryImpl::Flags flags,
|
||||
bool regex = false);
|
||||
|
||||
void
|
||||
AddOneLineSummary (TypeCategoryImpl::SharedPointer category_sp,
|
||||
ConstString type_name,
|
||||
TypeSummaryImpl::Flags flags,
|
||||
bool regex = false);
|
||||
|
||||
#ifndef LLDB_DISABLE_PYTHON
|
||||
void
|
||||
AddCXXSummary (TypeCategoryImpl::SharedPointer category_sp,
|
||||
CXXFunctionSummaryFormat::Callback funct,
|
||||
const char* description,
|
||||
ConstString type_name,
|
||||
TypeSummaryImpl::Flags flags,
|
||||
bool regex = false);
|
||||
|
||||
void
|
||||
AddCXXSynthetic (TypeCategoryImpl::SharedPointer category_sp,
|
||||
CXXSyntheticChildren::CreateFrontEndCallback generator,
|
||||
const char* description,
|
||||
ConstString type_name,
|
||||
ScriptedSyntheticChildren::Flags flags,
|
||||
bool regex = false);
|
||||
|
||||
void
|
||||
AddFilter (TypeCategoryImpl::SharedPointer category_sp,
|
||||
std::vector<std::string> children,
|
||||
const char* description,
|
||||
ConstString type_name,
|
||||
ScriptedSyntheticChildren::Flags flags,
|
||||
bool regex = false);
|
||||
#endif
|
||||
|
||||
} // namespace formatters
|
||||
} // namespace lldb_private
|
||||
|
||||
#endif // lldb_FormattersHelpers_h_
|
||||
@@ -779,6 +779,7 @@
|
||||
94CD705216F8F5BC00CF1E42 /* LibCxxMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CD705116F8F5BC00CF1E42 /* LibCxxMap.cpp */; };
|
||||
94CD7D0919A3FBA300908B7C /* AppleObjCClassDescriptorV2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CD7D0819A3FBA300908B7C /* AppleObjCClassDescriptorV2.cpp */; };
|
||||
94CD7D0C19A3FBCE00908B7C /* AppleObjCTypeEncodingParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CD7D0B19A3FBCE00908B7C /* AppleObjCTypeEncodingParser.cpp */; };
|
||||
94D0858C1B9675B8000D24BD /* FormattersHelpers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94D0858B1B9675B8000D24BD /* FormattersHelpers.cpp */; settings = {ASSET_TAGS = (); }; };
|
||||
94D0B10C16D5535900EA9C70 /* LibCxx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94D0B10A16D5535900EA9C70 /* LibCxx.cpp */; };
|
||||
94D0B10D16D5535900EA9C70 /* LibStdcpp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94D0B10B16D5535900EA9C70 /* LibStdcpp.cpp */; };
|
||||
94D6A0AA16CEB55F00833B6E /* NSArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94D6A0A716CEB55F00833B6E /* NSArray.cpp */; };
|
||||
@@ -2510,6 +2511,8 @@
|
||||
94CD7D0819A3FBA300908B7C /* AppleObjCClassDescriptorV2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppleObjCClassDescriptorV2.cpp; sourceTree = "<group>"; };
|
||||
94CD7D0A19A3FBC300908B7C /* AppleObjCTypeEncodingParser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppleObjCTypeEncodingParser.h; sourceTree = "<group>"; };
|
||||
94CD7D0B19A3FBCE00908B7C /* AppleObjCTypeEncodingParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = AppleObjCTypeEncodingParser.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||
94D0858A1B9675A0000D24BD /* FormattersHelpers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FormattersHelpers.h; path = include/lldb/DataFormatters/FormattersHelpers.h; sourceTree = "<group>"; };
|
||||
94D0858B1B9675B8000D24BD /* FormattersHelpers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FormattersHelpers.cpp; path = source/DataFormatters/FormattersHelpers.cpp; sourceTree = "<group>"; };
|
||||
94D0B10A16D5535900EA9C70 /* LibCxx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibCxx.cpp; path = source/DataFormatters/LibCxx.cpp; sourceTree = "<group>"; };
|
||||
94D0B10B16D5535900EA9C70 /* LibStdcpp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibStdcpp.cpp; path = source/DataFormatters/LibStdcpp.cpp; sourceTree = "<group>"; };
|
||||
94D6A0A716CEB55F00833B6E /* NSArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NSArray.cpp; path = source/DataFormatters/NSArray.cpp; sourceTree = "<group>"; };
|
||||
@@ -5300,6 +5303,8 @@
|
||||
94CB256216B069800059775D /* FormatManager.h */,
|
||||
94CB255A16B069770059775D /* FormatManager.cpp */,
|
||||
94EE33F218643C6900CD703B /* FormattersContainer.h */,
|
||||
94D0858A1B9675A0000D24BD /* FormattersHelpers.h */,
|
||||
94D0858B1B9675B8000D24BD /* FormattersHelpers.cpp */,
|
||||
942612F51B94FFE900EF842E /* LanguageCategory.h */,
|
||||
942612F61B95000000EF842E /* LanguageCategory.cpp */,
|
||||
94D0B10A16D5535900EA9C70 /* LibCxx.cpp */,
|
||||
@@ -6550,6 +6555,7 @@
|
||||
26FFC19D14FC072100087D58 /* DynamicLoaderPOSIXDYLD.cpp in Sources */,
|
||||
2694E99D14FC0BB30076DE67 /* PlatformFreeBSD.cpp in Sources */,
|
||||
2694E9A414FC0BBD0076DE67 /* PlatformLinux.cpp in Sources */,
|
||||
94D0858C1B9675B8000D24BD /* FormattersHelpers.cpp in Sources */,
|
||||
945E8D80152F6AB40019BCCD /* StreamGDBRemote.cpp in Sources */,
|
||||
945759671534941F005A9070 /* PlatformPOSIX.cpp in Sources */,
|
||||
26B1EFAE154638AF00E2DAC7 /* DWARFDeclContext.cpp in Sources */,
|
||||
|
||||
@@ -9,6 +9,7 @@ add_lldb_library(lldbDataFormatters
|
||||
FormatCache.cpp
|
||||
FormatClasses.cpp
|
||||
FormatManager.cpp
|
||||
FormattersHelpers.cpp
|
||||
LanguageCategory.cpp
|
||||
LibCxx.cpp
|
||||
LibCxxInitializerList.cpp
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "lldb/Core/Debugger.h"
|
||||
#include "lldb/DataFormatters/CXXFormatterFunctions.h"
|
||||
#include "lldb/DataFormatters/FormattersHelpers.h"
|
||||
#include "lldb/DataFormatters/LanguageCategory.h"
|
||||
#include "lldb/Target/ExecutionContext.h"
|
||||
#include "lldb/Target/Platform.h"
|
||||
@@ -25,7 +26,7 @@
|
||||
|
||||
using namespace lldb;
|
||||
using namespace lldb_private;
|
||||
|
||||
using namespace lldb_private::formatters;
|
||||
|
||||
struct FormatInfo
|
||||
{
|
||||
@@ -1024,104 +1025,6 @@ FormatManager::FormatManager() :
|
||||
EnableCategory(m_system_category_name,TypeCategoryMap::Last);
|
||||
}
|
||||
|
||||
static void
|
||||
AddFormat (TypeCategoryImpl::SharedPointer category_sp,
|
||||
lldb::Format format,
|
||||
ConstString type_name,
|
||||
TypeFormatImpl::Flags flags,
|
||||
bool regex = false)
|
||||
{
|
||||
lldb::TypeFormatImplSP format_sp(new TypeFormatImpl_Format(format, flags));
|
||||
|
||||
if (regex)
|
||||
category_sp->GetRegexTypeFormatsContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),format_sp);
|
||||
else
|
||||
category_sp->GetTypeFormatsContainer()->Add(type_name, format_sp);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
AddStringSummary(TypeCategoryImpl::SharedPointer category_sp,
|
||||
const char* string,
|
||||
ConstString type_name,
|
||||
TypeSummaryImpl::Flags flags,
|
||||
bool regex = false)
|
||||
{
|
||||
lldb::TypeSummaryImplSP summary_sp(new StringSummaryFormat(flags,
|
||||
string));
|
||||
|
||||
if (regex)
|
||||
category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),summary_sp);
|
||||
else
|
||||
category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
|
||||
}
|
||||
|
||||
static void
|
||||
AddOneLineSummary (TypeCategoryImpl::SharedPointer category_sp,
|
||||
ConstString type_name,
|
||||
TypeSummaryImpl::Flags flags,
|
||||
bool regex = false)
|
||||
{
|
||||
flags.SetShowMembersOneLiner(true);
|
||||
lldb::TypeSummaryImplSP summary_sp(new StringSummaryFormat(flags, ""));
|
||||
|
||||
if (regex)
|
||||
category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),summary_sp);
|
||||
else
|
||||
category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
|
||||
}
|
||||
|
||||
#ifndef LLDB_DISABLE_PYTHON
|
||||
static void
|
||||
AddCXXSummary (TypeCategoryImpl::SharedPointer category_sp,
|
||||
CXXFunctionSummaryFormat::Callback funct,
|
||||
const char* description,
|
||||
ConstString type_name,
|
||||
TypeSummaryImpl::Flags flags,
|
||||
bool regex = false)
|
||||
{
|
||||
lldb::TypeSummaryImplSP summary_sp(new CXXFunctionSummaryFormat(flags,funct,description));
|
||||
if (regex)
|
||||
category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),summary_sp);
|
||||
else
|
||||
category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef LLDB_DISABLE_PYTHON
|
||||
static void AddCXXSynthetic (TypeCategoryImpl::SharedPointer category_sp,
|
||||
CXXSyntheticChildren::CreateFrontEndCallback generator,
|
||||
const char* description,
|
||||
ConstString type_name,
|
||||
ScriptedSyntheticChildren::Flags flags,
|
||||
bool regex = false)
|
||||
{
|
||||
lldb::SyntheticChildrenSP synth_sp(new CXXSyntheticChildren(flags,description,generator));
|
||||
if (regex)
|
||||
category_sp->GetRegexTypeSyntheticsContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())), synth_sp);
|
||||
else
|
||||
category_sp->GetTypeSyntheticsContainer()->Add(type_name,synth_sp);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef LLDB_DISABLE_PYTHON
|
||||
static void AddFilter (TypeCategoryImpl::SharedPointer category_sp,
|
||||
std::vector<std::string> children,
|
||||
const char* description,
|
||||
ConstString type_name,
|
||||
ScriptedSyntheticChildren::Flags flags,
|
||||
bool regex = false)
|
||||
{
|
||||
TypeFilterImplSP filter_sp(new TypeFilterImpl(flags));
|
||||
for (auto child : children)
|
||||
filter_sp->AddExpressionPath(child);
|
||||
if (regex)
|
||||
category_sp->GetRegexTypeFiltersContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())), filter_sp);
|
||||
else
|
||||
category_sp->GetTypeFiltersContainer()->Add(type_name,filter_sp);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
FormatManager::LoadLibStdcppFormatters()
|
||||
{
|
||||
|
||||
120
lldb/source/DataFormatters/FormattersHelpers.cpp
Normal file
120
lldb/source/DataFormatters/FormattersHelpers.cpp
Normal file
@@ -0,0 +1,120 @@
|
||||
//===-- FormattersHelpers.cpp -------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// C Includes
|
||||
|
||||
// C++ Includes
|
||||
|
||||
// Other libraries and framework includes
|
||||
|
||||
// Project includes
|
||||
#include "lldb/DataFormatters/FormattersHelpers.h"
|
||||
|
||||
#include "lldb/Core/ConstString.h"
|
||||
#include "lldb/Core/RegularExpression.h"
|
||||
|
||||
using namespace lldb;
|
||||
using namespace lldb_private;
|
||||
using namespace lldb_private::formatters;
|
||||
|
||||
void
|
||||
lldb_private::formatters::AddFormat (TypeCategoryImpl::SharedPointer category_sp,
|
||||
lldb::Format format,
|
||||
ConstString type_name,
|
||||
TypeFormatImpl::Flags flags,
|
||||
bool regex)
|
||||
{
|
||||
lldb::TypeFormatImplSP format_sp(new TypeFormatImpl_Format(format, flags));
|
||||
|
||||
if (regex)
|
||||
category_sp->GetRegexTypeFormatsContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),format_sp);
|
||||
else
|
||||
category_sp->GetTypeFormatsContainer()->Add(type_name, format_sp);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
lldb_private::formatters::AddStringSummary(TypeCategoryImpl::SharedPointer category_sp,
|
||||
const char* string,
|
||||
ConstString type_name,
|
||||
TypeSummaryImpl::Flags flags,
|
||||
bool regex)
|
||||
{
|
||||
lldb::TypeSummaryImplSP summary_sp(new StringSummaryFormat(flags,
|
||||
string));
|
||||
|
||||
if (regex)
|
||||
category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),summary_sp);
|
||||
else
|
||||
category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
|
||||
}
|
||||
|
||||
void
|
||||
lldb_private::formatters::AddOneLineSummary (TypeCategoryImpl::SharedPointer category_sp,
|
||||
ConstString type_name,
|
||||
TypeSummaryImpl::Flags flags,
|
||||
bool regex)
|
||||
{
|
||||
flags.SetShowMembersOneLiner(true);
|
||||
lldb::TypeSummaryImplSP summary_sp(new StringSummaryFormat(flags, ""));
|
||||
|
||||
if (regex)
|
||||
category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),summary_sp);
|
||||
else
|
||||
category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
|
||||
}
|
||||
|
||||
#ifndef LLDB_DISABLE_PYTHON
|
||||
void
|
||||
lldb_private::formatters::AddCXXSummary (TypeCategoryImpl::SharedPointer category_sp,
|
||||
CXXFunctionSummaryFormat::Callback funct,
|
||||
const char* description,
|
||||
ConstString type_name,
|
||||
TypeSummaryImpl::Flags flags,
|
||||
bool regex)
|
||||
{
|
||||
lldb::TypeSummaryImplSP summary_sp(new CXXFunctionSummaryFormat(flags,funct,description));
|
||||
if (regex)
|
||||
category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),summary_sp);
|
||||
else
|
||||
category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
|
||||
}
|
||||
|
||||
void
|
||||
lldb_private::formatters::AddCXXSynthetic (TypeCategoryImpl::SharedPointer category_sp,
|
||||
CXXSyntheticChildren::CreateFrontEndCallback generator,
|
||||
const char* description,
|
||||
ConstString type_name,
|
||||
ScriptedSyntheticChildren::Flags flags,
|
||||
bool regex)
|
||||
{
|
||||
lldb::SyntheticChildrenSP synth_sp(new CXXSyntheticChildren(flags,description,generator));
|
||||
if (regex)
|
||||
category_sp->GetRegexTypeSyntheticsContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())), synth_sp);
|
||||
else
|
||||
category_sp->GetTypeSyntheticsContainer()->Add(type_name,synth_sp);
|
||||
}
|
||||
|
||||
void
|
||||
lldb_private::formatters::AddFilter (TypeCategoryImpl::SharedPointer category_sp,
|
||||
std::vector<std::string> children,
|
||||
const char* description,
|
||||
ConstString type_name,
|
||||
ScriptedSyntheticChildren::Flags flags,
|
||||
bool regex)
|
||||
{
|
||||
TypeFilterImplSP filter_sp(new TypeFilterImpl(flags));
|
||||
for (auto child : children)
|
||||
filter_sp->AddExpressionPath(child);
|
||||
if (regex)
|
||||
category_sp->GetRegexTypeFiltersContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())), filter_sp);
|
||||
else
|
||||
category_sp->GetTypeFiltersContainer()->Add(type_name,filter_sp);
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user