[Lldb-commits] [PATCH] D158009: [lldb] Enable synthetic providers in C++

2023-08-15 Thread Lily Orth-Smith via Phabricator via lldb-commits
electriclilies created this revision.
Herald added a project: All.
electriclilies requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158009

Files:
  lldb/include/lldb/Core/ValueObject.h
  lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
  lldb/source/Core/ValueObject.cpp
  lldb/source/DataFormatters/DataVisualization.cpp
  lldb/source/DataFormatters/FormatManager.cpp
  lldb/source/DataFormatters/LanguageCategory.cpp

Index: lldb/source/DataFormatters/LanguageCategory.cpp
===
--- lldb/source/DataFormatters/LanguageCategory.cpp
+++ lldb/source/DataFormatters/LanguageCategory.cpp
@@ -71,20 +71,16 @@
 
 template <>
 auto &LanguageCategory::GetHardcodedFinder() {
-llvm::errs() << "get hardedcoded finder type formatn\n";
   return m_hardcoded_formats;
 }
 
 template <>
 auto &LanguageCategory::GetHardcodedFinder() {
-  llvm::errs() << "get hardedcoded finder type summary\n";
   return m_hardcoded_summaries;
 }
 
 template <>
 auto &LanguageCategory::GetHardcodedFinder() {
-  llvm::errs() << "get hardedcoded finder synthetic children\n";
-
   return m_hardcoded_synthetics;
 }
 
@@ -94,19 +90,14 @@
 bool LanguageCategory::GetHardcoded(FormatManager &fmt_mgr,
 FormattersMatchData &match_data,
 ImplSP &retval_sp) {
-  llvm::errs() << "languagecategory::GetHardcoded\n";
-  if (!IsEnabled()) {
-llvm::errs() << "not enabled\n";
+  if (!IsEnabled())
 return false;
-  }
 
   ValueObject &valobj(match_data.GetValueObject());
   lldb::DynamicValueType use_dynamic(match_data.GetDynamicValueType());
-  llvm::errs() << "language category checkpoint\n";
+
   for (auto &candidate : GetHardcodedFinder()) {
-llvm::errs() << "looking at candidates\n;";
 if (auto result = candidate(valobj, use_dynamic, fmt_mgr)) {
-  llvm::errs() << "result\n";
   retval_sp = result;
   break;
 }
Index: lldb/source/DataFormatters/FormatManager.cpp
===
--- lldb/source/DataFormatters/FormatManager.cpp
+++ lldb/source/DataFormatters/FormatManager.cpp
@@ -588,13 +588,9 @@
 ImplSP FormatManager::GetHardcoded(FormattersMatchData &match_data) {
   ImplSP retval_sp;
   for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
-llvm::errs() << "lang type: " << lang_type << "\n";
 if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
-  llvm::errs() << "lang_category: " << lang_category << "\n";
-  if (lang_category->GetHardcoded(*this, match_data, retval_sp)) {
-llvm::errs() << "lang_category->GetHardcoded succeeded\n";
+  if (lang_category->GetHardcoded(*this, match_data, retval_sp))
 return retval_sp;
-  }
 }
   }
   return retval_sp;
@@ -612,12 +608,9 @@
 template 
 ImplSP FormatManager::Get(ValueObject &valobj,
   lldb::DynamicValueType use_dynamic) {
-  llvm::errs() << "format manager get\n";
-  llvm::errs() << "valobj dynamic value type: " << valobj.DoesProvideSyntheticValue() << "\n";
   FormattersMatchData match_data(valobj, use_dynamic);
   if (ImplSP retval_sp = GetCached(match_data))
 return retval_sp;
-  llvm::errs() << "ckpt 1\n";
 
   Log *log = GetLog(LLDBLog::DataFormatters);
 
@@ -632,8 +625,6 @@
 }
 }
   }
-  llvm::errs() << "ckpt 2\n";
-
 
   LLDB_LOGF(log, FORMAT_LOG("Search failed. Giving hardcoded a chance."));
   return GetHardcoded(match_data);
