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

2023-08-31 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

> add a way to make an SBTypeSynthetic from the appropriate C++ class

That's a great idea. Once we implement a couple of providers for our plugin 
I'll revisit the idea. 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-30 Thread walter erquinigo via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG79d5d9a0824d: [lldb] Allow synthetic providers in C++ and 
fix linking problems (authored by wallace).

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 ) : m_flags(flags) {}
+
+SyntheticChildren::~SyntheticChildren() = default;
+
+CXXSyntheticChildren::CXXSyntheticChildren(
+const SyntheticChildren::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 ) {
+  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;
@@ -1153,7 +1151,7 @@
 Stream , 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.
@@ -2766,15 +2764,15 @@
 
 ValueObjectSP ValueObject::Cast(const CompilerType _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 )
@@ -2970,8 +2959,6 @@
   

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

2023-08-30 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

For the sake of unblocking this diff, I'm accepting it because there's no clear 
actionable feedback at the moment.  @electriclilies, please follow up any 
feedback that is submitted post-landing.


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] D159031: [LLDB] Fix IOHandlerEditline::GetCurrentLines()

2023-08-30 Thread walter erquinigo via Phabricator via lldb-commits
wallace marked an inline comment as done.
wallace added a comment.

@aprantl , it turns out that there are no tests for this. I also don't know how 
easy it'd be to test this very specific feature, because it relies on the 
terminal not being affected by stuff like test runners.


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

https://reviews.llvm.org/D159031

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


[Lldb-commits] [PATCH] D159031: [LLDB] Fix IOHandlerEditline::GetCurrentLines()

2023-08-30 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 554712.

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

https://reviews.llvm.org/D159031

Files:
  lldb/include/lldb/Core/IOHandler.h
  lldb/include/lldb/Host/Editline.h
  lldb/source/Core/IOHandler.cpp
  lldb/source/Expression/REPL.cpp


Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -528,17 +528,15 @@
   current_code.append(m_code.CopyList());
 
   IOHandlerEditline  = static_cast(io_handler);
