2016-02-29 19:41:30 +00:00
|
|
|
//===-- CPlusPlusLanguage.cpp -----------------------------------*- C++ -*-===//
|
2015-08-27 21:33:50 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2015-08-27 21:33:50 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
#include "CPlusPlusLanguage.h"
|
|
|
|
|
|
2016-02-29 19:41:30 +00:00
|
|
|
#include <cctype>
|
|
|
|
|
#include <cstring>
|
2016-12-19 17:22:44 +00:00
|
|
|
|
2016-02-29 19:41:30 +00:00
|
|
|
#include <functional>
|
2016-12-19 17:22:44 +00:00
|
|
|
#include <memory>
|
2016-02-29 19:41:30 +00:00
|
|
|
#include <mutex>
|
2016-12-19 17:22:44 +00:00
|
|
|
#include <set>
|
2015-09-02 01:59:14 +00:00
|
|
|
|
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
2018-11-06 15:41:37 +00:00
|
|
|
#include "llvm/Demangle/ItaniumDemangle.h"
|
2015-09-02 01:59:14 +00:00
|
|
|
|
2019-11-06 14:06:56 -08:00
|
|
|
#include "lldb/Core/Mangled.h"
|
2015-08-27 21:33:50 +00:00
|
|
|
#include "lldb/Core/PluginManager.h"
|
2015-09-02 01:59:14 +00:00
|
|
|
#include "lldb/Core/UniqueCStringMap.h"
|
2015-09-16 18:28:11 +00:00
|
|
|
#include "lldb/DataFormatters/CXXFunctionPointer.h"
|
2015-09-04 21:01:18 +00:00
|
|
|
#include "lldb/DataFormatters/DataVisualization.h"
|
|
|
|
|
#include "lldb/DataFormatters/FormattersHelpers.h"
|
2015-09-16 18:28:11 +00:00
|
|
|
#include "lldb/DataFormatters/VectorType.h"
|
2017-02-02 21:39:50 +00:00
|
|
|
#include "lldb/Utility/ConstString.h"
|
2017-03-03 20:56:28 +00:00
|
|
|
#include "lldb/Utility/Log.h"
|
2017-02-02 21:39:50 +00:00
|
|
|
#include "lldb/Utility/RegularExpression.h"
|
2015-09-04 21:01:18 +00:00
|
|
|
|
2016-05-02 21:15:31 +00:00
|
|
|
#include "BlockPointer.h"
|
2017-04-06 22:36:02 +00:00
|
|
|
#include "CPlusPlusNameParser.h"
|
2015-09-04 21:01:18 +00:00
|
|
|
#include "CxxStringTypes.h"
|
|
|
|
|
#include "LibCxx.h"
|
2016-02-12 22:18:24 +00:00
|
|
|
#include "LibCxxAtomic.h"
|
2018-09-19 18:07:05 +00:00
|
|
|
#include "LibCxxVariant.h"
|
2015-09-04 21:01:18 +00:00
|
|
|
#include "LibStdcpp.h"
|
2018-11-06 08:02:55 +00:00
|
|
|
#include "MSVCUndecoratedNameParser.h"
|
2015-09-04 21:01:18 +00:00
|
|
|
|
2015-08-27 21:33:50 +00:00
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
2015-09-04 21:01:18 +00:00
|
|
|
using namespace lldb_private::formatters;
|
2015-08-27 21:33:50 +00:00
|
|
|
|
|
|
|
|
void CPlusPlusLanguage::Initialize() {
|
|
|
|
|
PluginManager::RegisterPlugin(GetPluginNameStatic(), "C++ Language",
|
|
|
|
|
CreateInstance);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CPlusPlusLanguage::Terminate() {
|
|
|
|
|
PluginManager::UnregisterPlugin(CreateInstance);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lldb_private::ConstString CPlusPlusLanguage::GetPluginNameStatic() {
|
|
|
|
|
static ConstString g_name("cplusplus");
|
|
|
|
|
return g_name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PluginInterface protocol
|
2016-02-29 19:41:30 +00:00
|
|
|
|
2015-08-27 21:33:50 +00:00
|
|
|
lldb_private::ConstString CPlusPlusLanguage::GetPluginName() {
|
|
|
|
|
return GetPluginNameStatic();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t CPlusPlusLanguage::GetPluginVersion() { return 1; }
|
|
|
|
|
|
|
|
|
|
// Static Functions
|
2016-02-29 19:41:30 +00:00
|
|
|
|
2015-08-27 21:33:50 +00:00
|
|
|
Language *CPlusPlusLanguage::CreateInstance(lldb::LanguageType language) {
|
2015-09-02 01:28:24 +00:00
|
|
|
if (Language::LanguageIsCPlusPlus(language))
|
|
|
|
|
return new CPlusPlusLanguage();
|
|
|
|
|
return nullptr;
|
2015-08-27 21:33:50 +00:00
|
|
|
}
|
2015-09-02 01:59:14 +00:00
|
|
|
|
|
|
|
|
void CPlusPlusLanguage::MethodName::Clear() {
|
|
|
|
|
m_full.Clear();
|
|
|
|
|
m_basename = llvm::StringRef();
|
|
|
|
|
m_context = llvm::StringRef();
|
|
|
|
|
m_arguments = llvm::StringRef();
|
|
|
|
|
m_qualifiers = llvm::StringRef();
|
|
|
|
|
m_parsed = false;
|
|
|
|
|
m_parse_error = false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-06 22:36:02 +00:00
|
|
|
static bool ReverseFindMatchingChars(const llvm::StringRef &s,
|
|
|
|
|
const llvm::StringRef &left_right_chars,
|
|
|
|
|
size_t &left_pos, size_t &right_pos,
|
|
|
|
|
size_t pos = llvm::StringRef::npos) {
|
2015-09-02 01:59:14 +00:00
|
|
|
assert(left_right_chars.size() == 2);
|
|
|
|
|
left_pos = llvm::StringRef::npos;
|
|
|
|
|
const char left_char = left_right_chars[0];
|
|
|
|
|
const char right_char = left_right_chars[1];
|
|
|
|
|
pos = s.find_last_of(left_right_chars, pos);
|
|
|
|
|
if (pos == llvm::StringRef::npos || s[pos] == left_char)
|
|
|
|
|
return false;
|
|
|
|
|
right_pos = pos;
|
|
|
|
|
uint32_t depth = 1;
|
|
|
|
|
while (pos > 0 && depth > 0) {
|
|
|
|
|
pos = s.find_last_of(left_right_chars, pos);
|
|
|
|
|
if (pos == llvm::StringRef::npos)
|
|
|
|
|
return false;
|
|
|
|
|
if (s[pos] == left_char) {
|
|
|
|
|
if (--depth == 0) {
|
|
|
|
|
left_pos = pos;
|
|
|
|
|
return left_pos < right_pos;
|
|
|
|
|
}
|
|
|
|
|
} else if (s[pos] == right_char) {
|
|
|
|
|
++depth;
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2015-09-02 01:59:14 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-06 22:36:02 +00:00
|
|
|
static bool IsTrivialBasename(const llvm::StringRef &basename) {
|
|
|
|
|
// Check that the basename matches with the following regular expression
|
2018-04-30 16:49:04 +00:00
|
|
|
// "^~?([A-Za-z_][A-Za-z_0-9]*)$" We are using a hand written implementation
|
|
|
|
|
// because it is significantly more efficient then using the general purpose
|
|
|
|
|
// regular expression library.
|
2015-10-27 10:43:27 +00:00
|
|
|
size_t idx = 0;
|
|
|
|
|
if (basename.size() > 0 && basename[0] == '~')
|
|
|
|
|
idx = 1;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-10-27 10:43:27 +00:00
|
|
|
if (basename.size() <= idx)
|
|
|
|
|
return false; // Empty string or "~"
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-10-27 10:43:27 +00:00
|
|
|
if (!std::isalpha(basename[idx]) && basename[idx] != '_')
|
|
|
|
|
return false; // First charater (after removing the possible '~'') isn't in
|
|
|
|
|
// [A-Za-z_]
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-10-27 10:43:27 +00:00
|
|
|
// Read all characters matching [A-Za-z_0-9]
|
2016-09-06 20:57:50 +00:00
|
|
|
++idx;
|
2015-10-27 10:43:27 +00:00
|
|
|
while (idx < basename.size()) {
|
|
|
|
|
if (!std::isalnum(basename[idx]) && basename[idx] != '_')
|
2016-09-06 20:57:50 +00:00
|
|
|
break;
|
2015-10-27 10:43:27 +00:00
|
|
|
++idx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We processed all characters. It is a vaild basename.
|
2018-12-15 00:15:33 +00:00
|
|
|
return idx == basename.size();
|
2017-04-06 22:36:02 +00:00
|
|
|
}
|
2015-10-27 10:43:27 +00:00
|
|
|
|
2017-04-06 22:36:02 +00:00
|
|
|
bool CPlusPlusLanguage::MethodName::TrySimplifiedParse() {
|
2018-04-30 16:49:04 +00:00
|
|
|
// This method tries to parse simple method definitions which are presumably
|
|
|
|
|
// most comman in user programs. Definitions that can be parsed by this
|
|
|
|
|
// function don't have return types and templates in the name.
|
2017-04-06 22:36:02 +00:00
|
|
|
// A::B::C::fun(std::vector<T> &) const
|
|
|
|
|
size_t arg_start, arg_end;
|
|
|
|
|
llvm::StringRef full(m_full.GetCString());
|
|
|
|
|
llvm::StringRef parens("()", 2);
|
|
|
|
|
if (ReverseFindMatchingChars(full, parens, arg_start, arg_end)) {
|
|
|
|
|
m_arguments = full.substr(arg_start, arg_end - arg_start + 1);
|
|
|
|
|
if (arg_end + 1 < full.size())
|
|
|
|
|
m_qualifiers = full.substr(arg_end + 1).ltrim();
|
|
|
|
|
|
|
|
|
|
if (arg_start == 0)
|
|
|
|
|
return false;
|
|
|
|
|
size_t basename_end = arg_start;
|
|
|
|
|
size_t context_start = 0;
|
|
|
|
|
size_t context_end = full.rfind(':', basename_end);
|
|
|
|
|
if (context_end == llvm::StringRef::npos)
|
|
|
|
|
m_basename = full.substr(0, basename_end);
|
|
|
|
|
else {
|
|
|
|
|
if (context_start < context_end)
|
|
|
|
|
m_context = full.substr(context_start, context_end - 1 - context_start);
|
|
|
|
|
const size_t basename_begin = context_end + 1;
|
|
|
|
|
m_basename = full.substr(basename_begin, basename_end - basename_begin);
|
|
|
|
|
}
|
2015-10-27 10:43:27 +00:00
|
|
|
|
2017-04-06 22:36:02 +00:00
|
|
|
if (IsTrivialBasename(m_basename)) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
// The C++ basename doesn't match our regular expressions so this can't
|
|
|
|
|
// be a valid C++ method, clear everything out and indicate an error
|
|
|
|
|
m_context = llvm::StringRef();
|
|
|
|
|
m_basename = llvm::StringRef();
|
|
|
|
|
m_arguments = llvm::StringRef();
|
|
|
|
|
m_qualifiers = llvm::StringRef();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2015-10-27 10:43:27 +00:00
|
|
|
}
|
2015-09-02 01:59:14 +00:00
|
|
|
|
|
|
|
|
void CPlusPlusLanguage::MethodName::Parse() {
|
|
|
|
|
if (!m_parsed && m_full) {
|
2017-04-06 22:36:02 +00:00
|
|
|
if (TrySimplifiedParse()) {
|
|
|
|
|
m_parse_error = false;
|
|
|
|
|
} else {
|
|
|
|
|
CPlusPlusNameParser parser(m_full.GetStringRef());
|
|
|
|
|
if (auto function = parser.ParseAsFunctionDefinition()) {
|
|
|
|
|
m_basename = function.getValue().name.basename;
|
|
|
|
|
m_context = function.getValue().name.context;
|
|
|
|
|
m_arguments = function.getValue().arguments;
|
|
|
|
|
m_qualifiers = function.getValue().qualifiers;
|
|
|
|
|
m_parse_error = false;
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2015-09-02 01:59:14 +00:00
|
|
|
m_parse_error = true;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2015-09-02 01:59:14 +00:00
|
|
|
}
|
2017-04-06 22:36:02 +00:00
|
|
|
m_parsed = true;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2015-09-02 01:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
llvm::StringRef CPlusPlusLanguage::MethodName::GetBasename() {
|
|
|
|
|
if (!m_parsed)
|
|
|
|
|
Parse();
|
|
|
|
|
return m_basename;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
llvm::StringRef CPlusPlusLanguage::MethodName::GetContext() {
|
|
|
|
|
if (!m_parsed)
|
|
|
|
|
Parse();
|
|
|
|
|
return m_context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
llvm::StringRef CPlusPlusLanguage::MethodName::GetArguments() {
|
|
|
|
|
if (!m_parsed)
|
|
|
|
|
Parse();
|
|
|
|
|
return m_arguments;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
llvm::StringRef CPlusPlusLanguage::MethodName::GetQualifiers() {
|
|
|
|
|
if (!m_parsed)
|
|
|
|
|
Parse();
|
|
|
|
|
return m_qualifiers;
|
|
|
|
|
}
|
|
|
|
|
|
Better scheme to lookup alternate mangled name when looking up function address.
Summary:
This change is relevant for inferiors compiled with GCC. GCC does not
emit complete debug info for std::basic_string<...>, and consequently, Clang
(the LLDB compiler) does not generate correct mangled names for certain
functions.
This change removes the hard-coded alternate names in
ItaniumABILanguageRuntime.cpp.
Before the hard-coded names were put in ItaniumABILanguageRuntime.cpp, one could
not evaluate std::string methods (ex. std::string::length). After putting in
the hard-coded names, one could evaluate them. However, it did not still
enable one to call methods on, say for example, std::vector<string>.
This change makes that possible.
There is some amount of incompleteness in this change. Consider the
following example:
std::string hello("hello"), world("world");
std::map<std::string, std::string> m;
m[hello] = world;
One can still not evaluate the expression "m[hello]" in LLDB. Will
address this issue in another pass.
Reviewers: jingham, vharron, evgeny777, spyffe, dawn
Subscribers: clayborg, dawn, lldb-commits
Differential Revision: http://reviews.llvm.org/D12809
llvm-svn: 257113
2016-01-07 23:32:34 +00:00
|
|
|
std::string CPlusPlusLanguage::MethodName::GetScopeQualifiedName() {
|
|
|
|
|
if (!m_parsed)
|
|
|
|
|
Parse();
|
2017-04-06 22:36:02 +00:00
|
|
|
if (m_context.empty())
|
|
|
|
|
return m_basename;
|
Better scheme to lookup alternate mangled name when looking up function address.
Summary:
This change is relevant for inferiors compiled with GCC. GCC does not
emit complete debug info for std::basic_string<...>, and consequently, Clang
(the LLDB compiler) does not generate correct mangled names for certain
functions.
This change removes the hard-coded alternate names in
ItaniumABILanguageRuntime.cpp.
Before the hard-coded names were put in ItaniumABILanguageRuntime.cpp, one could
not evaluate std::string methods (ex. std::string::length). After putting in
the hard-coded names, one could evaluate them. However, it did not still
enable one to call methods on, say for example, std::vector<string>.
This change makes that possible.
There is some amount of incompleteness in this change. Consider the
following example:
std::string hello("hello"), world("world");
std::map<std::string, std::string> m;
m[hello] = world;
One can still not evaluate the expression "m[hello]" in LLDB. Will
address this issue in another pass.
Reviewers: jingham, vharron, evgeny777, spyffe, dawn
Subscribers: clayborg, dawn, lldb-commits
Differential Revision: http://reviews.llvm.org/D12809
llvm-svn: 257113
2016-01-07 23:32:34 +00:00
|
|
|
|
|
|
|
|
std::string res;
|
|
|
|
|
res += m_context;
|
|
|
|
|
res += "::";
|
|
|
|
|
res += m_basename;
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-06 14:06:56 -08:00
|
|
|
bool CPlusPlusLanguage::IsCPPMangledName(llvm::StringRef name) {
|
2018-04-30 16:49:04 +00:00
|
|
|
// FIXME!! we should really run through all the known C++ Language plugins
|
|
|
|
|
// and ask each one if this is a C++ mangled name
|
2018-08-15 22:48:48 +00:00
|
|
|
|
2019-11-06 14:06:56 -08:00
|
|
|
Mangled::ManglingScheme scheme = Mangled::GetManglingScheme(name);
|
2018-08-15 22:48:48 +00:00
|
|
|
|
2019-11-06 14:06:56 -08:00
|
|
|
if (scheme == Mangled::eManglingSchemeNone)
|
|
|
|
|
return false;
|
2018-08-15 22:48:48 +00:00
|
|
|
|
2019-11-06 14:06:56 -08:00
|
|
|
return true;
|
2015-09-02 01:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CPlusPlusLanguage::ExtractContextAndIdentifier(
|
|
|
|
|
const char *name, llvm::StringRef &context, llvm::StringRef &identifier) {
|
2018-11-06 08:02:55 +00:00
|
|
|
if (MSVCUndecoratedNameParser::IsMSVCUndecoratedName(name))
|
|
|
|
|
return MSVCUndecoratedNameParser::ExtractContextAndIdentifier(name, context,
|
|
|
|
|
identifier);
|
|
|
|
|
|
2017-04-06 22:36:02 +00:00
|
|
|
CPlusPlusNameParser parser(name);
|
|
|
|
|
if (auto full_name = parser.ParseAsFullName()) {
|
|
|
|
|
identifier = full_name.getValue().basename;
|
|
|
|
|
context = full_name.getValue().context;
|
2015-09-02 01:59:14 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-06 15:41:37 +00:00
|
|
|
namespace {
|
|
|
|
|
class NodeAllocator {
|
|
|
|
|
llvm::BumpPtrAllocator Alloc;
|
2018-08-13 16:45:06 +00:00
|
|
|
|
2018-11-06 15:41:37 +00:00
|
|
|
public:
|
|
|
|
|
void reset() { Alloc.Reset(); }
|
2018-08-13 16:45:06 +00:00
|
|
|
|
2018-11-06 15:41:37 +00:00
|
|
|
template <typename T, typename... Args> T *makeNode(Args &&... args) {
|
|
|
|
|
return new (Alloc.Allocate(sizeof(T), alignof(T)))
|
|
|
|
|
T(std::forward<Args>(args)...);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void *allocateNodeArray(size_t sz) {
|
|
|
|
|
return Alloc.Allocate(sizeof(llvm::itanium_demangle::Node *) * sz,
|
|
|
|
|
alignof(llvm::itanium_demangle::Node *));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
[lldb/cpluspluslanguage] Add constructor substitutor
Summary:
This patch adds code which will substitute references to the full object
constructors/destructors with their base object versions.
Like all substitutions in this category, this operation is not really
sound, but doing this in a more precise way allows us to get rid of a
much larger hack -- matching function according to their demangled
names, which effectively does the same thing, but also much more.
This is a (very late) follow-up to D54074.
Background: clang has an optimization which can eliminate full object
structors completely, if they are found to be equivalent to their base
object versions. It does this because it assumes they can be regenerated
on demand in the compile unit that needs them (e.g., because they are
declared inline). However, this doesn't work for the debugging scenario,
where we don't have the structor bodies available -- we pretend all
constructors are defined out-of-line as far as clang is concerned. This
causes clang to emit references to the (nonexisting) full object
structors during expression evaluation.
Fun fact: This is not a problem on darwin, because the relevant
optimization is disabled to work around a linker bug.
Reviewers: teemperor, JDevlieghere
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D70721
2019-11-26 16:36:09 +01:00
|
|
|
template <typename Derived>
|
|
|
|
|
class ManglingSubstitutor
|
|
|
|
|
: public llvm::itanium_demangle::AbstractManglingParser<Derived,
|
2018-11-06 15:41:37 +00:00
|
|
|
NodeAllocator> {
|
[lldb/cpluspluslanguage] Add constructor substitutor
Summary:
This patch adds code which will substitute references to the full object
constructors/destructors with their base object versions.
Like all substitutions in this category, this operation is not really
sound, but doing this in a more precise way allows us to get rid of a
much larger hack -- matching function according to their demangled
names, which effectively does the same thing, but also much more.
This is a (very late) follow-up to D54074.
Background: clang has an optimization which can eliminate full object
structors completely, if they are found to be equivalent to their base
object versions. It does this because it assumes they can be regenerated
on demand in the compile unit that needs them (e.g., because they are
declared inline). However, this doesn't work for the debugging scenario,
where we don't have the structor bodies available -- we pretend all
constructors are defined out-of-line as far as clang is concerned. This
causes clang to emit references to the (nonexisting) full object
structors during expression evaluation.
Fun fact: This is not a problem on darwin, because the relevant
optimization is disabled to work around a linker bug.
Reviewers: teemperor, JDevlieghere
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D70721
2019-11-26 16:36:09 +01:00
|
|
|
using Base =
|
|
|
|
|
llvm::itanium_demangle::AbstractManglingParser<Derived, NodeAllocator>;
|
2018-11-06 15:41:37 +00:00
|
|
|
|
[lldb/cpluspluslanguage] Add constructor substitutor
Summary:
This patch adds code which will substitute references to the full object
constructors/destructors with their base object versions.
Like all substitutions in this category, this operation is not really
sound, but doing this in a more precise way allows us to get rid of a
much larger hack -- matching function according to their demangled
names, which effectively does the same thing, but also much more.
This is a (very late) follow-up to D54074.
Background: clang has an optimization which can eliminate full object
structors completely, if they are found to be equivalent to their base
object versions. It does this because it assumes they can be regenerated
on demand in the compile unit that needs them (e.g., because they are
declared inline). However, this doesn't work for the debugging scenario,
where we don't have the structor bodies available -- we pretend all
constructors are defined out-of-line as far as clang is concerned. This
causes clang to emit references to the (nonexisting) full object
structors during expression evaluation.
Fun fact: This is not a problem on darwin, because the relevant
optimization is disabled to work around a linker bug.
Reviewers: teemperor, JDevlieghere
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D70721
2019-11-26 16:36:09 +01:00
|
|
|
public:
|
|
|
|
|
ManglingSubstitutor() : Base(nullptr, nullptr) {}
|
2018-11-06 15:41:37 +00:00
|
|
|
|
[lldb/cpluspluslanguage] Add constructor substitutor
Summary:
This patch adds code which will substitute references to the full object
constructors/destructors with their base object versions.
Like all substitutions in this category, this operation is not really
sound, but doing this in a more precise way allows us to get rid of a
much larger hack -- matching function according to their demangled
names, which effectively does the same thing, but also much more.
This is a (very late) follow-up to D54074.
Background: clang has an optimization which can eliminate full object
structors completely, if they are found to be equivalent to their base
object versions. It does this because it assumes they can be regenerated
on demand in the compile unit that needs them (e.g., because they are
declared inline). However, this doesn't work for the debugging scenario,
where we don't have the structor bodies available -- we pretend all
constructors are defined out-of-line as far as clang is concerned. This
causes clang to emit references to the (nonexisting) full object
structors during expression evaluation.
Fun fact: This is not a problem on darwin, because the relevant
optimization is disabled to work around a linker bug.
Reviewers: teemperor, JDevlieghere
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D70721
2019-11-26 16:36:09 +01:00
|
|
|
template<typename... Ts>
|
|
|
|
|
ConstString substitute(llvm::StringRef Mangled, Ts &&... Vals) {
|
|
|
|
|
this->getDerived().reset(Mangled, std::forward<Ts>(Vals)...);
|
|
|
|
|
return substituteImpl(Mangled);
|
|
|
|
|
}
|
2018-11-06 15:41:37 +00:00
|
|
|
|
[lldb/cpluspluslanguage] Add constructor substitutor
Summary:
This patch adds code which will substitute references to the full object
constructors/destructors with their base object versions.
Like all substitutions in this category, this operation is not really
sound, but doing this in a more precise way allows us to get rid of a
much larger hack -- matching function according to their demangled
names, which effectively does the same thing, but also much more.
This is a (very late) follow-up to D54074.
Background: clang has an optimization which can eliminate full object
structors completely, if they are found to be equivalent to their base
object versions. It does this because it assumes they can be regenerated
on demand in the compile unit that needs them (e.g., because they are
declared inline). However, this doesn't work for the debugging scenario,
where we don't have the structor bodies available -- we pretend all
constructors are defined out-of-line as far as clang is concerned. This
causes clang to emit references to the (nonexisting) full object
structors during expression evaluation.
Fun fact: This is not a problem on darwin, because the relevant
optimization is disabled to work around a linker bug.
Reviewers: teemperor, JDevlieghere
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D70721
2019-11-26 16:36:09 +01:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void reset(llvm::StringRef Mangled) {
|
|
|
|
|
Base::reset(Mangled.begin(), Mangled.end());
|
2018-11-06 15:41:37 +00:00
|
|
|
Written = Mangled.begin();
|
|
|
|
|
Result.clear();
|
|
|
|
|
Substituted = false;
|
|
|
|
|
}
|
2018-08-13 16:45:06 +00:00
|
|
|
|
[lldb/cpluspluslanguage] Add constructor substitutor
Summary:
This patch adds code which will substitute references to the full object
constructors/destructors with their base object versions.
Like all substitutions in this category, this operation is not really
sound, but doing this in a more precise way allows us to get rid of a
much larger hack -- matching function according to their demangled
names, which effectively does the same thing, but also much more.
This is a (very late) follow-up to D54074.
Background: clang has an optimization which can eliminate full object
structors completely, if they are found to be equivalent to their base
object versions. It does this because it assumes they can be regenerated
on demand in the compile unit that needs them (e.g., because they are
declared inline). However, this doesn't work for the debugging scenario,
where we don't have the structor bodies available -- we pretend all
constructors are defined out-of-line as far as clang is concerned. This
causes clang to emit references to the (nonexisting) full object
structors during expression evaluation.
Fun fact: This is not a problem on darwin, because the relevant
optimization is disabled to work around a linker bug.
Reviewers: teemperor, JDevlieghere
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D70721
2019-11-26 16:36:09 +01:00
|
|
|
ConstString substituteImpl(llvm::StringRef Mangled) {
|
2018-11-06 15:41:37 +00:00
|
|
|
Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE);
|
[lldb/cpluspluslanguage] Add constructor substitutor
Summary:
This patch adds code which will substitute references to the full object
constructors/destructors with their base object versions.
Like all substitutions in this category, this operation is not really
sound, but doing this in a more precise way allows us to get rid of a
much larger hack -- matching function according to their demangled
names, which effectively does the same thing, but also much more.
This is a (very late) follow-up to D54074.
Background: clang has an optimization which can eliminate full object
structors completely, if they are found to be equivalent to their base
object versions. It does this because it assumes they can be regenerated
on demand in the compile unit that needs them (e.g., because they are
declared inline). However, this doesn't work for the debugging scenario,
where we don't have the structor bodies available -- we pretend all
constructors are defined out-of-line as far as clang is concerned. This
causes clang to emit references to the (nonexisting) full object
structors during expression evaluation.
Fun fact: This is not a problem on darwin, because the relevant
optimization is disabled to work around a linker bug.
Reviewers: teemperor, JDevlieghere
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D70721
2019-11-26 16:36:09 +01:00
|
|
|
if (this->parse() == nullptr) {
|
2018-11-06 15:41:37 +00:00
|
|
|
LLDB_LOG(log, "Failed to substitute mangling in {0}", Mangled);
|
|
|
|
|
return ConstString();
|
2016-12-19 17:22:44 +00:00
|
|
|
}
|
2018-11-06 15:41:37 +00:00
|
|
|
if (!Substituted)
|
|
|
|
|
return ConstString();
|
|
|
|
|
|
|
|
|
|
// Append any trailing unmodified input.
|
|
|
|
|
appendUnchangedInput();
|
|
|
|
|
LLDB_LOG(log, "Substituted mangling {0} -> {1}", Mangled, Result);
|
|
|
|
|
return ConstString(Result);
|
2018-08-13 16:45:06 +00:00
|
|
|
}
|
2016-12-19 17:22:44 +00:00
|
|
|
|
[lldb/cpluspluslanguage] Add constructor substitutor
Summary:
This patch adds code which will substitute references to the full object
constructors/destructors with their base object versions.
Like all substitutions in this category, this operation is not really
sound, but doing this in a more precise way allows us to get rid of a
much larger hack -- matching function according to their demangled
names, which effectively does the same thing, but also much more.
This is a (very late) follow-up to D54074.
Background: clang has an optimization which can eliminate full object
structors completely, if they are found to be equivalent to their base
object versions. It does this because it assumes they can be regenerated
on demand in the compile unit that needs them (e.g., because they are
declared inline). However, this doesn't work for the debugging scenario,
where we don't have the structor bodies available -- we pretend all
constructors are defined out-of-line as far as clang is concerned. This
causes clang to emit references to the (nonexisting) full object
structors during expression evaluation.
Fun fact: This is not a problem on darwin, because the relevant
optimization is disabled to work around a linker bug.
Reviewers: teemperor, JDevlieghere
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D70721
2019-11-26 16:36:09 +01:00
|
|
|
void trySubstitute(llvm::StringRef From, llvm::StringRef To) {
|
|
|
|
|
if (!llvm::StringRef(currentParserPos(), this->numLeft()).startswith(From))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// We found a match. Append unmodified input up to this point.
|
|
|
|
|
appendUnchangedInput();
|
|
|
|
|
|
|
|
|
|
// And then perform the replacement.
|
|
|
|
|
Result += To;
|
|
|
|
|
Written += From.size();
|
|
|
|
|
Substituted = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
/// Input character until which we have constructed the respective output
|
|
|
|
|
/// already.
|
|
|
|
|
const char *Written;
|
|
|
|
|
|
|
|
|
|
llvm::SmallString<128> Result;
|
|
|
|
|
|
|
|
|
|
/// Whether we have performed any substitutions.
|
|
|
|
|
bool Substituted;
|
|
|
|
|
|
|
|
|
|
const char *currentParserPos() const { return this->First; }
|
|
|
|
|
|
|
|
|
|
void appendUnchangedInput() {
|
|
|
|
|
Result +=
|
|
|
|
|
llvm::StringRef(Written, std::distance(Written, currentParserPos()));
|
|
|
|
|
Written = currentParserPos();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// Given a mangled function `Mangled`, replace all the primitive function type
|
|
|
|
|
/// arguments of `Search` with type `Replace`.
|
|
|
|
|
class TypeSubstitutor : public ManglingSubstitutor<TypeSubstitutor> {
|
|
|
|
|
llvm::StringRef Search;
|
|
|
|
|
llvm::StringRef Replace;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
void reset(llvm::StringRef Mangled, llvm::StringRef Search,
|
|
|
|
|
llvm::StringRef Replace) {
|
|
|
|
|
ManglingSubstitutor::reset(Mangled);
|
|
|
|
|
this->Search = Search;
|
|
|
|
|
this->Replace = Replace;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-06 15:41:37 +00:00
|
|
|
llvm::itanium_demangle::Node *parseType() {
|
[lldb/cpluspluslanguage] Add constructor substitutor
Summary:
This patch adds code which will substitute references to the full object
constructors/destructors with their base object versions.
Like all substitutions in this category, this operation is not really
sound, but doing this in a more precise way allows us to get rid of a
much larger hack -- matching function according to their demangled
names, which effectively does the same thing, but also much more.
This is a (very late) follow-up to D54074.
Background: clang has an optimization which can eliminate full object
structors completely, if they are found to be equivalent to their base
object versions. It does this because it assumes they can be regenerated
on demand in the compile unit that needs them (e.g., because they are
declared inline). However, this doesn't work for the debugging scenario,
where we don't have the structor bodies available -- we pretend all
constructors are defined out-of-line as far as clang is concerned. This
causes clang to emit references to the (nonexisting) full object
structors during expression evaluation.
Fun fact: This is not a problem on darwin, because the relevant
optimization is disabled to work around a linker bug.
Reviewers: teemperor, JDevlieghere
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D70721
2019-11-26 16:36:09 +01:00
|
|
|
trySubstitute(Search, Replace);
|
|
|
|
|
return ManglingSubstitutor::parseType();
|
2018-11-06 15:41:37 +00:00
|
|
|
}
|
|
|
|
|
};
|
[lldb/cpluspluslanguage] Add constructor substitutor
Summary:
This patch adds code which will substitute references to the full object
constructors/destructors with their base object versions.
Like all substitutions in this category, this operation is not really
sound, but doing this in a more precise way allows us to get rid of a
much larger hack -- matching function according to their demangled
names, which effectively does the same thing, but also much more.
This is a (very late) follow-up to D54074.
Background: clang has an optimization which can eliminate full object
structors completely, if they are found to be equivalent to their base
object versions. It does this because it assumes they can be regenerated
on demand in the compile unit that needs them (e.g., because they are
declared inline). However, this doesn't work for the debugging scenario,
where we don't have the structor bodies available -- we pretend all
constructors are defined out-of-line as far as clang is concerned. This
causes clang to emit references to the (nonexisting) full object
structors during expression evaluation.
Fun fact: This is not a problem on darwin, because the relevant
optimization is disabled to work around a linker bug.
Reviewers: teemperor, JDevlieghere
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D70721
2019-11-26 16:36:09 +01:00
|
|
|
|
|
|
|
|
class CtorDtorSubstitutor : public ManglingSubstitutor<CtorDtorSubstitutor> {
|
|
|
|
|
public:
|
|
|
|
|
llvm::itanium_demangle::Node *
|
|
|
|
|
parseCtorDtorName(llvm::itanium_demangle::Node *&SoFar, NameState *State) {
|
|
|
|
|
trySubstitute("C1", "C2");
|
|
|
|
|
trySubstitute("D1", "D2");
|
|
|
|
|
return ManglingSubstitutor::parseCtorDtorName(SoFar, State);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
} // namespace
|
2016-12-19 17:22:44 +00:00
|
|
|
|
|
|
|
|
uint32_t CPlusPlusLanguage::FindAlternateFunctionManglings(
|
|
|
|
|
const ConstString mangled_name, std::set<ConstString> &alternates) {
|
|
|
|
|
const auto start_size = alternates.size();
|
|
|
|
|
/// Get a basic set of alternative manglings for the given symbol `name`, by
|
|
|
|
|
/// making a few basic possible substitutions on basic types, storage duration
|
|
|
|
|
/// and `const`ness for the given symbol. The output parameter `alternates`
|
|
|
|
|
/// is filled with a best-guess, non-exhaustive set of different manglings
|
|
|
|
|
/// for the given name.
|
|
|
|
|
|
|
|
|
|
// Maybe we're looking for a const symbol but the debug info told us it was
|
|
|
|
|
// non-const...
|
|
|
|
|
if (!strncmp(mangled_name.GetCString(), "_ZN", 3) &&
|
|
|
|
|
strncmp(mangled_name.GetCString(), "_ZNK", 4)) {
|
|
|
|
|
std::string fixed_scratch("_ZNK");
|
|
|
|
|
fixed_scratch.append(mangled_name.GetCString() + 3);
|
|
|
|
|
alternates.insert(ConstString(fixed_scratch));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Maybe we're looking for a static symbol but we thought it was global...
|
|
|
|
|
if (!strncmp(mangled_name.GetCString(), "_Z", 2) &&
|
|
|
|
|
strncmp(mangled_name.GetCString(), "_ZL", 3)) {
|
|
|
|
|
std::string fixed_scratch("_ZL");
|
|
|
|
|
fixed_scratch.append(mangled_name.GetCString() + 2);
|
|
|
|
|
alternates.insert(ConstString(fixed_scratch));
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-06 15:41:37 +00:00
|
|
|
TypeSubstitutor TS;
|
2016-12-19 17:22:44 +00:00
|
|
|
// `char` is implementation defined as either `signed` or `unsigned`. As a
|
|
|
|
|
// result a char parameter has 3 possible manglings: 'c'-char, 'a'-signed
|
|
|
|
|
// char, 'h'-unsigned char. If we're looking for symbols with a signed char
|
|
|
|
|
// parameter, try finding matches which have the general case 'c'.
|
|
|
|
|
if (ConstString char_fixup =
|
2018-11-06 15:41:37 +00:00
|
|
|
TS.substitute(mangled_name.GetStringRef(), "a", "c"))
|
2016-12-19 17:22:44 +00:00
|
|
|
alternates.insert(char_fixup);
|
|
|
|
|
|
|
|
|
|
// long long parameter mangling 'x', may actually just be a long 'l' argument
|
|
|
|
|
if (ConstString long_fixup =
|
2018-11-06 15:41:37 +00:00
|
|
|
TS.substitute(mangled_name.GetStringRef(), "x", "l"))
|
2016-12-19 17:22:44 +00:00
|
|
|
alternates.insert(long_fixup);
|
|
|
|
|
|
|
|
|
|
// unsigned long long parameter mangling 'y', may actually just be unsigned
|
|
|
|
|
// long 'm' argument
|
|
|
|
|
if (ConstString ulong_fixup =
|
2018-11-06 15:41:37 +00:00
|
|
|
TS.substitute(mangled_name.GetStringRef(), "y", "m"))
|
2016-12-19 17:22:44 +00:00
|
|
|
alternates.insert(ulong_fixup);
|
|
|
|
|
|
[lldb/cpluspluslanguage] Add constructor substitutor
Summary:
This patch adds code which will substitute references to the full object
constructors/destructors with their base object versions.
Like all substitutions in this category, this operation is not really
sound, but doing this in a more precise way allows us to get rid of a
much larger hack -- matching function according to their demangled
names, which effectively does the same thing, but also much more.
This is a (very late) follow-up to D54074.
Background: clang has an optimization which can eliminate full object
structors completely, if they are found to be equivalent to their base
object versions. It does this because it assumes they can be regenerated
on demand in the compile unit that needs them (e.g., because they are
declared inline). However, this doesn't work for the debugging scenario,
where we don't have the structor bodies available -- we pretend all
constructors are defined out-of-line as far as clang is concerned. This
causes clang to emit references to the (nonexisting) full object
structors during expression evaluation.
Fun fact: This is not a problem on darwin, because the relevant
optimization is disabled to work around a linker bug.
Reviewers: teemperor, JDevlieghere
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D70721
2019-11-26 16:36:09 +01:00
|
|
|
if (ConstString ctor_fixup =
|
|
|
|
|
CtorDtorSubstitutor().substitute(mangled_name.GetStringRef()))
|
|
|
|
|
alternates.insert(ctor_fixup);
|
|
|
|
|
|
2016-12-19 17:22:44 +00:00
|
|
|
return alternates.size() - start_size;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
|
|
|
|
|
if (!cpp_category_sp)
|
|
|
|
|
return;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
TypeSummaryImpl::Flags stl_summary_flags;
|
|
|
|
|
stl_summary_flags.SetCascades(true)
|
|
|
|
|
.SetSkipPointers(false)
|
|
|
|
|
.SetSkipReferences(false)
|
|
|
|
|
.SetDontShowChildren(true)
|
|
|
|
|
.SetDontShowValue(true)
|
|
|
|
|
.SetShowMembersOneLiner(false)
|
|
|
|
|
.SetHideItemNames(false);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-02-01 19:10:39 +00:00
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxStringSummaryProviderASCII,
|
|
|
|
|
"std::string summary provider",
|
|
|
|
|
ConstString("^std::__[[:alnum:]]+::string$"), stl_summary_flags,
|
|
|
|
|
true);
|
|
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxStringSummaryProviderASCII,
|
|
|
|
|
"std::string summary provider",
|
|
|
|
|
ConstString("^std::__[[:alnum:]]+::basic_string<char, "
|
|
|
|
|
"std::__[[:alnum:]]+::char_traits<char>, "
|
|
|
|
|
"std::__[[:alnum:]]+::allocator<char> >$"),
|
|
|
|
|
stl_summary_flags, true);
|
[lldb][DataFormatters] Support pretty printing std::string when built with -funsigned-char.
Summary:
When built w/ `-funsigned-char`, `std::string` becomes equivalent to `std::basic_string<unsigned char>`, causing these formatters to not match. This patch adds overloads for both libstdc++ and libc++ string formatters that accepts unsigned char.
Motivated by the following example:
```
$ cat pretty_print.cc
template <typename T>
void print_val(T s) {
std::cerr << s << '\n'; // Set a breakpoint here!
}
int main() {
std::string val = "hello";
print_val(val);
return 0;
}
$ clang++ -stdlib=libc++ -funsigned-char -fstandalone-debug -g pretty_print.cc
$ lldb ./a.out -b -o 'b pretty_print.cc:6' -o r -o 'fr v'
...
(lldb) fr v
(std::__1::basic_string<unsigned char, std::__1::char_traits<unsigned char>, std::__1::allocator<unsigned char> >) s = {
__r_ = {
std::__1::__compressed_pair_elem<std::__1::basic_string<unsigned char, std::__1::char_traits<unsigned char>, std::__1::allocator<unsigned char> >::__rep, 0, false> = {
__value_ = {
= {
__l = (__cap_ = 122511465736202, __size_ = 0, __data_ = 0x0000000000000000)
__s = {
= (__size_ = '\n', __lx = '\n')
__data_ = {
[0] = 'h'
[1] = 'e'
[2] = 'l'
[3] = 'l'
[4] = 'o'
[5] = '\0'
...
```
Reviewers: labath, JDevlieghere, shafik
Subscribers: christof, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D70517
2019-11-22 10:25:03 -08:00
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxStringSummaryProviderASCII,
|
|
|
|
|
"std::string summary provider",
|
|
|
|
|
ConstString("^std::__[[:alnum:]]+::basic_string<unsigned char, "
|
|
|
|
|
"std::__[[:alnum:]]+::char_traits<unsigned char>, "
|
|
|
|
|
"std::__[[:alnum:]]+::allocator<unsigned char> >$"),
|
|
|
|
|
stl_summary_flags, true);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-02-01 19:10:39 +00:00
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxStringSummaryProviderUTF16,
|
|
|
|
|
"std::u16string summary provider",
|
|
|
|
|
ConstString(
|
|
|
|
|
"^std::__[[:alnum:]]+::basic_string<char16_t, "
|
|
|
|
|
"std::__[[:alnum:]]+::char_traits<char16_t>, "
|
|
|
|
|
"std::__[[:alnum:]]+::allocator<char16_t> >$"),
|
|
|
|
|
stl_summary_flags, true);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-02-01 19:10:39 +00:00
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxStringSummaryProviderUTF32,
|
|
|
|
|
"std::u32string summary provider",
|
|
|
|
|
ConstString(
|
|
|
|
|
"^std::__[[:alnum:]]+::basic_string<char32_t, "
|
|
|
|
|
"std::__[[:alnum:]]+::char_traits<char32_t>, "
|
|
|
|
|
"std::__[[:alnum:]]+::allocator<char32_t> >$"),
|
|
|
|
|
stl_summary_flags, true);
|
|
|
|
|
|
|
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxWStringSummaryProvider,
|
|
|
|
|
"std::wstring summary provider",
|
|
|
|
|
ConstString("^std::__[[:alnum:]]+::wstring$"),
|
|
|
|
|
stl_summary_flags, true);
|
|
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxWStringSummaryProvider,
|
|
|
|
|
"std::wstring summary provider",
|
|
|
|
|
ConstString("^std::__[[:alnum:]]+::basic_string<wchar_t, "
|
|
|
|
|
"std::__[[:alnum:]]+::char_traits<wchar_t>, "
|
|
|
|
|
"std::__[[:alnum:]]+::allocator<wchar_t> >$"),
|
|
|
|
|
stl_summary_flags, true);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
SyntheticChildren::Flags stl_synth_flags;
|
|
|
|
|
stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(
|
2016-09-06 20:57:50 +00:00
|
|
|
false);
|
2018-07-13 19:28:32 +00:00
|
|
|
SyntheticChildren::Flags stl_deref_flags = stl_synth_flags;
|
|
|
|
|
stl_deref_flags.SetFrontEndWantsDereference();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2017-11-14 11:15:03 +00:00
|
|
|
AddCXXSynthetic(
|
|
|
|
|
cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxBitsetSyntheticFrontEndCreator,
|
|
|
|
|
"libc++ std::bitset synthetic children",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::bitset<.+>(( )?&)?$"), stl_deref_flags,
|
2017-11-14 11:15:03 +00:00
|
|
|
true);
|
2016-07-06 22:35:34 +00:00
|
|
|
AddCXXSynthetic(
|
|
|
|
|
cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxStdVectorSyntheticFrontEndCreator,
|
2016-07-04 09:13:10 +00:00
|
|
|
"libc++ std::vector synthetic children",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::vector<.+>(( )?&)?$"), stl_deref_flags,
|
2016-07-04 09:13:10 +00:00
|
|
|
true);
|
2017-10-31 12:27:43 +00:00
|
|
|
AddCXXSynthetic(
|
|
|
|
|
cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxStdForwardListSyntheticFrontEndCreator,
|
|
|
|
|
"libc++ std::forward_list synthetic children",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::forward_list<.+>(( )?&)?$"),
|
2017-10-31 12:27:43 +00:00
|
|
|
stl_synth_flags, true);
|
2016-07-04 09:13:10 +00:00
|
|
|
AddCXXSynthetic(
|
|
|
|
|
cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxStdListSyntheticFrontEndCreator,
|
|
|
|
|
"libc++ std::list synthetic children",
|
2019-08-22 14:29:52 +00:00
|
|
|
// A POSIX variant of: "^std::__(?!cxx11:)[[:alnum:]]+::list<.+>(( )?&)?$"
|
|
|
|
|
// so that it does not clash with: "^std::(__cxx11::)?list<.+>(( )?&)?$"
|
|
|
|
|
ConstString("^std::__([A-Zabd-z0-9]|cx?[A-Za-wyz0-9]|cxx1?[A-Za-z02-9]|"
|
|
|
|
|
"cxx11[[:alnum:]])[[:alnum:]]*::list<.+>(( )?&)?$"),
|
|
|
|
|
stl_deref_flags, true);
|
2016-07-04 09:13:10 +00:00
|
|
|
AddCXXSynthetic(
|
|
|
|
|
cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
|
|
|
|
|
"libc++ std::map synthetic children",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::map<.+> >(( )?&)?$"), stl_synth_flags,
|
2016-07-04 09:13:10 +00:00
|
|
|
true);
|
|
|
|
|
AddCXXSynthetic(
|
|
|
|
|
cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
|
|
|
|
|
"libc++ std::set synthetic children",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::set<.+> >(( )?&)?$"), stl_deref_flags,
|
2016-07-04 09:13:10 +00:00
|
|
|
true);
|
|
|
|
|
AddCXXSynthetic(
|
|
|
|
|
cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
|
|
|
|
|
"libc++ std::multiset synthetic children",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::multiset<.+> >(( )?&)?$"),
|
|
|
|
|
stl_deref_flags, true);
|
2016-07-04 09:13:10 +00:00
|
|
|
AddCXXSynthetic(
|
|
|
|
|
cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
|
|
|
|
|
"libc++ std::multimap synthetic children",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::multimap<.+> >(( )?&)?$"),
|
|
|
|
|
stl_synth_flags, true);
|
2016-07-04 09:13:10 +00:00
|
|
|
AddCXXSynthetic(
|
|
|
|
|
cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEndCreator,
|
|
|
|
|
"libc++ std::unordered containers synthetic children",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^(std::__[[:alnum:]]+::)unordered_(multi)?(map|set)<.+> >$"),
|
2016-07-04 09:13:10 +00:00
|
|
|
stl_synth_flags, true);
|
|
|
|
|
AddCXXSynthetic(
|
2015-09-04 21:01:18 +00:00
|
|
|
cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxInitializerListSyntheticFrontEndCreator,
|
|
|
|
|
"libc++ std::initializer_list synthetic children",
|
|
|
|
|
ConstString("^std::initializer_list<.+>(( )?&)?$"), stl_synth_flags,
|
|
|
|
|
true);
|
2017-11-01 15:52:08 +00:00
|
|
|
AddCXXSynthetic(cpp_category_sp, LibcxxQueueFrontEndCreator,
|
|
|
|
|
"libc++ std::queue synthetic children",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::queue<.+>(( )?&)?$"),
|
2017-11-01 15:52:08 +00:00
|
|
|
stl_synth_flags, true);
|
2017-11-01 15:19:52 +00:00
|
|
|
AddCXXSynthetic(cpp_category_sp, LibcxxTupleFrontEndCreator,
|
|
|
|
|
"libc++ std::tuple synthetic children",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::tuple<.*>(( )?&)?$"),
|
|
|
|
|
stl_synth_flags, true);
|
2018-08-15 22:48:48 +00:00
|
|
|
AddCXXSynthetic(cpp_category_sp, LibcxxOptionalFrontEndCreator,
|
|
|
|
|
"libc++ std::optional synthetic children",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::optional<.+>(( )?&)?$"),
|
2018-08-15 22:48:48 +00:00
|
|
|
stl_synth_flags, true);
|
2018-09-19 18:07:05 +00:00
|
|
|
AddCXXSynthetic(cpp_category_sp, LibcxxVariantFrontEndCreator,
|
|
|
|
|
"libc++ std::variant synthetic children",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::variant<.+>(( )?&)?$"),
|
2018-09-19 18:07:05 +00:00
|
|
|
stl_synth_flags, true);
|
2015-09-04 21:01:18 +00:00
|
|
|
AddCXXSynthetic(
|
2016-07-04 09:13:10 +00:00
|
|
|
cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxAtomicSyntheticFrontEndCreator,
|
|
|
|
|
"libc++ std::atomic synthetic children",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::atomic<.+>$"), stl_synth_flags, true);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-07-04 09:13:10 +00:00
|
|
|
cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
|
2019-09-04 09:47:18 +00:00
|
|
|
RegularExpression(
|
|
|
|
|
llvm::StringRef("^(std::__[[:alnum:]]+::)deque<.+>(( )?&)?$")),
|
2015-09-04 21:01:18 +00:00
|
|
|
SyntheticChildrenSP(new ScriptedSyntheticChildren(
|
|
|
|
|
stl_synth_flags,
|
|
|
|
|
"lldb.formatters.cpp.libcxx.stddeque_SynthProvider")));
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-07-04 09:13:10 +00:00
|
|
|
AddCXXSynthetic(
|
|
|
|
|
cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator,
|
|
|
|
|
"shared_ptr synthetic children",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^(std::__[[:alnum:]]+::)shared_ptr<.+>(( )?&)?$"),
|
2016-07-04 09:13:10 +00:00
|
|
|
stl_synth_flags, true);
|
|
|
|
|
AddCXXSynthetic(
|
|
|
|
|
cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator,
|
|
|
|
|
"weak_ptr synthetic children",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^(std::__[[:alnum:]]+::)weak_ptr<.+>(( )?&)?$"),
|
|
|
|
|
stl_synth_flags, true);
|
2019-11-12 11:23:38 -08:00
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxFunctionSummaryProvider,
|
|
|
|
|
"libc++ std::function summary provider",
|
|
|
|
|
ConstString("^std::__[[:alnum:]]+::function<.+>$"),
|
|
|
|
|
stl_summary_flags, true);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
stl_summary_flags.SetDontShowChildren(false);
|
|
|
|
|
stl_summary_flags.SetSkipPointers(false);
|
2017-11-14 11:15:03 +00:00
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxContainerSummaryProvider,
|
|
|
|
|
"libc++ std::bitset summary provider",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::bitset<.+>(( )?&)?$"),
|
2017-11-14 11:15:03 +00:00
|
|
|
stl_summary_flags, true);
|
2016-07-04 09:13:10 +00:00
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxContainerSummaryProvider,
|
|
|
|
|
"libc++ std::vector summary provider",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::vector<.+>(( )?&)?$"),
|
2016-07-04 09:13:10 +00:00
|
|
|
stl_summary_flags, true);
|
2017-10-31 12:27:43 +00:00
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxContainerSummaryProvider,
|
|
|
|
|
"libc++ std::list summary provider",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::forward_list<.+>(( )?&)?$"),
|
2017-10-31 12:27:43 +00:00
|
|
|
stl_summary_flags, true);
|
2019-08-22 14:29:52 +00:00
|
|
|
AddCXXSummary(
|
|
|
|
|
cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider,
|
|
|
|
|
"libc++ std::list summary provider",
|
|
|
|
|
// A POSIX variant of: "^std::__(?!cxx11:)[[:alnum:]]+::list<.+>(( )?&)?$"
|
|
|
|
|
// so that it does not clash with: "^std::(__cxx11::)?list<.+>(( )?&)?$"
|
|
|
|
|
ConstString("^std::__([A-Zabd-z0-9]|cx?[A-Za-wyz0-9]|cxx1?[A-Za-z02-9]|"
|
|
|
|
|
"cxx11[[:alnum:]])[[:alnum:]]*::list<.+>(( )?&)?$"),
|
|
|
|
|
stl_summary_flags, true);
|
2016-07-04 09:13:10 +00:00
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxContainerSummaryProvider,
|
|
|
|
|
"libc++ std::map summary provider",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::map<.+>(( )?&)?$"),
|
2016-07-04 09:13:10 +00:00
|
|
|
stl_summary_flags, true);
|
|
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxContainerSummaryProvider,
|
|
|
|
|
"libc++ std::deque summary provider",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::deque<.+>(( )?&)?$"),
|
2016-07-04 09:13:10 +00:00
|
|
|
stl_summary_flags, true);
|
2017-11-01 15:52:08 +00:00
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxContainerSummaryProvider,
|
|
|
|
|
"libc++ std::queue summary provider",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::queue<.+>(( )?&)?$"),
|
2017-11-01 15:52:08 +00:00
|
|
|
stl_summary_flags, true);
|
2016-07-04 09:13:10 +00:00
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxContainerSummaryProvider,
|
|
|
|
|
"libc++ std::set summary provider",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::set<.+>(( )?&)?$"),
|
2016-07-04 09:13:10 +00:00
|
|
|
stl_summary_flags, true);
|
|
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxContainerSummaryProvider,
|
|
|
|
|
"libc++ std::multiset summary provider",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::multiset<.+>(( )?&)?$"),
|
2016-07-04 09:13:10 +00:00
|
|
|
stl_summary_flags, true);
|
|
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxContainerSummaryProvider,
|
|
|
|
|
"libc++ std::multimap summary provider",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::multimap<.+>(( )?&)?$"),
|
2016-07-04 09:13:10 +00:00
|
|
|
stl_summary_flags, true);
|
|
|
|
|
AddCXXSummary(
|
|
|
|
|
cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider,
|
|
|
|
|
"libc++ std::unordered containers summary provider",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^(std::__[[:alnum:]]+::)unordered_(multi)?(map|set)<.+> >$"),
|
2016-07-04 09:13:10 +00:00
|
|
|
stl_summary_flags, true);
|
2017-11-01 15:19:52 +00:00
|
|
|
AddCXXSummary(cpp_category_sp, LibcxxContainerSummaryProvider,
|
|
|
|
|
"libc++ std::tuple summary provider",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::tuple<.*>(( )?&)?$"),
|
|
|
|
|
stl_summary_flags, true);
|
2016-07-04 09:13:10 +00:00
|
|
|
AddCXXSummary(
|
|
|
|
|
cpp_category_sp, lldb_private::formatters::LibCxxAtomicSummaryProvider,
|
|
|
|
|
"libc++ std::atomic summary provider",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::atomic<.+>$"), stl_summary_flags,
|
|
|
|
|
true);
|
2018-08-15 22:48:48 +00:00
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxOptionalSummaryProvider,
|
|
|
|
|
"libc++ std::optional summary provider",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::optional<.+>(( )?&)?$"),
|
2018-08-15 22:48:48 +00:00
|
|
|
stl_summary_flags, true);
|
2018-09-19 18:07:05 +00:00
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxVariantSummaryProvider,
|
|
|
|
|
"libc++ std::variant summary provider",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::variant<.+>(( )?&)?$"),
|
2018-09-19 18:07:05 +00:00
|
|
|
stl_summary_flags, true);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-07-04 09:13:10 +00:00
|
|
|
stl_summary_flags.SetSkipPointers(true);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-07-04 09:13:10 +00:00
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibcxxSmartPointerSummaryProvider,
|
|
|
|
|
"libc++ std::shared_ptr summary provider",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::shared_ptr<.+>(( )?&)?$"),
|
2016-07-06 09:50:00 +00:00
|
|
|
stl_summary_flags, true);
|
|
|
|
|
AddCXXSummary(cpp_category_sp,
|
2016-07-04 09:13:10 +00:00
|
|
|
lldb_private::formatters::LibcxxSmartPointerSummaryProvider,
|
|
|
|
|
"libc++ std::weak_ptr summary provider",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::weak_ptr<.+>(( )?&)?$"),
|
2016-07-04 09:13:10 +00:00
|
|
|
stl_summary_flags, true);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-07-04 09:13:10 +00:00
|
|
|
AddCXXSynthetic(
|
|
|
|
|
cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibCxxVectorIteratorSyntheticFrontEndCreator,
|
|
|
|
|
"std::vector iterator synthetic children",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::__wrap_iter<.+>$"), stl_synth_flags,
|
|
|
|
|
true);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-07-04 09:13:10 +00:00
|
|
|
AddCXXSynthetic(
|
|
|
|
|
cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEndCreator,
|
|
|
|
|
"std::map iterator synthetic children",
|
2019-02-01 19:10:39 +00:00
|
|
|
ConstString("^std::__[[:alnum:]]+::__map_iterator<.+>$"), stl_synth_flags,
|
2016-07-04 09:13:10 +00:00
|
|
|
true);
|
2015-09-04 21:01:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
|
|
|
|
|
if (!cpp_category_sp)
|
|
|
|
|
return;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
TypeSummaryImpl::Flags stl_summary_flags;
|
|
|
|
|
stl_summary_flags.SetCascades(true)
|
|
|
|
|
.SetSkipPointers(false)
|
|
|
|
|
.SetSkipReferences(false)
|
|
|
|
|
.SetDontShowChildren(true)
|
|
|
|
|
.SetDontShowValue(true)
|
|
|
|
|
.SetShowMembersOneLiner(false)
|
|
|
|
|
.SetHideItemNames(false);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
lldb::TypeSummaryImplSP std_string_summary_sp(
|
|
|
|
|
new StringSummaryFormat(stl_summary_flags, "${var._M_dataplus._M_p}"));
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-10-22 00:23:38 +00:00
|
|
|
lldb::TypeSummaryImplSP cxx11_string_summary_sp(new CXXFunctionSummaryFormat(
|
|
|
|
|
stl_summary_flags, LibStdcppStringSummaryProvider,
|
|
|
|
|
"libstdc++ c++11 std::string summary provider"));
|
|
|
|
|
lldb::TypeSummaryImplSP cxx11_wstring_summary_sp(new CXXFunctionSummaryFormat(
|
|
|
|
|
stl_summary_flags, LibStdcppWStringSummaryProvider,
|
|
|
|
|
"libstdc++ c++11 std::wstring summary provider"));
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::string"),
|
|
|
|
|
std_string_summary_sp);
|
|
|
|
|
cpp_category_sp->GetTypeSummariesContainer()->Add(
|
|
|
|
|
ConstString("std::basic_string<char>"), std_string_summary_sp);
|
|
|
|
|
cpp_category_sp->GetTypeSummariesContainer()->Add(
|
|
|
|
|
ConstString("std::basic_string<char,std::char_traits<char>,std::"
|
|
|
|
|
"allocator<char> >"),
|
|
|
|
|
std_string_summary_sp);
|
|
|
|
|
cpp_category_sp->GetTypeSummariesContainer()->Add(
|
|
|
|
|
ConstString("std::basic_string<char, std::char_traits<char>, "
|
|
|
|
|
"std::allocator<char> >"),
|
|
|
|
|
std_string_summary_sp);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-10-22 00:23:38 +00:00
|
|
|
cpp_category_sp->GetTypeSummariesContainer()->Add(
|
|
|
|
|
ConstString("std::__cxx11::string"), cxx11_string_summary_sp);
|
|
|
|
|
cpp_category_sp->GetTypeSummariesContainer()->Add(
|
|
|
|
|
ConstString("std::__cxx11::basic_string<char, std::char_traits<char>, "
|
|
|
|
|
"std::allocator<char> >"),
|
|
|
|
|
cxx11_string_summary_sp);
|
[lldb][DataFormatters] Support pretty printing std::string when built with -funsigned-char.
Summary:
When built w/ `-funsigned-char`, `std::string` becomes equivalent to `std::basic_string<unsigned char>`, causing these formatters to not match. This patch adds overloads for both libstdc++ and libc++ string formatters that accepts unsigned char.
Motivated by the following example:
```
$ cat pretty_print.cc
template <typename T>
void print_val(T s) {
std::cerr << s << '\n'; // Set a breakpoint here!
}
int main() {
std::string val = "hello";
print_val(val);
return 0;
}
$ clang++ -stdlib=libc++ -funsigned-char -fstandalone-debug -g pretty_print.cc
$ lldb ./a.out -b -o 'b pretty_print.cc:6' -o r -o 'fr v'
...
(lldb) fr v
(std::__1::basic_string<unsigned char, std::__1::char_traits<unsigned char>, std::__1::allocator<unsigned char> >) s = {
__r_ = {
std::__1::__compressed_pair_elem<std::__1::basic_string<unsigned char, std::__1::char_traits<unsigned char>, std::__1::allocator<unsigned char> >::__rep, 0, false> = {
__value_ = {
= {
__l = (__cap_ = 122511465736202, __size_ = 0, __data_ = 0x0000000000000000)
__s = {
= (__size_ = '\n', __lx = '\n')
__data_ = {
[0] = 'h'
[1] = 'e'
[2] = 'l'
[3] = 'l'
[4] = 'o'
[5] = '\0'
...
```
Reviewers: labath, JDevlieghere, shafik
Subscribers: christof, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D70517
2019-11-22 10:25:03 -08:00
|
|
|
cpp_category_sp->GetTypeSummariesContainer()->Add(
|
|
|
|
|
ConstString("std::__cxx11::basic_string<unsigned char, std::char_traits<unsigned char>, "
|
|
|
|
|
"std::allocator<unsigned char> >"),
|
|
|
|
|
cxx11_string_summary_sp);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
// making sure we force-pick the summary for printing wstring (_M_p is a
|
|
|
|
|
// wchar_t*)
|
|
|
|
|
lldb::TypeSummaryImplSP std_wstring_summary_sp(
|
|
|
|
|
new StringSummaryFormat(stl_summary_flags, "${var._M_dataplus._M_p%S}"));
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::wstring"),
|
|
|
|
|
std_wstring_summary_sp);
|
|
|
|
|
cpp_category_sp->GetTypeSummariesContainer()->Add(
|
|
|
|
|
ConstString("std::basic_string<wchar_t>"), std_wstring_summary_sp);
|
|
|
|
|
cpp_category_sp->GetTypeSummariesContainer()->Add(
|
|
|
|
|
ConstString("std::basic_string<wchar_t,std::char_traits<wchar_t>,std::"
|
|
|
|
|
"allocator<wchar_t> >"),
|
|
|
|
|
std_wstring_summary_sp);
|
|
|
|
|
cpp_category_sp->GetTypeSummariesContainer()->Add(
|
|
|
|
|
ConstString("std::basic_string<wchar_t, std::char_traits<wchar_t>, "
|
|
|
|
|
"std::allocator<wchar_t> >"),
|
|
|
|
|
std_wstring_summary_sp);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-10-22 00:23:38 +00:00
|
|
|
cpp_category_sp->GetTypeSummariesContainer()->Add(
|
|
|
|
|
ConstString("std::__cxx11::wstring"), cxx11_wstring_summary_sp);
|
|
|
|
|
cpp_category_sp->GetTypeSummariesContainer()->Add(
|
|
|
|
|
ConstString("std::__cxx11::basic_string<wchar_t, "
|
|
|
|
|
"std::char_traits<wchar_t>, std::allocator<wchar_t> >"),
|
|
|
|
|
cxx11_wstring_summary_sp);
|
|
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
SyntheticChildren::Flags stl_synth_flags;
|
|
|
|
|
stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(
|
|
|
|
|
false);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
|
2019-09-04 09:47:18 +00:00
|
|
|
RegularExpression(llvm::StringRef("^std::vector<.+>(( )?&)?$")),
|
2015-09-04 21:01:18 +00:00
|
|
|
SyntheticChildrenSP(new ScriptedSyntheticChildren(
|
|
|
|
|
stl_synth_flags,
|
|
|
|
|
"lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider")));
|
|
|
|
|
cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
|
2019-09-04 09:47:18 +00:00
|
|
|
RegularExpression(llvm::StringRef("^std::map<.+> >(( )?&)?$")),
|
2015-09-04 21:01:18 +00:00
|
|
|
SyntheticChildrenSP(new ScriptedSyntheticChildren(
|
|
|
|
|
stl_synth_flags,
|
|
|
|
|
"lldb.formatters.cpp.gnu_libstdcpp.StdMapSynthProvider")));
|
2015-10-22 00:23:38 +00:00
|
|
|
cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
|
2019-09-04 09:47:18 +00:00
|
|
|
RegularExpression(llvm::StringRef("^std::(__cxx11::)?list<.+>(( )?&)?$")),
|
2015-10-22 00:23:38 +00:00
|
|
|
SyntheticChildrenSP(new ScriptedSyntheticChildren(
|
|
|
|
|
stl_synth_flags,
|
|
|
|
|
"lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider")));
|
2015-09-04 21:01:18 +00:00
|
|
|
stl_summary_flags.SetDontShowChildren(false);
|
|
|
|
|
stl_summary_flags.SetSkipPointers(true);
|
|
|
|
|
cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
|
2019-09-04 09:47:18 +00:00
|
|
|
RegularExpression(llvm::StringRef("^std::vector<.+>(( )?&)?$")),
|
2015-09-04 21:01:18 +00:00
|
|
|
TypeSummaryImplSP(
|
|
|
|
|
new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
|
|
|
|
|
cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
|
2019-09-04 09:47:18 +00:00
|
|
|
RegularExpression(llvm::StringRef("^std::map<.+> >(( )?&)?$")),
|
2015-09-04 21:01:18 +00:00
|
|
|
TypeSummaryImplSP(
|
|
|
|
|
new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
|
2015-10-22 00:23:38 +00:00
|
|
|
cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
|
2019-09-04 09:47:18 +00:00
|
|
|
RegularExpression(llvm::StringRef("^std::(__cxx11::)?list<.+>(( )?&)?$")),
|
2015-09-04 21:01:18 +00:00
|
|
|
TypeSummaryImplSP(
|
|
|
|
|
new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
AddCXXSynthetic(
|
|
|
|
|
cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibStdcppVectorIteratorSyntheticFrontEndCreator,
|
|
|
|
|
"std::vector iterator synthetic children",
|
|
|
|
|
ConstString("^__gnu_cxx::__normal_iterator<.+>$"), stl_synth_flags, true);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
AddCXXSynthetic(
|
|
|
|
|
cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibstdcppMapIteratorSyntheticFrontEndCreator,
|
|
|
|
|
"std::map iterator synthetic children",
|
|
|
|
|
ConstString("^std::_Rb_tree_iterator<.+>$"), stl_synth_flags, true);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-10-21 15:02:44 +00:00
|
|
|
AddCXXSynthetic(
|
|
|
|
|
cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibStdcppUniquePtrSyntheticFrontEndCreator,
|
|
|
|
|
"std::unique_ptr synthetic children",
|
|
|
|
|
ConstString("^std::unique_ptr<.+>(( )?&)?$"), stl_synth_flags, true);
|
2016-07-06 09:50:00 +00:00
|
|
|
AddCXXSynthetic(
|
|
|
|
|
cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibStdcppSharedPtrSyntheticFrontEndCreator,
|
|
|
|
|
"std::shared_ptr synthetic children",
|
|
|
|
|
ConstString("^std::shared_ptr<.+>(( )?&)?$"), stl_synth_flags, true);
|
|
|
|
|
AddCXXSynthetic(
|
|
|
|
|
cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibStdcppSharedPtrSyntheticFrontEndCreator,
|
|
|
|
|
"std::weak_ptr synthetic children",
|
|
|
|
|
ConstString("^std::weak_ptr<.+>(( )?&)?$"), stl_synth_flags, true);
|
2016-10-21 15:02:38 +00:00
|
|
|
AddCXXSynthetic(
|
|
|
|
|
cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibStdcppTupleSyntheticFrontEndCreator,
|
|
|
|
|
"std::tuple synthetic children", ConstString("^std::tuple<.+>(( )?&)?$"),
|
|
|
|
|
stl_synth_flags, true);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-10-21 15:02:44 +00:00
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibStdcppUniquePointerSummaryProvider,
|
|
|
|
|
"libstdc++ std::unique_ptr summary provider",
|
|
|
|
|
ConstString("^std::unique_ptr<.+>(( )?&)?$"), stl_summary_flags,
|
|
|
|
|
true);
|
2016-07-06 09:50:00 +00:00
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibStdcppSmartPointerSummaryProvider,
|
|
|
|
|
"libstdc++ std::shared_ptr summary provider",
|
|
|
|
|
ConstString("^std::shared_ptr<.+>(( )?&)?$"), stl_summary_flags,
|
|
|
|
|
true);
|
|
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::LibStdcppSmartPointerSummaryProvider,
|
|
|
|
|
"libstdc++ std::weak_ptr summary provider",
|
|
|
|
|
ConstString("^std::weak_ptr<.+>(( )?&)?$"), stl_summary_flags,
|
|
|
|
|
true);
|
2015-09-04 21:01:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void LoadSystemFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
|
|
|
|
|
if (!cpp_category_sp)
|
|
|
|
|
return;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
TypeSummaryImpl::Flags string_flags;
|
|
|
|
|
string_flags.SetCascades(true)
|
|
|
|
|
.SetSkipPointers(true)
|
|
|
|
|
.SetSkipReferences(false)
|
|
|
|
|
.SetDontShowChildren(true)
|
|
|
|
|
.SetDontShowValue(false)
|
|
|
|
|
.SetShowMembersOneLiner(false)
|
|
|
|
|
.SetHideItemNames(false);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
TypeSummaryImpl::Flags string_array_flags;
|
|
|
|
|
string_array_flags.SetCascades(true)
|
|
|
|
|
.SetSkipPointers(true)
|
|
|
|
|
.SetSkipReferences(false)
|
|
|
|
|
.SetDontShowChildren(true)
|
|
|
|
|
.SetDontShowValue(true)
|
|
|
|
|
.SetShowMembersOneLiner(false)
|
|
|
|
|
.SetHideItemNames(false);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
// FIXME because of a bug in the FormattersContainer we need to add a summary
|
|
|
|
|
// for both X* and const X* (<rdar://problem/12717717>)
|
2019-08-21 21:30:55 +00:00
|
|
|
AddCXXSummary(
|
|
|
|
|
cpp_category_sp, lldb_private::formatters::Char8StringSummaryProvider,
|
|
|
|
|
"char8_t * summary provider", ConstString("char8_t *"), string_flags);
|
|
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::Char8StringSummaryProvider,
|
|
|
|
|
"char8_t [] summary provider",
|
|
|
|
|
ConstString("char8_t \\[[0-9]+\\]"), string_array_flags, true);
|
|
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
AddCXXSummary(
|
|
|
|
|
cpp_category_sp, lldb_private::formatters::Char16StringSummaryProvider,
|
|
|
|
|
"char16_t * summary provider", ConstString("char16_t *"), string_flags);
|
2015-09-25 02:16:52 +00:00
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::Char16StringSummaryProvider,
|
|
|
|
|
"char16_t [] summary provider",
|
|
|
|
|
ConstString("char16_t \\[[0-9]+\\]"), string_array_flags, true);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
AddCXXSummary(
|
|
|
|
|
cpp_category_sp, lldb_private::formatters::Char32StringSummaryProvider,
|
|
|
|
|
"char32_t * summary provider", ConstString("char32_t *"), string_flags);
|
2015-09-25 02:16:52 +00:00
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::Char32StringSummaryProvider,
|
|
|
|
|
"char32_t [] summary provider",
|
|
|
|
|
ConstString("char32_t \\[[0-9]+\\]"), string_array_flags, true);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
AddCXXSummary(
|
|
|
|
|
cpp_category_sp, lldb_private::formatters::WCharStringSummaryProvider,
|
|
|
|
|
"wchar_t * summary provider", ConstString("wchar_t *"), string_flags);
|
|
|
|
|
AddCXXSummary(cpp_category_sp,
|
|
|
|
|
lldb_private::formatters::WCharStringSummaryProvider,
|
|
|
|
|
"wchar_t * summary provider",
|
|
|
|
|
ConstString("wchar_t \\[[0-9]+\\]"), string_array_flags, true);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
AddCXXSummary(
|
|
|
|
|
cpp_category_sp, lldb_private::formatters::Char16StringSummaryProvider,
|
|
|
|
|
"unichar * summary provider", ConstString("unichar *"), string_flags);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
TypeSummaryImpl::Flags widechar_flags;
|
|
|
|
|
widechar_flags.SetDontShowValue(true)
|
|
|
|
|
.SetSkipPointers(true)
|
|
|
|
|
.SetSkipReferences(false)
|
|
|
|
|
.SetCascades(true)
|
|
|
|
|
.SetDontShowChildren(true)
|
|
|
|
|
.SetHideItemNames(true)
|
|
|
|
|
.SetShowMembersOneLiner(false);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-08-21 21:30:55 +00:00
|
|
|
AddCXXSummary(cpp_category_sp, lldb_private::formatters::Char8SummaryProvider,
|
|
|
|
|
"char8_t summary provider", ConstString("char8_t"),
|
|
|
|
|
widechar_flags);
|
2015-09-04 21:01:18 +00:00
|
|
|
AddCXXSummary(
|
|
|
|
|
cpp_category_sp, lldb_private::formatters::Char16SummaryProvider,
|
|
|
|
|
"char16_t summary provider", ConstString("char16_t"), widechar_flags);
|
|
|
|
|
AddCXXSummary(
|
|
|
|
|
cpp_category_sp, lldb_private::formatters::Char32SummaryProvider,
|
|
|
|
|
"char32_t summary provider", ConstString("char32_t"), widechar_flags);
|
|
|
|
|
AddCXXSummary(cpp_category_sp, lldb_private::formatters::WCharSummaryProvider,
|
|
|
|
|
"wchar_t summary provider", ConstString("wchar_t"),
|
|
|
|
|
widechar_flags);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
AddCXXSummary(
|
|
|
|
|
cpp_category_sp, lldb_private::formatters::Char16SummaryProvider,
|
|
|
|
|
"unichar summary provider", ConstString("unichar"), widechar_flags);
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-27 18:44:45 +00:00
|
|
|
std::unique_ptr<Language::TypeScavenger> CPlusPlusLanguage::GetTypeScavenger() {
|
2016-11-01 18:50:49 +00:00
|
|
|
class CPlusPlusTypeScavenger : public Language::ImageListTypeScavenger {
|
|
|
|
|
public:
|
C.128 override, virtual keyword handling
Summary:
According to [C128] "Virtual functions should specify exactly one
of `virtual`, `override`, or `final`", I've added override where a
virtual function is overriden but the explicit `override` keyword
was missing. Whenever both `virtual` and `override` were specified,
I removed `virtual`. As C.128 puts it:
> [...] writing more than one of these three is both redundant and
> a potential source of errors.
I anticipate a discussion about whether or not to add `override` to
destructors but I went for it because of an example in [ISOCPP1000].
Let me repeat the comment for you here:
Consider this code:
```
struct Base {
virtual ~Base(){}
};
struct SubClass : Base {
~SubClass() {
std::cout << "It works!\n";
}
};
int main() {
std::unique_ptr<Base> ptr = std::make_unique<SubClass>();
}
```
If for some odd reason somebody removes the `virtual` keyword from the
`Base` struct, the code will no longer print `It works!`. So adding
`override` to destructors actively protects us from accidentally
breaking our code at runtime.
[C128]: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c128-virtual-functions-should-specify-exactly-one-of-virtual-override-or-final
[ISOCPP1000]: https://github.com/isocpp/CppCoreGuidelines/issues/1000#issuecomment-476951555
Reviewers: teemperor, JDevlieghere, davide, shafik
Reviewed By: teemperor
Subscribers: kwk, arphaman, kadircet, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D61440
llvm-svn: 359868
2019-05-03 10:03:28 +00:00
|
|
|
CompilerType AdjustForInclusion(CompilerType &candidate) override {
|
2016-11-01 18:50:49 +00:00
|
|
|
LanguageType lang_type(candidate.GetMinimumLanguage());
|
|
|
|
|
if (!Language::LanguageIsC(lang_type) &&
|
|
|
|
|
!Language::LanguageIsCPlusPlus(lang_type))
|
|
|
|
|
return CompilerType();
|
|
|
|
|
if (candidate.IsTypedefType())
|
|
|
|
|
return candidate.GetTypedefedType();
|
|
|
|
|
return candidate;
|
2016-10-27 18:44:45 +00:00
|
|
|
}
|
|
|
|
|
};
|
2016-12-19 17:22:44 +00:00
|
|
|
|
2016-10-27 18:44:45 +00:00
|
|
|
return std::unique_ptr<TypeScavenger>(new CPlusPlusTypeScavenger());
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-04 21:01:18 +00:00
|
|
|
lldb::TypeCategoryImplSP CPlusPlusLanguage::GetFormatters() {
|
2017-02-06 17:55:02 +00:00
|
|
|
static llvm::once_flag g_initialize;
|
2015-09-04 21:01:18 +00:00
|
|
|
static TypeCategoryImplSP g_category;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2017-02-06 17:55:02 +00:00
|
|
|
llvm::call_once(g_initialize, [this]() -> void {
|
2015-09-04 21:01:18 +00:00
|
|
|
DataVisualization::Categories::GetCategory(GetPluginName(), g_category);
|
|
|
|
|
if (g_category) {
|
|
|
|
|
LoadLibStdcppFormatters(g_category);
|
2019-02-01 19:10:39 +00:00
|
|
|
LoadLibCxxFormatters(g_category);
|
2015-09-04 21:01:18 +00:00
|
|
|
LoadSystemFormatters(g_category);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return g_category;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-16 18:28:11 +00:00
|
|
|
HardcodedFormatters::HardcodedSummaryFinder
|
|
|
|
|
CPlusPlusLanguage::GetHardcodedSummaries() {
|
2017-02-06 17:55:02 +00:00
|
|
|
static llvm::once_flag g_initialize;
|
2015-09-16 18:28:11 +00:00
|
|
|
static ConstString g_vectortypes("VectorTypes");
|
|
|
|
|
static HardcodedFormatters::HardcodedSummaryFinder g_formatters;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2017-02-06 17:55:02 +00:00
|
|
|
llvm::call_once(g_initialize, []() -> void {
|
2015-09-16 18:28:11 +00:00
|
|
|
g_formatters.push_back(
|
|
|
|
|
[](lldb_private::ValueObject &valobj, lldb::DynamicValueType,
|
|
|
|
|
FormatManager &) -> TypeSummaryImpl::SharedPointer {
|
|
|
|
|
static CXXFunctionSummaryFormat::SharedPointer formatter_sp(
|
|
|
|
|
new CXXFunctionSummaryFormat(
|
|
|
|
|
TypeSummaryImpl::Flags(),
|
|
|
|
|
lldb_private::formatters::CXXFunctionPointerSummaryProvider,
|
|
|
|
|
"Function pointer summary provider"));
|
|
|
|
|
if (valobj.GetCompilerType().IsFunctionPointerType()) {
|
|
|
|
|
return formatter_sp;
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
|
|
|
|
});
|
|
|
|
|
g_formatters.push_back(
|
|
|
|
|
[](lldb_private::ValueObject &valobj, lldb::DynamicValueType,
|
|
|
|
|
FormatManager &fmt_mgr) -> TypeSummaryImpl::SharedPointer {
|
|
|
|
|
static CXXFunctionSummaryFormat::SharedPointer formatter_sp(
|
|
|
|
|
new CXXFunctionSummaryFormat(
|
|
|
|
|
TypeSummaryImpl::Flags()
|
|
|
|
|
.SetCascades(true)
|
|
|
|
|
.SetDontShowChildren(true)
|
|
|
|
|
.SetHideItemNames(true)
|
|
|
|
|
.SetShowMembersOneLiner(true)
|
|
|
|
|
.SetSkipPointers(true)
|
|
|
|
|
.SetSkipReferences(false),
|
|
|
|
|
lldb_private::formatters::VectorTypeSummaryProvider,
|
|
|
|
|
"vector_type pointer summary provider"));
|
|
|
|
|
if (valobj.GetCompilerType().IsVectorType(nullptr, nullptr)) {
|
|
|
|
|
if (fmt_mgr.GetCategory(g_vectortypes)->IsEnabled())
|
|
|
|
|
return formatter_sp;
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
|
|
|
|
});
|
2016-05-02 21:15:31 +00:00
|
|
|
g_formatters.push_back(
|
|
|
|
|
[](lldb_private::ValueObject &valobj, lldb::DynamicValueType,
|
|
|
|
|
FormatManager &fmt_mgr) -> TypeSummaryImpl::SharedPointer {
|
|
|
|
|
static CXXFunctionSummaryFormat::SharedPointer formatter_sp(
|
|
|
|
|
new CXXFunctionSummaryFormat(
|
|
|
|
|
TypeSummaryImpl::Flags()
|
|
|
|
|
.SetCascades(true)
|
|
|
|
|
.SetDontShowChildren(true)
|
|
|
|
|
.SetHideItemNames(true)
|
|
|
|
|
.SetShowMembersOneLiner(true)
|
|
|
|
|
.SetSkipPointers(true)
|
|
|
|
|
.SetSkipReferences(false),
|
|
|
|
|
lldb_private::formatters::BlockPointerSummaryProvider,
|
|
|
|
|
"block pointer summary provider"));
|
|
|
|
|
if (valobj.GetCompilerType().IsBlockPointerType(nullptr)) {
|
|
|
|
|
return formatter_sp;
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
|
|
|
|
});
|
2015-09-16 18:28:11 +00:00
|
|
|
});
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-09-16 18:28:11 +00:00
|
|
|
return g_formatters;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HardcodedFormatters::HardcodedSyntheticFinder
|
|
|
|
|
CPlusPlusLanguage::GetHardcodedSynthetics() {
|
2017-02-06 17:55:02 +00:00
|
|
|
static llvm::once_flag g_initialize;
|
2015-09-16 18:28:11 +00:00
|
|
|
static ConstString g_vectortypes("VectorTypes");
|
|
|
|
|
static HardcodedFormatters::HardcodedSyntheticFinder g_formatters;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2017-02-06 17:55:02 +00:00
|
|
|
llvm::call_once(g_initialize, []() -> void {
|
2015-09-16 18:28:11 +00:00
|
|
|
g_formatters.push_back([](lldb_private::ValueObject &valobj,
|
|
|
|
|
lldb::DynamicValueType,
|
|
|
|
|
FormatManager &
|
|
|
|
|
fmt_mgr) -> SyntheticChildren::SharedPointer {
|
|
|
|
|
static CXXSyntheticChildren::SharedPointer formatter_sp(
|
|
|
|
|
new CXXSyntheticChildren(
|
2016-05-02 21:15:31 +00:00
|
|
|
SyntheticChildren::Flags()
|
|
|
|
|
.SetCascades(true)
|
|
|
|
|
.SetSkipPointers(true)
|
|
|
|
|
.SetSkipReferences(true)
|
|
|
|
|
.SetNonCacheable(true),
|
|
|
|
|
"vector_type synthetic children",
|
|
|
|
|
lldb_private::formatters::VectorTypeSyntheticFrontEndCreator));
|
|
|
|
|
if (valobj.GetCompilerType().IsVectorType(nullptr, nullptr)) {
|
|
|
|
|
if (fmt_mgr.GetCategory(g_vectortypes)->IsEnabled())
|
|
|
|
|
return formatter_sp;
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
2015-09-16 18:28:11 +00:00
|
|
|
});
|
2016-05-02 21:15:31 +00:00
|
|
|
g_formatters.push_back([](lldb_private::ValueObject &valobj,
|
|
|
|
|
lldb::DynamicValueType,
|
|
|
|
|
FormatManager &
|
|
|
|
|
fmt_mgr) -> SyntheticChildren::SharedPointer {
|
|
|
|
|
static CXXSyntheticChildren::SharedPointer formatter_sp(
|
|
|
|
|
new CXXSyntheticChildren(
|
2015-09-16 18:28:11 +00:00
|
|
|
SyntheticChildren::Flags()
|
|
|
|
|
.SetCascades(true)
|
|
|
|
|
.SetSkipPointers(true)
|
|
|
|
|
.SetSkipReferences(true)
|
|
|
|
|
.SetNonCacheable(true),
|
2016-07-06 22:35:34 +00:00
|
|
|
"block pointer synthetic children",
|
2015-09-16 18:28:11 +00:00
|
|
|
lldb_private::formatters::BlockPointerSyntheticFrontEndCreator));
|
|
|
|
|
if (valobj.GetCompilerType().IsBlockPointerType(nullptr)) {
|
|
|
|
|
return formatter_sp;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2015-09-16 18:28:11 +00:00
|
|
|
return nullptr;
|
2016-09-06 20:57:50 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2015-09-16 18:28:11 +00:00
|
|
|
return g_formatters;
|
|
|
|
|
}
|
2018-08-02 00:30:15 +00:00
|
|
|
|
|
|
|
|
bool CPlusPlusLanguage::IsSourceFile(llvm::StringRef file_path) const {
|
|
|
|
|
const auto suffixes = {".cpp", ".cxx", ".c++", ".cc", ".c",
|
|
|
|
|
".h", ".hh", ".hpp", ".hxx", ".h++"};
|
|
|
|
|
for (auto suffix : suffixes) {
|
|
|
|
|
if (file_path.endswith_lower(suffix))
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if we're in a STL path (where the files usually have no extension
|
|
|
|
|
// that we could check for.
|
|
|
|
|
return file_path.contains("/usr/include/c++/");
|
|
|
|
|
}
|