@@ -687,7 +678,6 @@
 lldb::SyntheticChildrenSP
 FormatManager::GetSyntheticChildren(ValueObject &valobj,
 lldb::DynamicValueType use_dynamic) {
-  llvm::errs() << "format manager get synthetic children\n";
   return Get(valobj, use_dynamic);
 }
 
Index: lldb/source/DataFormatters/DataVisualization.cpp
===
--- lldb/source/DataFormatters/DataVisualization.cpp
+++ lldb/source/DataFormatters/DataVisualization.cpp
@@ -52,7 +52,6 @@
 lldb::SyntheticChildrenSP
 DataVisualization::GetSyntheticChildren(ValueObject &valobj,
 lldb::DynamicValueType use_dynamic) {
-  llvm::errs() << "inside get synthetic children2\n";
   return GetFormatManager().GetSyntheticChildren(valobj, use_dynamic);
 }
 
Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -218,10 +218,8 @@
 SetValueFormat(DataVisualization::GetFormat(*this, eNoDynamicValues));
 SetSummaryFormat(
 DataVisualization::GetSummaryFormat(*this, GetDynamicValueType()));
-llvm::errs() << "about to call SetSyntheticChildren\n";
 SetSyntheticChildren(
 DataVisualization::GetSyntheticChil

[Lldb-commits] [PATCH] D158009: [lldb] Enable synthetic providers in C++

2023-08-15 Thread Lily Orth-Smith via Phabricator via lldb-commits
electriclilies added a comment.

Hangon reviewers, I forgot to squash my commits.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158009/new/

https://reviews.llvm.org/D158009

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D158010: [lldb] Allow synthetic providers in C++ and fix linking problems

2023-08-15 Thread Lily Orth-Smith via Phabricator via lldb-commits
electriclilies created this revision.
Herald added a project: All.
electriclilies requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Allow the definition of synthetic formatters in C++, and fix linking problems 
with the CXXSyntheticChildren


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158010

Files:
  lldb/include/lldb/DataFormatters/TypeSynthetic.h
  lldb/source/Commands/CommandObjectType.cpp
  lldb/source/Core/ValueObject.cpp
  lldb/source/DataFormatters/TypeSynthetic.cpp

Index: lldb/source/DataFormatters/TypeSynthetic.cpp
===
--- lldb/source/DataFormatters/TypeSynthetic.cpp
+++ lldb/source/DataFormatters/TypeSynthetic.cpp
@@ -84,6 +84,27 @@
   return std::string(sstr.GetString());
 }
 