-  const StringList *current_lines = editline.GetCurrentLines();
-  if (current_lines) {
-const uint32_t current_line_idx = editline.GetCurrentLineIndex();
-
-if (current_line_idx < current_lines->GetSize()) {
-  for (uint32_t i = 0; i < current_line_idx; ++i) {
-const char *line_cstr = current_lines->GetStringAtIndex(i);
-if (line_cstr) {
-  current_code.append("\n");
-  current_code.append(line_cstr);
-}
+  StringList current_lines = editline.GetCurrentLines();
+  const uint32_t current_line_idx = editline.GetCurrentLineIndex();
+
+  if (current_line_idx < current_lines.GetSize()) {
+for (uint32_t i = 0; i < current_line_idx; ++i) {
+  const char *line_cstr = current_lines.GetStringAtIndex(i);
+  if (line_cstr) {
+current_code.append("\n");
+current_code.append(line_cstr);
   }
 }
   }
Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -508,6 +508,21 @@
   return m_curr_line_idx;
 }
 
+StringList IOHandlerEditline::GetCurrentLines() const {
+#if LLDB_ENABLE_LIBEDIT
+  if (m_editline_up)
+return m_editline_up->GetInputAsStringList();
+#endif
+  // When libedit is not used, the current lines can be gotten from
+  // `m_current_lines_ptr`, which is updated whenever a new line is processed.
+  // This doesn't happen when libedit is used, in which case
+  // `m_current_lines_ptr` is only updated when the full input is terminated.
+
+  if (m_current_lines_ptr)
+return *m_current_lines_ptr;
+  return StringList();
+}
+
 bool IOHandlerEditline::GetLines(StringList , bool ) {
   m_current_lines_ptr = 
 
Index: lldb/include/lldb/Host/Editline.h
===
--- lldb/include/lldb/Host/Editline.h
+++ lldb/include/lldb/Host/Editline.h
@@ -227,6 +227,9 @@
 
   void PrintAsync(Stream *stream, const char *s, size_t len);
 
+  /// Convert the current input lines into a UTF8 StringList
+  StringList GetInputAsStringList(int line_count = UINT32_MAX);
+
 private:
   /// Sets the lowest line number for multi-line editing sessions.  A value of
   /// zero suppresses
@@ -282,9 +285,6 @@
   /// Save the line currently being edited
   void SaveEditedLine();
 
-  /// Convert the current input lines into a UTF8 StringList
-  StringList GetInputAsStringList(int line_count = UINT32_MAX);
-
   /// Replaces the current multi-line session with the next entry from history.
   unsigned char RecallHistory(HistoryOperation op);
 
Index: lldb/include/lldb/Core/IOHandler.h
===
--- lldb/include/lldb/Core/IOHandler.h
+++ lldb/include/lldb/Core/IOHandler.h
@@ -403,7 +403,7 @@
 
   void SetInterruptExits(bool b) { m_interrupt_exits = b; }
 
-  const StringList *GetCurrentLines() const { return m_current_lines_ptr; }
+  StringList GetCurrentLines() const;
 
   uint32_t GetCurrentLineIndex() const;
 


Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -528,17 +528,15 @@
   current_code.append(m_code.CopyList());
 
   IOHandlerEditline  = static_cast(io_handler);
-  const StringList *current_lines = editline.GetCurrentLines();
-  if (current_lines) {
-const uint32_t current_line_idx = editline.GetCurrentLineIndex();
-
-if (current_line_idx < current_lines->GetSize()) {
-  for (uint32_t i = 0; i < current_line_idx; ++i) {
-const char *line_cstr = current_lines->GetStringAtIndex(i);
-if (line_cstr) {
-  current_code.append("\n");
-  current_code.append(line_cstr);
-}
+  StringList current_lines = editline.GetCurrentLines();
+  const uint32_t current_line_idx = editline.GetCurrentLineIndex();
+
+  if (current_line_idx < current_lines.GetSize()) {
+for (uint32_t i = 0; i < current_line_idx; ++i) {
+  const char *line_cstr = current_lines.GetStringAtIndex(i);
+  if (line_cstr) {
+current_code.append("\n");
+current_code.append(line_cstr);
   }
 }
   }
Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ 

[Lldb-commits] [PATCH] D159031: [LLDB] Fix IOHandlerEditline::GetCurrentLines()

2023-08-29 Thread walter erquinigo via Phabricator via lldb-commits
wallace added inline comments.



Comment at: lldb/source/Expression/REPL.cpp:535
+  if (current_line_idx < current_lines.GetSize()) {
+for (uint32_t i = 0; i < current_line_idx; ++i) {
+  const char *line_cstr = current_lines.GetStringAtIndex(i);

aprantl wrote:
> `for (const char *line_cstr : current_lines)` ?
actually the current code is fine because we don't want to iterate through the 
entire set, we just want the first `current_line_idx + 1` elements


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159031

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


[Lldb-commits] [PATCH] D159031: [LLDB] Fix IOHandlerEditline::GetCurrentLines()

2023-08-28 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
wallace added reviewers: bulbazord, aprantl, JDevlieghere.
Herald added a project: All.
wallace requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This method was working as expected if `LLDB_ENABLE_LIBEDIT` is false, however, 
if it was true, then the variable `m_current_lines_ptr` was always pointing to 
an empty list, because Editline only updates its contents once the full input 
has been completed (see 
https://github.com/llvm/llvm-project/blob/main/lldb/source/Host/common/Editline.cpp#L1576).

A simple fix is to invoke `Editline::GetInputAsStringList()` from 
`GetCurrentLines()`, which is already used in many places as the common way to 
get the full input list.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159031

Files:
  lldb/include/lldb/Core/IOHandler.h
  lldb/include/lldb/Host/Editline.h
  lldb/source/Core/IOHandler.cpp
  lldb/source/Expression/REPL.cpp


Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -528,17 +528,15 @@
   current_code.append(m_code.CopyList());
 
   IOHandlerEditline  = static_cast(io_handler);
-  const StringList *current_lines = editline.GetCurrentLines();
-  if (current_lines) {
-const uint32_t current_line_idx = editline.GetCurrentLineIndex();
-
-if (current_line_idx < current_lines->GetSize()) {
-  for (uint32_t i = 0; i < current_line_idx; ++i) {
-const char *line_cstr = current_lines->GetStringAtIndex(i);
-if (line_cstr) {
-  current_code.append("\n");
-  current_code.append(line_cstr);
-}
+  StringList current_lines = editline.GetCurrentLines();
+  const uint32_t current_line_idx = editline.GetCurrentLineIndex();
+
+  if (current_line_idx < current_lines.GetSize()) {
+for (uint32_t i = 0; i < current_line_idx; ++i) {
+  const char *line_cstr = current_lines.GetStringAtIndex(i);
+  if (line_cstr) {
+current_code.append("\n");
+current_code.append(line_cstr);
   }
 }
   }
Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -508,6 +508,16 @@
   return m_curr_line_idx;
 }
 
+StringList IOHandlerEditline::GetCurrentLines() const {
+#if LLDB_ENABLE_LIBEDIT
+  if (m_editline_up)
+return m_editline_up->GetInputAsStringList();
+#endif
+  if (m_current_lines_ptr)
+return *m_current_lines_ptr;
+  return StringList();
+}
+
 bool IOHandlerEditline::GetLines(StringList , bool ) {
   m_current_lines_ptr = 
 
Index: lldb/include/lldb/Host/Editline.h
===
--- lldb/include/lldb/Host/Editline.h
+++ lldb/include/lldb/Host/Editline.h
@@ -227,6 +227,9 @@
 
   void PrintAsync(Stream *stream, const char *s, size_t len);
 
+  /// Convert the current input lines into a UTF8 StringList
+  StringList GetInputAsStringList(int line_count = UINT32_MAX);
+
 private:
   /// Sets the lowest line number for multi-line editing sessions.  A value of
   /// zero suppresses
@@ -282,9 +285,6 @@
   /// Save the line currently being edited
   void SaveEditedLine();
 
-  /// Convert the current input lines into a UTF8 StringList
-  StringList GetInputAsStringList(int line_count = UINT32_MAX);
-
   /// Replaces the current multi-line session with the next entry from history.
   unsigned char RecallHistory(HistoryOperation op);
 
Index: lldb/include/lldb/Core/IOHandler.h
===
--- lldb/include/lldb/Core/IOHandler.h
+++ lldb/include/lldb/Core/IOHandler.h
@@ -403,7 +403,7 @@
 
   void SetInterruptExits(bool b) { m_interrupt_exits = b; }
 
-  const StringList *GetCurrentLines() const { return m_current_lines_ptr; }
+  StringList GetCurrentLines() const;
 
   uint32_t GetCurrentLineIndex() const;
 


Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -528,17 +528,15 @@
   current_code.append(m_code.CopyList());
 
   IOHandlerEditline  = static_cast(io_handler);
-  const StringList *current_lines = editline.GetCurrentLines();
-  if (current_lines) {
-const uint32_t current_line_idx = editline.GetCurrentLineIndex();
-
-if (current_line_idx < current_lines->GetSize()) {
-  for (uint32_t i = 0; i < current_line_idx; ++i) {
-const char *line_cstr = current_lines->GetStringAtIndex(i);
-if (line_cstr) {
-  current_code.append("\n");
-  current_code.append(line_cstr);
-}
+  StringList current_lines = editline.GetCurrentLines();
+  const uint32_t current_line_idx = editline.GetCurrentLineIndex();
+
+  if (current_line_idx < current_lines.GetSize()) {
+for 

[Lldb-commits] [PATCH] D158958: [LLDB][REPL] Change the default tab size

2023-08-28 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

@aprantl, how should I proceed with the swift branch? Should I create a new 
branch in https://github.com/apple/swift and share it here so it's available 
for whoever does the merge?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158958

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


[Lldb-commits] [PATCH] D158958: [LLDB][REPL] Change the default tab size

2023-08-27 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 553804.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158958

Files:
  lldb/source/Core/CoreProperties.td


Index: lldb/source/Core/CoreProperties.td
===
--- lldb/source/Core/CoreProperties.td
+++ lldb/source/Core/CoreProperties.td
@@ -173,8 +173,8 @@
 Desc<"If true, LLDB will print the values of variables declared in an 
expression. Currently only supported in the REPL (default: true).">;
   def TabSize: Property<"tab-size", "UInt64">,
 Global,
-DefaultUnsignedValue<4>,
-Desc<"The tab size to use when indenting code in multi-line input mode 
(default: 4).">;
+DefaultUnsignedValue<2>,
+Desc<"The tab size to use when indenting code in multi-line input mode 
(default: 2).">;
   def EscapeNonPrintables: Property<"escape-non-printables", "Boolean">,
 Global,
 DefaultTrue,


Index: lldb/source/Core/CoreProperties.td
===
--- lldb/source/Core/CoreProperties.td
+++ lldb/source/Core/CoreProperties.td
@@ -173,8 +173,8 @@
 Desc<"If true, LLDB will print the values of variables declared in an expression. Currently only supported in the REPL (default: true).">;
   def TabSize: Property<"tab-size", "UInt64">,
 Global,
-DefaultUnsignedValue<4>,
-Desc<"The tab size to use when indenting code in multi-line input mode (default: 4).">;
+DefaultUnsignedValue<2>,
+Desc<"The tab size to use when indenting code in multi-line input mode (default: 2).">;
   def EscapeNonPrintables: Property<"escape-non-printables", "Boolean">,
 Global,
 DefaultTrue,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D158958: [LLDB][REPL] Change the default tab size

2023-08-27 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
wallace added reviewers: bulbazord, JDevlieghere.
Herald added a project: All.
wallace requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The REPL has a default tab size of 4 spaces, which seems to be a bit too much. 
The reason is that the REPL transforms tabs into spaces, and therefore whenever 
you want to manually deindent, you need to delete at least 4 characters. On the 
other hand, using 2 as default results in less keystrokes, without hurting 
readability.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158958

Files:
  lldb/source/Core/CoreProperties.td


Index: lldb/source/Core/CoreProperties.td
===
--- lldb/source/Core/CoreProperties.td
+++ lldb/source/Core/CoreProperties.td
@@ -173,8 +173,8 @@
 Desc<"If true, LLDB will print the values of variables declared in an 
expression. Currently only supported in the REPL (default: true).">;
   def TabSize: Property<"tab-size", "UInt64">,
 Global,
-DefaultUnsignedValue<4>,
-Desc<"The tab size to use when indenting code in multi-line input mode 
(default: 4).">;
+DefaultUnsignedValue<2>,
+Desc<"The tab size to use when indenting code in multi-line input mode 
(default: 2).">;
   def EscapeNonPrintables: Property<"escape-non-printables", "Boolean">,
 Global,
 DefaultTrue,


Index: lldb/source/Core/CoreProperties.td
===
--- lldb/source/Core/CoreProperties.td
+++ lldb/source/Core/CoreProperties.td
@@ -173,8 +173,8 @@
 Desc<"If true, LLDB will print the values of variables declared in an expression. Currently only supported in the REPL (default: true).">;
   def TabSize: Property<"tab-size", "UInt64">,
 Global,
-DefaultUnsignedValue<4>,
-Desc<"The tab size to use when indenting code in multi-line input mode (default: 4).">;
+DefaultUnsignedValue<2>,
+Desc<"The tab size to use when indenting code in multi-line input mode (default: 2).">;
   def EscapeNonPrintables: Property<"escape-non-printables", "Boolean">,
 Global,
 DefaultTrue,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D158893: [lldb] Fix TestVSCode_completions on Darwin

2023-08-25 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

Awesome!!


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

https://reviews.llvm.org/D158893

___
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 walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

In D158010#4617611 , @electriclilies 
wrote:

> @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

Great! Let's wait for Jim then.


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] D158801: [lldb-vscode] Update package.json

2023-08-24 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

Awesome!


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

https://reviews.llvm.org/D158801

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


[Lldb-commits] [PATCH] D158788: [lldb-vscode] Use a switch to avoid else-after-return (NFC)

2023-08-24 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

Thanks!


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

https://reviews.llvm.org/D158788

___
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-24 Thread walter erquinigo via Phabricator via lldb-commits
wallace added inline comments.



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

wallace wrote:
> electriclilies wrote:
> > 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. 
> @jingham , indeed, we couldn't add buildbot tests for this they all build 
> with python support.
> 
> However, a good compromise is to enable all these commands except for the 
> `add` ones, because they have the option to use python-defined extensions. 
> `clear`, `delete`, `info` and `list` should be fine even without python 
> scripting support.
> 
> What do you think?
After a second inspection of this diff, I want to rephrase my previous comment:

This patch is only enabling the `type synthetic` commands, and `type synthetic 
add` is the only one that can receive a python input. In fact, it only works 
with python, so @electriclilies, please keep `type synthetic add` guarded by 
`#if LLDB_ENABLE_PYTHON`, because it just doesn't work otherwise.

@jingham , we can't really test this in the buildbots, so, all good if Lily 
does some basic manual testing showing that these commands work even when the 
python scripting support is not enabled? 


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] D157764: [LLDB] Allow expression evaluators to set arbitrary timeouts

2023-08-22 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

@JDevlieghere , that worked. Thanks!!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157764

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


[Lldb-commits] [PATCH] D157764: [LLDB] Allow expression evaluators to set arbitrary timeouts

2023-08-22 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

@jasonmolenda , yep. I have already reverted this patch. I'll figure out how to 
make that work nicely with these changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157764

___
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-22 Thread walter erquinigo via Phabricator via lldb-commits
wallace added inline comments.



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

electriclilies wrote:
> 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. 
@jingham , indeed, we couldn't add buildbot tests for this they all build with 
python support.

However, a good compromise is to enable all these commands except for the `add` 
ones, because they have the option to use python-defined extensions. `clear`, 
`delete`, `info` and `list` should be fine even without python scripting 
support.

What do you think?


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] D157764: [LLDB] Allow expression evaluators to set arbitrary timeouts

2023-08-22 Thread walter erquinigo via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa4dbdf474993: [LLDB] Allow expression evaluators to set 
arbitrary timeouts (authored by wallace).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157764

Files:
  lldb/include/lldb/Target/Target.h


Index: lldb/include/lldb/Target/Target.h
===
--- lldb/include/lldb/Target/Target.h
+++ lldb/include/lldb/Target/Target.h
@@ -346,16 +346,9 @@
 m_use_dynamic = dynamic;
   }
 
-  const Timeout () const {
-assert(m_timeout && m_timeout->count() > 0);
-return m_timeout;
-  }
+  const Timeout () const { return m_timeout; }
 
-  void SetTimeout(const Timeout ) {
-// Disallow setting a non-zero timeout.
-if (timeout && timeout->count() > 0)
-  m_timeout = timeout;
-  }
+  void SetTimeout(const Timeout ) { m_timeout = timeout; }
 
   const Timeout () const {
 return m_one_thread_timeout;


Index: lldb/include/lldb/Target/Target.h
===
--- lldb/include/lldb/Target/Target.h
+++ lldb/include/lldb/Target/Target.h
@@ -346,16 +346,9 @@
 m_use_dynamic = dynamic;
   }
 
-  const Timeout () const {
-assert(m_timeout && m_timeout->count() > 0);
-return m_timeout;
-  }
+  const Timeout () const { return m_timeout; }
 
-  void SetTimeout(const Timeout ) {
-// Disallow setting a non-zero timeout.
-if (timeout && timeout->count() > 0)
-  m_timeout = timeout;
-  }
+  void SetTimeout(const Timeout ) { m_timeout = timeout; }
 
   const Timeout () const {
 return m_one_thread_timeout;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D157764: [LLDB] Allow expression evaluators to set arbitrary timeouts

2023-08-11 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

Btw, the SBAPI expects the old behavior.

  // Set the timeout for the expression, 0 means wait forever.
  void SetTimeoutInMicroSeconds(uint32_t timeout = 0);


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157764

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


[Lldb-commits] [PATCH] D157764: [LLDB] Allow expression evaluators to set arbitrary timeouts

2023-08-11 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
wallace added a reviewer: bulbazord.
Herald added a project: All.
wallace requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

https://github.com/llvm/llvm-project/commit/59237bb52c9483fce395428bfab5996eabe54ed0
 changed the behavior of the `SetTimeout` and `GetTimeout` methods of 
`EvaluateExpressionOptions`, which broke the Mojo REPL and related services 
(https://docs.modular.com/mojo/) because it relies on having infinite timeouts. 
That's a necessity because developers often use the REPL for executing 
extremely long-running numeric jobs. Having said that, 
`EvaluateExpressionOptions` shouldn't be that opinionated on this matter 
anyway. Instead, it should be the responsibility of the evaluator to define 
which timeout to use for each specific case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157764

Files:
  lldb/include/lldb/Target/Target.h


Index: lldb/include/lldb/Target/Target.h
===
--- lldb/include/lldb/Target/Target.h
+++ lldb/include/lldb/Target/Target.h
@@ -346,16 +346,9 @@
 m_use_dynamic = dynamic;
   }
 
-  const Timeout () const {
-assert(m_timeout && m_timeout->count() > 0);
-return m_timeout;
-  }
+  const Timeout () const { return m_timeout; }
 
-  void SetTimeout(const Timeout ) {
-// Disallow setting a non-zero timeout.
-if (timeout && timeout->count() > 0)
-  m_timeout = timeout;
-  }
+  void SetTimeout(const Timeout ) { m_timeout = timeout; }
 
   const Timeout () const {
 return m_one_thread_timeout;


Index: lldb/include/lldb/Target/Target.h
===
--- lldb/include/lldb/Target/Target.h
+++ lldb/include/lldb/Target/Target.h
@@ -346,16 +346,9 @@
 m_use_dynamic = dynamic;
   }
 
-  const Timeout () const {
-assert(m_timeout && m_timeout->count() > 0);
-return m_timeout;
-  }
+  const Timeout () const { return m_timeout; }
 
-  void SetTimeout(const Timeout ) {
-// Disallow setting a non-zero timeout.
-if (timeout && timeout->count() > 0)
-  m_timeout = timeout;
-  }
+  void SetTimeout(const Timeout ) { m_timeout = timeout; }
 
   const Timeout () const {
 return m_one_thread_timeout;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D156979: [lldb][lldb-vscode] Pretty print JSON to log files

2023-08-03 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

nice improvement for sure


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156979

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


[Lldb-commits] [PATCH] D156977: [lldb][lldb-vscode] Fix nullptr dereference when JSON is not an object

2023-08-03 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156977

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


[Lldb-commits] [PATCH] D140630: [lldb-vscode] Add data breakpoint support

2023-08-02 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

Greg hasn't been working for a while. You can go ahead and land this, and when 
he gets back he can share some feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140630

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


[Lldb-commits] [PATCH] D156465: [lldb-vscode] Adding support for displaying backtraces.

2023-07-28 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

fancy


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156465

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


[Lldb-commits] [PATCH] D156493: [lldb-vsocde] Adding support for the "disassemble" request.

2023-07-28 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

you are my hero


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156493

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


[Lldb-commits] [PATCH] D154989: [lldb-vsocde] Add a 'continued' event for programmatic continue events.

2023-07-25 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154989

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


[Lldb-commits] [PATCH] D155248: [lldb-vscode] Creating a new flag for adjusting the behavior of evaluation repl expressions to allow users to more easily invoke lldb commands.

2023-07-15 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

fingers crossed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155248

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


[Lldb-commits] [PATCH] D154990: [lldb-vsocde] Cleaning up the usage of the Separate helper in Options.td.

2023-07-11 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

wooo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154990

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


[Lldb-commits] [PATCH] D154989: [lldb-vsocde] Add a 'continued' event for programmatic continue events.

2023-07-11 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154989

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


[Lldb-commits] [PATCH] D154030: [lldb-vscode] Creating a new flag for adjusting the behavior of evaluation repl expressions to allow users to more easily invoke lldb commands.

2023-07-11 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

nice!!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154030

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


[Lldb-commits] [PATCH] D154030: [lldb-vscode] Creating a new flag for adjusting the behavior of evaluation repl expressions to allow users to more easily invoke lldb commands.

2023-07-10 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

Could you split the changes to the selected thread out of this? I'm seeing two 
features being implemented in this patch.
Other than that, it looks pretty good!




Comment at: lldb/tools/lldb-vscode/Options.td:20-38
+def port: S<"port">,
   MetaVarName<"">,
   HelpText<"Communicate with the lldb-vscode tool over the defined port.">;
 def: Separate<["-"], "p">,
   Alias,
   HelpText<"Alias for --port">;
 

+1



Comment at: lldb/tools/lldb-vscode/VSCode.cpp:768
 
+  return true; 
+}

use clang-format please



Comment at: lldb/tools/lldb-vscode/VSCode.h:89
+
+/// A huersitic for determining the context of an evaluation.
+enum class ExpressionContext {

typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154030

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


[Lldb-commits] [PATCH] D154029: [lldb-vscode] Adding support for column break points.

2023-07-05 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

Nice!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154029

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


[Lldb-commits] [PATCH] D154028: [lldb-vscode] Prior to running the launchCommands during a launch request set the launch info so the configured launch information is accessible by the launch commands.

2023-06-28 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

THANKS


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154028

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


[Lldb-commits] [PATCH] D154026: [lldb-vscode] Adjusting CreateSource to detect compiler generated frames.

2023-06-28 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

pretty nice. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154026

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


[Lldb-commits] [PATCH] D153073: [LLDB] Add DWARF definitions for the new Mojo language

2023-06-26 Thread walter erquinigo via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG582582fb474b: [LLDB] Add DWARF definitions for the new Mojo 
language (authored by wallace).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153073

Files:
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Target/Language.cpp
  llvm/include/llvm-c/DebugInfo.h
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/BinaryFormat/Dwarf.h
  llvm/lib/IR/DIBuilder.cpp

Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -140,7 +140,7 @@
 DICompileUnit::DebugNameTableKind NameTableKind, bool RangesBaseAddress,
 StringRef SysRoot, StringRef SDK) {
 
-  assert(((Lang <= dwarf::DW_LANG_Ada2012 && Lang >= dwarf::DW_LANG_C89) ||
+  assert(((Lang <= dwarf::DW_LANG_Mojo && Lang >= dwarf::DW_LANG_C89) ||
   (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
  "Invalid Language tag");
 
Index: llvm/include/llvm/BinaryFormat/Dwarf.h
===
--- llvm/include/llvm/BinaryFormat/Dwarf.h
+++ llvm/include/llvm/BinaryFormat/Dwarf.h
@@ -268,6 +268,7 @@
   case DW_LANG_Fortran18:
   case DW_LANG_Ada2005:
   case DW_LANG_Ada2012:
+  case DW_LANG_Mojo:
 result = false;
 break;
   }
@@ -334,6 +335,7 @@
   case DW_LANG_C17:
   case DW_LANG_Ada2005:
   case DW_LANG_Ada2012:
+  case DW_LANG_Mojo:
 result = false;
 break;
   }
@@ -398,6 +400,7 @@
   case DW_LANG_Fortran18:
   case DW_LANG_Ada2005:
   case DW_LANG_Ada2012:
+  case DW_LANG_Mojo:
 return false;
   }
   llvm_unreachable("Unknown language kind.");
Index: llvm/include/llvm/BinaryFormat/Dwarf.def
===
--- llvm/include/llvm/BinaryFormat/Dwarf.def
+++ llvm/include/llvm/BinaryFormat/Dwarf.def
@@ -948,6 +948,7 @@
 HANDLE_DW_LANG(0x002d, Fortran18, 0, 0, DWARF)
 HANDLE_DW_LANG(0x002e, Ada2005, 0, 0, DWARF)
 HANDLE_DW_LANG(0x002f, Ada2012, 0, 0, DWARF)
+HANDLE_DW_LANG(0x0033, Mojo, 0, 0, DWARF)
 // Vendor extensions:
 HANDLE_DW_LANG(0x8001, Mips_Assembler, std::nullopt, 0, MIPS)
 HANDLE_DW_LANG(0x8e57, GOOGLE_RenderScript, 0, 0, GOOGLE)
Index: llvm/include/llvm-c/DebugInfo.h
===
--- llvm/include/llvm-c/DebugInfo.h
+++ llvm/include/llvm-c/DebugInfo.h
@@ -125,6 +125,7 @@
   LLVMDWARFSourceLanguageFortran18,
   LLVMDWARFSourceLanguageAda2005,
   LLVMDWARFSourceLanguageAda2012,
+  LLVMDWARFSourceLanguageMojo,
   // Vendor extensions:
   LLVMDWARFSourceLanguageMips_Assembler,
   LLVMDWARFSourceLanguageGOOGLE_RenderScript,
Index: lldb/source/Target/Language.cpp
===
--- lldb/source/Target/Language.cpp
+++ lldb/source/Target/Language.cpp
@@ -209,9 +209,9 @@
 {"fortran18", eLanguageTypeFortran18},
 {"ada2005", eLanguageTypeAda2005},
 {"ada2012", eLanguageTypeAda2012},
+{"mojo", eLanguageTypeMojo},
 // Vendor Extensions
 {"assembler", eLanguageTypeMipsAssembler},
-{"mojo", eLanguageTypeMojo},
 // Now synonyms, in arbitrary order
 {"objc", eLanguageTypeObjC},
 {"objc++", eLanguageTypeObjC_plus_plus},
@@ -457,12 +457,12 @@
   return std::pair();
 }
 
-bool Language::DemangledNameContainsPath(llvm::StringRef path, 
+bool Language::DemangledNameContainsPath(llvm::StringRef path,
  ConstString demangled) const {
   // The base implementation does a simple contains comparision:
   if (path.empty())
 return false;
-  return demangled.GetStringRef().contains(path); 
+  return demangled.GetStringRef().contains(path);
 }
 
 DumpValueObjectOptions::DeclPrintingHelper Language::GetDeclPrintingHelper() {
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -490,16 +490,16 @@
   eLanguageTypeFortran18 = 0x002d,
   eLanguageTypeAda2005 = 0x002e,
   eLanguageTypeAda2012 = 0x002f,
+  eLanguageTypeMojo = 0x0033,
 
   // Vendor Extensions
   // Note: Language::GetNameForLanguageType
   // assumes these can be used as indexes into array language_names, and
   // Language::SetLanguageFromCString and Language::AsCString assume these can
   // be used as indexes into array g_languages.
-  eLanguageTypeMipsAssembler,   ///< Mips_Assembler.
+  eLanguageTypeMipsAssembler, ///< Mips_Assembler.
   // Mojo will move to the common list of languages once the DWARF committee
   // creates a language code for it.
-  eLanguageTypeMojo,
   eNumLanguageTypes
 };
 

[Lldb-commits] [PATCH] D153447: Creating a startDebugging reverse DAP request handler in lldb-vscode.

2023-06-21 Thread walter erquinigo via Phabricator via lldb-commits
wallace requested changes to this revision.
wallace added a comment.
This revision now requires changes to proceed.

Please write an entry about this in the documentation of lldb-vscode


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153447

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


[Lldb-commits] [PATCH] D153447: Creating a startDebugging reverse DAP request handler in lldb-vscode.

2023-06-21 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

pretty nice! Just a few nits, but other than that it's good to go




Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:1475
+  auto cmd = g_vsc.debugger.GetCommandInterpreter().AddMultiwordCommand(
+  "dap", nullptr);
+  cmd.AddCommand(

call it lldb-vscode instead of dap to have the same nomenclature all across



Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:1478
+  "startDebugging", _vsc.start_debugging_request_handler,
+  "Sends a startDebugging from the debug adapter to the client to start "
+  "child debug session of the same type as the caller.");





Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:1479
+  "Sends a startDebugging from the debug adapter to the client to start "
+  "child debug session of the same type as the caller.");
+




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153447

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


[Lldb-commits] [PATCH] D153073: [LLDB] Add DWARF definitions for the new Mojo language

2023-06-15 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
Herald added a reviewer: deadalnix.
Herald added a subscriber: hiraditya.
Herald added a project: All.
wallace requested review of this revision.
Herald added projects: LLDB, LLVM.
Herald added subscribers: llvm-commits, lldb-commits.

The new language Mojo recently received a proper DWARF code, which can be seen 
in https://dwarfstd.org/languages.html, and this patch adds the basic 
definitions for using this language in DWARF.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153073

Files:
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Target/Language.cpp
  llvm/include/llvm-c/DebugInfo.h
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/BinaryFormat/Dwarf.h
  llvm/lib/IR/DIBuilder.cpp

Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -138,7 +138,7 @@
 DICompileUnit::DebugNameTableKind NameTableKind, bool RangesBaseAddress,
 StringRef SysRoot, StringRef SDK) {
 
-  assert(((Lang <= dwarf::DW_LANG_Ada2012 && Lang >= dwarf::DW_LANG_C89) ||
+  assert(((Lang <= dwarf::DW_LANG_Mojo && Lang >= dwarf::DW_LANG_C89) ||
   (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
  "Invalid Language tag");
 
Index: llvm/include/llvm/BinaryFormat/Dwarf.h
===
--- llvm/include/llvm/BinaryFormat/Dwarf.h
+++ llvm/include/llvm/BinaryFormat/Dwarf.h
@@ -263,6 +263,7 @@
   case DW_LANG_Fortran18:
   case DW_LANG_Ada2005:
   case DW_LANG_Ada2012:
+  case DW_LANG_Mojo:
 result = false;
 break;
   }
@@ -329,6 +330,7 @@
   case DW_LANG_C17:
   case DW_LANG_Ada2005:
   case DW_LANG_Ada2012:
+  case DW_LANG_Mojo:
 result = false;
 break;
   }
@@ -393,6 +395,7 @@
   case DW_LANG_Fortran18:
   case DW_LANG_Ada2005:
   case DW_LANG_Ada2012:
+  case DW_LANG_Mojo:
 return false;
   }
   llvm_unreachable("Unknown language kind.");
Index: llvm/include/llvm/BinaryFormat/Dwarf.def
===
--- llvm/include/llvm/BinaryFormat/Dwarf.def
+++ llvm/include/llvm/BinaryFormat/Dwarf.def
@@ -925,6 +925,7 @@
 HANDLE_DW_LANG(0x002d, Fortran18, 0, 0, DWARF)
 HANDLE_DW_LANG(0x002e, Ada2005, 0, 0, DWARF)
 HANDLE_DW_LANG(0x002f, Ada2012, 0, 0, DWARF)
+HANDLE_DW_LANG(0x0033, Mojo, 0, 0, DWARF)
 // Vendor extensions:
 HANDLE_DW_LANG(0x8001, Mips_Assembler, std::nullopt, 0, MIPS)
 HANDLE_DW_LANG(0x8e57, GOOGLE_RenderScript, 0, 0, GOOGLE)
Index: llvm/include/llvm-c/DebugInfo.h
===
--- llvm/include/llvm-c/DebugInfo.h
+++ llvm/include/llvm-c/DebugInfo.h
@@ -125,6 +125,7 @@
   LLVMDWARFSourceLanguageFortran18,
   LLVMDWARFSourceLanguageAda2005,
   LLVMDWARFSourceLanguageAda2012,
+  LLVMDWARFSourceLanguageMojo,
   // Vendor extensions:
   LLVMDWARFSourceLanguageMips_Assembler,
   LLVMDWARFSourceLanguageGOOGLE_RenderScript,
Index: lldb/source/Target/Language.cpp
===
--- lldb/source/Target/Language.cpp
+++ lldb/source/Target/Language.cpp
@@ -209,9 +209,9 @@
 {"fortran18", eLanguageTypeFortran18},
 {"ada2005", eLanguageTypeAda2005},
 {"ada2012", eLanguageTypeAda2012},
+{"mojo", eLanguageTypeMojo},
 // Vendor Extensions
 {"assembler", eLanguageTypeMipsAssembler},
-{"mojo", eLanguageTypeMojo},
 // Now synonyms, in arbitrary order
 {"objc", eLanguageTypeObjC},
 {"objc++", eLanguageTypeObjC_plus_plus},
@@ -457,12 +457,12 @@
   return std::pair();
 }
 
-bool Language::DemangledNameContainsPath(llvm::StringRef path, 
+bool Language::DemangledNameContainsPath(llvm::StringRef path,
  ConstString demangled) const {
   // The base implementation does a simple contains comparision:
   if (path.empty())
 return false;
-  return demangled.GetStringRef().contains(path); 
+  return demangled.GetStringRef().contains(path);
 }
 
 DumpValueObjectOptions::DeclPrintingHelper Language::GetDeclPrintingHelper() {
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -490,16 +490,16 @@
   eLanguageTypeFortran18 = 0x002d,
   eLanguageTypeAda2005 = 0x002e,
   eLanguageTypeAda2012 = 0x002f,
+  eLanguageTypeMojo = 0x0033,
 
   // Vendor Extensions
   // Note: Language::GetNameForLanguageType
   // assumes these can be used as indexes into array language_names, and
   // Language::SetLanguageFromCString and Language::AsCString assume these can
   // be used as indexes into array g_languages.
-  eLanguageTypeMipsAssembler,   ///< Mips_Assembler.
+  eLanguageTypeMipsAssembler, ///< Mips_Assembler.
   // Mojo will move to the common list 

[Lldb-commits] [PATCH] D152326: [lldb][NFCI] DecodedThread::TraceItemStorage::error should own its own data

2023-06-06 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: JDevlieghere.

lgtm!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152326

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


[Lldb-commits] [PATCH] D151962: [lldb][NFCI] Change return type of REPL::GetSourceFileBasename

2023-06-01 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

LGTM. It also works with the mojo REPL.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151962

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


[Lldb-commits] [PATCH] D140630: [lldb-vscode] Add data breakpoint support

2023-05-26 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.

This seems reasonable to me and I'm accepting it to unblock this feature. When 
Greg gets back he should be able to provide some additional comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140630

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


[Lldb-commits] [PATCH] D151501: [LLDB] Explicitly declare constructor in `PersistentExpressionState`

2023-05-25 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.
Herald added subscribers: Michael137, JDevlieghere.

thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151501

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


[Lldb-commits] [PATCH] D150303: [LLDB] Add some declarations related to REPL support for mojo

2023-05-23 Thread walter erquinigo via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf237513cda8e: [LLDB] Add some declarations related to REPL 
support for mojo (authored by wallace).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150303

Files:
  lldb/include/lldb/Expression/ExpressionTypeSystemHelper.h
  lldb/include/lldb/Expression/ExpressionVariable.h
  lldb/include/lldb/Expression/REPL.h
  lldb/source/Expression/CMakeLists.txt
  lldb/source/Expression/ExpressionTypeSystemHelper.cpp
  lldb/source/Expression/ExpressionVariable.cpp
  lldb/source/Expression/REPL.cpp
  lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
  lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
  lldb/source/Plugins/REPL/Clang/ClangREPL.h

Index: lldb/source/Plugins/REPL/Clang/ClangREPL.h
===
--- lldb/source/Plugins/REPL/Clang/ClangREPL.h
+++ lldb/source/Plugins/REPL/Clang/ClangREPL.h
@@ -14,8 +14,11 @@
 namespace lldb_private {
 /// Implements a Clang-based REPL for C languages on top of LLDB's REPL
 /// framework.
-class ClangREPL : public REPL {
+class ClangREPL : public llvm::RTTIExtends {
 public:
+  // LLVM RTTI support
+  static char ID;
+
   ClangREPL(lldb::LanguageType language, Target );
 
   ~ClangREPL() override;
Index: lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
===
--- lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
+++ lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
@@ -15,8 +15,10 @@
 
 LLDB_PLUGIN_DEFINE(ClangREPL)
 
+char ClangREPL::ID;
+
 ClangREPL::ClangREPL(lldb::LanguageType language, Target )
-: REPL(eKindClang, target), m_language(language),
+: llvm::RTTIExtends(target), m_language(language),
   m_implicit_expr_result_regex("\\$[0-9]+") {}
 
 ClangREPL::~ClangREPL() = default;
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
@@ -72,11 +72,12 @@
ExecutionContext _ctx) override;
 
 private:
-  class ClangUtilityFunctionHelper : public ClangExpressionHelper {
+  class ClangUtilityFunctionHelper
+  : public llvm::RTTIExtends {
   public:
-ClangUtilityFunctionHelper() = default;
-
-~ClangUtilityFunctionHelper() override = default;
+// LLVM RTTI support
+static char ID;
 
 /// Return the object that the parser should use when resolving external
 /// values.  May be NULL if everything should be self-contained.
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
@@ -176,6 +176,8 @@
   }
 }
 
+char ClangUtilityFunction::ClangUtilityFunctionHelper::ID;
+
 void ClangUtilityFunction::ClangUtilityFunctionHelper::ResetDeclMap(
 ExecutionContext _ctx, bool keep_result_in_memory) {
   std::shared_ptr ast_importer;
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
@@ -51,13 +51,16 @@
 
   enum { kDefaultTimeout = 50u };
 
-  class ClangUserExpressionHelper : public ClangExpressionHelper {
+  class ClangUserExpressionHelper
+  : public llvm::RTTIExtends {
   public:
+// LLVM RTTI support
+static char ID;
+
 ClangUserExpressionHelper(Target , bool top_level)
 : m_target(target), m_top_level(top_level) {}
 
-~ClangUserExpressionHelper() override = default;
-
 /// Return the object that the parser should use when resolving external
 /// values.  May be NULL if everything should be self-contained.
 

[Lldb-commits] [PATCH] D150303: [LLDB] Add some declarations related to REPL support for mojo

2023-05-22 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 524449.
wallace added a comment.

nit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150303

Files:
  lldb/include/lldb/Expression/ExpressionTypeSystemHelper.h
  lldb/include/lldb/Expression/ExpressionVariable.h
  lldb/include/lldb/Expression/REPL.h
  lldb/source/Expression/CMakeLists.txt
  lldb/source/Expression/ExpressionTypeSystemHelper.cpp
  lldb/source/Expression/ExpressionVariable.cpp
  lldb/source/Expression/REPL.cpp
  lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
  lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
  lldb/source/Plugins/REPL/Clang/ClangREPL.h

Index: lldb/source/Plugins/REPL/Clang/ClangREPL.h
===
--- lldb/source/Plugins/REPL/Clang/ClangREPL.h
+++ lldb/source/Plugins/REPL/Clang/ClangREPL.h
@@ -14,8 +14,11 @@
 namespace lldb_private {
 /// Implements a Clang-based REPL for C languages on top of LLDB's REPL
 /// framework.
-class ClangREPL : public REPL {
+class ClangREPL : public llvm::RTTIExtends {
 public:
+  // LLVM RTTI support
+  static char ID;
+
   ClangREPL(lldb::LanguageType language, Target );
 
   ~ClangREPL() override;
Index: lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
===
--- lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
+++ lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
@@ -15,8 +15,10 @@
 
 LLDB_PLUGIN_DEFINE(ClangREPL)
 
+char ClangREPL::ID;
+
 ClangREPL::ClangREPL(lldb::LanguageType language, Target )
-: REPL(eKindClang, target), m_language(language),
+: llvm::RTTIExtends(target), m_language(language),
   m_implicit_expr_result_regex("\\$[0-9]+") {}
 
 ClangREPL::~ClangREPL() = default;
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
@@ -72,11 +72,12 @@
ExecutionContext _ctx) override;
 
 private:
-  class ClangUtilityFunctionHelper : public ClangExpressionHelper {
+  class ClangUtilityFunctionHelper
+  : public llvm::RTTIExtends {
   public:
-ClangUtilityFunctionHelper() = default;
-
-~ClangUtilityFunctionHelper() override = default;
+// LLVM RTTI support
+static char ID;
 
 /// Return the object that the parser should use when resolving external
 /// values.  May be NULL if everything should be self-contained.
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
@@ -176,6 +176,8 @@
   }
 }
 
+char ClangUtilityFunction::ClangUtilityFunctionHelper::ID;
+
 void ClangUtilityFunction::ClangUtilityFunctionHelper::ResetDeclMap(
 ExecutionContext _ctx, bool keep_result_in_memory) {
   std::shared_ptr ast_importer;
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
@@ -51,13 +51,16 @@
 
   enum { kDefaultTimeout = 50u };
 
-  class ClangUserExpressionHelper : public ClangExpressionHelper {
+  class ClangUserExpressionHelper
+  : public llvm::RTTIExtends {
   public:
+// LLVM RTTI support
+static char ID;
+
 ClangUserExpressionHelper(Target , bool top_level)
 : m_target(target), m_top_level(top_level) {}
 
-~ClangUserExpressionHelper() override = default;
-
 /// Return the object that the parser should use when resolving external
 /// values.  May be NULL if everything should be self-contained.
 ClangExpressionDeclMap *DeclMap() override {
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp

[Lldb-commits] [PATCH] D150303: [LLDB] Add some declarations related to REPL support for mojo

2023-05-22 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 524448.
wallace added a comment.

Use RTTIExtends


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150303

Files:
  lldb/include/lldb/Expression/ExpressionTypeSystemHelper.h
  lldb/include/lldb/Expression/ExpressionVariable.h
  lldb/include/lldb/Expression/REPL.h
  lldb/source/Expression/CMakeLists.txt
  lldb/source/Expression/ExpressionTypeSystemHelper.cpp
  lldb/source/Expression/ExpressionVariable.cpp
  lldb/source/Expression/REPL.cpp
  lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
  lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
  lldb/source/Plugins/REPL/Clang/ClangREPL.h

Index: lldb/source/Plugins/REPL/Clang/ClangREPL.h
===
--- lldb/source/Plugins/REPL/Clang/ClangREPL.h
+++ lldb/source/Plugins/REPL/Clang/ClangREPL.h
@@ -14,8 +14,11 @@
 namespace lldb_private {
 /// Implements a Clang-based REPL for C languages on top of LLDB's REPL
 /// framework.
-class ClangREPL : public REPL {
+class ClangREPL : public llvm::RTTIExtends {
 public:
+  // LLVM RTTI support
+  static char ID;
+
   ClangREPL(lldb::LanguageType language, Target );
 
   ~ClangREPL() override;
Index: lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
===
--- lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
+++ lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
@@ -15,8 +15,10 @@
 
 LLDB_PLUGIN_DEFINE(ClangREPL)
 
+char ClangREPL::ID;
+
 ClangREPL::ClangREPL(lldb::LanguageType language, Target )
-: REPL(eKindClang, target), m_language(language),
+: llvm::RTTIExtends(target), m_language(language),
   m_implicit_expr_result_regex("\\$[0-9]+") {}
 
 ClangREPL::~ClangREPL() = default;
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
@@ -72,11 +72,12 @@
ExecutionContext _ctx) override;
 
 private:
-  class ClangUtilityFunctionHelper : public ClangExpressionHelper {
+  class ClangUtilityFunctionHelper
+  : public llvm::RTTIExtends {
   public:
-ClangUtilityFunctionHelper() = default;
-
-~ClangUtilityFunctionHelper() override = default;
+// LLVM RTTI support
+static char ID;
 
 /// Return the object that the parser should use when resolving external
 /// values.  May be NULL if everything should be self-contained.
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
@@ -176,6 +176,8 @@
   }
 }
 
+char ClangUtilityFunction::ClangUtilityFunctionHelper::ID;
+
 void ClangUtilityFunction::ClangUtilityFunctionHelper::ResetDeclMap(
 ExecutionContext _ctx, bool keep_result_in_memory) {
   std::shared_ptr ast_importer;
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
@@ -51,13 +51,16 @@
 
   enum { kDefaultTimeout = 50u };
 
-  class ClangUserExpressionHelper : public ClangExpressionHelper {
+  class ClangUserExpressionHelper
+  : public llvm::RTTIExtends {
   public:
+// LLVM RTTI support
+static char ID;
+
 ClangUserExpressionHelper(Target , bool top_level)
 : m_target(target), m_top_level(top_level) {}
 
-~ClangUserExpressionHelper() override = default;
-
 /// Return the object that the parser should use when resolving external
 /// values.  May be NULL if everything should be self-contained.
 ClangExpressionDeclMap *DeclMap() override {
Index: 

[Lldb-commits] [PATCH] D150303: [LLDB] Add some declarations related to REPL support for mojo

2023-05-22 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

Sure, I can use it. I just didn't know it exists :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150303

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


[Lldb-commits] [PATCH] D150303: [LLDB] Add some declarations related to REPL support for mojo

2023-05-22 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 524398.
wallace added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150303

Files:
  lldb/include/lldb/Expression/ExpressionTypeSystemHelper.h
  lldb/include/lldb/Expression/ExpressionVariable.h
  lldb/include/lldb/Expression/REPL.h
  lldb/source/Expression/ExpressionVariable.cpp
  lldb/source/Expression/REPL.cpp
  lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
  lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
  lldb/source/Plugins/REPL/Clang/ClangREPL.h

Index: lldb/source/Plugins/REPL/Clang/ClangREPL.h
===
--- lldb/source/Plugins/REPL/Clang/ClangREPL.h
+++ lldb/source/Plugins/REPL/Clang/ClangREPL.h
@@ -15,6 +15,9 @@
 /// Implements a Clang-based REPL for C languages on top of LLDB's REPL
 /// framework.
 class ClangREPL : public REPL {
+  // LLVM RTTI support
+  static char ID;
+
 public:
   ClangREPL(lldb::LanguageType language, Target );
 
@@ -30,6 +33,9 @@
 
   static llvm::StringRef GetPluginNameStatic() { return "ClangREPL"; }
 
+  // LLVM casting support
+  bool isA(const void *ClassID) const override { return ClassID ==  }
+
 protected:
   Status DoInitialization() override;
 
Index: lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
===
--- lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
+++ lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
@@ -15,8 +15,10 @@
 
 LLDB_PLUGIN_DEFINE(ClangREPL)
 
+char ClangREPL::ID;
+
 ClangREPL::ClangREPL(lldb::LanguageType language, Target )
-: REPL(eKindClang, target), m_language(language),
+: REPL(target), m_language(language),
   m_implicit_expr_result_regex("\\$[0-9]+") {}
 
 ClangREPL::~ClangREPL() = default;
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
@@ -74,10 +74,6 @@
 private:
   class ClangUtilityFunctionHelper : public ClangExpressionHelper {
   public:
-ClangUtilityFunctionHelper() = default;
-
-~ClangUtilityFunctionHelper() override = default;
-
 /// Return the object that the parser should use when resolving external
 /// values.  May be NULL if everything should be self-contained.
 ClangExpressionDeclMap *DeclMap() override {
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
@@ -56,8 +56,6 @@
 ClangUserExpressionHelper(Target , bool top_level)
 : m_target(target), m_top_level(top_level) {}
 
-~ClangUserExpressionHelper() override = default;
-
 /// Return the object that the parser should use when resolving external
 /// values.  May be NULL if everything should be self-contained.
 ClangExpressionDeclMap *DeclMap() override {
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
@@ -32,14 +32,19 @@
 /// ClangPersistentVariable for more discussion.  Also provides an increasing,
 /// 0-based counter for naming result variables.
 class ClangPersistentVariables : public PersistentExpressionState {
+  // LLVM RTTI support
+  static char ID;
+
 public:
   ClangPersistentVariables(std::shared_ptr target_sp);
 
   ~ClangPersistentVariables() override = default;
 
-  // llvm casting support
-  static bool classof(const PersistentExpressionState *pv) {
-return pv->getKind() == PersistentExpressionState::eKindClang;
+  // LLVM casting support
+  bool isA(const void *ClassID) const override { return ClassID ==  }
+
+  static bool classof(const PersistentExpressionState *state) {
+return state->isA();
   }
 
   std::shared_ptr GetClangASTImporter();
Index: 

[Lldb-commits] [PATCH] D150470: [lldb-vscode] Make tests not wait for 'launch' process events if launch fails.

2023-05-22 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

makes sense


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150470

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


[Lldb-commits] [PATCH] D150303: [LLDB] Add some declarations related to REPL support for mojo

2023-05-10 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
Herald added a project: All.
wallace requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This simple diff declares some enum values needed to create a REPL for the mojo 
language.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150303

Files:
  lldb/include/lldb/Expression/ExpressionTypeSystemHelper.h
  lldb/include/lldb/Expression/ExpressionVariable.h
  lldb/include/lldb/Expression/REPL.h


Index: lldb/include/lldb/Expression/REPL.h
===
--- lldb/include/lldb/Expression/REPL.h
+++ lldb/include/lldb/Expression/REPL.h
@@ -21,7 +21,7 @@
 class REPL : public IOHandlerDelegate {
 public:
   // See TypeSystem.h for how to add subclasses to this.
-  enum LLVMCastKind { eKindClang, eKindSwift, eKindGo, kNumKinds };
+  enum LLVMCastKind { eKindClang, eKindSwift, eKindGo, eKindMojo, kNumKinds };
 
   LLVMCastKind getKind() const { return m_kind; }
 
Index: lldb/include/lldb/Expression/ExpressionVariable.h
===
--- lldb/include/lldb/Expression/ExpressionVariable.h
+++ lldb/include/lldb/Expression/ExpressionVariable.h
@@ -25,7 +25,7 @@
 : public std::enable_shared_from_this {
 public:
   // See TypeSystem.h for how to add subclasses to this.
-  enum LLVMCastKind { eKindClang, eKindSwift, eKindGo, kNumKinds };
+  enum LLVMCastKind { eKindClang, eKindSwift, eKindGo, eKindMojo, kNumKinds };
 
   LLVMCastKind getKind() const { return m_kind; }
 
@@ -203,7 +203,7 @@
 class PersistentExpressionState : public ExpressionVariableList {
 public:
   // See TypeSystem.h for how to add subclasses to this.
-  enum LLVMCastKind { eKindClang, eKindSwift, eKindGo, kNumKinds };
+  enum LLVMCastKind { eKindClang, eKindSwift, eKindGo, eKindMojo, kNumKinds };
 
   LLVMCastKind getKind() const { return m_kind; }
 
Index: lldb/include/lldb/Expression/ExpressionTypeSystemHelper.h
===
--- lldb/include/lldb/Expression/ExpressionTypeSystemHelper.h
+++ lldb/include/lldb/Expression/ExpressionTypeSystemHelper.h
@@ -29,6 +29,7 @@
 eKindClangHelper,
 eKindSwiftHelper,
 eKindGoHelper,
+eKindMojoHelper,
 kNumKinds
   };
 


Index: lldb/include/lldb/Expression/REPL.h
===
--- lldb/include/lldb/Expression/REPL.h
+++ lldb/include/lldb/Expression/REPL.h
@@ -21,7 +21,7 @@
 class REPL : public IOHandlerDelegate {
 public:
   // See TypeSystem.h for how to add subclasses to this.
-  enum LLVMCastKind { eKindClang, eKindSwift, eKindGo, kNumKinds };
+  enum LLVMCastKind { eKindClang, eKindSwift, eKindGo, eKindMojo, kNumKinds };
 
   LLVMCastKind getKind() const { return m_kind; }
 
Index: lldb/include/lldb/Expression/ExpressionVariable.h
===
--- lldb/include/lldb/Expression/ExpressionVariable.h
+++ lldb/include/lldb/Expression/ExpressionVariable.h
@@ -25,7 +25,7 @@
 : public std::enable_shared_from_this {
 public:
   // See TypeSystem.h for how to add subclasses to this.
-  enum LLVMCastKind { eKindClang, eKindSwift, eKindGo, kNumKinds };
+  enum LLVMCastKind { eKindClang, eKindSwift, eKindGo, eKindMojo, kNumKinds };
 
   LLVMCastKind getKind() const { return m_kind; }
 
@@ -203,7 +203,7 @@
 class PersistentExpressionState : public ExpressionVariableList {
 public:
   // See TypeSystem.h for how to add subclasses to this.
-  enum LLVMCastKind { eKindClang, eKindSwift, eKindGo, kNumKinds };
+  enum LLVMCastKind { eKindClang, eKindSwift, eKindGo, eKindMojo, kNumKinds };
 
   LLVMCastKind getKind() const { return m_kind; }
 
Index: lldb/include/lldb/Expression/ExpressionTypeSystemHelper.h
===
--- lldb/include/lldb/Expression/ExpressionTypeSystemHelper.h
+++ lldb/include/lldb/Expression/ExpressionTypeSystemHelper.h
@@ -29,6 +29,7 @@
 eKindClangHelper,
 eKindSwiftHelper,
 eKindGoHelper,
+eKindMojoHelper,
 kNumKinds
   };
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D149379: [lldb] Add tests for command removal

2023-05-09 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

The alias still works because it still holds a reference to it. I could add 
that as a test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149379

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


[Lldb-commits] [PATCH] D149719: [LLDB] Add a hook to notify REPLs that an expression was evaluated

2023-05-04 Thread walter erquinigo via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbfb7c99f3aea: [LLDB] Add a hook to notify REPLs that an 
expression was evaluated (authored by wallace).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149719

Files:
  lldb/include/lldb/Expression/REPL.h
  lldb/source/Expression/REPL.cpp


Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -342,9 +342,11 @@
expr_prefix, result_valobj_sp, error,
nullptr); // fixed expression
 
-  // CommandInterpreter  = debugger.GetCommandInterpreter();
-
-  if (process_sp && process_sp->IsAlive()) {
+  if (llvm::Error err = OnExpressionEvaluated(exe_ctx, code, expr_options,
+  execution_results,
+  result_valobj_sp, error)) {
+*error_sp << llvm::toString(std::move(err)) << "\n";
+  } else if (process_sp && process_sp->IsAlive()) {
 bool add_to_code = true;
 bool handled = false;
 if (result_valobj_sp) {
Index: lldb/include/lldb/Expression/REPL.h
===
--- lldb/include/lldb/Expression/REPL.h
+++ lldb/include/lldb/Expression/REPL.h
@@ -107,6 +107,24 @@
  CompletionRequest ) override;
 
 protected:
+  /// Method that can be optionally overriden by subclasses to get notified
+  /// whenever an expression has been evaluated. The params of this method
+  /// include the inputs and outputs of the expression evaluation.
+  ///
+  /// Note: meta commands that start with : are not covered by this method.
+  ///
+  /// \return
+  ///   An \a Error object that, if it is a failure, aborts the regular
+  ///   REPL expression result handling.
+  virtual llvm::Error
+  OnExpressionEvaluated(const ExecutionContext _ctx, llvm::StringRef code,
+const EvaluateExpressionOptions _options,
+lldb::ExpressionResults execution_results,
+const lldb::ValueObjectSP _valobj_sp,
+const Status ) {
+return llvm::Error::success();
+  }
+
   static int CalculateActualIndentation(const StringList );
 
   // Subclasses should override these functions to implement a functional REPL.


Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -342,9 +342,11 @@
expr_prefix, result_valobj_sp, error,
nullptr); // fixed expression
 
-  // CommandInterpreter  = debugger.GetCommandInterpreter();
-
-  if (process_sp && process_sp->IsAlive()) {
+  if (llvm::Error err = OnExpressionEvaluated(exe_ctx, code, expr_options,
+  execution_results,
+  result_valobj_sp, error)) {
+*error_sp << llvm::toString(std::move(err)) << "\n";
+  } else if (process_sp && process_sp->IsAlive()) {
 bool add_to_code = true;
 bool handled = false;
 if (result_valobj_sp) {
Index: lldb/include/lldb/Expression/REPL.h
===
--- lldb/include/lldb/Expression/REPL.h
+++ lldb/include/lldb/Expression/REPL.h
@@ -107,6 +107,24 @@
  CompletionRequest ) override;
 
 protected:
+  /// Method that can be optionally overriden by subclasses to get notified
+  /// whenever an expression has been evaluated. The params of this method
+  /// include the inputs and outputs of the expression evaluation.
+  ///
+  /// Note: meta commands that start with : are not covered by this method.
+  ///
+  /// \return
+  ///   An \a Error object that, if it is a failure, aborts the regular
+  ///   REPL expression result handling.
+  virtual llvm::Error
+  OnExpressionEvaluated(const ExecutionContext _ctx, llvm::StringRef code,
+const EvaluateExpressionOptions _options,
+lldb::ExpressionResults execution_results,
+const lldb::ValueObjectSP _valobj_sp,
+const Status ) {
+return llvm::Error::success();
+  }
+
   static int CalculateActualIndentation(const StringList );
 
   // Subclasses should override these functions to implement a functional REPL.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D149717: [lldb] Make some functions useful to REPLs public

2023-05-04 Thread walter erquinigo via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdb5f745a2bfc: [lldb] Make some functions useful to REPLs 
public (authored by wallace).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149717

Files:
  lldb/include/lldb/Core/Debugger.h


Index: lldb/include/lldb/Core/Debugger.h
===
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -500,6 +500,19 @@
   SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback,
  void *baton);
 
+  /// Manually start the global event handler thread. It is useful to plugins
+  /// that directly use the \a lldb_private namespace and want to use the
+  /// debugger's default event handler thread instead of defining their own.
+  bool StartEventHandlerThread();
+
+  /// Manually stop the debugger's default event handler.
+  void StopEventHandlerThread();
+
+  /// Force flushing the process's pending stdout and stderr to the debugger's
+  /// asynchronous stdout and stderr streams.
+  void FlushProcessOutput(Process , bool flush_stdout,
+  bool flush_stderr);
+
 protected:
   friend class CommandInterpreter;
   friend class REPL;
@@ -548,10 +561,6 @@
 
   void PrintProgress(const ProgressEventData );
 
-  bool StartEventHandlerThread();
-
-  void StopEventHandlerThread();
-
   void PushIOHandler(const lldb::IOHandlerSP _sp,
  bool cancel_top_handler = true);
 
@@ -587,8 +596,6 @@
 
   // Ensures two threads don't attempt to flush process output in parallel.
   std::mutex m_output_flush_mutex;
-  void FlushProcessOutput(Process , bool flush_stdout,
-  bool flush_stderr);
 
   SourceManager::SourceFileCache () {
 return m_source_file_cache;


Index: lldb/include/lldb/Core/Debugger.h
===
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -500,6 +500,19 @@
   SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback,
  void *baton);
 
+  /// Manually start the global event handler thread. It is useful to plugins
+  /// that directly use the \a lldb_private namespace and want to use the
+  /// debugger's default event handler thread instead of defining their own.
+  bool StartEventHandlerThread();
+
+  /// Manually stop the debugger's default event handler.
+  void StopEventHandlerThread();
+
+  /// Force flushing the process's pending stdout and stderr to the debugger's
+  /// asynchronous stdout and stderr streams.
+  void FlushProcessOutput(Process , bool flush_stdout,
+  bool flush_stderr);
+
 protected:
   friend class CommandInterpreter;
   friend class REPL;
@@ -548,10 +561,6 @@
 
   void PrintProgress(const ProgressEventData );
 
-  bool StartEventHandlerThread();
-
-  void StopEventHandlerThread();
-
   void PushIOHandler(const lldb::IOHandlerSP _sp,
  bool cancel_top_handler = true);
 
@@ -587,8 +596,6 @@
 
   // Ensures two threads don't attempt to flush process output in parallel.
   std::mutex m_output_flush_mutex;
-  void FlushProcessOutput(Process , bool flush_stdout,
-  bool flush_stderr);
 
   SourceManager::SourceFileCache () {
 return m_source_file_cache;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D149719: [LLDB] Add a hook to notify REPLs that an expression was evaluated

2023-05-04 Thread walter erquinigo via Phabricator via lldb-commits
wallace added inline comments.



Comment at: lldb/include/lldb/Expression/REPL.h:124
+const lldb::ValueObjectSP _valobj_sp,
+const Status ) {
+return llvm::Error::success();

bulbazord wrote:
> Do you still need the `Status` parameter?
that status is the result of the expression evaluation, so it's useful to have 
it here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149719

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


[Lldb-commits] [PATCH] D149717: [lldb] Make some functions useful to REPLs public

2023-05-04 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 519542.
wallace added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149717

Files:
  lldb/include/lldb/Core/Debugger.h


Index: lldb/include/lldb/Core/Debugger.h
===
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -500,6 +500,19 @@
   SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback,
  void *baton);
 
+  /// Manually start the global event handler thread. It is useful to plugins
+  /// that directly use the \a lldb_private namespace and want to use the
+  /// debugger's default event handler thread instead of defining their own.
+  bool StartEventHandlerThread();
+
+  /// Manually stop the debugger's default event handler.
+  void StopEventHandlerThread();
+
+  /// Force flushing the process's pending stdout and stderr to the debugger's
+  /// asynchronous stdout and stderr streams.
+  void FlushProcessOutput(Process , bool flush_stdout,
+  bool flush_stderr);
+
 protected:
   friend class CommandInterpreter;
   friend class REPL;
@@ -548,10 +561,6 @@
 
   void PrintProgress(const ProgressEventData );
 
-  bool StartEventHandlerThread();
-
-  void StopEventHandlerThread();
-
   void PushIOHandler(const lldb::IOHandlerSP _sp,
  bool cancel_top_handler = true);
 
@@ -587,8 +596,6 @@
 
   // Ensures two threads don't attempt to flush process output in parallel.
   std::mutex m_output_flush_mutex;
-  void FlushProcessOutput(Process , bool flush_stdout,
-  bool flush_stderr);
 
   SourceManager::SourceFileCache () {
 return m_source_file_cache;


Index: lldb/include/lldb/Core/Debugger.h
===
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -500,6 +500,19 @@
   SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback,
  void *baton);
 
+  /// Manually start the global event handler thread. It is useful to plugins
+  /// that directly use the \a lldb_private namespace and want to use the
+  /// debugger's default event handler thread instead of defining their own.
+  bool StartEventHandlerThread();
+
+  /// Manually stop the debugger's default event handler.
+  void StopEventHandlerThread();
+
+  /// Force flushing the process's pending stdout and stderr to the debugger's
+  /// asynchronous stdout and stderr streams.
+  void FlushProcessOutput(Process , bool flush_stdout,
+  bool flush_stderr);
+
 protected:
   friend class CommandInterpreter;
   friend class REPL;
@@ -548,10 +561,6 @@
 
   void PrintProgress(const ProgressEventData );
 
-  bool StartEventHandlerThread();
-
-  void StopEventHandlerThread();
-
   void PushIOHandler(const lldb::IOHandlerSP _sp,
  bool cancel_top_handler = true);
 
@@ -587,8 +596,6 @@
 
   // Ensures two threads don't attempt to flush process output in parallel.
   std::mutex m_output_flush_mutex;
-  void FlushProcessOutput(Process , bool flush_stdout,
-  bool flush_stderr);
 
   SourceManager::SourceFileCache () {
 return m_source_file_cache;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D149702: [DebugInfo] Add language code for the new Mojo language

2023-05-03 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 519338.
wallace added a comment.

add the language as a vendor extension


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149702

Files:
  lldb/docs/python_api_enums.rst
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Target/Language.cpp


Index: lldb/source/Target/Language.cpp
===
--- lldb/source/Target/Language.cpp
+++ lldb/source/Target/Language.cpp
@@ -211,6 +211,7 @@
 {"ada2012", eLanguageTypeAda2012},
 // Vendor Extensions
 {"assembler", eLanguageTypeMipsAssembler},
+{"mojo", eLanguageTypeMojo},
 // Now synonyms, in arbitrary order
 {"objc", eLanguageTypeObjC},
 {"objc++", eLanguageTypeObjC_plus_plus},
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -497,6 +497,9 @@
   // Language::SetLanguageFromCString and Language::AsCString assume these can
   // be used as indexes into array g_languages.
   eLanguageTypeMipsAssembler,   ///< Mips_Assembler.
+  // Mojo will move to the common list of languages once the DWARF committee
+  // creates a language code for it.
+  eLanguageTypeMojo,
   eNumLanguageTypes
 };
 
Index: lldb/docs/python_api_enums.rst
===
--- lldb/docs/python_api_enums.rst
+++ lldb/docs/python_api_enums.rst
@@ -731,6 +731,7 @@
 .. py:data:: eLanguageTypeFortran03
 .. py:data:: eLanguageTypeFortran08
 .. py:data:: eLanguageTypeMipsAssembler
+.. py:data:: eLanguageTypeMojo
 .. py:data:: eLanguageTypeExtRenderScript
 .. py:data:: eNumLanguageTypes
 


Index: lldb/source/Target/Language.cpp
===
--- lldb/source/Target/Language.cpp
+++ lldb/source/Target/Language.cpp
@@ -211,6 +211,7 @@
 {"ada2012", eLanguageTypeAda2012},
 // Vendor Extensions
 {"assembler", eLanguageTypeMipsAssembler},
+{"mojo", eLanguageTypeMojo},
 // Now synonyms, in arbitrary order
 {"objc", eLanguageTypeObjC},
 {"objc++", eLanguageTypeObjC_plus_plus},
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -497,6 +497,9 @@
   // Language::SetLanguageFromCString and Language::AsCString assume these can
   // be used as indexes into array g_languages.
   eLanguageTypeMipsAssembler,   ///< Mips_Assembler.
+  // Mojo will move to the common list of languages once the DWARF committee
+  // creates a language code for it.
+  eLanguageTypeMojo,
   eNumLanguageTypes
 };
 
Index: lldb/docs/python_api_enums.rst
===
--- lldb/docs/python_api_enums.rst
+++ lldb/docs/python_api_enums.rst
@@ -731,6 +731,7 @@
 .. py:data:: eLanguageTypeFortran03
 .. py:data:: eLanguageTypeFortran08
 .. py:data:: eLanguageTypeMipsAssembler
+.. py:data:: eLanguageTypeMojo
 .. py:data:: eLanguageTypeExtRenderScript
 .. py:data:: eNumLanguageTypes
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D149702: [DebugInfo] Add language code for the new Mojo language

2023-05-03 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

In D149702#4316747 , @aprantl wrote:

> You can also use a constant in the Vendor extension space, which might be 
> more appropriate until the languages sees adoption by a wider audience.

That sounds like a better idea. Thanks! I'll give it a try


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149702

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


[Lldb-commits] [PATCH] D149719: [LLDB] Add a hook to notify REPLs that an expression was evaluated

2023-05-03 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 519163.
wallace added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149719

Files:
  lldb/include/lldb/Expression/REPL.h
  lldb/source/Expression/REPL.cpp


Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -342,9 +342,11 @@
expr_prefix, result_valobj_sp, error,
nullptr); // fixed expression
 
-  // CommandInterpreter  = debugger.GetCommandInterpreter();
-
-  if (process_sp && process_sp->IsAlive()) {
+  if (llvm::Error err = OnExpressionEvaluated(exe_ctx, code, expr_options,
+  execution_results,
+  result_valobj_sp, error)) {
+*error_sp << llvm::toString(std::move(err)) << "\n";
+  } else if (process_sp && process_sp->IsAlive()) {
 bool add_to_code = true;
 bool handled = false;
 if (result_valobj_sp) {
Index: lldb/include/lldb/Expression/REPL.h
===
--- lldb/include/lldb/Expression/REPL.h
+++ lldb/include/lldb/Expression/REPL.h
@@ -107,6 +107,24 @@
  CompletionRequest ) override;
 
 protected:
+  /// Method that can be optionally overriden by subclasses to get notified
+  /// whenever an expression has been evaluated. The params of this method
+  /// include the inputs and outputs of the expression evaluation.
+  ///
+  /// Note: meta commands that start with : are not covered by this method.
+  ///
+  /// \return
+  ///   An \a Error object that, if it is a failure, aborts the regular
+  ///   REPL expression result handling.
+  virtual llvm::Error
+  OnExpressionEvaluated(const ExecutionContext _ctx, llvm::StringRef code,
+const EvaluateExpressionOptions _options,
+lldb::ExpressionResults execution_results,
+const lldb::ValueObjectSP _valobj_sp,
+const Status ) {
+return llvm::Error::success();
+  }
+
   static int CalculateActualIndentation(const StringList );
 
   // Subclasses should override these functions to implement a functional REPL.


Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -342,9 +342,11 @@
expr_prefix, result_valobj_sp, error,
nullptr); // fixed expression
 
-  // CommandInterpreter  = debugger.GetCommandInterpreter();
-
-  if (process_sp && process_sp->IsAlive()) {
+  if (llvm::Error err = OnExpressionEvaluated(exe_ctx, code, expr_options,
+  execution_results,
+  result_valobj_sp, error)) {
+*error_sp << llvm::toString(std::move(err)) << "\n";
+  } else if (process_sp && process_sp->IsAlive()) {
 bool add_to_code = true;
 bool handled = false;
 if (result_valobj_sp) {
Index: lldb/include/lldb/Expression/REPL.h
===
--- lldb/include/lldb/Expression/REPL.h
+++ lldb/include/lldb/Expression/REPL.h
@@ -107,6 +107,24 @@
  CompletionRequest ) override;
 
 protected:
+  /// Method that can be optionally overriden by subclasses to get notified
+  /// whenever an expression has been evaluated. The params of this method
+  /// include the inputs and outputs of the expression evaluation.
+  ///
+  /// Note: meta commands that start with : are not covered by this method.
+  ///
+  /// \return
+  ///   An \a Error object that, if it is a failure, aborts the regular
+  ///   REPL expression result handling.
+  virtual llvm::Error
+  OnExpressionEvaluated(const ExecutionContext _ctx, llvm::StringRef code,
+const EvaluateExpressionOptions _options,
+lldb::ExpressionResults execution_results,
+const lldb::ValueObjectSP _valobj_sp,
+const Status ) {
+return llvm::Error::success();
+  }
+
   static int CalculateActualIndentation(const StringList );
 
   // Subclasses should override these functions to implement a functional REPL.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D149717: [lldb] Make some functions useful to REPLs public

2023-05-03 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 519141.
wallace added a comment.

address comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149717

Files:
  lldb/include/lldb/Core/Debugger.h


Index: lldb/include/lldb/Core/Debugger.h
===
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -500,6 +500,20 @@
   SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback,
  void *baton);
 
+  /// Manually start the global event handler thread. It is useful to plugins
+  /// that directly use the \a lldb_private namespace and want to use the
+  /// default LLDB event handler thread instead of defining their own.
+  bool StartEventHandlerThread();
+
+  /// Stop the global event handler thread. It should only be used by programs
+  /// that manually invoked \a Debugger::StartEventHandlerThread().
+  void StopEventHandlerThread();
+
+  /// Force flushing the process's pending stdout and stderr to the debuggers'
+  /// asynchronous stdout and stderr streams.
+  void FlushProcessOutput(Process , bool flush_stdout,
+  bool flush_stderr);
+
 protected:
   friend class CommandInterpreter;
   friend class REPL;
@@ -548,10 +562,6 @@
 
   void PrintProgress(const ProgressEventData );
 
-  bool StartEventHandlerThread();
-
-  void StopEventHandlerThread();
-
   void PushIOHandler(const lldb::IOHandlerSP _sp,
  bool cancel_top_handler = true);
 
@@ -587,8 +597,6 @@
 
   // Ensures two threads don't attempt to flush process output in parallel.
   std::mutex m_output_flush_mutex;
-  void FlushProcessOutput(Process , bool flush_stdout,
-  bool flush_stderr);
 
   SourceManager::SourceFileCache () {
 return m_source_file_cache;


Index: lldb/include/lldb/Core/Debugger.h
===
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -500,6 +500,20 @@
   SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback,
  void *baton);
 
+  /// Manually start the global event handler thread. It is useful to plugins
+  /// that directly use the \a lldb_private namespace and want to use the
+  /// default LLDB event handler thread instead of defining their own.
+  bool StartEventHandlerThread();
+
+  /// Stop the global event handler thread. It should only be used by programs
+  /// that manually invoked \a Debugger::StartEventHandlerThread().
+  void StopEventHandlerThread();
+
+  /// Force flushing the process's pending stdout and stderr to the debuggers'
+  /// asynchronous stdout and stderr streams.
+  void FlushProcessOutput(Process , bool flush_stdout,
+  bool flush_stderr);
+
 protected:
   friend class CommandInterpreter;
   friend class REPL;
@@ -548,10 +562,6 @@
 
   void PrintProgress(const ProgressEventData );
 
-  bool StartEventHandlerThread();
-
-  void StopEventHandlerThread();
-
   void PushIOHandler(const lldb::IOHandlerSP _sp,
  bool cancel_top_handler = true);
 
@@ -587,8 +597,6 @@
 
   // Ensures two threads don't attempt to flush process output in parallel.
   std::mutex m_output_flush_mutex;
-  void FlushProcessOutput(Process , bool flush_stdout,
-  bool flush_stderr);
 
   SourceManager::SourceFileCache () {
 return m_source_file_cache;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D149717: [lldb] Make some functions useful to REPLs public

2023-05-03 Thread walter erquinigo via Phabricator via lldb-commits
wallace added inline comments.



Comment at: lldb/include/lldb/Core/Debugger.h:503-504
 
+  /// Manually start the global event handler thread. It should be used by
+  /// programs that use LLDB as a library.
+  bool StartEventHandlerThread();

bulbazord wrote:
> There are program that use LLDB as a library but go through the SBAPI instead 
> of lldb_private. Could you update this comment to be more specific about the 
> intentions here? I assume you mean things like plugins.
sure


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149717

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


[Lldb-commits] [PATCH] D149719: [LLDB] Add a hook to notify REPLs that an expression was evaluated

2023-05-03 Thread walter erquinigo via Phabricator via lldb-commits
wallace added inline comments.



Comment at: lldb/include/lldb/Expression/REPL.h:115-120
+  virtual void
+  OnExpressionEvaluated(const ExecutionContext _ctx, llvm::StringRef code,
+const EvaluateExpressionOptions _options,
+lldb::ExpressionResults execution_results,
+const lldb::ValueObjectSP _valobj_sp,
+const Status ) {}

bulbazord wrote:
> Why not return a `Status` object instead of having the return type be `void`? 
> Or instead of `Status` you could use `llvm::Error` so we are forced to check 
> it.
my initial idea was to make this a simple observer, but a llvm::Error is 
probably more generic. I'll do that


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149719

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


[Lldb-commits] [PATCH] D149719: [LLDB] Add a hook to notify REPLs that an expression was evaluated

2023-05-02 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
Herald added a project: All.
wallace requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

REPL implementations don't have an easy way to know that an expression has been 
evaluated, so I'm adding a simple function for that. In the future we can add 
another hook for meta commands.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149719

Files:
  lldb/include/lldb/Expression/REPL.h
  lldb/source/Expression/REPL.cpp


Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -342,7 +342,8 @@
expr_prefix, result_valobj_sp, error,
nullptr); // fixed expression
 
-  // CommandInterpreter  = debugger.GetCommandInterpreter();
+  OnExpressionEvaluated(exe_ctx, code, expr_options, execution_results,
+result_valobj_sp, error);
 
   if (process_sp && process_sp->IsAlive()) {
 bool add_to_code = true;
Index: lldb/include/lldb/Expression/REPL.h
===
--- lldb/include/lldb/Expression/REPL.h
+++ lldb/include/lldb/Expression/REPL.h
@@ -107,6 +107,18 @@
  CompletionRequest ) override;
 
 protected:
+  /// Method that can be optionally overriden by subclasses to get notified
+  /// whenever an expression has been evaluated. The params of this method
+  /// include the inputs and outputs of the expression evaluation.
+  ///
+  /// Note: meta commands that start with : are not included by this method.
+  virtual void
+  OnExpressionEvaluated(const ExecutionContext _ctx, llvm::StringRef code,
+const EvaluateExpressionOptions _options,
+lldb::ExpressionResults execution_results,
+const lldb::ValueObjectSP _valobj_sp,
+const Status ) {}
+
   static int CalculateActualIndentation(const StringList );
 
   // Subclasses should override these functions to implement a functional REPL.


Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -342,7 +342,8 @@
expr_prefix, result_valobj_sp, error,
nullptr); // fixed expression
 
-  // CommandInterpreter  = debugger.GetCommandInterpreter();
+  OnExpressionEvaluated(exe_ctx, code, expr_options, execution_results,
+result_valobj_sp, error);
 
   if (process_sp && process_sp->IsAlive()) {
 bool add_to_code = true;
Index: lldb/include/lldb/Expression/REPL.h
===
--- lldb/include/lldb/Expression/REPL.h
+++ lldb/include/lldb/Expression/REPL.h
@@ -107,6 +107,18 @@
  CompletionRequest ) override;
 
 protected:
+  /// Method that can be optionally overriden by subclasses to get notified
+  /// whenever an expression has been evaluated. The params of this method
+  /// include the inputs and outputs of the expression evaluation.
+  ///
+  /// Note: meta commands that start with : are not included by this method.
+  virtual void
+  OnExpressionEvaluated(const ExecutionContext _ctx, llvm::StringRef code,
+const EvaluateExpressionOptions _options,
+lldb::ExpressionResults execution_results,
+const lldb::ValueObjectSP _valobj_sp,
+const Status ) {}
+
   static int CalculateActualIndentation(const StringList );
 
   // Subclasses should override these functions to implement a functional REPL.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D149717: [lldb] Make some functions useful to REPLs public

2023-05-02 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
Herald added a project: All.
wallace requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

`StartEventHandlerThread` and `StopEventHandlerThread` are available to the 
SwiftREPL even though they are protected because SwiftREPL is a friend class of 
Debugger. I'm developing my own REPL and having access to these functions, 
including `FlushProcessOutput`, is desirable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149717

Files:
  lldb/include/lldb/Core/Debugger.h


Index: lldb/include/lldb/Core/Debugger.h
===
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -500,6 +500,19 @@
   SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback,
  void *baton);
 
+  /// Manually start the global event handler thread. It should be used by
+  /// programs that use LLDB as a library.
+  bool StartEventHandlerThread();
+
+  /// Stop the global event handler thread. It should only be used by programs
+  /// that manually invoked \a Debugger::StartEventHandlerThread().
+  void StopEventHandlerThread();
+
+  /// Force flushing the process's pending stdout and stderr to the debuggers'
+  /// asynchronous stdout and stderr streams.
+  void FlushProcessOutput(Process , bool flush_stdout,
+  bool flush_stderr);
+
 protected:
   friend class CommandInterpreter;
   friend class REPL;
@@ -548,10 +561,6 @@
 
   void PrintProgress(const ProgressEventData );
 
-  bool StartEventHandlerThread();
-
-  void StopEventHandlerThread();
-
   void PushIOHandler(const lldb::IOHandlerSP _sp,
  bool cancel_top_handler = true);
 
@@ -587,8 +596,6 @@
 
   // Ensures two threads don't attempt to flush process output in parallel.
   std::mutex m_output_flush_mutex;
-  void FlushProcessOutput(Process , bool flush_stdout,
-  bool flush_stderr);
 
   SourceManager::SourceFileCache () {
 return m_source_file_cache;


Index: lldb/include/lldb/Core/Debugger.h
===
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -500,6 +500,19 @@
   SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback,
  void *baton);
 
+  /// Manually start the global event handler thread. It should be used by
+  /// programs that use LLDB as a library.
+  bool StartEventHandlerThread();
+
+  /// Stop the global event handler thread. It should only be used by programs
+  /// that manually invoked \a Debugger::StartEventHandlerThread().
+  void StopEventHandlerThread();
+
+  /// Force flushing the process's pending stdout and stderr to the debuggers'
+  /// asynchronous stdout and stderr streams.
+  void FlushProcessOutput(Process , bool flush_stdout,
+  bool flush_stderr);
+
 protected:
   friend class CommandInterpreter;
   friend class REPL;
@@ -548,10 +561,6 @@
 
   void PrintProgress(const ProgressEventData );
 
-  bool StartEventHandlerThread();
-
-  void StopEventHandlerThread();
-
   void PushIOHandler(const lldb::IOHandlerSP _sp,
  bool cancel_top_handler = true);
 
@@ -587,8 +596,6 @@
 
   // Ensures two threads don't attempt to flush process output in parallel.
   std::mutex m_output_flush_mutex;
-  void FlushProcessOutput(Process , bool flush_stdout,
-  bool flush_stderr);
 
   SourceManager::SourceFileCache () {
 return m_source_file_cache;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D149702: [DebugInfo] Add language code for the new Mojo language

2023-05-02 Thread walter erquinigo via Phabricator via lldb-commits
wallace added inline comments.



Comment at: lldb/include/lldb/lldb-enumerations.h:493
   eLanguageTypeAda2012 = 0x002f,
+  eLanguageTypeMojo = 0x0030,
 

aprantl wrote:
> bulbazord wrote:
> > These values correspond to DWARF5's official language codes and `0x0030` is 
> > technically already taken. LLDB just hasn't been updated yet. I don't think 
> > this should necessarily block this patch but this value will need to be 
> > changed at some point.
> > 
> > See: https://dwarfstd.org/languages.html
> Registering a new language with the DWARF committee is a pretty quick process 
> nowadays. Please do that before taking a constant in the reserved range.
Thanks for the information. I'll do so then :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149702

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


[Lldb-commits] [PATCH] D149702: [DebugInfo] Add language code for the new Mojo language

2023-05-02 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
Herald added a reviewer: deadalnix.
Herald added a subscriber: hiraditya.
Herald added a project: All.
wallace requested review of this revision.
Herald added projects: LLDB, LLVM.
Herald added subscribers: llvm-commits, lldb-commits.

Modular just announced a new language called Mojo. This patch adds the 
corresponding language code that will ease development and sharing of its LLDB 
language plug-in.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149702

Files:
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Target/Language.cpp
  llvm/include/llvm-c/DebugInfo.h
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/BinaryFormat/Dwarf.h
  llvm/lib/IR/DIBuilder.cpp


Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -150,7 +150,7 @@
 DICompileUnit::DebugNameTableKind NameTableKind, bool RangesBaseAddress,
 StringRef SysRoot, StringRef SDK) {
 
-  assert(((Lang <= dwarf::DW_LANG_Ada2012 && Lang >= dwarf::DW_LANG_C89) ||
+  assert(((Lang <= dwarf::DW_LANG_Mojo && Lang >= dwarf::DW_LANG_C89) ||
   (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) 
&&
  "Invalid Language tag");
 
Index: llvm/include/llvm/BinaryFormat/Dwarf.h
===
--- llvm/include/llvm/BinaryFormat/Dwarf.h
+++ llvm/include/llvm/BinaryFormat/Dwarf.h
@@ -263,6 +263,7 @@
   case DW_LANG_Fortran18:
   case DW_LANG_Ada2005:
   case DW_LANG_Ada2012:
+  case DW_LANG_Mojo:
 result = false;
 break;
   }
@@ -329,6 +330,7 @@
   case DW_LANG_C17:
   case DW_LANG_Ada2005:
   case DW_LANG_Ada2012:
+  case DW_LANG_Mojo:
 result = false;
 break;
   }
@@ -393,6 +395,7 @@
   case DW_LANG_Fortran18:
   case DW_LANG_Ada2005:
   case DW_LANG_Ada2012:
+  case DW_LANG_Mojo:
 return false;
   }
   llvm_unreachable("Unknown language kind.");
Index: llvm/include/llvm/BinaryFormat/Dwarf.def
===
--- llvm/include/llvm/BinaryFormat/Dwarf.def
+++ llvm/include/llvm/BinaryFormat/Dwarf.def
@@ -925,6 +925,7 @@
 HANDLE_DW_LANG(0x002d, Fortran18, 0, 0, DWARF)
 HANDLE_DW_LANG(0x002e, Ada2005, 0, 0, DWARF)
 HANDLE_DW_LANG(0x002f, Ada2012, 0, 0, DWARF)
+HANDLE_DW_LANG(0x0030, Mojo, 0, 0, DWARF)
 // Vendor extensions:
 HANDLE_DW_LANG(0x8001, Mips_Assembler, std::nullopt, 0, MIPS)
 HANDLE_DW_LANG(0x8e57, GOOGLE_RenderScript, 0, 0, GOOGLE)
Index: llvm/include/llvm-c/DebugInfo.h
===
--- llvm/include/llvm-c/DebugInfo.h
+++ llvm/include/llvm-c/DebugInfo.h
@@ -125,6 +125,7 @@
   LLVMDWARFSourceLanguageFortran18,
   LLVMDWARFSourceLanguageAda2005,
   LLVMDWARFSourceLanguageAda2012,
+  LLVMDWARFSourceLanguageMojo,
   // Vendor extensions:
   LLVMDWARFSourceLanguageMips_Assembler,
   LLVMDWARFSourceLanguageGOOGLE_RenderScript,
Index: lldb/source/Target/Language.cpp
===
--- lldb/source/Target/Language.cpp
+++ lldb/source/Target/Language.cpp
@@ -209,6 +209,7 @@
 {"fortran18", eLanguageTypeFortran18},
 {"ada2005", eLanguageTypeAda2005},
 {"ada2012", eLanguageTypeAda2012},
+{"mojo", eLanguageTypeMojo},
 // Vendor Extensions
 {"assembler", eLanguageTypeMipsAssembler},
 // Now synonyms, in arbitrary order
@@ -463,7 +464,7 @@
   // The base implementation does a simple contains comparision:
   if (path.empty())
 return false;
-  return demangled.GetStringRef().contains(path);  
   
+  return demangled.GetStringRef().contains(path); 
 }
 
 DumpValueObjectOptions::DeclPrintingHelper Language::GetDeclPrintingHelper() {
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -490,6 +490,7 @@
   eLanguageTypeFortran18 = 0x002d,
   eLanguageTypeAda2005 = 0x002e,
   eLanguageTypeAda2012 = 0x002f,
+  eLanguageTypeMojo = 0x0030,
 
   // Vendor Extensions
   // Note: Language::GetNameForLanguageType


Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -150,7 +150,7 @@
 DICompileUnit::DebugNameTableKind NameTableKind, bool RangesBaseAddress,
 StringRef SysRoot, StringRef SDK) {
 
-  assert(((Lang <= dwarf::DW_LANG_Ada2012 && Lang >= dwarf::DW_LANG_C89) ||
+  assert(((Lang <= dwarf::DW_LANG_Mojo && Lang >= dwarf::DW_LANG_C89) ||
   (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
  "Invalid Language tag");
 
Index: llvm/include/llvm/BinaryFormat/Dwarf.h
===
--- 

[Lldb-commits] [PATCH] D147831: [lldb-vscode] Implement RestartRequest

2023-05-01 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

lgtm!




Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:1983
+  g_vsc.debugger.SetAsync(true);
+  LaunchProcess(*g_vsc.last_launch_or_attach_request);
+

jgorbe wrote:
> labath wrote:
> > I have no idea if that's a good idea or not, but I'm wondering if, instead 
> > of from the last attach request, we should be taking the arguments from 
> > lldb. So that if the user say changes the `target.run-args` setting, then 
> > the new restart request will take that into account...
> I think the intended way to allow the user to modify the configuration is to 
> use the optional `arguments` field in `RestartRequest`, which the client can 
> use to send the latest version of the config.
> 
> https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Restart
> 
> > ```
> > interface RestartRequest extends Request {
> >   command: 'restart';
> > 
> >   arguments?: RestartArguments;
> > }
> > ```
> > Arguments for restart request.
> > 
> > ```
> > interface RestartArguments {
> >   /**
> >* The latest version of the `launch` or `attach` configuration.
> >*/
> >   arguments?: LaunchRequestArguments | AttachRequestArguments;
> > }
> > ```
> 
> We can check if the restart request has `arguments` and only used the saved 
> config if that's not the case. What do you think?
> 
> @wallace any opinions here? Is this kind of lldb state manipulation via 
> console commands something that is expected to work correctly in lldb-vscode?
i think it's better to reuse the same arguments that the user passed using the 
vscode interface. Modifying them in the command line might seems 
counterintuitive.


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

https://reviews.llvm.org/D147831

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


[Lldb-commits] [PATCH] D147831: [lldb-vscode] Implement RestartRequest

2023-04-28 Thread walter erquinigo via Phabricator via lldb-commits
wallace added inline comments.



Comment at: lldb/source/API/SBProcess.cpp:772
 
-  return (event.GetBroadcasterClass() == SBProcess::GetBroadcasterClass()) &&
- !EventIsStructuredDataEvent(event);
+  return Process::ProcessEventData::GetEventDataFromEvent(event.get()) !=
+ nullptr;

+1



Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:1976
+if (state != lldb::eStateConnected) {
+  process.Kill();
+}

Kill actually detaches if lldb originally attached to the debuggee. The actual 
implementation says

```
  /// Kills the process and shuts down all threads that were spawned to track
  /// and monitor the process.
  ///
  /// This function is not meant to be overridden by Process subclasses.
  ///
  /// \param[in] force_kill
  /// Whether lldb should force a kill (instead of a detach) from
  /// the inferior process.  Normally if lldb launched a binary and
  /// Destory is called, lldb kills it.  If lldb attached to a
  /// running process and Destory is called, lldb detaches.  If
  /// this behavior needs to be over-ridden, this is the bool that
  /// can be used.
  ///
  /// \return
  /// Returns an error object.
  Status Destroy(bool force_kill);
```
You could have the restart command reattach to the process instead of failing 
if the user originally attached. 

What do you think of this?


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

https://reviews.llvm.org/D147831

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


[Lldb-commits] [PATCH] D149312: [lldb] Create a way to force remove commands

2023-04-27 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

@jingham, in my use case, I'm exposing a minified LLDB client remotely, so the 
user won't have access to script command nor the SB API.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149312

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


[Lldb-commits] [PATCH] D149312: [lldb] Create a way to force remove commands

2023-04-27 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

-> https://reviews.llvm.org/D149379


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149312

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


[Lldb-commits] [PATCH] D149379: [lldb] Add tests for command removal

2023-04-27 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
wallace added a reviewer: jingham.
Herald added a project: All.
wallace requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This adds some tests for removing lldb commands, user command and aliases. I've 
done in the SB API side for comleteness of this features. Besides that, I found 
a bug in the creation of the DummyCommand used in the test file: they were 
being allocated in the stack but they should have been allocated in the heap 
because CommandPluginInterfaceImplementation ends up owning the pointer passed 
to it, which is internally managed by a shared_ptr.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149379

Files:
  lldb/include/lldb/API/SBCommandInterpreter.h
  lldb/source/API/SBCommandInterpreter.cpp
  lldb/unittests/API/SBCommandInterpreterTest.cpp

Index: lldb/unittests/API/SBCommandInterpreterTest.cpp
===
--- lldb/unittests/API/SBCommandInterpreterTest.cpp
+++ lldb/unittests/API/SBCommandInterpreterTest.cpp
@@ -44,15 +44,41 @@
   std::string m_message;
 };
 
+TEST_F(SBCommandInterpreterTest, RemoveCommandsAndAliases) {
+  // We first test removing non-existent commands
+  EXPECT_FALSE(m_interp.RemoveUserCommand("non-existent-user-command"));
+  EXPECT_FALSE(m_interp.RemoveCommand("non-existent-command"));
+  EXPECT_FALSE(m_interp.RemoveAlias("non-existent-alias"));
+
+  // We now test removing a built-in command
+  EXPECT_TRUE(m_interp.CommandExists("target"));
+  EXPECT_FALSE(m_interp.RemoveCommand("target"));
+  // Built-in commands need to be force removed.
+  EXPECT_TRUE(m_interp.RemoveCommand("target", /*force=*/true));
+  EXPECT_FALSE(m_interp.CommandExists("target"));
+
+  // Finally we test with a user defined command
+  m_interp.AddCommand("dummy", new DummyCommand("A dummy command"),
+  /*help=*/nullptr);
+  EXPECT_TRUE(m_interp.UserCommandExists("dummy"));
+  EXPECT_TRUE(m_interp.RemoveUserCommand("dummy"));
+  EXPECT_FALSE(m_interp.UserCommandExists("dummy"));
+
+  // Now we remove an alias
+  EXPECT_TRUE(m_interp.AliasExists("b"));
+  EXPECT_TRUE(m_interp.RemoveAlias("b"));
+  EXPECT_FALSE(m_interp.AliasExists("b"));
+}
+
 TEST_F(SBCommandInterpreterTest, SingleWordCommand) {
   // We first test a command without autorepeat
-  DummyCommand dummy("It worked");
-  m_interp.AddCommand("dummy", , /*help=*/nullptr);
+  m_interp.AddCommand("dummy", new DummyCommand("Dummy command"),
+  /*help=*/nullptr);
   {
 SBCommandReturnObject result;
 m_interp.HandleCommand("dummy", result, /*add_to_history=*/true);
 EXPECT_TRUE(result.Succeeded());
-EXPECT_STREQ(result.GetOutput(), "It worked\n");
+EXPECT_STREQ(result.GetOutput(), "Dummy command\n");
   }
   {
 SBCommandReturnObject result;
@@ -62,34 +88,36 @@
   }
 
   // Now we test a command with autorepeat
-  m_interp.AddCommand("dummy_with_autorepeat", , /*help=*/nullptr,
+  m_interp.AddCommand("dummy_with_autorepeat",
+  new DummyCommand("Command with autorepeat"),
+  /*help=*/nullptr,
   /*syntax=*/nullptr, /*auto_repeat_command=*/nullptr);
   {
 SBCommandReturnObject result;
 m_interp.HandleCommand("dummy_with_autorepeat", result,
/*add_to_history=*/true);
 EXPECT_TRUE(result.Succeeded());
-EXPECT_STREQ(result.GetOutput(), "It worked\n");
+EXPECT_STREQ(result.GetOutput(), "Command with autorepeat\n");
   }
   {
 SBCommandReturnObject result;
 m_interp.HandleCommand("", result);
 EXPECT_TRUE(result.Succeeded());
-EXPECT_STREQ(result.GetOutput(), "It worked\n");
+EXPECT_STREQ(result.GetOutput(), "Command with autorepeat\n");
   }
 }
 
 TEST_F(SBCommandInterpreterTest, MultiWordCommand) {
   auto command = m_interp.AddMultiwordCommand("multicommand", /*help=*/nullptr);
   // We first test a subcommand without autorepeat
-  DummyCommand subcommand("It worked again");
-  command.AddCommand("subcommand", , /*help=*/nullptr);
+  command.AddCommand("subcommand", new DummyCommand("Dummy command"),
+ /*help=*/nullptr);
   {
 SBCommandReturnObject result;
 m_interp.HandleCommand("multicommand subcommand", result,
/*add_to_history=*/true);
 EXPECT_TRUE(result.Succeeded());
-EXPECT_STREQ(result.GetOutput(), "It worked again\n");
+EXPECT_STREQ(result.GetOutput(), "Dummy command\n");
   }
   {
 SBCommandReturnObject result;
@@ -99,7 +127,8 @@
   }
 
   // We first test a subcommand with autorepeat
-  command.AddCommand("subcommand_with_autorepeat", ,
+  command.AddCommand("subcommand_with_autorepeat",
+ new DummyCommand("Dummy command with autorepeat"),
  /*help=*/nullptr, /*syntax=*/nullptr,
  /*auto_repeat_command=*/nullptr);
   {
@@ -107,19 +136,19 @@
 

[Lldb-commits] [PATCH] D149312: [lldb] Create a way to force remove commands

2023-04-27 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

Sure


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149312

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


[Lldb-commits] [PATCH] D149312: [lldb] Create a way to force remove commands

2023-04-26 Thread walter erquinigo via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb1465cd49efc: [lldb] Create a way to force remove commands 
(authored by wallace).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149312

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/Interpreter/CommandInterpreter.cpp


Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1374,11 +1374,12 @@
   return false;
 }
 
-bool CommandInterpreter::RemoveCommand(llvm::StringRef cmd) {
+bool CommandInterpreter::RemoveCommand(llvm::StringRef cmd, bool force) {
   auto pos = m_command_dict.find(std::string(cmd));
   if (pos != m_command_dict.end()) {
-if (pos->second->IsRemovable()) {
-  // Only regular expression objects or python commands are removable
+if (force || pos->second->IsRemovable()) {
+  // Only regular expression objects or python commands are removable under
+  // normal circumstances.
   m_command_dict.erase(pos);
   return true;
 }
Index: lldb/include/lldb/Interpreter/CommandInterpreter.h
===
--- lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -324,8 +324,9 @@
  lldb::CommandObjectSP _obj_sp,
  llvm::StringRef args_string = llvm::StringRef());
 
-  // Remove a command if it is removable (python or regex command)
-  bool RemoveCommand(llvm::StringRef cmd);
+  /// Remove a command if it is removable (python or regex command). If \b 
force
+  /// is provided, the command is removed regardless of its removable status.
+  bool RemoveCommand(llvm::StringRef cmd, bool force = false);
 
   bool RemoveAlias(llvm::StringRef alias_name);
 


Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1374,11 +1374,12 @@
   return false;
 }
 
-bool CommandInterpreter::RemoveCommand(llvm::StringRef cmd) {
+bool CommandInterpreter::RemoveCommand(llvm::StringRef cmd, bool force) {
   auto pos = m_command_dict.find(std::string(cmd));
   if (pos != m_command_dict.end()) {
-if (pos->second->IsRemovable()) {
-  // Only regular expression objects or python commands are removable
+if (force || pos->second->IsRemovable()) {
+  // Only regular expression objects or python commands are removable under
+  // normal circumstances.
   m_command_dict.erase(pos);
   return true;
 }
Index: lldb/include/lldb/Interpreter/CommandInterpreter.h
===
--- lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -324,8 +324,9 @@
  lldb::CommandObjectSP _obj_sp,
  llvm::StringRef args_string = llvm::StringRef());
 
-  // Remove a command if it is removable (python or regex command)
-  bool RemoveCommand(llvm::StringRef cmd);
+  /// Remove a command if it is removable (python or regex command). If \b force
+  /// is provided, the command is removed regardless of its removable status.
+  bool RemoveCommand(llvm::StringRef cmd, bool force = false);
 
   bool RemoveAlias(llvm::StringRef alias_name);
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D149312: [lldb] Create a way to force remove commands

2023-04-26 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 517399.
wallace added a comment.

remove whitespace changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149312

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/Interpreter/CommandInterpreter.cpp


Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1374,11 +1374,12 @@
   return false;
 }
 
-bool CommandInterpreter::RemoveCommand(llvm::StringRef cmd) {
+bool CommandInterpreter::RemoveCommand(llvm::StringRef cmd, bool force) {
   auto pos = m_command_dict.find(std::string(cmd));
   if (pos != m_command_dict.end()) {
-if (pos->second->IsRemovable()) {
-  // Only regular expression objects or python commands are removable
+if (force || pos->second->IsRemovable()) {
+  // Only regular expression objects or python commands are removable under
+  // normal circumstances.
   m_command_dict.erase(pos);
   return true;
 }
Index: lldb/include/lldb/Interpreter/CommandInterpreter.h
===
--- lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -324,8 +324,9 @@
  lldb::CommandObjectSP _obj_sp,
  llvm::StringRef args_string = llvm::StringRef());
 
-  // Remove a command if it is removable (python or regex command)
-  bool RemoveCommand(llvm::StringRef cmd);
+  /// Remove a command if it is removable (python or regex command). If \b 
force
+  /// is provided, the command is removed regardless of its removable status.
+  bool RemoveCommand(llvm::StringRef cmd, bool force = false);
 
   bool RemoveAlias(llvm::StringRef alias_name);
 


Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1374,11 +1374,12 @@
   return false;
 }
 
-bool CommandInterpreter::RemoveCommand(llvm::StringRef cmd) {
+bool CommandInterpreter::RemoveCommand(llvm::StringRef cmd, bool force) {
   auto pos = m_command_dict.find(std::string(cmd));
   if (pos != m_command_dict.end()) {
-if (pos->second->IsRemovable()) {
-  // Only regular expression objects or python commands are removable
+if (force || pos->second->IsRemovable()) {
+  // Only regular expression objects or python commands are removable under
+  // normal circumstances.
   m_command_dict.erase(pos);
   return true;
 }
Index: lldb/include/lldb/Interpreter/CommandInterpreter.h
===
--- lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -324,8 +324,9 @@
  lldb::CommandObjectSP _obj_sp,
  llvm::StringRef args_string = llvm::StringRef());
 
-  // Remove a command if it is removable (python or regex command)
-  bool RemoveCommand(llvm::StringRef cmd);
+  /// Remove a command if it is removable (python or regex command). If \b force
+  /// is provided, the command is removed regardless of its removable status.
+  bool RemoveCommand(llvm::StringRef cmd, bool force = false);
 
   bool RemoveAlias(llvm::StringRef alias_name);
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D149312: [lldb] Create a way to force remove commands

2023-04-26 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
Herald added a project: All.
wallace requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Some LLDB set ups need to hide certain commands for security reasons, so I'm 
adding a flag that allows removing non-user commands.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149312

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/Interpreter/CommandInterpreter.cpp

Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1374,10 +1374,10 @@
   return false;
 }
 
-bool CommandInterpreter::RemoveCommand(llvm::StringRef cmd) {
+bool CommandInterpreter::RemoveCommand(llvm::StringRef cmd, bool force) {
   auto pos = m_command_dict.find(std::string(cmd));
   if (pos != m_command_dict.end()) {
-if (pos->second->IsRemovable()) {
+if (force || pos->second->IsRemovable()) {
   // Only regular expression objects or python commands are removable
   m_command_dict.erase(pos);
   return true;
@@ -1689,19 +1689,19 @@
   return nullptr;
 }
 llvm::StringRef arg_text = entry.ref();
-if (strpos - start_fudge + arg_text.size() + len_fudge 
+if (strpos - start_fudge + arg_text.size() + len_fudge
 > raw_input_string.size()) {
   result.AppendError("Unmatched quote at command end.");
-  return nullptr;  
+  return nullptr;
 }
 raw_input_string = raw_input_string.erase(
-strpos - start_fudge, 
+strpos - start_fudge,
 strlen(cmd_args.GetArgumentAtIndex(index)) + len_fudge);
   }
   if (quote_char == '\0')
 result_str.Printf("%s", cmd_args.GetArgumentAtIndex(index));
   else
-result_str.Printf("%c%s%c", quote_char, 
+result_str.Printf("%c%s%c", quote_char,
   entry.c_str(), quote_char);
 }
   }
@@ -1759,7 +1759,7 @@
 command.insert(start_backtick, std::string(expr_str));
 pos = start_backtick + expr_str.size();
   }
-  return error;
+  return error;
 }
 
 Status
@@ -1794,7 +1794,7 @@
   expr_result_valobj_sp->GetQualifiedRepresentationIfAvailable(
   expr_result_valobj_sp->GetDynamicValueType(), true);
 if (expr_result_valobj_sp->ResolveValue(scalar)) {
-  
+
   StreamString value_strm;
   const bool show_type = false;
   scalar.GetValue(_strm, show_type);
@@ -1982,11 +1982,11 @@
 
   CommandObject *cmd_obj = ResolveCommandImpl(command_string, result);
 
-  // We have to preprocess the whole command string for Raw commands, since we 
+  // We have to preprocess the whole command string for Raw commands, since we
   // don't know the structure of the command.  For parsed commands, we only
   // treat backticks as quote characters specially.
   // FIXME: We probably want to have raw commands do their own preprocessing.
-  // For instance, I don't think people expect substitution in expr expressions. 
+  // For instance, I don't think people expect substitution in expr expressions.
   if (cmd_obj && cmd_obj->WantsRawCommandString()) {
 Status error(PreprocessCommand(command_string));
 
@@ -3391,7 +3391,7 @@
 // If the current thread is not managed by a host thread, we won't detect
 // that this IS the CommandInterpreter IOHandler thread, so make it so:
 HostThread new_io_handler_thread(Host::GetCurrentThread());
-HostThread old_io_handler_thread 
+HostThread old_io_handler_thread
 = m_debugger.SetIOHandlerThread(new_io_handler_thread);
 m_debugger.RunIOHandlers();
 m_debugger.SetIOHandlerThread(old_io_handler_thread);
Index: lldb/include/lldb/Interpreter/CommandInterpreter.h
===
--- lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -240,7 +240,7 @@
 eCommandTypesAllThem = 0x  //< all commands
   };
 
-  // The CommandAlias and CommandInterpreter both have a hand in 
+  // The CommandAlias and CommandInterpreter both have a hand in
   // substituting for alias commands.  They work by writing special tokens
   // in the template form of the Alias command, and then detecting them when the
   // command is executed.  These are the special tokens:
@@ -324,8 +324,9 @@
  lldb::CommandObjectSP _obj_sp,
  llvm::StringRef args_string = llvm::StringRef());
 
-  // Remove a command if it is removable (python or regex command)
-  bool RemoveCommand(llvm::StringRef cmd);
+  /// Remove a command if it is removable (python or regex command). If \b force
+  /// is provided, the command is removed regardless of its removable status.
+  bool 

[Lldb-commits] [PATCH] D149180: [LLDB][REPL] Destroy the repl instances correctly

2023-04-25 Thread walter erquinigo via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG59a39c2fc91e: [LLDB][REPL] Destroy the repl instances 
correctly (authored by wallace).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149180

Files:
  lldb/source/Target/Target.cpp


Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -293,6 +293,7 @@
   m_stop_hooks.clear();
   m_stop_hook_next_id = 0;
   m_suppress_stop_hooks = false;
+  m_repl_map.clear();
   Args signal_args;
   ClearDummySignals(signal_args);
 }


Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -293,6 +293,7 @@
   m_stop_hooks.clear();
   m_stop_hook_next_id = 0;
   m_suppress_stop_hooks = false;
+  m_repl_map.clear();
   Args signal_args;
   ClearDummySignals(signal_args);
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D149180: [LLDB][REPL] Destroy the repl instances correctly

2023-04-25 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
Herald added a project: All.
wallace requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This change ensures that the REPL map inside Target is destroyed correctly when 
`Target::Destroy()` is invoked. Not doing so results in the REPL not finishing 
its job when the debugger is initialized in REPL mode reading from a file. In 
my particular case, my REPL doesn't print the stdout of the last expression in 
the input file unless I include this change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149180

Files:
  lldb/source/Target/Target.cpp


Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -293,6 +293,7 @@
   m_stop_hooks.clear();
   m_stop_hook_next_id = 0;
   m_suppress_stop_hooks = false;
+  m_repl_map.clear();
   Args signal_args;
   ClearDummySignals(signal_args);
 }


Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -293,6 +293,7 @@
   m_stop_hooks.clear();
   m_stop_hook_next_id = 0;
   m_suppress_stop_hooks = false;
+  m_repl_map.clear();
   Args signal_args;
   ClearDummySignals(signal_args);
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D147805: [lldb-vscode] Fix two issues with runInTerminal test.

2023-04-07 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

wow, nice improvement. I don't have anything else to add besides what 
@rupprecht said


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147805

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


[Lldb-commits] [PATCH] D147453: [LLDB] Ensure LLDB symbols are exported in LLDB_EXPORT_ALL_SYMBOLS is provided.

2023-04-03 Thread walter erquinigo via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe538c6fc3048: [LLDB] Ensure LLDB symbols are exported in 
LLDB_EXPORT_ALL_SYMBOLS is provided. (authored by wallace).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147453

Files:
  lldb/cmake/modules/AddLLDB.cmake


Index: lldb/cmake/modules/AddLLDB.cmake
===
--- lldb/cmake/modules/AddLLDB.cmake
+++ lldb/cmake/modules/AddLLDB.cmake
@@ -165,6 +165,13 @@
   else()
 set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
   endif()
+
+  # If we want to export all lldb symbols (i.e LLDB_EXPORT_ALL_SYMBOLS=ON), we
+  # need to use default visibility for all LLDB libraries even if a global
+  # `CMAKE_CXX_VISIBILITY_PRESET=hidden`is present.
+  if (LLDB_EXPORT_ALL_SYMBOLS)
+set_target_properties(${name} PROPERTIES CXX_VISIBILITY_PRESET default)
+  endif()
 endfunction(add_lldb_library)
 
 function(add_lldb_executable name)


Index: lldb/cmake/modules/AddLLDB.cmake
===
--- lldb/cmake/modules/AddLLDB.cmake
+++ lldb/cmake/modules/AddLLDB.cmake
@@ -165,6 +165,13 @@
   else()
 set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
   endif()
+
+  # If we want to export all lldb symbols (i.e LLDB_EXPORT_ALL_SYMBOLS=ON), we
+  # need to use default visibility for all LLDB libraries even if a global
+  # `CMAKE_CXX_VISIBILITY_PRESET=hidden`is present.
+  if (LLDB_EXPORT_ALL_SYMBOLS)
+set_target_properties(${name} PROPERTIES CXX_VISIBILITY_PRESET default)
+  endif()
 endfunction(add_lldb_library)
 
 function(add_lldb_executable name)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D147453: [LLDB] Ensure LLDB symbols are exported in LLDB_EXPORT_ALL_SYMBOLS is provided.

2023-04-03 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 510588.
wallace added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147453

Files:
  lldb/cmake/modules/AddLLDB.cmake


Index: lldb/cmake/modules/AddLLDB.cmake
===
--- lldb/cmake/modules/AddLLDB.cmake
+++ lldb/cmake/modules/AddLLDB.cmake
@@ -165,6 +165,13 @@
   else()
 set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
   endif()
+
+  # If we want to export all lldb symbols (i.e LLDB_EXPORT_ALL_SYMBOLS=ON), we
+  # need to use default visibility for all LLDB libraries even if a global
+  # `CMAKE_CXX_VISIBILITY_PRESET=hidden`is present.
+  if (LLDB_EXPORT_ALL_SYMBOLS)
+set_target_properties(${name} PROPERTIES CXX_VISIBILITY_PRESET default)
+  endif()
 endfunction(add_lldb_library)
 
 function(add_lldb_executable name)


Index: lldb/cmake/modules/AddLLDB.cmake
===
--- lldb/cmake/modules/AddLLDB.cmake
+++ lldb/cmake/modules/AddLLDB.cmake
@@ -165,6 +165,13 @@
   else()
 set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
   endif()
+
+  # If we want to export all lldb symbols (i.e LLDB_EXPORT_ALL_SYMBOLS=ON), we
+  # need to use default visibility for all LLDB libraries even if a global
+  # `CMAKE_CXX_VISIBILITY_PRESET=hidden`is present.
+  if (LLDB_EXPORT_ALL_SYMBOLS)
+set_target_properties(${name} PROPERTIES CXX_VISIBILITY_PRESET default)
+  endif()
 endfunction(add_lldb_library)
 
 function(add_lldb_executable name)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D147453: [LLDB] Ensure LLDB symbols are exported in LLDB_EXPORT_ALL_SYMBOLS is provided.

2023-04-03 Thread walter erquinigo via Phabricator via lldb-commits
wallace added inline comments.



Comment at: lldb/cmake/modules/AddLLDB.cmake:175
+CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
+  target_compile_options(${name} PRIVATE "-fvisibility=default")
+endif()

JDevlieghere wrote:
> Rather than changing the compile options directly, can we change the 
> `CXX_VISIBILITY_PRESET` property?
> 
> ```
> set_target_properties((${name} PROPERTIES CXX_VISIBILITY_PRESET default)
> ```
Thanks @JDevlieghere , that works and is cleaner


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147453

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


[Lldb-commits] [PATCH] D147453: [LLDB] Ensure LLDB symbols are exported in LLDB_EXPORT_ALL_SYMBOLS is provided.

2023-04-03 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 510557.
wallace added a comment.

gate the target OS


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147453

Files:
  lldb/cmake/modules/AddLLDB.cmake


Index: lldb/cmake/modules/AddLLDB.cmake
===
--- lldb/cmake/modules/AddLLDB.cmake
+++ lldb/cmake/modules/AddLLDB.cmake
@@ -165,6 +165,16 @@
   else()
 set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
   endif()
+
+  # If we want to export all lldb symbols (i.e LLDB_EXPORT_ALL_SYMBOLS=ON), we
+  # need to use default visibility for all LLDB libraries even if a global
+  # `CMAKE_CXX_VISIBILITY_PRESET=hidden`is present.
+  if (LLDB_EXPORT_ALL_SYMBOLS)
+if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows" AND
+CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
+  target_compile_options(${name} PRIVATE "-fvisibility=default")
+endif()
+  endif()
 endfunction(add_lldb_library)
 
 function(add_lldb_executable name)


Index: lldb/cmake/modules/AddLLDB.cmake
===
--- lldb/cmake/modules/AddLLDB.cmake
+++ lldb/cmake/modules/AddLLDB.cmake
@@ -165,6 +165,16 @@
   else()
 set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
   endif()
+
+  # If we want to export all lldb symbols (i.e LLDB_EXPORT_ALL_SYMBOLS=ON), we
+  # need to use default visibility for all LLDB libraries even if a global
+  # `CMAKE_CXX_VISIBILITY_PRESET=hidden`is present.
+  if (LLDB_EXPORT_ALL_SYMBOLS)
+if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows" AND
+CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
+  target_compile_options(${name} PRIVATE "-fvisibility=default")
+endif()
+  endif()
 endfunction(add_lldb_library)
 
 function(add_lldb_executable name)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D147453: [LLDB] Ensure LLDB symbols are exported in LLDB_EXPORT_ALL_SYMBOLS is provided.

2023-04-03 Thread walter erquinigo via Phabricator via lldb-commits
wallace added inline comments.



Comment at: lldb/cmake/modules/AddLLDB.cmake:173
+  if (LLDB_EXPORT_ALL_SYMBOLS)
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
+  target_compile_options(${name} PRIVATE "-fvisibility=default")

rriddle wrote:
> Other places uses `if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")` to check for 
> non-windows, should that check be used here as well? Not sure what's 
> consistent for the lldb codebase.
I initially thought that it might be fine just to check the compiler id, but 
better be safer gating the target OS as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147453

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


[Lldb-commits] [PATCH] D147453: [LLDB] Ensure LLDB symbols are exported in LLDB_EXPORT_ALL_SYMBOLS is provided.

2023-04-03 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 510551.
wallace added a comment.

another nit...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147453

Files:
  lldb/cmake/modules/AddLLDB.cmake


Index: lldb/cmake/modules/AddLLDB.cmake
===
--- lldb/cmake/modules/AddLLDB.cmake
+++ lldb/cmake/modules/AddLLDB.cmake
@@ -165,6 +165,15 @@
   else()
 set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
   endif()
+
+  # If we want to export all lldb symbols (i.e LLDB_EXPORT_ALL_SYMBOLS=ON), we
+  # need to use default visibility for all LLDB libraries even if a global
+  # `CMAKE_CXX_VISIBILITY_PRESET=hidden`is present.
+  if (LLDB_EXPORT_ALL_SYMBOLS)
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
+  target_compile_options(${name} PRIVATE "-fvisibility=default")
+endif()
+  endif()
 endfunction(add_lldb_library)
 
 function(add_lldb_executable name)


Index: lldb/cmake/modules/AddLLDB.cmake
===
--- lldb/cmake/modules/AddLLDB.cmake
+++ lldb/cmake/modules/AddLLDB.cmake
@@ -165,6 +165,15 @@
   else()
 set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
   endif()
+
+  # If we want to export all lldb symbols (i.e LLDB_EXPORT_ALL_SYMBOLS=ON), we
+  # need to use default visibility for all LLDB libraries even if a global
+  # `CMAKE_CXX_VISIBILITY_PRESET=hidden`is present.
+  if (LLDB_EXPORT_ALL_SYMBOLS)
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
+  target_compile_options(${name} PRIVATE "-fvisibility=default")
+endif()
+  endif()
 endfunction(add_lldb_library)
 
 function(add_lldb_executable name)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D147453: [LLDB] Ensure LLDB symbols are exported in LLDB_EXPORT_ALL_SYMBOLS is provided.

2023-04-03 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 510550.
wallace added a comment.

nits


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147453

Files:
  lldb/cmake/modules/AddLLDB.cmake


Index: lldb/cmake/modules/AddLLDB.cmake
===
--- lldb/cmake/modules/AddLLDB.cmake
+++ lldb/cmake/modules/AddLLDB.cmake
@@ -165,6 +165,15 @@
   else()
 set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
   endif()
+
+  # If we want to export all lldb symbols (i.e LLDB_EXPORT_ALL_SYMBOLS=ON), we
+  # need to use default visibility for all LLDB symbols even if a global
+  # `CMAKE_CXX_VISIBILITY_PRESET=hidden`is present.
+  if (LLDB_EXPORT_ALL_SYMBOLS)
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
+  target_compile_options(${name} PRIVATE "-fvisibility=default")
+endif()
+  endif()
 endfunction(add_lldb_library)
 
 function(add_lldb_executable name)


Index: lldb/cmake/modules/AddLLDB.cmake
===
--- lldb/cmake/modules/AddLLDB.cmake
+++ lldb/cmake/modules/AddLLDB.cmake
@@ -165,6 +165,15 @@
   else()
 set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
   endif()
+
+  # If we want to export all lldb symbols (i.e LLDB_EXPORT_ALL_SYMBOLS=ON), we
+  # need to use default visibility for all LLDB symbols even if a global
+  # `CMAKE_CXX_VISIBILITY_PRESET=hidden`is present.
+  if (LLDB_EXPORT_ALL_SYMBOLS)
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
+  target_compile_options(${name} PRIVATE "-fvisibility=default")
+endif()
+  endif()
 endfunction(add_lldb_library)
 
 function(add_lldb_executable name)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D147453: [LLDB] Ensure LLDB symbols are exported in LLDB_EXPORT_ALL_SYMBOLS is provided.

2023-04-03 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
wallace added a reviewer: rriddle.
Herald added a project: All.
wallace requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

If we want to export all lldb symbols (i.e
LLDB_EXPORT_ALL_SYMBOLS=ON), we need to use default visibility for all 
LLDB symbols even if a global `CMAKE_CXX_VISIBILITY_PRESET=hidden` is present.A


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147453

Files:
  lldb/cmake/modules/AddLLDB.cmake


Index: lldb/cmake/modules/AddLLDB.cmake
===
--- lldb/cmake/modules/AddLLDB.cmake
+++ lldb/cmake/modules/AddLLDB.cmake
@@ -165,6 +165,16 @@
   else()
 set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
   endif()
+
+
+  # If we want to export all lldb symbols (i.e LLDB_EXPORT_ALL_SYMBOLS=ON), we
+  # need to use default visibility# for all LLDB symbols even if a global
+  # `CMAKE_CXX_VISIBILITY_PRESET=hidden` is present.
+  if (LLDB_EXPORT_ALL_SYMBOLS)
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
+  target_compile_options(${name} PRIVATE "-fvisibility=default")
+endif()
+  endif()
 endfunction(add_lldb_library)
 
 function(add_lldb_executable name)


Index: lldb/cmake/modules/AddLLDB.cmake
===
--- lldb/cmake/modules/AddLLDB.cmake
+++ lldb/cmake/modules/AddLLDB.cmake
@@ -165,6 +165,16 @@
   else()
 set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
   endif()
+
+
+  # If we want to export all lldb symbols (i.e LLDB_EXPORT_ALL_SYMBOLS=ON), we
+  # need to use default visibility# for all LLDB symbols even if a global
+  # `CMAKE_CXX_VISIBILITY_PRESET=hidden` is present.
+  if (LLDB_EXPORT_ALL_SYMBOLS)
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
+  target_compile_options(${name} PRIVATE "-fvisibility=default")
+endif()
+  endif()
 endfunction(add_lldb_library)
 
 function(add_lldb_executable name)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D147252: [lldb][NFC] Move various constructor definitions from .h to .cpp

2023-03-30 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147252

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


[Lldb-commits] [PATCH] D139969: Add a json dumper for call graph reconstructor

2022-12-13 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

I'll take a look at this later tonight or tomorrow


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139969

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


[Lldb-commits] [PATCH] D138345: [test][lldb-vscode] Un-realpath coreFile test.

2022-11-18 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

yep, there's no need for the realpath
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138345

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


[Lldb-commits] [PATCH] D137645: [trace] Add `SBTraceCursor::GetWallClockTime` API

2022-11-08 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added inline comments.
This revision is now accepted and ready to land.



Comment at: lldb/source/API/SBTraceCursor.cpp:127-131
+double SBTraceCursor::GetWallClockTime() const {
+  LLDB_INSTRUMENT_VA(this);
+
+  const auto _wall_clock_time = m_opaque_sp->GetWallClockTime();
+  return maybe_wall_clock_time ? *maybe_wall_clock_time : -1.0;

hawkinsw wrote:
> wallace wrote:
> > we don't have optionals in the SB bridge, so you could do the following
> > 
> >   bool SBTraceCursor::GetWallClockTime(double ) {
> > if (const auto _wall_clock_time = 
> > m_opaque_sp->GetWallClockTime()) {
> >   time = *maybe_wall_clock_time;
> >   return true;
> > }
> > return false;
> >   }
> Not that it matters, but *that* was going to be my other suggestion! @wallace 
> is smarter than I am!
<3


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137645

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


[Lldb-commits] [PATCH] D137614: [trace] Add a new call graph reconstructor

2022-11-08 Thread walter erquinigo via Phabricator via lldb-commits
wallace added inline comments.



Comment at: lldb/source/Plugins/Trace/intel-pt/DecodedThread.h:296
   std::vector m_item_data;
+  std::vector m_insn_extra_info;
   /// The TraceItemKind for each trace item encoded as uint8_t. We don't 
include

jj10306 wrote:
> do we need to store this or can this information be calculated on demand? 
> just thinking about massive traces and want to make sure we're intentional 
> about only storing what we absolutely need to for each instruction
I thought about it and it will help us have more correctness for now and a 
little bit more speed with little memory cost. The total size per instruction 
went from 9 bytes to 11, which is very decent. 

Now some details: the Disassembler fails with some instructions. I was tracing 
dynolog and found many instances of the disassembler failing, but libipt 
doesn't fail. In other words, we can't get the control flow kind from LLDB but 
we can from libipt. Same for the byte size. That means that we need to fix the 
disassembler, but that will require a lot of work that I can hardly prioritize, 
so I'd rather use libipt for now.




Comment at: lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp:317
  events_stats.total_count);
-for (const auto _to_count : events_stats.events_counts) {
-  s.Format("  {0}: {1}\n",
-   TraceCursor::EventKindToString(event_to_count.first),
-   event_to_count.second);
+for (auto it = events_stats.events_counts.begin();
+ it != events_stats.events_counts.end(); ++it) {

jj10306 wrote:
> what's the reason for this change?
wtf, i think this is from a previous commit i never intended to publish. I was 
playing with some stuff. I need to revert this


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137614

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


[Lldb-commits] [PATCH] D137645: [trace] Add `SBTraceCursor::GetWallClockTime` API

2022-11-08 Thread walter erquinigo via Phabricator via lldb-commits
wallace requested changes to this revision.
wallace added inline comments.
This revision now requires changes to proceed.



Comment at: lldb/include/lldb/API/SBTraceCursor.h:175
+  /// if not available.
+  double GetWallClockTime() const;
+  /// \}

mention here that the trace plugin decides how to estimate wall clock time it 
needed, and that not all trace items are guaranteed to have wall clock time, as 
it depends on the trace plug-in capabilities



Comment at: lldb/source/API/SBTraceCursor.cpp:127-131
+double SBTraceCursor::GetWallClockTime() const {
+  LLDB_INSTRUMENT_VA(this);
+
+  const auto _wall_clock_time = m_opaque_sp->GetWallClockTime();
+  return maybe_wall_clock_time ? *maybe_wall_clock_time : -1.0;

we don't have optionals in the SB bridge, so you could do the following

  bool SBTraceCursor::GetWallClockTime(double ) {
if (const auto _wall_clock_time = m_opaque_sp->GetWallClockTime()) {
  time = *maybe_wall_clock_time;
  return true;
}
return false;
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137645

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


[Lldb-commits] [PATCH] D137509: [NFC][intelpt] Improve IntelPT trace bundle documentation

2022-11-07 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added inline comments.
This revision is now accepted and ready to land.



Comment at: lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp:244
   // Optional clang/llvm target triple.
+  // This must be provided if the trace will be created not using the 
CLI or on a machine other than where the target was traced.
   "threads": [

jj10306 wrote:
> wallace wrote:
> > split this into 80-char lines, please :)
> wonder why `git clang-format` didn't suggest this?
I think it's because this is a special kind of string that should be taken 
literal


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137509

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


[Lldb-commits] [PATCH] D137509: [NFC][intelpt] Improve IntelPT trace bundle documentation

2022-11-06 Thread walter erquinigo via Phabricator via lldb-commits
wallace added inline comments.



Comment at: lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp:244
   // Optional clang/llvm target triple.
+  // This must be provided if the trace will be created not using the 
CLI or on a machine other than where the target was traced.
   "threads": [

split this into 80-char lines, please :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137509

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


[Lldb-commits] [PATCH] D137509: [NFC][intelpt] Improve IntelPT trace bundle documentation

2022-11-06 Thread walter erquinigo via Phabricator via lldb-commits
wallace added inline comments.



Comment at: lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp:244
   // Optional clang/llvm target triple.
+  // This must be provided if the trace will be consumed using 
`SBTraceCursor`.
   "threads": [

something along these lines is more accurate


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137509

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


[Lldb-commits] [PATCH] D136801: [intelpt] Update Python tests to account for new errrors

2022-10-26 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136801

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


[Lldb-commits] [PATCH] D136610: [trace][intelpt] Fix multi CPU decoding TSC assertion error

2022-10-25 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

thanks. Your explanation of why the verbose error is useful was good :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136610

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


[Lldb-commits] [PATCH] D136557: [trace][intel pt] Simple detection of infinite decoding loops

2022-10-24 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 470343.
wallace added a comment.

address issues and comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136557

Files:
  lldb/include/lldb/Core/PluginManager.h
  lldb/source/Core/PluginManager.cpp
  lldb/source/Plugins/Trace/intel-pt/CMakeLists.txt
  lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
  lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
  lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTProperties.td
  lldb/test/API/commands/trace/TestTraceDumpInfo.py
  lldb/test/API/commands/trace/TestTraceLoad.py

Index: lldb/test/API/commands/trace/TestTraceLoad.py
===
--- lldb/test/API/commands/trace/TestTraceLoad.py
+++ lldb/test/API/commands/trace/TestTraceLoad.py
@@ -37,6 +37,12 @@
   "totalCount": 0,
   "individualCounts": {}
 },
+"errors": {
+  "totalCount": 0,
+  "libiptErrors": {},
+  "fatalErrors": 0,
+  "otherErrors": 0
+},
 "continuousExecutions": 0,
 "PSBBlocks": 0
   },
@@ -72,6 +78,12 @@
 "HW clock tick": 8
   }
 },
+"errors": {
+  "totalCount": 1,
+  "libiptErrors": {},
+  "fatalErrors": 0,
+  "otherErrors": 1
+},
 "continuousExecutions": 1,
 "PSBBlocks": 1
   },
Index: lldb/test/API/commands/trace/TestTraceDumpInfo.py
===
--- lldb/test/API/commands/trace/TestTraceDumpInfo.py
+++ lldb/test/API/commands/trace/TestTraceDumpInfo.py
@@ -78,6 +78,12 @@
 "software disabled tracing": 2,
 "trace synchronization point": 1
   }
+},
+"errors": {
+  "totalCount": 0,
+  "libiptErrors": {},
+  "fatalErrors": 0,
+  "otherErrors": 0
 }
   },
   "globalStats": {
Index: lldb/source/Plugins/Trace/intel-pt/TraceIntelPTProperties.td
===
--- /dev/null
+++ lldb/source/Plugins/Trace/intel-pt/TraceIntelPTProperties.td
@@ -0,0 +1,24 @@
+include "../../../../include/lldb/Core/PropertiesBase.td"
+
+let Definition = "traceintelpt" in {
+  def InfiniteDecodingLoopVerificationThreshold:
+  Property<"infinite-decoding-loop-verification-threshold", "UInt64">,
+Global,
+DefaultUnsignedValue<1>,
+Desc<"Specify how many instructions following an individual Intel PT "
+  "packet must have been decoded before triggering the verification of "
+  "infinite decoding loops. If no decoding loop has been found after this "
+  "threshold T, another attempt will be done after 2T instructions, then "
+  "4T, 8T and so on, which guarantees a total linear time spent checking "
+  "this anomaly. If a loop is found, then decoding of the corresponding "
+  "PSB block is stopped. An error is hence emitted in the trace and "
+  "decoding is resumed in the next PSB block.">;
+  def ExtremelyLargeDecodingThreshold:
+  Property<"extremely-large-decoding-threshold", "UInt64">,
+Global,
+DefaultUnsignedValue<50>,
+Desc<"Specify how many instructions following an individual Intel PT "
+  "packet must have been decoded before stopping the decoding of the "
+  "corresponding PSB block. An error is hence emitted in the trace and "
+  "decoding is resumed in the next PSB block.">;
+}
Index: lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
===
--- lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
+++ lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
@@ -22,6 +22,23 @@
 
 class TraceIntelPT : public Trace {
 public:
+  /// Properties to be used with the `settings` command.
+  class PluginProperties : public Properties {
+  public:
+static ConstString GetSettingName();
+
+PluginProperties();
+
+~PluginProperties() override = default;
+
+uint64_t GetInfiniteDecodingLoopVerificationThreshold();
+
+uint64_t GetExtremelyLargeDecodingThreshold();
+  };
+
+  /// Return the global properties for this trace plug-in.
+  static PluginProperties ();
+
   void Dump(Stream *s) const override;
 
   llvm::Expected SaveToDisk(FileSpec directory,
@@ -59,6 +76,8 @@
   CreateInstanceForLiveProcess(Process );
 
   static llvm::StringRef GetPluginNameStatic() { return "intel-pt"; }
+
+  static void DebuggerInitialize(Debugger );
   /// \}
 
   lldb::CommandObjectSP
Index: lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
===
--- lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
+++ lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
@@ -16,6 +16,7 @@
 #include "TraceIntelPTBundleSaver.h"
 #include "TraceIntelPTConstants.h"
 #include 

[Lldb-commits] [PATCH] D136557: [trace][intel pt] Simple detection of infinite decoding loops

2022-10-24 Thread walter erquinigo via Phabricator via lldb-commits
wallace added inline comments.



Comment at: lldb/source/Plugins/Trace/intel-pt/DecodedThread.h:123
 /// of a DenseMap because DenseMap can't understand enums.
-std::unordered_map events_counts;
-size_t total_count = 0;
+std::unordered_map events_counts;
+uint64_t total_count = 0;

jj10306 wrote:
> 
ahh good one



Comment at: lldb/source/Plugins/Trace/intel-pt/DecodedThread.h:130
+  // Struct holding counts for errors
+  struct ErrorStats {
+/// The following counters are mutually exclusive

jj10306 wrote:
> nice, I was about to add this as part of my diff (:
oh nice!



Comment at: lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp:206
+  }
+  m_next_infinite_decoding_loop_threshold *= 2;
+}

jj10306 wrote:
> can you explain why we are increasing the threshold?
the idea is to check for infinite loops sporadically without making the total 
checks in O(N^2) and instead do it in O(N)

If we first do a linear check in the trace, which is O(T) after T instructions 
are appended and there are no loops, we might want to check again in the 
future. We could wait for the next T instructions and then run another check, 
and if we fail, wait for the next T and so on. This result in a total time 
spent of O(T + 2T + 3T + 4T + ... + N) which is O(N^2). Instead, we can run the 
check after 2T, and then after 4T and then after 8T and so on. This gives us a 
geometric progression of (N + N/2 + N / 4 + ... + T) which is amortized total 
O(N). A similar algorithm is vector::push_back 
(https://cs.stackexchange.com/questions/9380/why-is-push-back-in-c-vectors-constant-amortized)
 which is total O(N) using a similar approach.



Comment at: lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp:235-241
+if (m_decoded_thread.GetInstructionLoadAddress(last_insn_index) !=
+eTraceItemKindInstruction) {
+  if (Optional prev_index = prev_insn_index(last_insn_index)) {
+last_insn_index = *prev_index;
+  } else {
+return None;
+  }

jj10306 wrote:
> if you move the `--item_index` in `prev_insn_index` lambda, would that allow 
> you to remove this duplicated `eTraceItemKindInstruction` check and instead 
> unconditionally call `prev_insn_index`?
> or would this not work because the intention of the lamda is to skip the 
> current event even if it's already an instruction
I like your idea. I think I can simplify the code



Comment at: lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp:281
+lldb::addr_t new_packet_offset;
+if (!IsLibiptError(pt_insn_get_offset(_decoder, _packet_offset)) &&
+new_packet_offset != m_last_packet_offset) {

jj10306 wrote:
> help me understand this please. I thought `pt_insn_get_offset` would always 
> return a new, increasing offset every time this function is called.
Not really. pt_insn_get_offset returns the offset of the last packet that was 
processed, and that single could lead to many individual sequential 
instructions until the next packet is needed.
 
Let's imagine that you have this trace

PSB with starting address of 0xAAA
TNT with 4 bits
TIP with address 0xFFF

What the decoder will do is to first read the PSB and start at IP 0xAAA. It'll 
then decode sequential instructions until it reaches the first branch or jump. 
It then needs to read the next packet, which is the TNT with 4 bits, so it will 
help decode the next 4 branches but not the fifth one. So the decoder will 
change the offset and resume decoding instructions sequentially until that 
fifth branch (or jump) is reached. Then the decoder will read the next packet, 
which is a TIP and tells the decoder to jump to address 0xFFF.
So this means that with the PSB, the decoder produced, let's say, 10 
instructions, and with the TNT maybe 1000 were produced,, and then the decoder 
moved to the offset of the TIP for the next instruction.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136557

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


[Lldb-commits] [PATCH] D136610: [trace][intelpt] Fix multi CPU decoding TSC assertion error

2022-10-24 Thread walter erquinigo via Phabricator via lldb-commits
wallace requested changes to this revision.
wallace added a comment.
This revision now requires changes to proceed.

pretty good! I just left cosmetic requests




Comment at: lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp:285-312
+  if (event.has_tsc) {
+if (m_tsc_upper_bound && event.tsc > m_tsc_upper_bound.value()) {
+  // This event and all the remaining events of this PSB have a TSC
+  // outside the range of the "owning" ThreadContinuousExecution. For
+  // now we drop all of these events/instructions, future work can
+  // improve upon this by determining the "owning"
+  // ThreadContinuousExecution of the remaining PSB data.

I suggest moving all of this to another function because it's a bit long



Comment at: lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp:286
+  if (event.has_tsc) {
+if (m_tsc_upper_bound && event.tsc > m_tsc_upper_bound.value()) {
+  // This event and all the remaining events of this PSB have a TSC

use * instead of value(). value() is rarely used in LLVM code. Also use >= 
instead of >



Comment at: lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp:294-295
+  formatv(
+  "TSC {0} exceeds maximum TSC value {1}. Will skip decoding"
+  " the remining the remaining data of the PSB.",
+  event.tsc, m_tsc_upper_bound.value())

add a prefix message for easier regexp search
  "decoding truncated: TSC packet {0} exceeds maximum TSC value {1} for this 
PSB block . Will resume decoding with the next PSB."

Use a better prefix if you can, and btw, you wrote `the remining the remaining 
` here. 



Comment at: lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp:296
+  " the remining the remaining data of the PSB.",
+  event.tsc, m_tsc_upper_bound.value())
+  .str();

ditto



Comment at: lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp:299-307
+  uint64_t offset;
+  int status = pt_insn_get_offset(m_decoder_up.get(), );
+  if (!IsLibiptError(status)) {
+err_msg =
+formatv("At byte offset {0} of PSB with size {1} bytes, {2}",
+offset, m_psb_block.size, err_msg)
+.str();

I think let's better not include this to keep the error a bit smaller. In any 
case, you can do `thread trace dump instructions  -E` and then look for 
the error prefix when debugging.

but if you insist, the byte offset message should come after the textual 
description of the error



Comment at: lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp:308
+  m_decoded_thread.AppendCustomError(err_msg);
+  return -1;
+} else {

return -pte_internal;



Comment at: lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp:345
   DecodedThread _decoded_thread;
+  // Maximum allowed value of TSCs decoded from m_psb_block.
+  llvm::Optional m_tsc_upper_bound;

move this to the constructor so that it's highlighted by IDEs and appears in 
the public documentation

  Maximum allowed value of TSCs decoded from this psb block. If this value is 
hit, then decoding for this block is stopped and an error is appended to the 
trace.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136610

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


[Lldb-commits] [PATCH] D136557: [trace][intel pt] Simple detection of infinite decoding loops

2022-10-23 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 470047.
wallace edited the summary of this revision.
wallace added a comment.

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136557

Files:
  lldb/include/lldb/Core/PluginManager.h
  lldb/source/Core/PluginManager.cpp
  lldb/source/Plugins/Trace/intel-pt/CMakeLists.txt
  lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
  lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
  lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTProperties.td
  lldb/test/API/commands/trace/TestTraceDumpInfo.py
  lldb/test/API/commands/trace/TestTraceLoad.py

Index: lldb/test/API/commands/trace/TestTraceLoad.py
===
--- lldb/test/API/commands/trace/TestTraceLoad.py
+++ lldb/test/API/commands/trace/TestTraceLoad.py
@@ -37,6 +37,12 @@
   "totalCount": 0,
   "individualCounts": {}
 },
+"errors": {
+  "totalCount": 0,
+  "libiptErrors": {},
+  "fatalErrors": 0,
+  "otherErrors": 0
+},
 "continuousExecutions": 0,
 "PSBBlocks": 0
   },
@@ -72,6 +78,12 @@
 "HW clock tick": 8
   }
 },
+"errors": {
+  "totalCount": 1,
+  "libiptErrors": {},
+  "fatalErrors": 0,
+  "otherErrors": 1
+},
 "continuousExecutions": 1,
 "PSBBlocks": 1
   },
Index: lldb/test/API/commands/trace/TestTraceDumpInfo.py
===
--- lldb/test/API/commands/trace/TestTraceDumpInfo.py
+++ lldb/test/API/commands/trace/TestTraceDumpInfo.py
@@ -78,6 +78,12 @@
 "software disabled tracing": 2,
 "trace synchronization point": 1
   }
+},
+"errors": {
+  "totalCount": 0,
+  "libiptErrors": {},
+  "fatalErrors": 0,
+  "otherErrors": 0
 }
   },
   "globalStats": {
Index: lldb/source/Plugins/Trace/intel-pt/TraceIntelPTProperties.td
===
--- /dev/null
+++ lldb/source/Plugins/Trace/intel-pt/TraceIntelPTProperties.td
@@ -0,0 +1,24 @@
+include "../../../../include/lldb/Core/PropertiesBase.td"
+
+let Definition = "traceintelpt" in {
+  def InfiniteDecodingLoopVerificationThreshold:
+  Property<"infinite-decoding-loop-verification-threshold", "UInt64">,
+Global,
+DefaultUnsignedValue<1>,
+Desc<"Specify how many instructions following an individual Intel PT "
+  "packet must have been decoded before triggering the verification of "
+  "infinite decoding loops. If no decoding loop has been found after this "
+  "threshold T, another attempt will be done after 2T instructions, then "
+  "4T, 8T and so on, which guarantees a total linear time spent checking "
+  "this anomaly. If a loop is found, then decoding of the corresponding "
+  "PSB block is stopped. An error is hence emitted in the trace and "
+  "decoding is resumed in the next PSB block.">;
+  def ExtremelyLargeDecodingThreshold:
+  Property<"extremely-large-decoding-threshold", "UInt64">,
+Global,
+DefaultUnsignedValue<50>,
+Desc<"Specify how many instructions following an individual Intel PT "
+  "packet must have been decoded before stopping the decoding of the "
+  "corresponding PSB block. An error is hence emitted in the trace and "
+  "decoding is resumed in the next PSB block.">;
+}
Index: lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
===
--- lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
+++ lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
@@ -22,6 +22,23 @@
 
 class TraceIntelPT : public Trace {
 public:
+  /// Properties to be used with the `settings` command.
+  class PluginProperties : public Properties {
+  public:
+static ConstString GetSettingName();
+
+PluginProperties();
+
+~PluginProperties() override = default;
+
+uint64_t GetInfiniteDecodingLoopVerificationThreshold();
+
+uint64_t GetExtremelyLargeDecodingThreshold();
+  };
+
+  /// Return the global properties for this trace plug-in.
+  static PluginProperties ();
+
   void Dump(Stream *s) const override;
 
   llvm::Expected SaveToDisk(FileSpec directory,
@@ -59,6 +76,8 @@
   CreateInstanceForLiveProcess(Process );
 
   static llvm::StringRef GetPluginNameStatic() { return "intel-pt"; }
+
+  static void DebuggerInitialize(Debugger );
   /// \}
 
   lldb::CommandObjectSP
Index: lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
===
--- lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
+++ lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
@@ -16,6 +16,7 @@
 #include "TraceIntelPTBundleSaver.h"
 #include 

  1   2   3   4   5   6   7   8   9   10   >