2017-01-02 14:26:05 -05:00
|
|
|
//===-- SBTypeSummary.cpp -----------------------------------------*- C++
|
|
|
|
|
//-*-===//
|
2013-08-23 13:46:38 -04:00
|
|
|
//
|
2019-08-20 16:51:52 -04: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
|
2013-08-23 13:46:38 -04:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
#include "lldb/API/SBTypeSummary.h"
|
2019-08-20 16:51:52 -04:00
|
|
|
#include "SBReproducerPrivate.h"
|
|
|
|
|
#include "Utils.h"
|
2013-08-23 13:46:38 -04:00
|
|
|
#include "lldb/API/SBStream.h"
|
2015-12-30 06:55:28 -05:00
|
|
|
#include "lldb/API/SBValue.h"
|
2013-08-23 13:46:38 -04:00
|
|
|
#include "lldb/DataFormatters/DataVisualization.h"
|
|
|
|
|
|
2015-12-30 06:55:28 -05:00
|
|
|
#include "llvm/Support/Casting.h"
|
|
|
|
|
|
2013-08-23 13:46:38 -04:00
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
SBTypeSummaryOptions::SBTypeSummaryOptions() {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeSummaryOptions);
|
|
|
|
|
|
|
|
|
|
m_opaque_up.reset(new TypeSummaryOptions());
|
2017-01-02 14:26:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SBTypeSummaryOptions::SBTypeSummaryOptions(
|
|
|
|
|
const lldb::SBTypeSummaryOptions &rhs) {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBTypeSummaryOptions,
|
|
|
|
|
(const lldb::SBTypeSummaryOptions &), rhs);
|
|
|
|
|
|
|
|
|
|
m_opaque_up = clone(rhs.m_opaque_up);
|
2015-02-06 16:38:51 -05:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
SBTypeSummaryOptions::~SBTypeSummaryOptions() {}
|
|
|
|
|
|
2019-08-20 16:51:52 -04:00
|
|
|
bool SBTypeSummaryOptions::IsValid() {
|
|
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSummaryOptions, IsValid);
|
|
|
|
|
return this->operator bool();
|
|
|
|
|
}
|
|
|
|
|
SBTypeSummaryOptions::operator bool() const {
|
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSummaryOptions, operator bool);
|
|
|
|
|
|
|
|
|
|
return m_opaque_up.get();
|
|
|
|
|
}
|
2017-01-02 14:26:05 -05:00
|
|
|
|
|
|
|
|
lldb::LanguageType SBTypeSummaryOptions::GetLanguage() {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::LanguageType, SBTypeSummaryOptions,
|
|
|
|
|
GetLanguage);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
if (IsValid())
|
2019-08-20 16:51:52 -04:00
|
|
|
return m_opaque_up->GetLanguage();
|
2017-01-02 14:26:05 -05:00
|
|
|
return lldb::eLanguageTypeUnknown;
|
2015-02-06 16:38:51 -05:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
lldb::TypeSummaryCapping SBTypeSummaryOptions::GetCapping() {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::TypeSummaryCapping, SBTypeSummaryOptions,
|
|
|
|
|
GetCapping);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
if (IsValid())
|
2019-08-20 16:51:52 -04:00
|
|
|
return m_opaque_up->GetCapping();
|
2017-01-02 14:26:05 -05:00
|
|
|
return eTypeSummaryCapped;
|
2015-02-06 16:38:51 -05:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
void SBTypeSummaryOptions::SetLanguage(lldb::LanguageType l) {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_METHOD(void, SBTypeSummaryOptions, SetLanguage,
|
|
|
|
|
(lldb::LanguageType), l);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
if (IsValid())
|
2019-08-20 16:51:52 -04:00
|
|
|
m_opaque_up->SetLanguage(l);
|
2015-02-06 16:38:51 -05:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
void SBTypeSummaryOptions::SetCapping(lldb::TypeSummaryCapping c) {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_METHOD(void, SBTypeSummaryOptions, SetCapping,
|
|
|
|
|
(lldb::TypeSummaryCapping), c);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
if (IsValid())
|
2019-08-20 16:51:52 -04:00
|
|
|
m_opaque_up->SetCapping(c);
|
2015-02-06 16:38:51 -05:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
lldb_private::TypeSummaryOptions *SBTypeSummaryOptions::operator->() {
|
2019-08-20 16:51:52 -04:00
|
|
|
return m_opaque_up.get();
|
2015-02-06 16:38:51 -05:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
const lldb_private::TypeSummaryOptions *SBTypeSummaryOptions::
|
|
|
|
|
operator->() const {
|
2019-08-20 16:51:52 -04:00
|
|
|
return m_opaque_up.get();
|
2015-02-06 16:38:51 -05:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
lldb_private::TypeSummaryOptions *SBTypeSummaryOptions::get() {
|
2019-08-20 16:51:52 -04:00
|
|
|
return m_opaque_up.get();
|
2015-02-06 16:38:51 -05:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
lldb_private::TypeSummaryOptions &SBTypeSummaryOptions::ref() {
|
2019-08-20 16:51:52 -04:00
|
|
|
return *m_opaque_up;
|
2015-02-06 16:38:51 -05:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
const lldb_private::TypeSummaryOptions &SBTypeSummaryOptions::ref() const {
|
2019-08-20 16:51:52 -04:00
|
|
|
return *m_opaque_up;
|
2015-02-06 16:38:51 -05:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
SBTypeSummaryOptions::SBTypeSummaryOptions(
|
|
|
|
|
const lldb_private::TypeSummaryOptions *lldb_object_ptr) {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBTypeSummaryOptions,
|
|
|
|
|
(const lldb_private::TypeSummaryOptions *),
|
|
|
|
|
lldb_object_ptr);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
SetOptions(lldb_object_ptr);
|
2015-02-06 16:38:51 -05:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
void SBTypeSummaryOptions::SetOptions(
|
|
|
|
|
const lldb_private::TypeSummaryOptions *lldb_object_ptr) {
|
|
|
|
|
if (lldb_object_ptr)
|
2019-08-20 16:51:52 -04:00
|
|
|
m_opaque_up.reset(new TypeSummaryOptions(*lldb_object_ptr));
|
2017-01-02 14:26:05 -05:00
|
|
|
else
|
2019-08-20 16:51:52 -04:00
|
|
|
m_opaque_up.reset(new TypeSummaryOptions());
|
2015-02-06 16:38:51 -05:00
|
|
|
}
|
|
|
|
|
|
2019-08-20 16:51:52 -04:00
|
|
|
SBTypeSummary::SBTypeSummary() : m_opaque_sp() {
|
|
|
|
|
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeSummary);
|
|
|
|
|
}
|
2017-01-02 14:26:05 -05:00
|
|
|
|
|
|
|
|
SBTypeSummary SBTypeSummary::CreateWithSummaryString(const char *data,
|
|
|
|
|
uint32_t options) {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary,
|
|
|
|
|
CreateWithSummaryString, (const char *, uint32_t),
|
|
|
|
|
data, options);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
if (!data || data[0] == 0)
|
2019-08-20 16:51:52 -04:00
|
|
|
return LLDB_RECORD_RESULT(SBTypeSummary());
|
2017-01-02 14:26:05 -05:00
|
|
|
|
2019-08-20 16:51:52 -04:00
|
|
|
return LLDB_RECORD_RESULT(
|
|
|
|
|
SBTypeSummary(TypeSummaryImplSP(new StringSummaryFormat(options, data))));
|
2015-02-06 16:38:51 -05:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
SBTypeSummary SBTypeSummary::CreateWithFunctionName(const char *data,
|
|
|
|
|
uint32_t options) {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary,
|
|
|
|
|
CreateWithFunctionName, (const char *, uint32_t),
|
|
|
|
|
data, options);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
if (!data || data[0] == 0)
|
2019-08-20 16:51:52 -04:00
|
|
|
return LLDB_RECORD_RESULT(SBTypeSummary());
|
2017-01-02 14:26:05 -05:00
|
|
|
|
2019-08-20 16:51:52 -04:00
|
|
|
return LLDB_RECORD_RESULT(
|
|
|
|
|
SBTypeSummary(TypeSummaryImplSP(new ScriptSummaryFormat(options, data))));
|
2015-02-06 16:38:51 -05:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
SBTypeSummary SBTypeSummary::CreateWithScriptCode(const char *data,
|
|
|
|
|
uint32_t options) {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary,
|
|
|
|
|
CreateWithScriptCode, (const char *, uint32_t),
|
|
|
|
|
data, options);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
if (!data || data[0] == 0)
|
2019-08-20 16:51:52 -04:00
|
|
|
return LLDB_RECORD_RESULT(SBTypeSummary());
|
2017-01-02 14:26:05 -05:00
|
|
|
|
2019-08-20 16:51:52 -04:00
|
|
|
return LLDB_RECORD_RESULT(SBTypeSummary(
|
|
|
|
|
TypeSummaryImplSP(new ScriptSummaryFormat(options, "", data))));
|
2017-01-02 14:26:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SBTypeSummary SBTypeSummary::CreateWithCallback(FormatCallback cb,
|
|
|
|
|
uint32_t options,
|
|
|
|
|
const char *description) {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_DUMMY(
|
|
|
|
|
lldb::SBTypeSummary, SBTypeSummary, CreateWithCallback,
|
|
|
|
|
(lldb::SBTypeSummary::FormatCallback, uint32_t, const char *), cb,
|
|
|
|
|
options, description);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
SBTypeSummary retval;
|
|
|
|
|
if (cb) {
|
|
|
|
|
retval.SetSP(TypeSummaryImplSP(new CXXFunctionSummaryFormat(
|
|
|
|
|
options,
|
|
|
|
|
[cb](ValueObject &valobj, Stream &stm,
|
|
|
|
|
const TypeSummaryOptions &opt) -> bool {
|
|
|
|
|
SBStream stream;
|
|
|
|
|
SBValue sb_value(valobj.GetSP());
|
|
|
|
|
SBTypeSummaryOptions options(&opt);
|
|
|
|
|
if (!cb(sb_value, options, stream))
|
|
|
|
|
return false;
|
|
|
|
|
stm.Write(stream.GetData(), stream.GetSize());
|
|
|
|
|
return true;
|
|
|
|
|
},
|
|
|
|
|
description ? description : "callback summary formatter")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SBTypeSummary::SBTypeSummary(const lldb::SBTypeSummary &rhs)
|
2019-08-20 16:51:52 -04:00
|
|
|
: m_opaque_sp(rhs.m_opaque_sp) {
|
|
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBTypeSummary, (const lldb::SBTypeSummary &), rhs);
|
|
|
|
|
}
|
2017-01-02 14:26:05 -05:00
|
|
|
|
|
|
|
|
SBTypeSummary::~SBTypeSummary() {}
|
|
|
|
|
|
2019-08-20 16:51:52 -04:00
|
|
|
bool SBTypeSummary::IsValid() const {
|
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSummary, IsValid);
|
|
|
|
|
return this->operator bool();
|
|
|
|
|
}
|
|
|
|
|
SBTypeSummary::operator bool() const {
|
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSummary, operator bool);
|
|
|
|
|
|
|
|
|
|
return m_opaque_sp.get() != nullptr;
|
|
|
|
|
}
|
2017-01-02 14:26:05 -05:00
|
|
|
|
|
|
|
|
bool SBTypeSummary::IsFunctionCode() {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSummary, IsFunctionCode);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
if (!IsValid())
|
2013-08-23 13:46:38 -04:00
|
|
|
return false;
|
2017-01-02 14:26:05 -05:00
|
|
|
if (ScriptSummaryFormat *script_summary_ptr =
|
|
|
|
|
llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get())) {
|
|
|
|
|
const char *ftext = script_summary_ptr->GetPythonScript();
|
|
|
|
|
return (ftext && *ftext != 0);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2013-08-23 13:46:38 -04:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
bool SBTypeSummary::IsFunctionName() {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSummary, IsFunctionName);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
if (!IsValid())
|
2013-08-23 13:46:38 -04:00
|
|
|
return false;
|
2017-01-02 14:26:05 -05:00
|
|
|
if (ScriptSummaryFormat *script_summary_ptr =
|
|
|
|
|
llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get())) {
|
|
|
|
|
const char *ftext = script_summary_ptr->GetPythonScript();
|
|
|
|
|
return (!ftext || *ftext == 0);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2013-08-23 13:46:38 -04:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
bool SBTypeSummary::IsSummaryString() {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSummary, IsSummaryString);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
if (!IsValid())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return m_opaque_sp->GetKind() == TypeSummaryImpl::Kind::eSummaryString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *SBTypeSummary::GetData() {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeSummary, GetData);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
if (!IsValid())
|
2019-08-20 16:51:52 -04:00
|
|
|
return nullptr;
|
2017-01-02 14:26:05 -05:00
|
|
|
if (ScriptSummaryFormat *script_summary_ptr =
|
|
|
|
|
llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get())) {
|
|
|
|
|
const char *fname = script_summary_ptr->GetFunctionName();
|
|
|
|
|
const char *ftext = script_summary_ptr->GetPythonScript();
|
|
|
|
|
if (ftext && *ftext)
|
|
|
|
|
return ftext;
|
|
|
|
|
return fname;
|
|
|
|
|
} else if (StringSummaryFormat *string_summary_ptr =
|
|
|
|
|
llvm::dyn_cast<StringSummaryFormat>(m_opaque_sp.get()))
|
|
|
|
|
return string_summary_ptr->GetSummaryString();
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t SBTypeSummary::GetOptions() {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeSummary, GetOptions);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
if (!IsValid())
|
|
|
|
|
return lldb::eTypeOptionNone;
|
|
|
|
|
return m_opaque_sp->GetOptions();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SBTypeSummary::SetOptions(uint32_t value) {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_METHOD(void, SBTypeSummary, SetOptions, (uint32_t), value);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
if (!CopyOnWrite_Impl())
|
|
|
|
|
return;
|
|
|
|
|
m_opaque_sp->SetOptions(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SBTypeSummary::SetSummaryString(const char *data) {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_METHOD(void, SBTypeSummary, SetSummaryString, (const char *),
|
|
|
|
|
data);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
if (!IsValid())
|
|
|
|
|
return;
|
|
|
|
|
if (!llvm::isa<StringSummaryFormat>(m_opaque_sp.get()))
|
|
|
|
|
ChangeSummaryType(false);
|
|
|
|
|
if (StringSummaryFormat *string_summary_ptr =
|
|
|
|
|
llvm::dyn_cast<StringSummaryFormat>(m_opaque_sp.get()))
|
|
|
|
|
string_summary_ptr->SetSummaryString(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SBTypeSummary::SetFunctionName(const char *data) {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_METHOD(void, SBTypeSummary, SetFunctionName, (const char *),
|
|
|
|
|
data);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
if (!IsValid())
|
|
|
|
|
return;
|
|
|
|
|
if (!llvm::isa<ScriptSummaryFormat>(m_opaque_sp.get()))
|
|
|
|
|
ChangeSummaryType(true);
|
|
|
|
|
if (ScriptSummaryFormat *script_summary_ptr =
|
|
|
|
|
llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get()))
|
|
|
|
|
script_summary_ptr->SetFunctionName(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SBTypeSummary::SetFunctionCode(const char *data) {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_METHOD(void, SBTypeSummary, SetFunctionCode, (const char *),
|
|
|
|
|
data);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
if (!IsValid())
|
|
|
|
|
return;
|
|
|
|
|
if (!llvm::isa<ScriptSummaryFormat>(m_opaque_sp.get()))
|
|
|
|
|
ChangeSummaryType(true);
|
|
|
|
|
if (ScriptSummaryFormat *script_summary_ptr =
|
|
|
|
|
llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get()))
|
|
|
|
|
script_summary_ptr->SetPythonScript(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SBTypeSummary::GetDescription(lldb::SBStream &description,
|
|
|
|
|
lldb::DescriptionLevel description_level) {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_METHOD(bool, SBTypeSummary, GetDescription,
|
|
|
|
|
(lldb::SBStream &, lldb::DescriptionLevel), description,
|
|
|
|
|
description_level);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
if (!CopyOnWrite_Impl())
|
|
|
|
|
return false;
|
|
|
|
|
else {
|
|
|
|
|
description.Printf("%s\n", m_opaque_sp->GetDescription().c_str());
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SBTypeSummary::DoesPrintValue(lldb::SBValue value) {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_METHOD(bool, SBTypeSummary, DoesPrintValue, (lldb::SBValue),
|
|
|
|
|
value);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
if (!IsValid())
|
|
|
|
|
return false;
|
|
|
|
|
lldb::ValueObjectSP value_sp = value.GetSP();
|
|
|
|
|
return m_opaque_sp->DoesPrintValue(value_sp.get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lldb::SBTypeSummary &SBTypeSummary::operator=(const lldb::SBTypeSummary &rhs) {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBTypeSummary &,
|
|
|
|
|
SBTypeSummary, operator=,(const lldb::SBTypeSummary &),
|
|
|
|
|
rhs);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
if (this != &rhs) {
|
|
|
|
|
m_opaque_sp = rhs.m_opaque_sp;
|
|
|
|
|
}
|
2019-08-20 16:51:52 -04:00
|
|
|
return LLDB_RECORD_RESULT(*this);
|
2017-01-02 14:26:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SBTypeSummary::operator==(lldb::SBTypeSummary &rhs) {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_METHOD(bool, SBTypeSummary, operator==,(lldb::SBTypeSummary &),
|
|
|
|
|
rhs);
|
|
|
|
|
|
2019-01-19 05:06:29 -05:00
|
|
|
if (!IsValid())
|
2017-01-02 14:26:05 -05:00
|
|
|
return !rhs.IsValid();
|
|
|
|
|
return m_opaque_sp == rhs.m_opaque_sp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SBTypeSummary::IsEqualTo(lldb::SBTypeSummary &rhs) {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_METHOD(bool, SBTypeSummary, IsEqualTo, (lldb::SBTypeSummary &),
|
|
|
|
|
rhs);
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
if (IsValid()) {
|
|
|
|
|
// valid and invalid are different
|
|
|
|
|
if (!rhs.IsValid())
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
// invalid and valid are different
|
|
|
|
|
if (rhs.IsValid())
|
|
|
|
|
return false;
|
2015-12-30 06:55:28 -05:00
|
|
|
else
|
2017-01-02 14:26:05 -05:00
|
|
|
// both invalid are the same
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_opaque_sp->GetKind() != rhs.m_opaque_sp->GetKind())
|
2015-12-30 06:55:28 -05:00
|
|
|
return false;
|
2017-01-02 14:26:05 -05:00
|
|
|
|
|
|
|
|
switch (m_opaque_sp->GetKind()) {
|
|
|
|
|
case TypeSummaryImpl::Kind::eCallback:
|
|
|
|
|
return llvm::dyn_cast<CXXFunctionSummaryFormat>(m_opaque_sp.get()) ==
|
|
|
|
|
llvm::dyn_cast<CXXFunctionSummaryFormat>(rhs.m_opaque_sp.get());
|
|
|
|
|
case TypeSummaryImpl::Kind::eScript:
|
|
|
|
|
if (IsFunctionCode() != rhs.IsFunctionCode())
|
|
|
|
|
return false;
|
|
|
|
|
if (IsFunctionName() != rhs.IsFunctionName())
|
|
|
|
|
return false;
|
|
|
|
|
return GetOptions() == rhs.GetOptions();
|
|
|
|
|
case TypeSummaryImpl::Kind::eSummaryString:
|
|
|
|
|
if (IsSummaryString() != rhs.IsSummaryString())
|
|
|
|
|
return false;
|
|
|
|
|
return GetOptions() == rhs.GetOptions();
|
|
|
|
|
case TypeSummaryImpl::Kind::eInternal:
|
|
|
|
|
return (m_opaque_sp.get() == rhs.m_opaque_sp.get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
2013-08-23 13:46:38 -04:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
bool SBTypeSummary::operator!=(lldb::SBTypeSummary &rhs) {
|
2019-08-20 16:51:52 -04:00
|
|
|
LLDB_RECORD_METHOD(bool, SBTypeSummary, operator!=,(lldb::SBTypeSummary &),
|
|
|
|
|
rhs);
|
|
|
|
|
|
2019-01-19 05:06:29 -05:00
|
|
|
if (!IsValid())
|
2017-01-02 14:26:05 -05:00
|
|
|
return !rhs.IsValid();
|
|
|
|
|
return m_opaque_sp != rhs.m_opaque_sp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lldb::TypeSummaryImplSP SBTypeSummary::GetSP() { return m_opaque_sp; }
|
|
|
|
|
|
|
|
|
|
void SBTypeSummary::SetSP(const lldb::TypeSummaryImplSP &typesummary_impl_sp) {
|
|
|
|
|
m_opaque_sp = typesummary_impl_sp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SBTypeSummary::SBTypeSummary(const lldb::TypeSummaryImplSP &typesummary_impl_sp)
|
|
|
|
|
: m_opaque_sp(typesummary_impl_sp) {}
|
|
|
|
|
|
|
|
|
|
bool SBTypeSummary::CopyOnWrite_Impl() {
|
|
|
|
|
if (!IsValid())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (m_opaque_sp.unique())
|
2013-08-23 13:46:38 -04:00
|
|
|
return true;
|
2017-01-02 14:26:05 -05:00
|
|
|
|
|
|
|
|
TypeSummaryImplSP new_sp;
|
|
|
|
|
|
|
|
|
|
if (CXXFunctionSummaryFormat *current_summary_ptr =
|
|
|
|
|
llvm::dyn_cast<CXXFunctionSummaryFormat>(m_opaque_sp.get())) {
|
|
|
|
|
new_sp = TypeSummaryImplSP(new CXXFunctionSummaryFormat(
|
|
|
|
|
GetOptions(), current_summary_ptr->m_impl,
|
|
|
|
|
current_summary_ptr->m_description.c_str()));
|
|
|
|
|
} else if (ScriptSummaryFormat *current_summary_ptr =
|
|
|
|
|
llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get())) {
|
|
|
|
|
new_sp = TypeSummaryImplSP(new ScriptSummaryFormat(
|
|
|
|
|
GetOptions(), current_summary_ptr->GetFunctionName(),
|
|
|
|
|
current_summary_ptr->GetPythonScript()));
|
|
|
|
|
} else if (StringSummaryFormat *current_summary_ptr =
|
|
|
|
|
llvm::dyn_cast<StringSummaryFormat>(m_opaque_sp.get())) {
|
|
|
|
|
new_sp = TypeSummaryImplSP(new StringSummaryFormat(
|
|
|
|
|
GetOptions(), current_summary_ptr->GetSummaryString()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetSP(new_sp);
|
|
|
|
|
|
|
|
|
|
return nullptr != new_sp.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SBTypeSummary::ChangeSummaryType(bool want_script) {
|
|
|
|
|
if (!IsValid())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
TypeSummaryImplSP new_sp;
|
|
|
|
|
|
|
|
|
|
if (want_script ==
|
|
|
|
|
(m_opaque_sp->GetKind() == TypeSummaryImpl::Kind::eScript)) {
|
|
|
|
|
if (m_opaque_sp->GetKind() ==
|
|
|
|
|
lldb_private::TypeSummaryImpl::Kind::eCallback &&
|
|
|
|
|
!want_script)
|
|
|
|
|
new_sp = TypeSummaryImplSP(new StringSummaryFormat(GetOptions(), ""));
|
|
|
|
|
else
|
|
|
|
|
return CopyOnWrite_Impl();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!new_sp) {
|
|
|
|
|
if (want_script)
|
|
|
|
|
new_sp = TypeSummaryImplSP(new ScriptSummaryFormat(GetOptions(), "", ""));
|
|
|
|
|
else
|
|
|
|
|
new_sp = TypeSummaryImplSP(new StringSummaryFormat(GetOptions(), ""));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetSP(new_sp);
|
|
|
|
|
|
|
|
|
|
return true;
|
2013-08-23 13:46:38 -04:00
|
|
|
}
|
2019-08-20 16:51:52 -04:00
|
|
|
|
|
|
|
|
namespace lldb_private {
|
|
|
|
|
namespace repro {
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
|
void RegisterMethods<SBTypeSummaryOptions>(Registry &R) {
|
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBTypeSummaryOptions, ());
|
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBTypeSummaryOptions,
|
|
|
|
|
(const lldb::SBTypeSummaryOptions &));
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBTypeSummaryOptions, IsValid, ());
|
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBTypeSummaryOptions, operator bool, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::LanguageType, SBTypeSummaryOptions, GetLanguage,
|
|
|
|
|
());
|
|
|
|
|
LLDB_REGISTER_METHOD(lldb::TypeSummaryCapping, SBTypeSummaryOptions,
|
|
|
|
|
GetCapping, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(void, SBTypeSummaryOptions, SetLanguage,
|
|
|
|
|
(lldb::LanguageType));
|
|
|
|
|
LLDB_REGISTER_METHOD(void, SBTypeSummaryOptions, SetCapping,
|
|
|
|
|
(lldb::TypeSummaryCapping));
|
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBTypeSummaryOptions,
|
|
|
|
|
(const lldb_private::TypeSummaryOptions *));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
|
void RegisterMethods<SBTypeSummary>(Registry &R) {
|
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBTypeSummary, ());
|
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary,
|
|
|
|
|
CreateWithSummaryString,
|
|
|
|
|
(const char *, uint32_t));
|
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary,
|
|
|
|
|
CreateWithFunctionName,
|
|
|
|
|
(const char *, uint32_t));
|
|
|
|
|
LLDB_REGISTER_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary,
|
|
|
|
|
CreateWithScriptCode, (const char *, uint32_t));
|
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBTypeSummary, (const lldb::SBTypeSummary &));
|
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBTypeSummary, IsValid, ());
|
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBTypeSummary, operator bool, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBTypeSummary, IsFunctionCode, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBTypeSummary, IsFunctionName, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBTypeSummary, IsSummaryString, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBTypeSummary, GetData, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(uint32_t, SBTypeSummary, GetOptions, ());
|
|
|
|
|
LLDB_REGISTER_METHOD(void, SBTypeSummary, SetOptions, (uint32_t));
|
|
|
|
|
LLDB_REGISTER_METHOD(void, SBTypeSummary, SetSummaryString, (const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(void, SBTypeSummary, SetFunctionName, (const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(void, SBTypeSummary, SetFunctionCode, (const char *));
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBTypeSummary, GetDescription,
|
|
|
|
|
(lldb::SBStream &, lldb::DescriptionLevel));
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBTypeSummary, DoesPrintValue, (lldb::SBValue));
|
|
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
|
lldb::SBTypeSummary &,
|
|
|
|
|
SBTypeSummary, operator=,(const lldb::SBTypeSummary &));
|
|
|
|
|
LLDB_REGISTER_METHOD(bool,
|
|
|
|
|
SBTypeSummary, operator==,(lldb::SBTypeSummary &));
|
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBTypeSummary, IsEqualTo,
|
|
|
|
|
(lldb::SBTypeSummary &));
|
|
|
|
|
LLDB_REGISTER_METHOD(bool,
|
|
|
|
|
SBTypeSummary, operator!=,(lldb::SBTypeSummary &));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|