+SyntheticChildren::SyntheticChildren(const Flags &flags) : m_flags(flags) {}
+
+SyntheticChildren::~SyntheticChildren() = default;
+
+CXXSyntheticChildren::CXXSyntheticChildren(
+const SyntheticChildren::Flags &flags, const char *description,
+CreateFrontEndCallback callback)
+: SyntheticChildren(flags), m_create_callback(std::move(callback)),
+  m_description(description ? description : "") {}
+
+CXXSyntheticChildren::~CXXSyntheticChildren() = default;
+
+bool SyntheticChildren::IsScripted() { return false; }
+
+std::string SyntheticChildren::GetDescription() { return ""; }
+
+SyntheticChildrenFrontEnd::AutoPointer
+SyntheticChildren::GetFrontEnd(ValueObject &backend) {
+  return nullptr;
+}
+
 std::string CXXSyntheticChildren::GetDescription() {
   StreamString sstr;
   sstr.Printf("%s%s%s %s", Cascades() ? "" : " (not cascading)",
Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -218,10 +218,8 @@
 SetValueFormat(DataVisualization::GetFormat(*this, eNoDynamicValues));
 SetSummaryFormat(
 DataVisualization::GetSummaryFormat(*this, GetDynamicValueType()));
-#if LLDB_ENABLE_PYTHON
 SetSyntheticChildren(
 DataVisualization::GetSyntheticChildren(*this, GetDynamicValueType()));
-#endif
   }
 
   return any_change;
@@ -1170,7 +1168,7 @@
 Stream &s, ValueObjectRepresentationStyle val_obj_display,
 Format custom_format, PrintableRepresentationSpecialCases special,
 bool do_dump_error) {
-
+
   // If the ValueObject has an error, we might end up dumping the type, which
   // is useful, but if we don't even have a type, then don't examine the object
   // further as that's not meaningful, only the error is.
@@ -2785,15 +2783,15 @@
 
 ValueObjectSP ValueObject::Cast(const CompilerType &compiler_type) {
   // Only allow casts if the original type is equal or larger than the cast
-  // type.  We don't know how to fetch more data for all the ConstResult types, 
+  // type.  We don't know how to fetch more data for all the ConstResult types,
   // so we can't guarantee this will work:
   Status error;
   CompilerType my_type = GetCompilerType();
 
-  ExecutionContextScope *exe_scope 
+  ExecutionContextScope *exe_scope
   = ExecutionContext(GetExecutionContextRef())
   .GetBestExecutionContextScope();
-  if (compiler_type.GetByteSize(exe_scope) 
+  if (compiler_type.GetByteSize(exe_scope)
   <= GetCompilerType().GetByteSize(exe_scope)) {
 return DoCast(compiler_type);
   }
Index: lldb/source/Commands/CommandObjectType.cpp
===
--- lldb/source/Commands/CommandObjectType.cpp
+++ lldb/source/Commands/CommandObjectType.cpp
@@ -2171,8 +2171,6 @@
"Show a list of current filters.") {}
 };
 
-#if LLDB_ENABLE_PYTHON
-
 // CommandObjectTypeSynthList
 
 class CommandObjectTypeSynthList
@@ -2184,8 +2182,6 @@
 "Show a list of current synthetic providers.") {}
 };
 
-#endif
-
 // CommandObjectTypeFilterDelete
 
 class CommandObjectTypeFilterDelete : public CommandObjectTypeFormatterDelete {
@@ -2197,8 +2193,6 @@
   ~CommandObjectTypeFilterDelete() override = default;
 };
 
-#if LLDB_ENABLE_PYTHON
-
 // CommandObjectTypeSynthDelete
 
 class CommandObjectTypeSynthDelete : public CommandObjectTypeFormatterDelete {
@@ -2210,7 +2204,6 @@
   ~CommandObjectTypeSynthDelete() override = default;
 };
 
-#endif
 
 // CommandObjectTypeFilterClear
 
@@ -,7 +2215,6 @@
 "Delete all existing filter.") {}
 };
 
-#if LLDB_ENABLE_PYTHON
 // CommandObjectTypeSynthClear
 
 class CommandObjectTypeSynthClear : public CommandObjectTypeFormatterClear {
@@ -2393,7 +2385,6 @@
   return true;
 }
 
-#endif
 #define LLDB_OPTIONS_type_filter_add
 #include "CommandOptions.inc"
 
@@ -2941,8 +2932,6 @@
   ~CommandObjectTypeFormat() override = default;
 };
 
-#if LLDB_ENABLE_PYTHON
-
 class CommandObjectTypeSynth : public CommandObjectMultiword {
 public:
   CommandObje

[Lldb-commits] [PATCH] D158009: [lldb] Enable synthetic providers in C++

2023-08-15 Thread Lily Orth-Smith via Phabricator via lldb-commits
electriclilies abandoned this revision.
electriclilies added a comment.

Abandoning this since I messed up when updating, changes are now at 
https://reviews.llvm.org/D158010


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158009/new/

https://reviews.llvm.org/D158009

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D158010: [lldb] Allow synthetic providers in C++ and fix linking problems

2023-08-15 Thread Lily Orth-Smith via Phabricator via lldb-commits
electriclilies added inline comments.



Comment at: lldb/include/lldb/DataFormatters/TypeSynthetic.h:257-262
+  virtual bool IsScripted();
 
-  virtual std::string GetDescription() = 0;
+  virtual std::string GetDescription();
 
   virtual SyntheticChildrenFrontEnd::AutoPointer
+  GetFrontEnd(ValueObject &backend);

rriddle wrote:
> Why these changes?
I thought that this was causing linking problems but it is not, so I will 
revert.



Comment at: lldb/source/Commands/CommandObjectType.cpp:2174
 
-#if LLDB_ENABLE_PYTHON
-

rriddle wrote:
> Why is this dropped?
Walter and I want to use the synthetic types from C++, but right now it's only 
supported in Python. The motivation behind this is to make it so that we can 
actually use the synthetic types. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158010/new/

https://reviews.llvm.org/D158010

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D158010: [lldb] Allow synthetic providers in C++ and fix linking problems

2023-08-15 Thread Lily Orth-Smith via Phabricator via lldb-commits
electriclilies added inline comments.



Comment at: lldb/source/Commands/CommandObjectType.cpp:2174
 
-#if LLDB_ENABLE_PYTHON
-

jingham wrote:
> electriclilies wrote:
> > rriddle wrote:
> > > Why is this dropped?
> > Walter and I want to use the synthetic types from C++, but right now it's 
> > only supported in Python. The motivation behind this is to make it so that 
> > we can actually use the synthetic types. 
> Just to be clear.  There are already lots of synthetic child providers 
> implemented in C++ in in lldb already (look for CXXSyntheticChildren 
> constructors in CPlusPlusLanguage.cpp for instance).  
> 
> I think what you are saying is that you are removing the restriction that you 
> have to BUILD lldb with Python in order to add C++ implemented summaries.  If 
> that's indeed what you are saying, then this is fine, since that seems an odd 
> restriction...
> 
> But it would be nice to have some kind of testing that this actually works, 
> since I don't think any of our bots build lldb w/o Python.
Yes that's exactly it! I agree it would be nice to have a test for it but I 
don't know how to add it. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158010/new/

https://reviews.llvm.org/D158010

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D158010: [lldb] Allow synthetic providers in C++ and fix linking problems

2023-08-16 Thread Lily Orth-Smith via Phabricator via lldb-commits
electriclilies updated this revision to Diff 550795.
electriclilies added a comment.

Fix


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158010/new/

https://reviews.llvm.org/D158010

Files:
  lldb/include/lldb/DataFormatters/TypeSynthetic.h
  lldb/source/Commands/CommandObjectType.cpp
  lldb/source/Core/ValueObject.cpp
  lldb/source/DataFormatters/TypeSynthetic.cpp

Index: lldb/source/DataFormatters/TypeSynthetic.cpp
===
--- lldb/source/DataFormatters/TypeSynthetic.cpp
+++ lldb/source/DataFormatters/TypeSynthetic.cpp
@@ -84,6 +84,27 @@
   return std::string(sstr.GetString());
 }
 
+SyntheticChildren::SyntheticChildren(const Flags &flags) : m_flags(flags) {}
+
+SyntheticChildren::~SyntheticChildren() = default;
+
+CXXSyntheticChildren::CXXSyntheticChildren(
+const SyntheticChildren::Flags &flags, const char *description,
+CreateFrontEndCallback callback)
+: SyntheticChildren(flags), m_create_callback(std::move(callback)),
+  m_description(description ? description : "") {}
+
+CXXSyntheticChildren::~CXXSyntheticChildren() = default;
+
+bool SyntheticChildren::IsScripted() { return false; }
+
+std::string SyntheticChildren::GetDescription() { return ""; }
+
+SyntheticChildrenFrontEnd::AutoPointer
+SyntheticChildren::GetFrontEnd(ValueObject &backend) {
+  return nullptr;
+}
+
 std::string CXXSyntheticChildren::GetDescription() {
   StreamString sstr;
   sstr.Printf("%s%s%s %s", Cascades() ? "" : " (not cascading)",
Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -218,10 +218,8 @@
 SetValueFormat(DataVisualization::GetFormat(*this, eNoDynamicValues));
 SetSummaryFormat(
 DataVisualization::GetSummaryFormat(*this, GetDynamicValueType()));
-#if LLDB_ENABLE_PYTHON
 SetSyntheticChildren(
 DataVisualization::GetSyntheticChildren(*this, GetDynamicValueType()));
-#endif
   }
 
   return any_change;
@@ -1170,7 +1168,7 @@
 Stream &s, ValueObjectRepresentationStyle val_obj_display,
 Format custom_format, PrintableRepresentationSpecialCases special,
 bool do_dump_error) {
-
+
   // If the ValueObject has an error, we might end up dumping the type, which
   // is useful, but if we don't even have a type, then don't examine the object
   // further as that's not meaningful, only the error is.
@@ -2785,15 +2783,15 @@
 
 ValueObjectSP ValueObject::Cast(const CompilerType &compiler_type) {
   // Only allow casts if the original type is equal or larger than the cast
-  // type.  We don't know how to fetch more data for all the ConstResult types, 
+  // type.  We don't know how to fetch more data for all the ConstResult types,
   // so we can't guarantee this will work:
   Status error;
   CompilerType my_type = GetCompilerType();
 
-  ExecutionContextScope *exe_scope 
+  ExecutionContextScope *exe_scope
   = ExecutionContext(GetExecutionContextRef())
   .GetBestExecutionContextScope();
-  if (compiler_type.GetByteSize(exe_scope) 
+  if (compiler_type.GetByteSize(exe_scope)
   <= GetCompilerType().GetByteSize(exe_scope)) {
 return DoCast(compiler_type);
   }
Index: lldb/source/Commands/CommandObjectType.cpp
===
--- lldb/source/Commands/CommandObjectType.cpp
+++ lldb/source/Commands/CommandObjectType.cpp
@@ -2171,8 +2171,6 @@
"Show a list of current filters.") {}
 };
 
-#if LLDB_ENABLE_PYTHON
-
 // CommandObjectTypeSynthList
 
 class CommandObjectTypeSynthList
@@ -2184,8 +2182,6 @@
 "Show a list of current synthetic providers.") {}
 };
 
-#endif
-
 // CommandObjectTypeFilterDelete
 
 class CommandObjectTypeFilterDelete : public CommandObjectTypeFormatterDelete {
@@ -2197,8 +2193,6 @@
   ~CommandObjectTypeFilterDelete() override = default;
 };
 
-#if LLDB_ENABLE_PYTHON
-
 // CommandObjectTypeSynthDelete
 
 class CommandObjectTypeSynthDelete : public CommandObjectTypeFormatterDelete {
@@ -2210,7 +2204,6 @@
   ~CommandObjectTypeSynthDelete() override = default;
 };
 
-#endif
 
 // CommandObjectTypeFilterClear
 
@@ -,7 +2215,6 @@
 "Delete all existing filter.") {}
 };
 
-#if LLDB_ENABLE_PYTHON
 // CommandObjectTypeSynthClear
 
 class CommandObjectTypeSynthClear : public CommandObjectTypeFormatterClear {
@@ -2393,7 +2385,6 @@
   return true;
 }
 
-#endif
 #define LLDB_OPTIONS_type_filter_add
 #include "CommandOptions.inc"
 
@@ -2941,8 +2932,6 @@
   ~CommandObjectTypeFormat() override = default;
 };
 
-#if LLDB_ENABLE_PYTHON
-
 class CommandObjectTypeSynth : public CommandObjectMultiword {
 public:
   CommandObjectTypeSynth(CommandInterpreter &interpreter)
@@ -2970,8 +2959,6 @@
   ~CommandObjectTypeSynth() override = default;
 };
 
-#endif
-
 class Co

[Lldb-commits] [PATCH] D158010: [lldb] Allow synthetic providers in C++ and fix linking problems

2023-08-21 Thread Lily Orth-Smith via Phabricator via lldb-commits
electriclilies added a comment.

@jingham Any other changes I should make? Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158010/new/

https://reviews.llvm.org/D158010

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D158010: [lldb] Allow synthetic providers in C++ and fix linking problems

2023-08-25 Thread Lily Orth-Smith via Phabricator via lldb-commits
electriclilies added a comment.

@wallace The type synthetic add command already disables itself if python is 
not enabled (the check is at CommandObjectType::1564), so I think there aren't 
any changes I need to make


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158010/new/

https://reviews.llvm.org/D158010

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits