[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-24 Thread David Spickett via lldb-commits

DavidSpickett wrote:

> It's somewhat implied, but is the goal to (continue to) avoid that 
> dependency? Other parts of LLDB do rely on libxml2 but I can see how you'd 
> want to limit the dependencies of lldb-server.

Yeah I agree with how lldb-server does it now, and don't want to change that.

Just mentioning it because without looking at the whole file, it might seem 
weird to be inserting raw strings into something that is elsewhere built with 
libXML.

https://github.com/llvm/llvm-project/pull/69951
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-24 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett edited 
https://github.com/llvm/llvm-project/pull/69951
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 2325b3c - [lldb] Add test for reserved XML chars in register field names

2023-10-24 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-10-24T09:39:44Z
New Revision: 2325b3cfdadf266651294ff469ce600a8ee402ce

URL: 
https://github.com/llvm/llvm-project/commit/2325b3cfdadf266651294ff469ce600a8ee402ce
DIFF: 
https://github.com/llvm/llvm-project/commit/2325b3cfdadf266651294ff469ce600a8ee402ce.diff

LOG: [lldb] Add test for reserved XML chars in register field names

Replacements like & were already handled by libXML but we have
no tests to confirm that, this adds some.

Added: 


Modified: 
lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py
index 9e553c57f39cb7a..e2c75970c2d2ed5 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py
@@ -636,3 +636,21 @@ def test_flags_in_register_info(self):
 "|  C   |  D  |"
 ],
 )
+
+@skipIfXmlSupportMissing
+@skipIfRemote
+def test_flags_name_xml_reserved_characters(self):
+"""Check that lldb converts reserved character replacements like &
+when found in field names."""
+self.setup_flags_test(
+''
+''
+''
+''
+''
+)
+
+self.expect(
+"register info cpsr",
+substrs=["| A< | B> | C' | D\" | E& |"],
+)



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


[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-24 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/69951

>From 5c8b9538e1e5646f19d5bb40ab19afaf2c68e804 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 9 Oct 2023 10:33:08 +0100
Subject: [PATCH 1/4] [lldb][lldb-server] Enable sending registerflags as XML

This adds ToXML methods to encode RegisterFlags and its fields
into XML according to GDB's target XML format:
https://sourceware.org/gdb/onlinedocs/gdb/Target-Description-Format.html#Target-Description-Format

lldb-server does not currently use libXML to build XML,
so this follows the existing code that uses strings. Indentation
is used so the result is still human readable.

```

  

```

This is used by lldb-server when building target XML,
though no one sets any fields yet. That'll come in a later commit.
---
 lldb/include/lldb/Target/RegisterFlags.h  |  8 +
 .../GDBRemoteCommunicationServerLLGS.cpp  | 10 ++
 lldb/source/Target/RegisterFlags.cpp  | 32 +++
 lldb/unittests/Target/RegisterFlagsTest.cpp   | 32 +++
 4 files changed, 82 insertions(+)

diff --git a/lldb/include/lldb/Target/RegisterFlags.h 
b/lldb/include/lldb/Target/RegisterFlags.h
index d98bc0263e35e23..4edbe7255f621e5 100644
--- a/lldb/include/lldb/Target/RegisterFlags.h
+++ b/lldb/include/lldb/Target/RegisterFlags.h
@@ -10,6 +10,7 @@
 #define LLDB_TARGET_REGISTERFLAGS_H
 
 #include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
 
 namespace lldb_private {
 
@@ -51,6 +52,10 @@ class RegisterFlags {
 /// covered by either field.
 unsigned PaddingDistance(const Field &other) const;
 
+/// Output XML that describes this field, to be inserted into a target XML
+/// file.
+void ToXML(StreamString &strm) const;
+
 bool operator<(const Field &rhs) const {
   return GetStart() < rhs.GetStart();
 }
@@ -106,6 +111,9 @@ class RegisterFlags {
   /// be split into many tables as needed.
   std::string AsTable(uint32_t max_width) const;
 
+  // Output XML that describes this set of flags.
+  void ToXML(StreamString &strm) const;
+
 private:
   const std::string m_id;
   /// Size in bytes
diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 23c2f18cd388a86..1a4d561146c3bfb 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -3094,6 +3094,12 @@ GDBRemoteCommunicationServerLLGS::BuildTargetXml() {
   continue;
 }
 
+if (reg_info->flags_type) {
+  response.IndentMore();
+  reg_info->flags_type->ToXML(response);
+  response.IndentLess();
+}
+
 response.Indent();
 response.Printf("flags_type) {
+  response << "type=\"" << reg_info->flags_type->GetID() << "\" ";
+}
+
 const char *const register_set_name =
 reg_context.GetRegisterSetNameForRegisterAtIndex(reg_index);
 if (register_set_name)
diff --git a/lldb/source/Target/RegisterFlags.cpp 
b/lldb/source/Target/RegisterFlags.cpp
index 06fb45d777ec36f..a0019d15a2088b2 100644
--- a/lldb/source/Target/RegisterFlags.cpp
+++ b/lldb/source/Target/RegisterFlags.cpp
@@ -175,3 +175,35 @@ std::string RegisterFlags::AsTable(uint32_t max_width) 
const {
 
   return table;
 }
+
+void RegisterFlags::ToXML(StreamString &strm) const {
+  // Example XML:
+  // 
+  //   
+  // 
+  strm.Indent();
+  strm << "";
+  for (const Field &field : m_fields) {
+// Skip padding fields.
+if (field.GetName().empty())
+  continue;
+
+strm << "\n";
+strm.IndentMore();
+field.ToXML(strm);
+strm.IndentLess();
+  }
+  strm.PutChar('\n');
+  strm.Indent("\n");
+}
+
+void RegisterFlags::Field::ToXML(StreamString &strm) const {
+  // Example XML:
+  // 
+  strm.Indent();
+  strm << "";
+}
diff --git a/lldb/unittests/Target/RegisterFlagsTest.cpp 
b/lldb/unittests/Target/RegisterFlagsTest.cpp
index 167e28d0cecb3bd..3b34e6b1e1c160c 100644
--- a/lldb/unittests/Target/RegisterFlagsTest.cpp
+++ b/lldb/unittests/Target/RegisterFlagsTest.cpp
@@ -258,3 +258,35 @@ TEST(RegisterFlagsTest, AsTable) {
 "| really long name |",
 max_many_columns.AsTable(23));
 }
+
+TEST(RegisterFieldsTest, ToXML) {
+  StreamString strm;
+
+  // RegisterFlags requires that some fields be given, so no testing of empty
+  // input.
+
+  // Unnamed fields are padding that are ignored. This applies to fields passed
+  // in, and those generated to fill the other bits (31-1 here).
+  RegisterFlags("Foo", 4, {RegisterFlags::Field("", 0, 0)}).ToXML(strm);
+  ASSERT_EQ(strm.GetString(), "\n"
+  "\n");
+
+  strm.Clear();
+  RegisterFlags("Foo", 4, {RegisterFlags::Field("abc", 0, 0)}).ToXML(strm);
+  ASSERT_EQ(strm.GetString(), "\n"
+  "  \n"
+  "\n");
+
+  strm.Cl

[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-24 Thread David Spickett via lldb-commits


@@ -175,3 +175,35 @@ std::string RegisterFlags::AsTable(uint32_t max_width) 
const {
 
   return table;
 }
+
+void RegisterFlags::ToXML(StreamString &strm) const {
+  // Example XML:
+  // 
+  //   
+  // 
+  strm.Indent();
+  strm << "";
+  for (const Field &field : m_fields) {
+// Skip padding fields.
+if (field.GetName().empty())
+  continue;
+
+strm << "\n";
+strm.IndentMore();
+field.ToXML(strm);
+strm.IndentLess();
+  }
+  strm.PutChar('\n');
+  strm.Indent("\n");
+}
+
+void RegisterFlags::Field::ToXML(StreamString &strm) const {
+  // Example XML:
+  // 
+  strm.Indent();
+  strm << "` isn't that unlikely, 
especially if you've got a lot of system registers. Split fields like 
`Foo[3:1Foo[0]` aren't that uncommon. I could imagine `'` being used to 
mean `prime` like `Foo` and `Foo'`.

So I've used printHTMLEscaped to replace the reserved chars (which are the same 
as for XML), and gone ahead and committed some tests to check that lldb itself 
will convert those back to the original characters 
(https://github.com/llvm/llvm-project/commit/2325b3cfdadf266651294ff469ce600a8ee402ce).

https://github.com/llvm/llvm-project/pull/69951
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-24 Thread David Spickett via lldb-commits


@@ -3113,6 +3119,10 @@ GDBRemoteCommunicationServerLLGS::BuildTargetXml() {
 if (!format.empty())
   response << "format=\"" << format << "\" ";
 
+if (reg_info->flags_type) {
+  response << "type=\"" << reg_info->flags_type->GetID() << "\" ";
+}

DavidSpickett wrote:

Done.

https://github.com/llvm/llvm-project/pull/69951
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-24 Thread David Spickett via lldb-commits


@@ -10,6 +10,7 @@
 #define LLDB_TARGET_REGISTERFLAGS_H
 
 #include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"

DavidSpickett wrote:

Done.

https://github.com/llvm/llvm-project/pull/69951
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-24 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/69951

>From 5c8b9538e1e5646f19d5bb40ab19afaf2c68e804 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 9 Oct 2023 10:33:08 +0100
Subject: [PATCH 1/5] [lldb][lldb-server] Enable sending registerflags as XML

This adds ToXML methods to encode RegisterFlags and its fields
into XML according to GDB's target XML format:
https://sourceware.org/gdb/onlinedocs/gdb/Target-Description-Format.html#Target-Description-Format

lldb-server does not currently use libXML to build XML,
so this follows the existing code that uses strings. Indentation
is used so the result is still human readable.

```

  

```

This is used by lldb-server when building target XML,
though no one sets any fields yet. That'll come in a later commit.
---
 lldb/include/lldb/Target/RegisterFlags.h  |  8 +
 .../GDBRemoteCommunicationServerLLGS.cpp  | 10 ++
 lldb/source/Target/RegisterFlags.cpp  | 32 +++
 lldb/unittests/Target/RegisterFlagsTest.cpp   | 32 +++
 4 files changed, 82 insertions(+)

diff --git a/lldb/include/lldb/Target/RegisterFlags.h 
b/lldb/include/lldb/Target/RegisterFlags.h
index d98bc0263e35e23..4edbe7255f621e5 100644
--- a/lldb/include/lldb/Target/RegisterFlags.h
+++ b/lldb/include/lldb/Target/RegisterFlags.h
@@ -10,6 +10,7 @@
 #define LLDB_TARGET_REGISTERFLAGS_H
 
 #include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
 
 namespace lldb_private {
 
@@ -51,6 +52,10 @@ class RegisterFlags {
 /// covered by either field.
 unsigned PaddingDistance(const Field &other) const;
 
+/// Output XML that describes this field, to be inserted into a target XML
+/// file.
+void ToXML(StreamString &strm) const;
+
 bool operator<(const Field &rhs) const {
   return GetStart() < rhs.GetStart();
 }
@@ -106,6 +111,9 @@ class RegisterFlags {
   /// be split into many tables as needed.
   std::string AsTable(uint32_t max_width) const;
 
+  // Output XML that describes this set of flags.
+  void ToXML(StreamString &strm) const;
+
 private:
   const std::string m_id;
   /// Size in bytes
diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 23c2f18cd388a86..1a4d561146c3bfb 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -3094,6 +3094,12 @@ GDBRemoteCommunicationServerLLGS::BuildTargetXml() {
   continue;
 }
 
+if (reg_info->flags_type) {
+  response.IndentMore();
+  reg_info->flags_type->ToXML(response);
+  response.IndentLess();
+}
+
 response.Indent();
 response.Printf("flags_type) {
+  response << "type=\"" << reg_info->flags_type->GetID() << "\" ";
+}
+
 const char *const register_set_name =
 reg_context.GetRegisterSetNameForRegisterAtIndex(reg_index);
 if (register_set_name)
diff --git a/lldb/source/Target/RegisterFlags.cpp 
b/lldb/source/Target/RegisterFlags.cpp
index 06fb45d777ec36f..a0019d15a2088b2 100644
--- a/lldb/source/Target/RegisterFlags.cpp
+++ b/lldb/source/Target/RegisterFlags.cpp
@@ -175,3 +175,35 @@ std::string RegisterFlags::AsTable(uint32_t max_width) 
const {
 
   return table;
 }
+
+void RegisterFlags::ToXML(StreamString &strm) const {
+  // Example XML:
+  // 
+  //   
+  // 
+  strm.Indent();
+  strm << "";
+  for (const Field &field : m_fields) {
+// Skip padding fields.
+if (field.GetName().empty())
+  continue;
+
+strm << "\n";
+strm.IndentMore();
+field.ToXML(strm);
+strm.IndentLess();
+  }
+  strm.PutChar('\n');
+  strm.Indent("\n");
+}
+
+void RegisterFlags::Field::ToXML(StreamString &strm) const {
+  // Example XML:
+  // 
+  strm.Indent();
+  strm << "";
+}
diff --git a/lldb/unittests/Target/RegisterFlagsTest.cpp 
b/lldb/unittests/Target/RegisterFlagsTest.cpp
index 167e28d0cecb3bd..3b34e6b1e1c160c 100644
--- a/lldb/unittests/Target/RegisterFlagsTest.cpp
+++ b/lldb/unittests/Target/RegisterFlagsTest.cpp
@@ -258,3 +258,35 @@ TEST(RegisterFlagsTest, AsTable) {
 "| really long name |",
 max_many_columns.AsTable(23));
 }
+
+TEST(RegisterFieldsTest, ToXML) {
+  StreamString strm;
+
+  // RegisterFlags requires that some fields be given, so no testing of empty
+  // input.
+
+  // Unnamed fields are padding that are ignored. This applies to fields passed
+  // in, and those generated to fill the other bits (31-1 here).
+  RegisterFlags("Foo", 4, {RegisterFlags::Field("", 0, 0)}).ToXML(strm);
+  ASSERT_EQ(strm.GetString(), "\n"
+  "\n");
+
+  strm.Clear();
+  RegisterFlags("Foo", 4, {RegisterFlags::Field("abc", 0, 0)}).ToXML(strm);
+  ASSERT_EQ(strm.GetString(), "\n"
+  "  \n"
+  "\n");
+
+  strm.Cl

[Lldb-commits] [lldb] febc4ff - [lldb][AArch64][NFC] Fix typo in get trap handler function

2023-10-24 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-10-24T10:36:20Z
New Revision: febc4ff74a4e0311c3663fa5d690c59f7f692583

URL: 
https://github.com/llvm/llvm-project/commit/febc4ff74a4e0311c3663fa5d690c59f7f692583
DIFF: 
https://github.com/llvm/llvm-project/commit/febc4ff74a4e0311c3663fa5d690c59f7f692583.diff

LOG: [lldb][AArch64][NFC] Fix typo in get trap handler function

Added: 


Modified: 
lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp 
b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
index 149f541a5d3d96c..dd50bfc2dc04a37 100644
--- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
@@ -205,7 +205,7 @@ void PlatformLinux::CalculateTrapHandlerSymbolNames() {
   m_trap_handlers.push_back(ConstString("__restore_rt"));
 }
 
-static lldb::UnwindPlanSP GetAArch64TrapHanlderUnwindPlan(ConstString name) {
+static lldb::UnwindPlanSP GetAArch64TrapHandlerUnwindPlan(ConstString name) {
   UnwindPlanSP unwind_plan_sp;
   if (name != "__kernel_rt_sigreturn")
 return unwind_plan_sp;
@@ -290,7 +290,7 @@ lldb::UnwindPlanSP
 PlatformLinux::GetTrapHandlerUnwindPlan(const llvm::Triple &triple,
 ConstString name) {
   if (triple.isAArch64())
-return GetAArch64TrapHanlderUnwindPlan(name);
+return GetAArch64TrapHandlerUnwindPlan(name);
 
   return {};
 }



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


[Lldb-commits] [lldb] [lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)` return `void` (not `bool`) (PR #69989)

2023-10-24 Thread Pete Lawrence via lldb-commits

https://github.com/PortalPete updated 
https://github.com/llvm/llvm-project/pull/69989

>From fe1bc418f4404e1201da388be46a37d40b6af038 Mon Sep 17 00:00:00 2001
From: Pete Lawrence 
Date: Thu, 19 Oct 2023 18:59:57 -1000
Subject: [PATCH] [lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)`
 to return `void` instead of ~~`bool`~~

Justifications:
- The code doesn't ultimately apply the `true`/`false` return values.
- The methods already pass around a `CommandReturnObject`, typically with a 
`result` parameter.
- Each command return object already contains:
- A more precise status
- The error code(s) that apply to that status

Part 2 refactors the `CommandObject::DoExecute(...)` method.

rdar://117378957
---
 lldb/include/lldb/Interpreter/CommandAlias.h  |  2 +-
 lldb/include/lldb/Interpreter/CommandObject.h |  6 ++---
 .../lldb/Interpreter/CommandObjectMultiword.h |  4 ++--
 .../Commands/CommandObjectMultiword.cpp   | 23 ++-
 lldb/source/Interpreter/CommandAlias.cpp  |  2 +-
 lldb/source/Interpreter/CommandObject.cpp | 15 ++--
 6 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/lldb/include/lldb/Interpreter/CommandAlias.h 
b/lldb/include/lldb/Interpreter/CommandAlias.h
index 26826db62705d67..7b59ea0a74bb9e5 100644
--- a/lldb/include/lldb/Interpreter/CommandAlias.h
+++ b/lldb/include/lldb/Interpreter/CommandAlias.h
@@ -56,7 +56,7 @@ class CommandAlias : public CommandObject {
 
   void SetHelpLong(llvm::StringRef str) override;
 
-  bool Execute(const char *args_string, CommandReturnObject &result) override;
+  void Execute(const char *args_string, CommandReturnObject &result) override;
 
   lldb::CommandObjectSP GetUnderlyingCommand() {
 return m_underlying_command_sp;
diff --git a/lldb/include/lldb/Interpreter/CommandObject.h 
b/lldb/include/lldb/Interpreter/CommandObject.h
index d8358435a483bab..004f5d42f1e44ee 100644
--- a/lldb/include/lldb/Interpreter/CommandObject.h
+++ b/lldb/include/lldb/Interpreter/CommandObject.h
@@ -312,7 +312,7 @@ class CommandObject : public 
std::enable_shared_from_this {
   return false;
   }
 
-  virtual bool Execute(const char *args_string,
+  virtual void Execute(const char *args_string,
CommandReturnObject &result) = 0;
 
 protected:
@@ -398,7 +398,7 @@ class CommandObjectParsed : public CommandObject {
 
   ~CommandObjectParsed() override = default;
 
-  bool Execute(const char *args_string, CommandReturnObject &result) override;
+  void Execute(const char *args_string, CommandReturnObject &result) override;
 
 protected:
   virtual bool DoExecute(Args &command, CommandReturnObject &result) = 0;
@@ -415,7 +415,7 @@ class CommandObjectRaw : public CommandObject {
 
   ~CommandObjectRaw() override = default;
 
-  bool Execute(const char *args_string, CommandReturnObject &result) override;
+  void Execute(const char *args_string, CommandReturnObject &result) override;
 
 protected:
   virtual bool DoExecute(llvm::StringRef command,
diff --git a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h 
b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
index 1c14b492c8097fe..bceb7f0e51edb6c 100644
--- a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
+++ b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
@@ -59,7 +59,7 @@ class CommandObjectMultiword : public CommandObject {
   std::optional GetRepeatCommand(Args ¤t_command_args,
   uint32_t index) override;
 
-  bool Execute(const char *args_string, CommandReturnObject &result) override;
+  void Execute(const char *args_string, CommandReturnObject &result) override;
 
   bool IsRemovable() const override { return m_can_be_removed; }
 
@@ -129,7 +129,7 @@ class CommandObjectProxy : public CommandObject {
   /// Execute is called) and \a GetProxyCommandObject returned null.
   virtual llvm::StringRef GetUnsupportedError();
 
-  bool Execute(const char *args_string, CommandReturnObject &result) override;
+  void Execute(const char *args_string, CommandReturnObject &result) override;
 
 protected:
   // These two want to iterate over the subcommand dictionary.
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp 
b/lldb/source/Commands/CommandObjectMultiword.cpp
index 7ef829afaab6e7d..9ae09cef2eaecb9 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -159,25 +159,25 @@ llvm::Error 
CommandObjectMultiword::RemoveUserSubcommand(llvm::StringRef cmd_nam
   return llvm::Error::success();
 }
 
-bool CommandObjectMultiword::Execute(const char *args_string,
+void CommandObjectMultiword::Execute(const char *args_string,
  CommandReturnObject &result) {
   Args args(args_string);
   const size_t argc = args.GetArgumentCount();
   if (argc == 0) {
 this->CommandObject::GenerateHelpText(result);
-return result.Succeeded();
+return;
   }
 
   auto sub_com

[Lldb-commits] [lldb] [lldb] Part 2 of 2 - Refactor `CommandObject::DoExecute(...)` return `void` (not `bool`) (PR #69991)

2023-10-24 Thread Pete Lawrence via lldb-commits


@@ -1541,18 +1539,18 @@ class CommandObjectMemoryWrite : public 
CommandObjectParsed {
 
 if (!buffer.GetString().empty()) {
   Status error;
-  if (process->WriteMemory(addr, buffer.GetString().data(),
-   buffer.GetString().size(),
-   error) == buffer.GetString().size())
-return true;
-  else {
+  const char *bufferData = buffer.GetString().data();

PortalPete wrote:

Ah yes, of course.
Done and done.

https://github.com/llvm/llvm-project/pull/69991
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Part 2 of 2 - Refactor `CommandObject::DoExecute(...)` return `void` (not `bool`) (PR #69991)

2023-10-24 Thread Pete Lawrence via lldb-commits


@@ -429,11 +428,12 @@ llvm::StringRef CommandObjectProxy::GetUnsupportedError() 
{
   return "command is not implemented";
 }
 
-bool CommandObjectProxy::Execute(const char *args_string,
+void CommandObjectProxy::Execute(const char *args_string,
  CommandReturnObject &result) {
   CommandObject *proxy_command = GetProxyCommandObject();
-  if (proxy_command)
-return proxy_command->Execute(args_string, result);
+  if (proxy_command) {
+proxy_command->Execute(args_string, result);

PortalPete wrote:

Good catch and fixed.

This particular change belongs to Part 1, which is where @kastiglione pointed 
out in the other PR (https://github.com/llvm/llvm-project/pull/69989).

https://github.com/llvm/llvm-project/pull/69991
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Part 2 of 2 - Refactor `CommandObject::DoExecute(...)` return `void` (not `bool`) (PR #69991)

2023-10-24 Thread Pete Lawrence via lldb-commits


@@ -769,10 +768,10 @@ bool CommandObjectRaw::Execute(const char *args_string,
 handled = InvokeOverrideCallback(argv, result);
   }
   if (!handled) {
-if (CheckRequirements(result))
-  handled = DoExecute(args_string, result);
+if (CheckRequirements(result)) {

PortalPete wrote:

I agree with you, which is why I didn't remove `if (!handled)`.

Did you mean to refer to something else in this part of the diff?

https://github.com/llvm/llvm-project/pull/69991
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)` return `void` (not `bool`) (PR #69989)

2023-10-24 Thread Pete Lawrence via lldb-commits


@@ -429,11 +428,12 @@ llvm::StringRef CommandObjectProxy::GetUnsupportedError() 
{
   return "command is not implemented";
 }
 
-bool CommandObjectProxy::Execute(const char *args_string,
+void CommandObjectProxy::Execute(const char *args_string,
  CommandReturnObject &result) {
   CommandObject *proxy_command = GetProxyCommandObject();
-  if (proxy_command)
-return proxy_command->Execute(args_string, result);
+  if (proxy_command) {
+proxy_command->Execute(args_string, result);

PortalPete wrote:

Agreed and fixed! Thanks for catching that.

https://github.com/llvm/llvm-project/pull/69989
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][AArch64] Invalidate SVG prior to reconfiguring ZA regdef (PR #66768)

2023-10-24 Thread David Spickett via lldb-commits

DavidSpickett wrote:

ping!

I know you're very busy at the moment, but if you have time to review this week 
this is the most important patch I've got queued.

https://github.com/llvm/llvm-project/pull/66768
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)` return `void` (not `bool`) (PR #69989)

2023-10-24 Thread Dave Lee via lldb-commits

https://github.com/kastiglione edited 
https://github.com/llvm/llvm-project/pull/69989
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-24 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

@clayborg Thank you for extensive feedback! Can you clarify where do you want 
me to put the changes?

---
You expected the following:
> v.SetFormat(lldb.eFormatDecimal)
v.GetValue()
`1(1)`

But my patch doesn't seem to alter the behavior of `eFormatDecimal`. The code 
and LLDB output with this PR applied are below.
```cpp
enum E {
  E1 = 0
};

int main()
{
E e;
return 0;
}
```
```
* thread #1, name = 'enum_test', stop reason = breakpoint 1.1
frame #0: 0x513b enum_test`main at test.cxx:8:5
   5int main()
   6{
   7E e;
-> 8return 0;
   9}
(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
>>> lldb.frame.FindVariable("e")
(E) e = E1(0)
>>> e = lldb.frame.FindVariable("e")
>>> e.SetFormat(lldb.eFormatDecimal)
>>> e
(E) e = 0
>>> e.GetValue()
'0'
>>> e.GetSummary()
>>>
```

---

I'm also wondering if refactoring this patch to use summaries is going to 
affect the way we dump enum *types* (with enumerators included). Apparently, 
this is covered by `TestRustEnumStructs.py` test that I change in this PR.

https://github.com/llvm/llvm-project/pull/69815
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-24 Thread Aaron Ballman via lldb-commits

AaronBallman wrote:

> What IDE are you using for the screenshot above? 

Visual Studio

> The issue you might run into is that IDE might only be showing the value 
> string and not the summary string. XCode and Visual Studio code will show the 
> value if there is one _and_ the summary if there is one. If there is no value 
> (structs and class instances have no values), then they show the summary only.

Ah that could explain it. I'm used to seeing the value and the summary when 
both are available.

https://github.com/llvm/llvm-project/pull/69815
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][AArch64] Correct type of 32 bit GPR RegisterValues when using core files (PR #70054)

2023-10-24 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett created 
https://github.com/llvm/llvm-project/pull/70054

As ReadRegister always read into a uint64_t, when it called operator= with 
uint64_t it was setting the RegisterValue's type to eTypeUInt64 regardless of 
its size.

This mostly works because most registers are 64 bit, and very few bits of code 
rely on the type being correct. However, cpsr, fpsr and fpcr are in fact 32 
bit, and my upcoming register fields code relies on this type being correct.

Which is how I found this bug and unfortunately is the only way to test it. As 
RegisterValue::Type never makes it out via the API anywhere. So this change 
will be tested once I start adding register field information.

>From fe4fba18d7fbe6d7e0111ca592d4c517262d8122 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Tue, 24 Oct 2023 14:56:58 +
Subject: [PATCH] [lldb][AArch64] Correct type of 32 bit GPR RegisterValues
 when using core files

As ReadRegister always read into a uint64_t, when it called operator= with 
uint64_t
it was setting the RegisterValue's type to eTypeUInt64 regardless of its size.

This mostly works because most registers are 64 bit, and very few bits of code
rely on the type being correct. However, cpsr, fpsr and fpcr are in fact 32 bit,
and my upcoming register fields code relies on this type being correct.

Which is how I found this bug and unfortunately is the only way to test it.
As RegisterValue::Type never makes it out via the API anywhere. So this
change will be tested once I start adding register field information.
---
 .../Process/elf-core/RegisterContextPOSIXCore_arm64.cpp   | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git 
a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp 
b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
index 6f6c6d073939a61..f3e763b0475ceb1 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
@@ -184,11 +184,9 @@ bool RegisterContextCorePOSIX_arm64::ReadRegister(const 
RegisterInfo *reg_info,
 
   offset = reg_info->byte_offset;
   if (offset + reg_info->byte_size <= GetGPRSize()) {
-uint64_t v = m_gpr_data.GetMaxU64(&offset, reg_info->byte_size);
-if (offset == reg_info->byte_offset + reg_info->byte_size) {
-  value = v;
-  return true;
-}
+value.SetFromMemoryData(*reg_info, m_gpr_data.GetDataStart() + offset,
+reg_info->byte_size, lldb::eByteOrderLittle, 
error);
+return error.Success();
   }
 
   const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];

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


[Lldb-commits] [lldb] [lldb][AArch64] Correct type of 32 bit GPR RegisterValues when using core files (PR #70054)

2023-10-24 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)


Changes

As ReadRegister always read into a uint64_t, when it called operator= with 
uint64_t it was setting the RegisterValue's type to eTypeUInt64 regardless of 
its size.

This mostly works because most registers are 64 bit, and very few bits of code 
rely on the type being correct. However, cpsr, fpsr and fpcr are in fact 32 
bit, and my upcoming register fields code relies on this type being correct.

Which is how I found this bug and unfortunately is the only way to test it. As 
RegisterValue::Type never makes it out via the API anywhere. So this change 
will be tested once I start adding register field information.

---
Full diff: https://github.com/llvm/llvm-project/pull/70054.diff


1 Files Affected:

- (modified) 
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp (+3-5) 


``diff
diff --git 
a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp 
b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
index 6f6c6d073939a61..f3e763b0475ceb1 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
@@ -184,11 +184,9 @@ bool RegisterContextCorePOSIX_arm64::ReadRegister(const 
RegisterInfo *reg_info,
 
   offset = reg_info->byte_offset;
   if (offset + reg_info->byte_size <= GetGPRSize()) {
-uint64_t v = m_gpr_data.GetMaxU64(&offset, reg_info->byte_size);
-if (offset == reg_info->byte_offset + reg_info->byte_size) {
-  value = v;
-  return true;
-}
+value.SetFromMemoryData(*reg_info, m_gpr_data.GetDataStart() + offset,
+reg_info->byte_size, lldb::eByteOrderLittle, 
error);
+return error.Success();
   }
 
   const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];

``




https://github.com/llvm/llvm-project/pull/70054
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 00d3ed6 - [Reland] Detect against invalid variant index for LibStdC++ std::variant data formatters (#69614)

2023-10-24 Thread via lldb-commits

Author: jeffreytan81
Date: 2023-10-24T08:44:34-07:00
New Revision: 00d3ed6deadb1d647b70ab37ac66ada6a550c1ba

URL: 
https://github.com/llvm/llvm-project/commit/00d3ed6deadb1d647b70ab37ac66ada6a550c1ba
DIFF: 
https://github.com/llvm/llvm-project/commit/00d3ed6deadb1d647b70ab37ac66ada6a550c1ba.diff

LOG: [Reland] Detect against invalid variant index for LibStdC++ std::variant 
data formatters (#69614)

This is relanding of https://github.com/llvm/llvm-project/pull/69253.
`TestTemplatePackArgs.py` is passing now.

https://github.com/llvm/llvm-project/pull/68012/files added new data
formatters for LibStdC++ std::variant.

However, this formatter can crash if std::variant's index field has
invalid value (exceeds the number of template arguments).
This can happen if the current IP stops at a place std::variant is not
initialized yet.

This patch fixes the crash by ensuring the index is a valid value and
fix GetNthTemplateArgument() to make sure it is not crashing.

Co-authored-by: jeffreytan81 

Added: 


Modified: 
lldb/examples/synthetic/gnu_libstdcpp.py
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py

Removed: 




diff  --git a/lldb/examples/synthetic/gnu_libstdcpp.py 
b/lldb/examples/synthetic/gnu_libstdcpp.py
index 29c926167fb440c..f778065aaca3771 100644
--- a/lldb/examples/synthetic/gnu_libstdcpp.py
+++ b/lldb/examples/synthetic/gnu_libstdcpp.py
@@ -914,6 +914,11 @@ def get_variant_npos_value(index_byte_size):
 if index == npos_value:
 return " No Value"
 
+# Invalid index can happen when the variant is not initialized yet.
+template_arg_count = data_obj.GetType().GetNumberOfTemplateArguments()
+if index >= template_arg_count:
+return " "
+
 active_type = data_obj.GetType().GetTemplateArgumentType(index)
 return f" Active Type = {active_type.GetDisplayTypeName()} "
 

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index f1353db2631ddc6..df06ba0ed952af7 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7183,7 +7183,8 @@ GetNthTemplateArgument(const 
clang::ClassTemplateSpecializationDecl *decl,
   // (including the ones preceding the parameter pack).
   const auto &pack = args[last_idx];
   const size_t pack_idx = idx - last_idx;
-  assert(pack_idx < pack.pack_size() && "parameter pack index out-of-bounds");
+  if (pack_idx >= pack.pack_size())
+return nullptr;
   return &pack.pack_elements()[pack_idx];
 }
 

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
index 96a9c8d30c45b00..ba1641888b6f30f 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
@@ -71,3 +71,29 @@ def test_with_run_command(self):
 substrs=["v_many_types_no_value =  No Value"],
 )
 """
+
+@add_test_categories(["libstdcxx"])
+def test_invalid_variant_index(self):
+"""Test LibStdC++ data formatter for std::variant with invalid 
index."""
+self.build()
+
+(self.target, self.process, thread, bkpt) = 
lldbutil.run_to_source_breakpoint(
+self, "// break here", lldb.SBFileSpec("main.cpp", False)
+)
+
+lldbutil.continue_to_breakpoint(self.process, bkpt)
+
+self.expect(
+"frame variable v1",
+substrs=["v1 =  Active Type = int  {", "Value = 12", "}"],
+)
+
+var_v1 = thread.frames[0].FindVariable("v1")
+var_v1_raw_obj = var_v1.GetNonSyntheticValue()
+index_obj = var_v1_raw_obj.GetChildMemberWithName("_M_index")
+self.assertTrue(index_obj and index_obj.IsValid())
+
+INVALID_INDEX = "100"
+index_obj.SetValueFromCString(INVALID_INDEX)
+
+self.expect("frame variable v1", substrs=["v1 =  "])



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


[Lldb-commits] [lldb] [Reland] Detect against invalid variant index for LibStdC++ std::variant data formatters (PR #69614)

2023-10-24 Thread via lldb-commits

https://github.com/jeffreytan81 closed 
https://github.com/llvm/llvm-project/pull/69614
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Part 2 of 2 - Refactor `CommandObject::DoExecute(...)` return `void` (not `bool`) (PR #69991)

2023-10-24 Thread Jason Molenda via lldb-commits


@@ -769,10 +768,10 @@ bool CommandObjectRaw::Execute(const char *args_string,
 handled = InvokeOverrideCallback(argv, result);
   }
   if (!handled) {
-if (CheckRequirements(result))
-  handled = DoExecute(args_string, result);
+if (CheckRequirements(result)) {

jasonmolenda wrote:

ah my eyes might have been glazing over at this point, I must have misread it. 
:)

https://github.com/llvm/llvm-project/pull/69991
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 3b89794 - Reintroduce accidentally deleted "protected" keyword in SymbolFileDWARF (#69990)

2023-10-24 Thread via lldb-commits

Author: Augusto Noronha
Date: 2023-10-24T09:27:08-07:00
New Revision: 3b897943045c00509af586a7fbe95fbeaf32c12e

URL: 
https://github.com/llvm/llvm-project/commit/3b897943045c00509af586a7fbe95fbeaf32c12e
DIFF: 
https://github.com/llvm/llvm-project/commit/3b897943045c00509af586a7fbe95fbeaf32c12e.diff

LOG: Reintroduce accidentally deleted "protected" keyword in SymbolFileDWARF 
(#69990)

The "protected" was accidentally removed during refactoring of
SymbolFileDWARF. Reintroduce it and also make DWARFASTParser a friend
class since 040c4f4d98f3306e068521e3c218bdbc170f81f3 was merged and
won't build without it, as it dependeds on a method which was made
public by accident.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 646d5d9a471c41c..0818ee206fe06f6 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -82,6 +82,7 @@ class SymbolFileDWARF : public SymbolFileCommon {
   friend class DebugMapModule;
   friend class DWARFCompileUnit;
   friend class DWARFDIE;
+  friend class DWARFASTParser;
   friend class ::DWARFASTParserClang;
 
   // Static Functions
@@ -321,6 +322,7 @@ class SymbolFileDWARF : public SymbolFileCommon {
 m_file_index = file_index;
   }
 
+protected:
   typedef llvm::DenseMap DIEToTypePtr;
   typedef llvm::DenseMap
   DIEToVariableSP;



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


[Lldb-commits] [lldb] Reintroduce accidentally deleted "protected" keyword in SymbolFileDWARF (PR #69990)

2023-10-24 Thread Augusto Noronha via lldb-commits

https://github.com/augusto2112 closed 
https://github.com/llvm/llvm-project/pull/69990
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][gardening] Remove full name of "DWARFDIE" type in GetTypeForDIE (PR #70062)

2023-10-24 Thread Augusto Noronha via lldb-commits

https://github.com/augusto2112 created 
https://github.com/llvm/llvm-project/pull/70062

When moving the GetTypeForDIE function from DWARFASTParserClang to 
DWARFASTParser, I kept the signature as-is. To match the rest of the function 
signatures in DWARFASTParser, remove the full name 
(lldb_private::plugin::dwarf::DWARFDIE -> DWARFDIE) in the signature of 
DWARFASTParser::GetTypeForDIE.

>From 3c6b7d07b088c50bb4efc05c9ffac484fd6d30a6 Mon Sep 17 00:00:00 2001
From: Augusto Noronha 
Date: Tue, 24 Oct 2023 09:44:19 -0700
Subject: [PATCH] [lldb][gardening] Remove full name of "DWARFDIE" type in
 GetTypeForDIE

When moving the GetTypeForDIE function from DWARFASTParserClang to
DWARFASTParser, I kept the signature as-is. To match the rest of the
function signatures in DWARFASTParser, remove the full name
(lldb_private::plugin::dwarf::DWARFDIE -> DWARFDIE) in the signature
of DWARFASTParser::GetTypeForDIE.
---
 lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
index 6749cb0e5db17a6..66db396279e0630 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
@@ -64,8 +64,7 @@ class DWARFASTParser {
   ParseChildArrayInfo(const DWARFDIE &parent_die,
   const ExecutionContext *exe_ctx = nullptr);
 
-  lldb_private::Type *
-  GetTypeForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die);
+  lldb_private::Type *GetTypeForDIE(const DWARFDIE &die);
 
   static lldb::AccessType GetAccessTypeFromDWARF(uint32_t dwarf_accessibility);
 

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


[Lldb-commits] [lldb] [lldb][gardening] Remove full name of "DWARFDIE" type in GetTypeForDIE (PR #70062)

2023-10-24 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Augusto Noronha (augusto2112)


Changes

When moving the GetTypeForDIE function from DWARFASTParserClang to 
DWARFASTParser, I kept the signature as-is. To match the rest of the function 
signatures in DWARFASTParser, remove the full name 
(lldb_private::plugin::dwarf::DWARFDIE -> DWARFDIE) in the signature of 
DWARFASTParser::GetTypeForDIE.

---
Full diff: https://github.com/llvm/llvm-project/pull/70062.diff


1 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h (+1-2) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
index 6749cb0e5db17a6..66db396279e0630 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
@@ -64,8 +64,7 @@ class DWARFASTParser {
   ParseChildArrayInfo(const DWARFDIE &parent_die,
   const ExecutionContext *exe_ctx = nullptr);
 
-  lldb_private::Type *
-  GetTypeForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die);
+  lldb_private::Type *GetTypeForDIE(const DWARFDIE &die);
 
   static lldb::AccessType GetAccessTypeFromDWARF(uint32_t dwarf_accessibility);
 

``




https://github.com/llvm/llvm-project/pull/70062
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] e3476f6 - [lldb][gardening] Remove full name of "DWARFDIE" type in GetTypeForDIE (#70062)

2023-10-24 Thread via lldb-commits

Author: Augusto Noronha
Date: 2023-10-24T09:49:08-07:00
New Revision: e3476f68af5dd5e7ed672ac688396d6d6fba09b4

URL: 
https://github.com/llvm/llvm-project/commit/e3476f68af5dd5e7ed672ac688396d6d6fba09b4
DIFF: 
https://github.com/llvm/llvm-project/commit/e3476f68af5dd5e7ed672ac688396d6d6fba09b4.diff

LOG: [lldb][gardening] Remove full name of "DWARFDIE" type in GetTypeForDIE 
(#70062)

When moving the GetTypeForDIE function from DWARFASTParserClang to
DWARFASTParser, I kept the signature as-is. To match the rest of the
function signatures in DWARFASTParser, remove the full name
(lldb_private::plugin::dwarf::DWARFDIE -> DWARFDIE) in the signature of
DWARFASTParser::GetTypeForDIE.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
index 6749cb0e5db17a6..66db396279e0630 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
@@ -64,8 +64,7 @@ class DWARFASTParser {
   ParseChildArrayInfo(const DWARFDIE &parent_die,
   const ExecutionContext *exe_ctx = nullptr);
 
-  lldb_private::Type *
-  GetTypeForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die);
+  lldb_private::Type *GetTypeForDIE(const DWARFDIE &die);
 
   static lldb::AccessType GetAccessTypeFromDWARF(uint32_t dwarf_accessibility);
 



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


[Lldb-commits] [lldb] [lldb][gardening] Remove full name of "DWARFDIE" type in GetTypeForDIE (PR #70062)

2023-10-24 Thread Augusto Noronha via lldb-commits

https://github.com/augusto2112 closed 
https://github.com/llvm/llvm-project/pull/70062
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)` return `void` (not `bool`) (PR #69989)

2023-10-24 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere edited 
https://github.com/llvm/llvm-project/pull/69989
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)` return `void` (not `bool`) (PR #69989)

2023-10-24 Thread Jonas Devlieghere via lldb-commits


@@ -769,10 +768,10 @@ bool CommandObjectRaw::Execute(const char *args_string,
 handled = InvokeOverrideCallback(argv, result);
   }
   if (!handled) {
-if (CheckRequirements(result))
-  handled = DoExecute(args_string, result);
+if (CheckRequirements(result)) {
+  DoExecute(args_string, result);
+}

JDevlieghere wrote:

No braces around single line if's as per the [LLVM Coding 
Standards](https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements).
 

https://github.com/llvm/llvm-project/pull/69989
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)` return `void` (not `bool`) (PR #69989)

2023-10-24 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere approved this pull request.

A few small nits but overall this LGTM. 

https://github.com/llvm/llvm-project/pull/69989
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)` return `void` (not `bool`) (PR #69989)

2023-10-24 Thread Jonas Devlieghere via lldb-commits


@@ -715,7 +715,7 @@ Thread *CommandObject::GetDefaultThread() {
 return nullptr;
 }
 
-bool CommandObjectParsed::Execute(const char *args_string,
+void CommandObjectParsed::Execute(const char *args_string,
   CommandReturnObject &result) {
   bool handled = false;

JDevlieghere wrote:

Not necessary for this patch, but you could probably get rid of `handled` with 
some an return. 

https://github.com/llvm/llvm-project/pull/69989
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)` return `void` (not `bool`) (PR #69989)

2023-10-24 Thread Jonas Devlieghere via lldb-commits


@@ -429,11 +428,13 @@ llvm::StringRef CommandObjectProxy::GetUnsupportedError() 
{
   return "command is not implemented";
 }
 
-bool CommandObjectProxy::Execute(const char *args_string,
+void CommandObjectProxy::Execute(const char *args_string,
  CommandReturnObject &result) {
   CommandObject *proxy_command = GetProxyCommandObject();
-  if (proxy_command)
-return proxy_command->Execute(args_string, result);
-  result.AppendError(GetUnsupportedError());
-  return false;
+  if (!proxy_command) {
+result.AppendError(GetUnsupportedError());
+return;
+  }
+
+  proxy_command->Execute(args_string, result);
 }

JDevlieghere wrote:

Possibly simpler:

```
if (CommandObject *proxy_command = GetProxyCommandObject()) 
  proxy_command->Execute(args_string, result); 
else 
  result.AppendError(GetUnsupportedError());
```

https://github.com/llvm/llvm-project/pull/69989
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb/Interpreter] Make ScriptedInterface Object creation more generic (PR #68052)

2023-10-24 Thread Jonas Devlieghere via lldb-commits


@@ -19,11 +19,11 @@
 namespace lldb_private {
 class ScriptedPlatformInterface : virtual public ScriptedInterface {
 public:
-  StructuredData::GenericSP
+  virtual llvm::Expected
   CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
  StructuredData::DictionarySP args_sp,
- StructuredData::Generic *script_obj = nullptr) override {
-return {};
+ StructuredData::Generic *script_obj = nullptr) {
+llvm_unreachable("unimplemented!");

JDevlieghere wrote:

Could this be a pure virtual method? If not maybe something like "Cannot create 
an instance of an interface" would be a more informative error message.

https://github.com/llvm/llvm-project/pull/68052
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb/Interpreter] Make ScriptedInterface Object creation more generic (PR #68052)

2023-10-24 Thread Jonas Devlieghere via lldb-commits


@@ -32,6 +32,84 @@ class ScriptedPythonInterface : virtual public 
ScriptedInterface {
   ScriptedPythonInterface(ScriptInterpreterPythonImpl &interpreter);
   ~ScriptedPythonInterface() override = default;
 
+  template 
+  llvm::Expected
+  CreatePluginObject(llvm::StringRef class_name,
+ StructuredData::Generic *script_obj, Args... args) {
+using namespace python;
+using Locker = ScriptInterpreterPythonImpl::Locker;
+
+std::string error_string;
+if (class_name.empty() &&
+llvm::StringRef(m_interpreter.GetDictionaryName()).empty() &&
+!script_obj)
+  return llvm::createStringError(
+  llvm::inconvertibleErrorCode(),
+  "ScriptedPythonInterface::CreatePluginObject - missing script class "
+  "name, dictionary or object.");
+
+Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
+   Locker::FreeLock);
+
+PythonObject result = {};
+
+if (!script_obj) {
+  auto dict =
+  PythonModule::MainModule().ResolveName(
+  m_interpreter.GetDictionaryName());
+  auto pfunc =
+  PythonObject::ResolveNameWithDictionary(
+  class_name, dict);
+
+  if (!pfunc.IsAllocated()) {
+error_string.append("Could not find script class: ");
+error_string.append(class_name);
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   error_string);
+  }
+
+  std::tuple original_args = std::forward_as_tuple(args...);
+  auto transformed_args = TransformArgs(original_args);
+
+  llvm::Expected arg_info = pfunc.GetArgInfo();
+  if (!arg_info) {
+llvm::handleAllErrors(
+arg_info.takeError(),
+[&](PythonException &E) { error_string.append(E.ReadBacktrace()); 
},
+[&](const llvm::ErrorInfoBase &E) {
+  error_string.append(E.message());
+});
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   error_string);
+  }
+
+  llvm::Expected expected_return_object =
+  llvm::make_error("Not initialized.",
+  llvm::inconvertibleErrorCode());
+
+  std::apply(
+  [&pfunc, &expected_return_object](auto &&...args) {
+llvm::consumeError(expected_return_object.takeError());
+expected_return_object = pfunc(args...);
+  },
+  transformed_args);
+
+  if (llvm::Error e = expected_return_object.takeError())
+return e;
+  result = std::move(expected_return_object.get());
+} else
+  result = PythonObject(PyRefType::Borrowed,
+static_cast(script_obj->GetValue()));

JDevlieghere wrote:

This is mostly personal preference, but since this is simpler than the other 
case, I'd put this one first. That way I can page out the "what if script_obj 
is not NULL" as I'm reading the bigger block above. 

https://github.com/llvm/llvm-project/pull/68052
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb/Interpreter] Make ScriptedInterface Object creation more generic (PR #68052)

2023-10-24 Thread Jonas Devlieghere via lldb-commits


@@ -56,14 +56,17 @@ ScriptedThread::Create(ScriptedProcess &process,
   }
 
   ExecutionContext exe_ctx(process);
-  StructuredData::GenericSP owned_script_object_sp =
-  scripted_thread_interface->CreatePluginObject(
-  thread_class_name, exe_ctx, process.m_scripted_metadata.GetArgsSP(),
-  script_object);
+  auto obj_or_err = scripted_thread_interface->CreatePluginObject(
+  thread_class_name, exe_ctx, process.m_scripted_metadata.GetArgsSP(),
+  script_object);
 
-  if (!owned_script_object_sp)
+  if (!obj_or_err) {
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"Failed to create script object.");
+  }

JDevlieghere wrote:

No braces around single-line if.

https://github.com/llvm/llvm-project/pull/68052
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb/Interpreter] Make ScriptedInterface Object creation more generic (PR #68052)

2023-10-24 Thread Jonas Devlieghere via lldb-commits


@@ -32,6 +32,84 @@ class ScriptedPythonInterface : virtual public 
ScriptedInterface {
   ScriptedPythonInterface(ScriptInterpreterPythonImpl &interpreter);
   ~ScriptedPythonInterface() override = default;
 
+  template 
+  llvm::Expected
+  CreatePluginObject(llvm::StringRef class_name,
+ StructuredData::Generic *script_obj, Args... args) {
+using namespace python;
+using Locker = ScriptInterpreterPythonImpl::Locker;
+
+std::string error_string;
+if (class_name.empty() &&
+llvm::StringRef(m_interpreter.GetDictionaryName()).empty() &&
+!script_obj)
+  return llvm::createStringError(
+  llvm::inconvertibleErrorCode(),
+  "ScriptedPythonInterface::CreatePluginObject - missing script class "
+  "name, dictionary or object.");
+
+Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
+   Locker::FreeLock);
+
+PythonObject result = {};
+
+if (!script_obj) {
+  auto dict =
+  PythonModule::MainModule().ResolveName(
+  m_interpreter.GetDictionaryName());
+  auto pfunc =
+  PythonObject::ResolveNameWithDictionary(
+  class_name, dict);
+
+  if (!pfunc.IsAllocated()) {
+error_string.append("Could not find script class: ");
+error_string.append(class_name);
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   error_string);

JDevlieghere wrote:

Could you just pass those as twines to `createStringError`? 

https://github.com/llvm/llvm-project/pull/68052
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb/Interpreter] Make ScriptedInterface Object creation more generic (PR #68052)

2023-10-24 Thread Jonas Devlieghere via lldb-commits


@@ -32,6 +32,84 @@ class ScriptedPythonInterface : virtual public 
ScriptedInterface {
   ScriptedPythonInterface(ScriptInterpreterPythonImpl &interpreter);
   ~ScriptedPythonInterface() override = default;
 
+  template 
+  llvm::Expected
+  CreatePluginObject(llvm::StringRef class_name,
+ StructuredData::Generic *script_obj, Args... args) {
+using namespace python;
+using Locker = ScriptInterpreterPythonImpl::Locker;
+
+std::string error_string;
+if (class_name.empty() &&
+llvm::StringRef(m_interpreter.GetDictionaryName()).empty() &&
+!script_obj)
+  return llvm::createStringError(
+  llvm::inconvertibleErrorCode(),
+  "ScriptedPythonInterface::CreatePluginObject - missing script class "
+  "name, dictionary or object.");

JDevlieghere wrote:

Can we make these 3 separate errors? We know which ones are missing. 
Alternatively, you could make them bools and conditionally include the "name", 
"dictionary" and "object" substrings based on that. 

https://github.com/llvm/llvm-project/pull/68052
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D62732: [RISCV] Add SystemV ABI

2023-10-24 Thread Aditya Kumar via Phabricator via lldb-commits
hiraditya added a comment.
Herald added subscribers: wangpc, jobnoorman, luke.

We should close this as it has been pushed upstream as part of 
https://reviews.llvm.org/rG847de9c332775d1841fec9fea5cb5c41592a4c8f


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62732

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


[Lldb-commits] [lldb] [lldb][AArch64] Correct type of 32 bit GPR RegisterValues when using core files (PR #70054)

2023-10-24 Thread Alex Langford via lldb-commits

https://github.com/bulbazord approved this pull request.

Since this bug only really manifests with later changes, I think it's fine to 
fix it without a test for now. Please make sure there is a test that exercises 
this behavior in your follow-up.



https://github.com/llvm/llvm-project/pull/70054
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-24 Thread Greg Clayton via lldb-commits

clayborg wrote:

Is there a way to have Visual Studio change the display format of the enum 
values? 

I currently like the way that enum values are displayed without any changes 
where we try to show the enum value as an integer because I can change the 
format if that is needed, or use the command line API to get the lldb::SBValue 
and get the value and signed or unsigned manually if it is needed.

Does anyone else have any input for or against showing the signed/unsigned 
value as a summary? 

I would vote to leave things as is, but if others support showing the 
signed/unsigned value, then we can make that happen. The needed change in that 
case would be to show the signed/unsigned as a value as the summary.

https://github.com/llvm/llvm-project/pull/69815
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)` return `void` (not `bool`) (PR #69989)

2023-10-24 Thread Alex Langford via lldb-commits

https://github.com/bulbazord approved this pull request.

LGTM with everyone else's comments. Thanks for working on this!

https://github.com/llvm/llvm-project/pull/69989
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (PR #69981)

2023-10-24 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/69981

>From 367431f51f5f75b2035e6bac7944fc0a03ca3cc0 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Mon, 23 Oct 2023 15:55:40 -0700
Subject: [PATCH] Expose DWARFDIE::GetDeclContext() in lldb_private::Function.

I need this API in the Swift plugin, but it seems generally useful
enough to expose it in the main branch.
---
 lldb/include/lldb/Symbol/Function.h   |  6 
 lldb/include/lldb/Symbol/SymbolFile.h | 12 ---
 lldb/include/lldb/Symbol/Type.h   |  2 +-
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  |  9 +++---
 .../Plugins/SymbolFile/DWARF/DWARFDIE.cpp | 32 ++-
 .../Plugins/SymbolFile/DWARF/DWARFDIE.h   |  2 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 14 ++--
 .../SymbolFile/DWARF/SymbolFileDWARF.h|  3 ++
 .../DWARF/SymbolFileDWARFDebugMap.cpp | 18 +++
 .../DWARF/SymbolFileDWARFDebugMap.h   |  2 ++
 lldb/source/Symbol/Function.cpp   | 23 ++---
 lldb/source/Symbol/Type.cpp   | 32 ++-
 .../DWARF/x86/find-basic-function.cpp |  2 +-
 .../SymbolFile/DWARF/x86/module-ownership.mm  |  2 +-
 lldb/tools/lldb-test/lldb-test.cpp|  8 ++---
 15 files changed, 106 insertions(+), 61 deletions(-)

diff --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index 28afdbff1eb233e..8255c2baea77001 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -533,6 +533,12 @@ class Function : public UserID, public SymbolContextScope {
   /// The DeclContext, or NULL if none exists.
   CompilerDeclContext GetDeclContext();
 
+  /// Get the CompilerContext for this function, if available.
+  ///
+  /// \return
+  /// The CompilerContext, or an empty vector if none is available.
+  std::vector GetCompilerContext();
+
   /// Get accessor for the type that describes the function return value type,
   /// and parameter types.
   ///
diff --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index 512dd9acb86db61..b40d0f03b6e0130 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -225,14 +225,16 @@ class SymbolFile : public PluginInterface {
 
   virtual bool CompleteType(CompilerType &compiler_type) = 0;
   virtual void ParseDeclsForContext(CompilerDeclContext decl_ctx) {}
-  virtual CompilerDecl GetDeclForUID(lldb::user_id_t uid) {
-return CompilerDecl();
-  }
+  virtual CompilerDecl GetDeclForUID(lldb::user_id_t uid) { return {}; }
   virtual CompilerDeclContext GetDeclContextForUID(lldb::user_id_t uid) {
-return CompilerDeclContext();
+return {};
   }
   virtual CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid) 
{
-return CompilerDeclContext();
+return {};
+  }
+  virtual std::vector
+  GetCompilerContextForUID(lldb::user_id_t uid) {
+return {};
   }
   virtual uint32_t ResolveSymbolContext(const Address &so_addr,
 lldb::SymbolContextItem resolve_scope,
diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index c505262cd9eaecf..3d9ed2183d81ecd 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -34,7 +34,7 @@ struct CompilerContext {
   }
   bool operator!=(const CompilerContext &rhs) const { return !(*this == rhs); }
 
-  void Dump() const;
+  void Dump(Stream *s) const;
 
   CompilerContextKind kind;
   ConstString name;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 545a5dcc7d0fd09..43d61a9f66c0ba2 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -142,8 +142,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const 
SymbolContext &sc,
   // If this type comes from a Clang module, recursively look in the
   // DWARF section of the .pcm file in the module cache. Clang
   // generates DWO skeleton units as breadcrumbs to find them.
-  llvm::SmallVector decl_context;
-  die.GetDeclContext(decl_context);
+  std::vector decl_context = die.GetDeclContext();
   TypeMap pcm_types;
 
   // The type in the Clang module must have the same language as the current 
CU.
@@ -2286,7 +2285,7 @@ CompilerDecl 
DWARFASTParserClang::GetDeclForUIDFromDWARF(const DWARFDIE &die) {
   clang::Decl *clang_decl = GetClangDeclForDIE(die);
   if (clang_decl != nullptr)
 return m_ast.GetCompilerDecl(clang_decl);
-  return CompilerDecl();
+  return {};
 }
 
 CompilerDeclContext
@@ -2294,7 +2293,7 @@ DWARFASTParserClang::GetDeclContextForUIDFromDWARF(const 
DWARFDIE &die) {
   clang::DeclContext *clang_decl_ctx = GetClangDeclContextForDIE(die);
   if (clang_decl_ctx)
 return m_ast.CreateDeclContext(clang_dec

[Lldb-commits] [lldb] Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (PR #69981)

2023-10-24 Thread Adrian Prantl via lldb-commits


@@ -34,7 +34,7 @@ struct CompilerContext {
   }
   bool operator!=(const CompilerContext &rhs) const { return !(*this == rhs); }
 
-  void Dump() const;
+  void Dump(Stream *s) const;

adrian-prantl wrote:

Sounds good to me!

https://github.com/llvm/llvm-project/pull/69981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (PR #69981)

2023-10-24 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/69981

>From b60b12b15d431d291032427a76473eb5f3661cb4 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Mon, 23 Oct 2023 15:55:40 -0700
Subject: [PATCH] Expose DWARFDIE::GetDeclContext() in lldb_private::Function.

I need this API in the Swift plugin, but it seems generally useful
enough to expose it in the main branch.
---
 lldb/include/lldb/Symbol/Function.h   |  6 
 lldb/include/lldb/Symbol/SymbolFile.h | 12 ---
 lldb/include/lldb/Symbol/Type.h   |  2 +-
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  |  9 +++---
 .../Plugins/SymbolFile/DWARF/DWARFDIE.cpp | 32 ++-
 .../Plugins/SymbolFile/DWARF/DWARFDIE.h   |  2 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 14 ++--
 .../SymbolFile/DWARF/SymbolFileDWARF.h|  3 ++
 .../DWARF/SymbolFileDWARFDebugMap.cpp | 18 +++
 .../DWARF/SymbolFileDWARFDebugMap.h   |  2 ++
 lldb/source/Symbol/Function.cpp   | 23 ++---
 lldb/source/Symbol/Type.cpp   | 30 -
 .../DWARF/x86/find-basic-function.cpp |  2 +-
 .../SymbolFile/DWARF/x86/module-ownership.mm  |  2 +-
 lldb/tools/lldb-test/lldb-test.cpp|  8 ++---
 15 files changed, 104 insertions(+), 61 deletions(-)

diff --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index 28afdbff1eb233e..8255c2baea77001 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -533,6 +533,12 @@ class Function : public UserID, public SymbolContextScope {
   /// The DeclContext, or NULL if none exists.
   CompilerDeclContext GetDeclContext();
 
+  /// Get the CompilerContext for this function, if available.
+  ///
+  /// \return
+  /// The CompilerContext, or an empty vector if none is available.
+  std::vector GetCompilerContext();
+
   /// Get accessor for the type that describes the function return value type,
   /// and parameter types.
   ///
diff --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index 512dd9acb86db61..b40d0f03b6e0130 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -225,14 +225,16 @@ class SymbolFile : public PluginInterface {
 
   virtual bool CompleteType(CompilerType &compiler_type) = 0;
   virtual void ParseDeclsForContext(CompilerDeclContext decl_ctx) {}
-  virtual CompilerDecl GetDeclForUID(lldb::user_id_t uid) {
-return CompilerDecl();
-  }
+  virtual CompilerDecl GetDeclForUID(lldb::user_id_t uid) { return {}; }
   virtual CompilerDeclContext GetDeclContextForUID(lldb::user_id_t uid) {
-return CompilerDeclContext();
+return {};
   }
   virtual CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid) 
{
-return CompilerDeclContext();
+return {};
+  }
+  virtual std::vector
+  GetCompilerContextForUID(lldb::user_id_t uid) {
+return {};
   }
   virtual uint32_t ResolveSymbolContext(const Address &so_addr,
 lldb::SymbolContextItem resolve_scope,
diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index c505262cd9eaecf..c5ef1f53021207a 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -34,7 +34,7 @@ struct CompilerContext {
   }
   bool operator!=(const CompilerContext &rhs) const { return !(*this == rhs); }
 
-  void Dump() const;
+  void Dump(Stream &s) const;
 
   CompilerContextKind kind;
   ConstString name;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 545a5dcc7d0fd09..43d61a9f66c0ba2 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -142,8 +142,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const 
SymbolContext &sc,
   // If this type comes from a Clang module, recursively look in the
   // DWARF section of the .pcm file in the module cache. Clang
   // generates DWO skeleton units as breadcrumbs to find them.
-  llvm::SmallVector decl_context;
-  die.GetDeclContext(decl_context);
+  std::vector decl_context = die.GetDeclContext();
   TypeMap pcm_types;
 
   // The type in the Clang module must have the same language as the current 
CU.
@@ -2286,7 +2285,7 @@ CompilerDecl 
DWARFASTParserClang::GetDeclForUIDFromDWARF(const DWARFDIE &die) {
   clang::Decl *clang_decl = GetClangDeclForDIE(die);
   if (clang_decl != nullptr)
 return m_ast.GetCompilerDecl(clang_decl);
-  return CompilerDecl();
+  return {};
 }
 
 CompilerDeclContext
@@ -2294,7 +2293,7 @@ DWARFASTParserClang::GetDeclContextForUIDFromDWARF(const 
DWARFDIE &die) {
   clang::DeclContext *clang_decl_ctx = GetClangDeclContextForDIE(die);
   if (clang_decl_ctx)
 return m_ast.CreateDeclContext(clang_decl_

[Lldb-commits] [lldb] Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (PR #69981)

2023-10-24 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl closed 
https://github.com/llvm/llvm-project/pull/69981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 4950467 - Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (#69981)

2023-10-24 Thread via lldb-commits

Author: Adrian Prantl
Date: 2023-10-24T10:55:23-07:00
New Revision: 49504674dbca6f753771f790ea4062bcbc9cc829

URL: 
https://github.com/llvm/llvm-project/commit/49504674dbca6f753771f790ea4062bcbc9cc829
DIFF: 
https://github.com/llvm/llvm-project/commit/49504674dbca6f753771f790ea4062bcbc9cc829.diff

LOG: Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (#69981)

I need this API in the Swift plugin, but it seems generally useful
enough to expose it in the main branch.

Added: 


Modified: 
lldb/include/lldb/Symbol/Function.h
lldb/include/lldb/Symbol/SymbolFile.h
lldb/include/lldb/Symbol/Type.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
lldb/source/Symbol/Function.cpp
lldb/source/Symbol/Type.cpp
lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-function.cpp
lldb/test/Shell/SymbolFile/DWARF/x86/module-ownership.mm
lldb/tools/lldb-test/lldb-test.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index 28afdbff1eb233e..8255c2baea77001 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -533,6 +533,12 @@ class Function : public UserID, public SymbolContextScope {
   /// The DeclContext, or NULL if none exists.
   CompilerDeclContext GetDeclContext();
 
+  /// Get the CompilerContext for this function, if available.
+  ///
+  /// \return
+  /// The CompilerContext, or an empty vector if none is available.
+  std::vector GetCompilerContext();
+
   /// Get accessor for the type that describes the function return value type,
   /// and parameter types.
   ///

diff  --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index 512dd9acb86db61..b40d0f03b6e0130 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -225,14 +225,16 @@ class SymbolFile : public PluginInterface {
 
   virtual bool CompleteType(CompilerType &compiler_type) = 0;
   virtual void ParseDeclsForContext(CompilerDeclContext decl_ctx) {}
-  virtual CompilerDecl GetDeclForUID(lldb::user_id_t uid) {
-return CompilerDecl();
-  }
+  virtual CompilerDecl GetDeclForUID(lldb::user_id_t uid) { return {}; }
   virtual CompilerDeclContext GetDeclContextForUID(lldb::user_id_t uid) {
-return CompilerDeclContext();
+return {};
   }
   virtual CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid) 
{
-return CompilerDeclContext();
+return {};
+  }
+  virtual std::vector
+  GetCompilerContextForUID(lldb::user_id_t uid) {
+return {};
   }
   virtual uint32_t ResolveSymbolContext(const Address &so_addr,
 lldb::SymbolContextItem resolve_scope,

diff  --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index c505262cd9eaecf..c5ef1f53021207a 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -34,7 +34,7 @@ struct CompilerContext {
   }
   bool operator!=(const CompilerContext &rhs) const { return !(*this == rhs); }
 
-  void Dump() const;
+  void Dump(Stream &s) const;
 
   CompilerContextKind kind;
   ConstString name;

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 22528e09c34995e..f642e8d67403dee 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -143,8 +143,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const 
SymbolContext &sc,
   // If this type comes from a Clang module, recursively look in the
   // DWARF section of the .pcm file in the module cache. Clang
   // generates DWO skeleton units as breadcrumbs to find them.
-  llvm::SmallVector decl_context;
-  die.GetDeclContext(decl_context);
+  std::vector decl_context = die.GetDeclContext();
   TypeMap pcm_types;
 
   // The type in the Clang module must have the same language as the current 
CU.
@@ -2287,7 +2286,7 @@ CompilerDecl 
DWARFASTParserClang::GetDeclForUIDFromDWARF(const DWARFDIE &die) {
   clang::Decl *clang_decl = GetClangDeclForDIE(die);
   if (clang_decl != nullptr)
 return m_ast.GetCompilerDecl(clang_decl);
-  return CompilerDecl();
+  return {};
 }
 
 CompilerDeclContext
@@ -2295,7 +2294,7 @@ DWARFASTParserClang::GetDeclContextForUIDFromDWARF(const 
DWARFDIE &die) {
   clang::DeclContext *clang_decl_ctx = GetClangDeclContextForDIE(die);
   if (clang_decl_ctx)
 return m_ast.C

[Lldb-commits] [lldb] [lldb] Part 2 of 2 - Refactor `CommandObject::DoExecute(...)` return `void` (not `bool`) (PR #69991)

2023-10-24 Thread Alex Langford via lldb-commits

https://github.com/bulbazord edited 
https://github.com/llvm/llvm-project/pull/69991
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Part 2 of 2 - Refactor `CommandObject::DoExecute(...)` return `void` (not `bool`) (PR #69991)

2023-10-24 Thread Alex Langford via lldb-commits

https://github.com/bulbazord approved this pull request.

I think I looked at every changed line, looks good to me overall. Found one 
place with a small style issue but it's not a blocker. Thanks!

https://github.com/llvm/llvm-project/pull/69991
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Part 2 of 2 - Refactor `CommandObject::DoExecute(...)` return `void` (not `bool`) (PR #69991)

2023-10-24 Thread Alex Langford via lldb-commits


@@ -34,16 +34,17 @@ CommandObjectMultipleThreads::CommandObjectMultipleThreads(
   m_arguments.push_back({thread_arg});
 }
 
-bool CommandObjectIterateOverThreads::DoExecute(Args &command,
+void CommandObjectIterateOverThreads::DoExecute(Args &command,
 CommandReturnObject &result) {
   result.SetStatus(m_success_return);
 
   bool all_threads = false;
   if (command.GetArgumentCount() == 0) {
 Thread *thread = m_exe_ctx.GetThreadPtr();
-if (!thread || !HandleOneThread(thread->GetID(), result))
-  return false;
-return result.Succeeded();
+if (thread) {
+  HandleOneThread(thread->GetID(), result);
+}

bulbazord wrote:

LLVM style guidelines say no braces for single-line block in if/else/loop 
constructs

https://github.com/llvm/llvm-project/pull/69991
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-24 Thread Greg Clayton via lldb-commits


@@ -9,10 +9,16 @@
 #ifndef LLDB_TARGET_REGISTERFLAGS_H
 #define LLDB_TARGET_REGISTERFLAGS_H
 
-#include "lldb/Utility/Log.h"
+#include 
+#include 
+#include 
+#include 

clayborg wrote:

Not needed in this header, move to .cpp if needed there?

https://github.com/llvm/llvm-project/pull/69951
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-24 Thread Greg Clayton via lldb-commits


@@ -9,10 +9,16 @@
 #ifndef LLDB_TARGET_REGISTERFLAGS_H
 #define LLDB_TARGET_REGISTERFLAGS_H
 
-#include "lldb/Utility/Log.h"
+#include 

clayborg wrote:

Not needed in this header, move to .cpp if needed there?

https://github.com/llvm/llvm-project/pull/69951
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb/Interpreter] Make ScriptedInterface Object creation more generic (PR #68052)

2023-10-24 Thread Alex Langford via lldb-commits

https://github.com/bulbazord edited 
https://github.com/llvm/llvm-project/pull/68052
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb/Interpreter] Make ScriptedInterface Object creation more generic (PR #68052)

2023-10-24 Thread Alex Langford via lldb-commits


@@ -32,6 +32,84 @@ class ScriptedPythonInterface : virtual public 
ScriptedInterface {
   ScriptedPythonInterface(ScriptInterpreterPythonImpl &interpreter);
   ~ScriptedPythonInterface() override = default;
 
+  template 
+  llvm::Expected
+  CreatePluginObject(llvm::StringRef class_name,
+ StructuredData::Generic *script_obj, Args... args) {
+using namespace python;
+using Locker = ScriptInterpreterPythonImpl::Locker;
+
+std::string error_string;
+if (class_name.empty() &&
+llvm::StringRef(m_interpreter.GetDictionaryName()).empty() &&
+!script_obj)
+  return llvm::createStringError(
+  llvm::inconvertibleErrorCode(),
+  "ScriptedPythonInterface::CreatePluginObject - missing script class "
+  "name, dictionary or object.");
+
+Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
+   Locker::FreeLock);
+
+PythonObject result = {};
+
+if (!script_obj) {
+  auto dict =
+  PythonModule::MainModule().ResolveName(
+  m_interpreter.GetDictionaryName());
+  auto pfunc =
+  PythonObject::ResolveNameWithDictionary(
+  class_name, dict);
+
+  if (!pfunc.IsAllocated()) {
+error_string.append("Could not find script class: ");
+error_string.append(class_name);
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   error_string);
+  }
+
+  std::tuple original_args = std::forward_as_tuple(args...);
+  auto transformed_args = TransformArgs(original_args);
+
+  llvm::Expected arg_info = pfunc.GetArgInfo();
+  if (!arg_info) {
+llvm::handleAllErrors(
+arg_info.takeError(),
+[&](PythonException &E) { error_string.append(E.ReadBacktrace()); 
},
+[&](const llvm::ErrorInfoBase &E) {
+  error_string.append(E.message());
+});
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   error_string);
+  }
+
+  llvm::Expected expected_return_object =
+  llvm::make_error("Not initialized.",
+  llvm::inconvertibleErrorCode());
+
+  std::apply(
+  [&pfunc, &expected_return_object](auto &&...args) {
+llvm::consumeError(expected_return_object.takeError());
+expected_return_object = pfunc(args...);
+  },
+  transformed_args);
+
+  if (llvm::Error e = expected_return_object.takeError())
+return e;
+  result = std::move(expected_return_object.get());
+} else
+  result = PythonObject(PyRefType::Borrowed,
+static_cast(script_obj->GetValue()));

bulbazord wrote:

+1

https://github.com/llvm/llvm-project/pull/68052
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb/Interpreter] Make ScriptedInterface Object creation more generic (PR #68052)

2023-10-24 Thread Alex Langford via lldb-commits


@@ -32,6 +32,84 @@ class ScriptedPythonInterface : virtual public 
ScriptedInterface {
   ScriptedPythonInterface(ScriptInterpreterPythonImpl &interpreter);
   ~ScriptedPythonInterface() override = default;
 
+  template 
+  llvm::Expected
+  CreatePluginObject(llvm::StringRef class_name,
+ StructuredData::Generic *script_obj, Args... args) {
+using namespace python;
+using Locker = ScriptInterpreterPythonImpl::Locker;
+
+std::string error_string;
+if (class_name.empty() &&
+llvm::StringRef(m_interpreter.GetDictionaryName()).empty() &&
+!script_obj)
+  return llvm::createStringError(
+  llvm::inconvertibleErrorCode(),
+  "ScriptedPythonInterface::CreatePluginObject - missing script class "
+  "name, dictionary or object.");
+
+Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
+   Locker::FreeLock);
+
+PythonObject result = {};
+
+if (!script_obj) {
+  auto dict =
+  PythonModule::MainModule().ResolveName(
+  m_interpreter.GetDictionaryName());
+  auto pfunc =
+  PythonObject::ResolveNameWithDictionary(
+  class_name, dict);
+
+  if (!pfunc.IsAllocated()) {
+error_string.append("Could not find script class: ");
+error_string.append(class_name);
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   error_string);
+  }
+
+  std::tuple original_args = std::forward_as_tuple(args...);
+  auto transformed_args = TransformArgs(original_args);
+
+  llvm::Expected arg_info = pfunc.GetArgInfo();
+  if (!arg_info) {
+llvm::handleAllErrors(
+arg_info.takeError(),
+[&](PythonException &E) { error_string.append(E.ReadBacktrace()); 
},
+[&](const llvm::ErrorInfoBase &E) {
+  error_string.append(E.message());
+});
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   error_string);
+  }
+
+  llvm::Expected expected_return_object =
+  llvm::make_error("Not initialized.",
+  llvm::inconvertibleErrorCode());
+
+  std::apply(
+  [&pfunc, &expected_return_object](auto &&...args) {
+llvm::consumeError(expected_return_object.takeError());
+expected_return_object = pfunc(args...);
+  },
+  transformed_args);
+
+  if (llvm::Error e = expected_return_object.takeError())
+return e;
+  result = std::move(expected_return_object.get());
+} else
+  result = PythonObject(PyRefType::Borrowed,
+static_cast(script_obj->GetValue()));
+
+if (!result.IsValid())
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "python object result is invalid.");

bulbazord wrote:

You could augment this error to say something like "The resulting object from 
the call to $NAME is not a valid Python Object" or something to this effect

https://github.com/llvm/llvm-project/pull/68052
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb/Interpreter] Make ScriptedInterface Object creation more generic (PR #68052)

2023-10-24 Thread Alex Langford via lldb-commits


@@ -32,6 +32,84 @@ class ScriptedPythonInterface : virtual public 
ScriptedInterface {
   ScriptedPythonInterface(ScriptInterpreterPythonImpl &interpreter);
   ~ScriptedPythonInterface() override = default;
 
+  template 
+  llvm::Expected
+  CreatePluginObject(llvm::StringRef class_name,
+ StructuredData::Generic *script_obj, Args... args) {
+using namespace python;
+using Locker = ScriptInterpreterPythonImpl::Locker;
+
+std::string error_string;
+if (class_name.empty() &&
+llvm::StringRef(m_interpreter.GetDictionaryName()).empty() &&
+!script_obj)
+  return llvm::createStringError(
+  llvm::inconvertibleErrorCode(),
+  "ScriptedPythonInterface::CreatePluginObject - missing script class "
+  "name, dictionary or object.");
+
+Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
+   Locker::FreeLock);
+
+PythonObject result = {};
+
+if (!script_obj) {
+  auto dict =
+  PythonModule::MainModule().ResolveName(
+  m_interpreter.GetDictionaryName());

bulbazord wrote:

Do we need to check the validity of the dictionary?

https://github.com/llvm/llvm-project/pull/68052
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb/Interpreter] Make ScriptedInterface Object creation more generic (PR #68052)

2023-10-24 Thread Alex Langford via lldb-commits

https://github.com/bulbazord commented:

Works for me generally. I'm curious to know if some of these can be pure 
virtual function as Jonas mentioned.

https://github.com/llvm/llvm-project/pull/68052
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-24 Thread Aaron Ballman via lldb-commits

AaronBallman wrote:

> Is there a way to have Visual Studio change the display format of the enum 
> values?

Sort of. You can specify you want to view values in hex and then you'll get 
`EK_ParenAggInitMember (0x0015)` instead of `EK_ParenAggInitMember (21)`, 
but that all the more formatting changes you can get in the debug view.

https://github.com/llvm/llvm-project/pull/69815
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [OpenMPIRBuilder] Remove wrapper function in `createTask`, `createTeams` (PR #67723)

2023-10-24 Thread Johannes Doerfert via lldb-commits


@@ -5771,84 +5779,63 @@ OpenMPIRBuilder::createTeams(const LocationDescription 
&Loc,
   BasicBlock *AllocaBB =
   splitBB(Builder, /*CreateBranch=*/true, "teams.alloca");
 
+  // Generate the body of teams.
+  InsertPointTy AllocaIP(AllocaBB, AllocaBB->begin());
+  InsertPointTy CodeGenIP(BodyBB, BodyBB->begin());
+  BodyGenCB(AllocaIP, CodeGenIP);
+
   OutlineInfo OI;
   OI.EntryBB = AllocaBB;
   OI.ExitBB = ExitBB;
   OI.OuterAllocaBB = &OuterAllocaBB;
-  OI.PostOutlineCB = [this, Ident](Function &OutlinedFn) {
-// The input IR here looks like the following-
-// ```
-// func @current_fn() {
-//   outlined_fn(%args)
-// }
-// func @outlined_fn(%args) { ... }
-// ```
-//
-// This is changed to the following-
-//
-// ```
-// func @current_fn() {
-//   runtime_call(..., wrapper_fn, ...)
-// }
-// func @wrapper_fn(..., %args) {
-//   outlined_fn(%args)
-// }
-// func @outlined_fn(%args) { ... }
-// ```
 
+  // Insert fake values for global tid and bound tid.
+  std::stack ToBeDeleted;
+  InsertPointTy OuterAllocaIP(&OuterAllocaBB, OuterAllocaBB.begin());
+  OI.ExcludeArgsFromAggregate.push_back(createFakeIntVal(
+  Builder, OuterAllocaIP, ToBeDeleted, AllocaIP, "gid", true));
+  OI.ExcludeArgsFromAggregate.push_back(createFakeIntVal(
+  Builder, OuterAllocaIP, ToBeDeleted, AllocaIP, "tid", true));
+
+  OI.PostOutlineCB = [this, Ident, ToBeDeleted](Function &OutlinedFn) mutable {
 // The stale call instruction will be replaced with a new call instruction
-// for runtime call with a wrapper function.
+// for runtime call with the outlined function.
 
 assert(OutlinedFn.getNumUses() == 1 &&
"there must be a single user for the outlined function");
 CallInst *StaleCI = cast(OutlinedFn.user_back());
+ToBeDeleted.push(StaleCI);
+
+assert((OutlinedFn.arg_size() == 2 || OutlinedFn.arg_size() == 3) &&
+   "Outlined function must have two or three arguments only");
+
+bool HasShared = OutlinedFn.arg_size() == 3;
 
-// Create the wrapper function.
-SmallVector WrapperArgTys{Builder.getPtrTy(), Builder.getPtrTy()};
-for (auto &Arg : OutlinedFn.args())
-  WrapperArgTys.push_back(Arg.getType());
-FunctionCallee WrapperFuncVal = M.getOrInsertFunction(
-(Twine(OutlinedFn.getName()) + ".teams").str(),
-FunctionType::get(Builder.getVoidTy(), WrapperArgTys, false));
-Function *WrapperFunc = dyn_cast(WrapperFuncVal.getCallee());
-WrapperFunc->getArg(0)->setName("global_tid");
-WrapperFunc->getArg(1)->setName("bound_tid");
-if (WrapperFunc->arg_size() > 2)
-  WrapperFunc->getArg(2)->setName("data");
-
-// Emit the body of the wrapper function - just a call to outlined function
-// and return statement.
-BasicBlock *WrapperEntryBB =
-BasicBlock::Create(M.getContext(), "entrybb", WrapperFunc);
-Builder.SetInsertPoint(WrapperEntryBB);
-SmallVector Args;
-for (size_t ArgIndex = 2; ArgIndex < WrapperFunc->arg_size(); ArgIndex++)
-  Args.push_back(WrapperFunc->getArg(ArgIndex));
-Builder.CreateCall(&OutlinedFn, Args);
-Builder.CreateRetVoid();
-
-OutlinedFn.addFnAttr(Attribute::AttrKind::AlwaysInline);
+OutlinedFn.getArg(0)->setName("global.tid.ptr");
+OutlinedFn.getArg(1)->setName("bound.tid.ptr");
+if (HasShared)
+  OutlinedFn.getArg(2)->setName("data");
 
 // Call to the runtime function for teams in the current function.
 assert(StaleCI && "Error while outlining - no CallInst user found for the "
   "outlined function.");
 Builder.SetInsertPoint(StaleCI);
-Args = {Ident, Builder.getInt32(StaleCI->arg_size()), WrapperFunc};
-for (Use &Arg : StaleCI->args())
-  Args.push_back(Arg);
+SmallVector Args = {
+Ident, Builder.getInt32(StaleCI->arg_size() - 2), &OutlinedFn};
+if (HasShared)
+  Args.push_back(StaleCI->getArgOperand(2));
 Builder.CreateCall(getOrCreateRuntimeFunctionPtr(
omp::RuntimeFunction::OMPRTL___kmpc_fork_teams),
Args);
-StaleCI->eraseFromParent();
+
+while (!ToBeDeleted.empty()) {
+  ToBeDeleted.top()->eraseFromParent();
+  ToBeDeleted.pop();

jdoerfert wrote:

same

https://github.com/llvm/llvm-project/pull/67723
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [OpenMPIRBuilder] Remove wrapper function in `createTask`, `createTeams` (PR #67723)

2023-10-24 Thread Johannes Doerfert via lldb-commits


@@ -1736,26 +1750,20 @@ OpenMPIRBuilder::createTask(const LocationDescription 
&Loc,
 
 StaleCI->eraseFromParent();
 
-// Emit the body for wrapper function
-BasicBlock *WrapperEntryBB =
-BasicBlock::Create(M.getContext(), "", WrapperFunc);
-Builder.SetInsertPoint(WrapperEntryBB);
+Builder.SetInsertPoint(TaskAllocaBB, TaskAllocaBB->begin());
 if (HasShareds) {
-  llvm::Value *Shareds =
-  Builder.CreateLoad(VoidPtr, WrapperFunc->getArg(1));
-  Builder.CreateCall(&OutlinedFn, {Shareds});
-} else {
-  Builder.CreateCall(&OutlinedFn);
+  LoadInst *Shareds = Builder.CreateLoad(VoidPtr, OutlinedFn.getArg(1));
+  OutlinedFn.getArg(1)->replaceUsesWithIf(
+  Shareds, [Shareds](Use &U) { return U.getUser() != Shareds; });
+}
+
+while (!ToBeDeleted.empty()) {
+  ToBeDeleted.top()->eraseFromParent();
+  ToBeDeleted.pop();

jdoerfert wrote:

There is no need to pop anything, we have this code in other places already, 
why do we need to come up with new and exciting ways to do the same thing?

```
for (auto *TBD : ToBeDeleted)
  TBD->eraseFromParent
```

https://github.com/llvm/llvm-project/pull/67723
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [OpenMPIRBuilder] Remove wrapper function in `createTask`, `createTeams` (PR #67723)

2023-10-24 Thread Johannes Doerfert via lldb-commits


@@ -1523,41 +1560,31 @@ OpenMPIRBuilder::createTask(const LocationDescription 
&Loc,
   BasicBlock *TaskAllocaBB =
   splitBB(Builder, /*CreateBranch=*/true, "task.alloca");
 
+  InsertPointTy TaskAllocaIP =
+  InsertPointTy(TaskAllocaBB, TaskAllocaBB->begin());
+  InsertPointTy TaskBodyIP = InsertPointTy(TaskBodyBB, TaskBodyBB->begin());
+  BodyGenCB(TaskAllocaIP, TaskBodyIP);
+
   OutlineInfo OI;
   OI.EntryBB = TaskAllocaBB;
   OI.OuterAllocaBB = AllocaIP.getBlock();
   OI.ExitBB = TaskExitBB;
-  OI.PostOutlineCB = [this, Ident, Tied, Final, IfCondition,
-  Dependencies](Function &OutlinedFn) {
-// The input IR here looks like the following-
-// ```
-// func @current_fn() {
-//   outlined_fn(%args)
-// }
-// func @outlined_fn(%args) { ... }
-// ```
-//
-// This is changed to the following-
-//
-// ```
-// func @current_fn() {
-//   runtime_call(..., wrapper_fn, ...)
-// }
-// func @wrapper_fn(..., %args) {
-//   outlined_fn(%args)
-// }
-// func @outlined_fn(%args) { ... }
-// ```
 
-// The stale call instruction will be replaced with a new call instruction
-// for runtime call with a wrapper function.
+  // Add the thread ID argument.
+  std::stack ToBeDeleted;

jdoerfert wrote:

Why not a SmallVector, like we use everywhere else? We can reasonably guess the 
size to avoid dynamic allocations.

https://github.com/llvm/llvm-project/pull/67723
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)` return `void` (not `bool`) (PR #69989)

2023-10-24 Thread Pete Lawrence via lldb-commits


@@ -715,7 +715,7 @@ Thread *CommandObject::GetDefaultThread() {
 return nullptr;
 }
 
-bool CommandObjectParsed::Execute(const char *args_string,
+void CommandObjectParsed::Execute(const char *args_string,
   CommandReturnObject &result) {
   bool handled = false;

PortalPete wrote:

I looked into removing `handled` but if we did so, then we'd have to add a bit 
more conditional logic to cover when `HasOverrideCallback()` or 
`HasOverrideCallback()` return `false`/`NULL`;

https://github.com/llvm/llvm-project/pull/69989
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)` return `void` (not `bool`) (PR #69989)

2023-10-24 Thread Pete Lawrence via lldb-commits

https://github.com/PortalPete updated 
https://github.com/llvm/llvm-project/pull/69989

>From d18c6e2fd2200ec14a8ef9f0a525bb2da6a4a968 Mon Sep 17 00:00:00 2001
From: Pete Lawrence 
Date: Thu, 19 Oct 2023 18:59:57 -1000
Subject: [PATCH] [lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)`
 to return `void` instead of ~~`bool`~~

Justifications:
- The code doesn't ultimately apply the `true`/`false` return values.
- The methods already pass around a `CommandReturnObject`, typically with a 
`result` parameter.
- Each command return object already contains:
- A more precise status
- The error code(s) that apply to that status

Part 2 refactors the `CommandObject::DoExecute(...)` method.

rdar://117378957
---
 lldb/include/lldb/Interpreter/CommandAlias.h  |  2 +-
 lldb/include/lldb/Interpreter/CommandObject.h |  6 ++---
 .../lldb/Interpreter/CommandObjectMultiword.h |  4 ++--
 .../Commands/CommandObjectMultiword.cpp   | 22 +--
 lldb/source/Interpreter/CommandAlias.cpp  |  2 +-
 lldb/source/Interpreter/CommandObject.cpp | 12 +-
 6 files changed, 22 insertions(+), 26 deletions(-)

diff --git a/lldb/include/lldb/Interpreter/CommandAlias.h 
b/lldb/include/lldb/Interpreter/CommandAlias.h
index 26826db62705d67..7b59ea0a74bb9e5 100644
--- a/lldb/include/lldb/Interpreter/CommandAlias.h
+++ b/lldb/include/lldb/Interpreter/CommandAlias.h
@@ -56,7 +56,7 @@ class CommandAlias : public CommandObject {
 
   void SetHelpLong(llvm::StringRef str) override;
 
-  bool Execute(const char *args_string, CommandReturnObject &result) override;
+  void Execute(const char *args_string, CommandReturnObject &result) override;
 
   lldb::CommandObjectSP GetUnderlyingCommand() {
 return m_underlying_command_sp;
diff --git a/lldb/include/lldb/Interpreter/CommandObject.h 
b/lldb/include/lldb/Interpreter/CommandObject.h
index d8358435a483bab..004f5d42f1e44ee 100644
--- a/lldb/include/lldb/Interpreter/CommandObject.h
+++ b/lldb/include/lldb/Interpreter/CommandObject.h
@@ -312,7 +312,7 @@ class CommandObject : public 
std::enable_shared_from_this {
   return false;
   }
 
-  virtual bool Execute(const char *args_string,
+  virtual void Execute(const char *args_string,
CommandReturnObject &result) = 0;
 
 protected:
@@ -398,7 +398,7 @@ class CommandObjectParsed : public CommandObject {
 
   ~CommandObjectParsed() override = default;
 
-  bool Execute(const char *args_string, CommandReturnObject &result) override;
+  void Execute(const char *args_string, CommandReturnObject &result) override;
 
 protected:
   virtual bool DoExecute(Args &command, CommandReturnObject &result) = 0;
@@ -415,7 +415,7 @@ class CommandObjectRaw : public CommandObject {
 
   ~CommandObjectRaw() override = default;
 
-  bool Execute(const char *args_string, CommandReturnObject &result) override;
+  void Execute(const char *args_string, CommandReturnObject &result) override;
 
 protected:
   virtual bool DoExecute(llvm::StringRef command,
diff --git a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h 
b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
index 1c14b492c8097fe..bceb7f0e51edb6c 100644
--- a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
+++ b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
@@ -59,7 +59,7 @@ class CommandObjectMultiword : public CommandObject {
   std::optional GetRepeatCommand(Args ¤t_command_args,
   uint32_t index) override;
 
-  bool Execute(const char *args_string, CommandReturnObject &result) override;
+  void Execute(const char *args_string, CommandReturnObject &result) override;
 
   bool IsRemovable() const override { return m_can_be_removed; }
 
@@ -129,7 +129,7 @@ class CommandObjectProxy : public CommandObject {
   /// Execute is called) and \a GetProxyCommandObject returned null.
   virtual llvm::StringRef GetUnsupportedError();
 
-  bool Execute(const char *args_string, CommandReturnObject &result) override;
+  void Execute(const char *args_string, CommandReturnObject &result) override;
 
 protected:
   // These two want to iterate over the subcommand dictionary.
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp 
b/lldb/source/Commands/CommandObjectMultiword.cpp
index 7ef829afaab6e7d..4efa5652a717035 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -159,25 +159,25 @@ llvm::Error 
CommandObjectMultiword::RemoveUserSubcommand(llvm::StringRef cmd_nam
   return llvm::Error::success();
 }
 
-bool CommandObjectMultiword::Execute(const char *args_string,
+void CommandObjectMultiword::Execute(const char *args_string,
  CommandReturnObject &result) {
   Args args(args_string);
   const size_t argc = args.GetArgumentCount();
   if (argc == 0) {
 this->CommandObject::GenerateHelpText(result);
-return result.Succeeded();
+return;
   }
 
   auto sub_comma

[Lldb-commits] [lldb] [lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)` return `void` (not `bool`) (PR #69989)

2023-10-24 Thread Pete Lawrence via lldb-commits


@@ -429,11 +428,13 @@ llvm::StringRef CommandObjectProxy::GetUnsupportedError() 
{
   return "command is not implemented";
 }
 
-bool CommandObjectProxy::Execute(const char *args_string,
+void CommandObjectProxy::Execute(const char *args_string,
  CommandReturnObject &result) {
   CommandObject *proxy_command = GetProxyCommandObject();
-  if (proxy_command)
-return proxy_command->Execute(args_string, result);
-  result.AppendError(GetUnsupportedError());
-  return false;
+  if (!proxy_command) {
+result.AppendError(GetUnsupportedError());
+return;
+  }
+
+  proxy_command->Execute(args_string, result);
 }

PortalPete wrote:

I put that in, thanks.

https://github.com/llvm/llvm-project/pull/69989
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)` return `void` (not `bool`) (PR #69989)

2023-10-24 Thread Pete Lawrence via lldb-commits


@@ -769,10 +768,10 @@ bool CommandObjectRaw::Execute(const char *args_string,
 handled = InvokeOverrideCallback(argv, result);
   }
   if (!handled) {
-if (CheckRequirements(result))
-  handled = DoExecute(args_string, result);
+if (CheckRequirements(result)) {
+  DoExecute(args_string, result);
+}

PortalPete wrote:

I took out the braces.
Interesting the code_formatter test/bot didn't flag that or the other 
one-liners within curly braces.

I typically write my code for safety first and then 
readability/maintainability, and I put in the curly braces in for those reasons.

https://github.com/llvm/llvm-project/pull/69989
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb/Interpreter] Make ScriptedInterface Object creation more generic (PR #68052)

2023-10-24 Thread Med Ismail Bennani via lldb-commits


@@ -32,6 +32,84 @@ class ScriptedPythonInterface : virtual public 
ScriptedInterface {
   ScriptedPythonInterface(ScriptInterpreterPythonImpl &interpreter);
   ~ScriptedPythonInterface() override = default;
 
+  template 
+  llvm::Expected
+  CreatePluginObject(llvm::StringRef class_name,
+ StructuredData::Generic *script_obj, Args... args) {
+using namespace python;
+using Locker = ScriptInterpreterPythonImpl::Locker;
+
+std::string error_string;
+if (class_name.empty() &&
+llvm::StringRef(m_interpreter.GetDictionaryName()).empty() &&
+!script_obj)
+  return llvm::createStringError(
+  llvm::inconvertibleErrorCode(),
+  "ScriptedPythonInterface::CreatePluginObject - missing script class "
+  "name, dictionary or object.");
+
+Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
+   Locker::FreeLock);
+
+PythonObject result = {};
+
+if (!script_obj) {
+  auto dict =
+  PythonModule::MainModule().ResolveName(
+  m_interpreter.GetDictionaryName());
+  auto pfunc =
+  PythonObject::ResolveNameWithDictionary(
+  class_name, dict);
+
+  if (!pfunc.IsAllocated()) {
+error_string.append("Could not find script class: ");
+error_string.append(class_name);
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   error_string);
+  }
+
+  std::tuple original_args = std::forward_as_tuple(args...);
+  auto transformed_args = TransformArgs(original_args);
+
+  llvm::Expected arg_info = pfunc.GetArgInfo();
+  if (!arg_info) {
+llvm::handleAllErrors(
+arg_info.takeError(),
+[&](PythonException &E) { error_string.append(E.ReadBacktrace()); 
},
+[&](const llvm::ErrorInfoBase &E) {
+  error_string.append(E.message());
+});
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   error_string);
+  }
+
+  llvm::Expected expected_return_object =
+  llvm::make_error("Not initialized.",
+  llvm::inconvertibleErrorCode());
+
+  std::apply(
+  [&pfunc, &expected_return_object](auto &&...args) {
+llvm::consumeError(expected_return_object.takeError());
+expected_return_object = pfunc(args...);
+  },
+  transformed_args);
+
+  if (llvm::Error e = expected_return_object.takeError())
+return e;
+  result = std::move(expected_return_object.get());
+} else
+  result = PythonObject(PyRefType::Borrowed,
+static_cast(script_obj->GetValue()));
+
+if (!result.IsValid())
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "python object result is invalid.");

medismailben wrote:

Thanks for the suggestions however I can't get the $name of the called passed a 
`script_obj`. I'll still rephrase it though.

https://github.com/llvm/llvm-project/pull/68052
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-24 Thread Greg Clayton via lldb-commits

clayborg wrote:

> > Is there a way to have Visual Studio change the display format of the enum 
> > values?
> 
> Sort of. You can specify you want to view values in hex and then you'll get 
> `EK_ParenAggInitMember (0x0015)` instead of `EK_ParenAggInitMember (21)`, 
> but that all the more formatting changes you can get in the debug view.

How is Visual Studio getting access to LLDB when debugging? Is it using the 
lldb-vscode debug adaptor protocol from the VS Code stuff?


https://github.com/llvm/llvm-project/pull/69815
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-24 Thread Jason Molenda via lldb-commits


@@ -0,0 +1,140 @@
+//===-- WatchpointResource.h *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+#define LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+
+#include "lldb/Breakpoint/WatchpointCollection.h"
+#include "lldb/lldb-public.h"
+
+#include 
+
+namespace lldb_private {
+
+class WatchpointResource
+: public std::enable_shared_from_this {
+
+public:
+  // Constructors and Destructors
+  WatchpointResource(lldb::addr_t addr, size_t size, bool read, bool write);
+
+  ~WatchpointResource();
+
+  void GetMemoryRange(lldb::addr_t &addr, size_t &size) const;

jasonmolenda wrote:

I originally wrote the WatchpointResource::GetMemoryRange that returned both 
via out parameters, then at a later point I added a GetAddress & GetByteSize 
methods meaning to remove GetMemoryRange which I wasn't happy with... but 
forgot.

https://github.com/llvm/llvm-project/pull/68845
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-24 Thread Jason Molenda via lldb-commits


@@ -0,0 +1,140 @@
+//===-- WatchpointResource.h *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+#define LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+
+#include "lldb/Breakpoint/WatchpointCollection.h"
+#include "lldb/lldb-public.h"
+
+#include 
+
+namespace lldb_private {
+
+class WatchpointResource
+: public std::enable_shared_from_this {
+
+public:
+  // Constructors and Destructors
+  WatchpointResource(lldb::addr_t addr, size_t size, bool read, bool write);
+
+  ~WatchpointResource();
+
+  void GetMemoryRange(lldb::addr_t &addr, size_t &size) const;
+
+  lldb::addr_t GetAddress() const;
+
+  size_t GetByteSize() const;
+
+  void GetType(bool &read, bool &write) const;
+
+  void SetType(bool read, bool write);
+
+  /// The "Owners" are the watchpoints that share this resource.
+  /// The method adds the \a owner to this resource's owner list.
+  ///
+  /// \param[in] owner
+  ///\a owner is the Wachpoint to add.
+  void AddOwner(const lldb::WatchpointSP &owner);
+
+  /// The method removes the owner at \a owner from this watchpoint
+  /// resource.
+  void RemoveOwner(lldb::WatchpointSP &owner);
+
+  /// This method returns the number of Watchpoints currently using
+  /// watchpoint resource.
+  ///
+  /// \return
+  ///The number of owners.
+  size_t GetNumberOfOwners();

jasonmolenda wrote:

I lock the object's mutex in all of these methods.

https://github.com/llvm/llvm-project/pull/68845
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-24 Thread Jason Molenda via lldb-commits


@@ -0,0 +1,140 @@
+//===-- WatchpointResource.h *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+#define LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+
+#include "lldb/Breakpoint/WatchpointCollection.h"
+#include "lldb/lldb-public.h"
+
+#include 
+
+namespace lldb_private {
+
+class WatchpointResource
+: public std::enable_shared_from_this {
+
+public:
+  // Constructors and Destructors
+  WatchpointResource(lldb::addr_t addr, size_t size, bool read, bool write);
+
+  ~WatchpointResource();
+
+  void GetMemoryRange(lldb::addr_t &addr, size_t &size) const;
+
+  lldb::addr_t GetAddress() const;
+
+  size_t GetByteSize() const;
+
+  void GetType(bool &read, bool &write) const;

jasonmolenda wrote:

idk about this one, `GetType(bool &read, bool &write)` makes the order easy to 
see, and matches the `SetType (bool read, bool write)` whereas the pair would 
be less explicitly named.  I should follow the Watchpoint class method and have 
`bool WatchpointResourceRead()`, `bool WatchpointResourceWrite()`.

https://github.com/llvm/llvm-project/pull/68845
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-24 Thread Alex Langford via lldb-commits


@@ -0,0 +1,140 @@
+//===-- WatchpointResource.h *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+#define LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+
+#include "lldb/Breakpoint/WatchpointCollection.h"
+#include "lldb/lldb-public.h"
+
+#include 
+
+namespace lldb_private {
+
+class WatchpointResource
+: public std::enable_shared_from_this {
+
+public:
+  // Constructors and Destructors
+  WatchpointResource(lldb::addr_t addr, size_t size, bool read, bool write);
+
+  ~WatchpointResource();
+
+  void GetMemoryRange(lldb::addr_t &addr, size_t &size) const;
+
+  lldb::addr_t GetAddress() const;
+
+  size_t GetByteSize() const;
+
+  void GetType(bool &read, bool &write) const;
+
+  void SetType(bool read, bool write);
+
+  /// The "Owners" are the watchpoints that share this resource.
+  /// The method adds the \a owner to this resource's owner list.
+  ///
+  /// \param[in] owner
+  ///\a owner is the Wachpoint to add.
+  void AddOwner(const lldb::WatchpointSP &owner);
+
+  /// The method removes the owner at \a owner from this watchpoint
+  /// resource.
+  void RemoveOwner(lldb::WatchpointSP &owner);
+
+  /// This method returns the number of Watchpoints currently using
+  /// watchpoint resource.
+  ///
+  /// \return
+  ///The number of owners.
+  size_t GetNumberOfOwners();

bulbazord wrote:

Ah I could have sworn the mutex was marked as `mutable`. How are things like 
`GetType` and `GetByteSize` marked `const` then? Do they not lock?

https://github.com/llvm/llvm-project/pull/68845
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-24 Thread Alex Langford via lldb-commits


@@ -0,0 +1,140 @@
+//===-- WatchpointResource.h *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+#define LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+
+#include "lldb/Breakpoint/WatchpointCollection.h"
+#include "lldb/lldb-public.h"
+
+#include 
+
+namespace lldb_private {
+
+class WatchpointResource
+: public std::enable_shared_from_this {
+
+public:
+  // Constructors and Destructors
+  WatchpointResource(lldb::addr_t addr, size_t size, bool read, bool write);
+
+  ~WatchpointResource();
+
+  void GetMemoryRange(lldb::addr_t &addr, size_t &size) const;
+
+  lldb::addr_t GetAddress() const;
+
+  size_t GetByteSize() const;
+
+  void GetType(bool &read, bool &write) const;
+
+  void SetType(bool read, bool write);
+
+  /// The "Owners" are the watchpoints that share this resource.
+  /// The method adds the \a owner to this resource's owner list.
+  ///
+  /// \param[in] owner
+  ///\a owner is the Wachpoint to add.
+  void AddOwner(const lldb::WatchpointSP &owner);
+
+  /// The method removes the owner at \a owner from this watchpoint
+  /// resource.
+  void RemoveOwner(lldb::WatchpointSP &owner);
+
+  /// This method returns the number of Watchpoints currently using
+  /// watchpoint resource.
+  ///
+  /// \return
+  ///The number of owners.
+  size_t GetNumberOfOwners();

bulbazord wrote:

Oh wait, the mutex is to protect the Owners. Nevermind! 

https://github.com/llvm/llvm-project/pull/68845
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-24 Thread Jason Molenda via lldb-commits


@@ -0,0 +1,140 @@
+//===-- WatchpointResource.h *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+#define LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+
+#include "lldb/Breakpoint/WatchpointCollection.h"
+#include "lldb/lldb-public.h"
+
+#include 
+
+namespace lldb_private {
+
+class WatchpointResource
+: public std::enable_shared_from_this {
+
+public:
+  // Constructors and Destructors
+  WatchpointResource(lldb::addr_t addr, size_t size, bool read, bool write);
+
+  ~WatchpointResource();
+
+  void GetMemoryRange(lldb::addr_t &addr, size_t &size) const;
+
+  lldb::addr_t GetAddress() const;
+
+  size_t GetByteSize() const;
+
+  void GetType(bool &read, bool &write) const;
+
+  void SetType(bool read, bool write);
+
+  /// The "Owners" are the watchpoints that share this resource.
+  /// The method adds the \a owner to this resource's owner list.
+  ///
+  /// \param[in] owner
+  ///\a owner is the Wachpoint to add.
+  void AddOwner(const lldb::WatchpointSP &owner);
+
+  /// The method removes the owner at \a owner from this watchpoint
+  /// resource.
+  void RemoveOwner(lldb::WatchpointSP &owner);
+
+  /// This method returns the number of Watchpoints currently using
+  /// watchpoint resource.
+  ///
+  /// \return
+  ///The number of owners.
+  size_t GetNumberOfOwners();

jasonmolenda wrote:

tbh there could be an argument for locking the whole object because a 
WatchpointResource may be expanded to service multiple watchpoints (one 
watchpoint watches bytes 0-1, a second watchpoint watches bytes 2-3) and then 
reduced again when one of those watchpoints is deleted/disabled.

https://github.com/llvm/llvm-project/pull/68845
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-24 Thread Jason Molenda via lldb-commits


@@ -0,0 +1,140 @@
+//===-- WatchpointResource.h *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+#define LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+
+#include "lldb/Breakpoint/WatchpointCollection.h"
+#include "lldb/lldb-public.h"
+
+#include 
+
+namespace lldb_private {
+
+class WatchpointResource
+: public std::enable_shared_from_this {
+
+public:
+  // Constructors and Destructors
+  WatchpointResource(lldb::addr_t addr, size_t size, bool read, bool write);
+
+  ~WatchpointResource();
+
+  void GetMemoryRange(lldb::addr_t &addr, size_t &size) const;
+
+  lldb::addr_t GetAddress() const;
+
+  size_t GetByteSize() const;
+
+  void GetType(bool &read, bool &write) const;
+
+  void SetType(bool read, bool write);
+
+  /// The "Owners" are the watchpoints that share this resource.
+  /// The method adds the \a owner to this resource's owner list.
+  ///
+  /// \param[in] owner
+  ///\a owner is the Wachpoint to add.
+  void AddOwner(const lldb::WatchpointSP &owner);
+
+  /// The method removes the owner at \a owner from this watchpoint
+  /// resource.
+  void RemoveOwner(lldb::WatchpointSP &owner);
+
+  /// This method returns the number of Watchpoints currently using
+  /// watchpoint resource.
+  ///
+  /// \return
+  ///The number of owners.
+  size_t GetNumberOfOwners();

jasonmolenda wrote:

none of that is done yet though.

https://github.com/llvm/llvm-project/pull/68845
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-24 Thread Jason Molenda via lldb-commits


@@ -0,0 +1,140 @@
+//===-- WatchpointResource.h *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+#define LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+
+#include "lldb/Breakpoint/WatchpointCollection.h"
+#include "lldb/lldb-public.h"
+
+#include 
+
+namespace lldb_private {
+
+class WatchpointResource
+: public std::enable_shared_from_this {
+
+public:
+  // Constructors and Destructors
+  WatchpointResource(lldb::addr_t addr, size_t size, bool read, bool write);
+
+  ~WatchpointResource();
+
+  void GetMemoryRange(lldb::addr_t &addr, size_t &size) const;
+
+  lldb::addr_t GetAddress() const;
+
+  size_t GetByteSize() const;
+
+  void GetType(bool &read, bool &write) const;
+
+  void SetType(bool read, bool write);
+
+  /// The "Owners" are the watchpoints that share this resource.
+  /// The method adds the \a owner to this resource's owner list.
+  ///
+  /// \param[in] owner
+  ///\a owner is the Wachpoint to add.
+  void AddOwner(const lldb::WatchpointSP &owner);
+
+  /// The method removes the owner at \a owner from this watchpoint
+  /// resource.
+  void RemoveOwner(lldb::WatchpointSP &owner);
+
+  /// This method returns the number of Watchpoints currently using
+  /// watchpoint resource.
+  ///
+  /// \return
+  ///The number of owners.
+  size_t GetNumberOfOwners();
+
+  /// This method returns the Watchpoint at index \a index using this
+  /// Resource.  The owners are listed ordinally from 0 to
+  /// GetNumberOfOwners() - 1 so you can use this method to iterate over the
+  /// owners.
+  ///
+  /// \param[in] idx
+  /// The index in the list of owners for which you wish the owner 
location.
+  ///
+  /// \return
+  ///The Watchpoint at that index.
+  lldb::WatchpointSP GetOwnerAtIndex(size_t idx);
+
+  /// Check if the owners includes a watchpoint.
+  ///
+  /// \param[in] wp_sp
+  /// The WatchpointSP to search for.
+  ///
+  /// \result
+  /// true if this resource's owners includes the watchpoint.
+  bool OwnersContains(lldb::WatchpointSP &wp_sp);
+
+  /// Check if the owners includes a watchpoint.
+  ///
+  /// \param[in] wp
+  /// The Watchpoint to search for.
+  ///
+  /// \result
+  /// true if this resource's owners includes the watchpoint.
+  bool OwnersContains(const lldb_private::Watchpoint *wp);
+
+  /// This method copies the watchpoint resource's owners into a new 
collection.
+  /// It does this while the owners mutex is locked.
+  ///
+  /// \param[out] out_collection
+  ///The BreakpointLocationCollection into which to put the owners
+  ///of this breakpoint site.
+  ///
+  /// \return
+  ///The number of elements copied into out_collection.
+  size_t CopyOwnersList(WatchpointCollection &out_collection);

jasonmolenda wrote:

Hm, I do not have a lot of confidence about avoiding an extra copy of the 
vector if I return by value.

https://github.com/llvm/llvm-project/pull/68845
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-24 Thread Jason Molenda via lldb-commits


@@ -491,14 +491,13 @@ static StopInfoSP GetStopInfoForHardwareBP(Thread 
&thread, Target *target,
uint64_t exc_sub_sub_code) {
   // Try hardware watchpoint.
   if (target) {
+// LWP_TODO: We need to find the WatchpointResource that matches

jasonmolenda wrote:

Yeah good point my idea was that these are temporary placeholders as I roll 
this out, so they wouldn't be in the source for very long. (this feature is not 
really useful with all the parts landed so it's unlikely I'll be distracted by 
some other issue )

https://github.com/llvm/llvm-project/pull/68845
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-24 Thread Jason Molenda via lldb-commits


@@ -839,11 +841,11 @@ std::optional 
ProcessWindows::GetWatchpointSlotCount() {
   return RegisterContextWindows::GetNumHardwareBreakpointSlots();
 }
 
-Status ProcessWindows::EnableWatchpoint(Watchpoint *wp, bool notify) {
+Status ProcessWindows::EnableWatchpoint(WatchpointSP wp_sp, bool notify) {
   Status error;
 
-  if (wp->IsEnabled()) {
-wp->SetEnabled(true, notify);
+  if (wp_sp->IsEnabled()) {

jasonmolenda wrote:

The original code didn't check it, but more importantly on this topic, I have 
real concern about touching any of ProcessWindows, NativeProcessWindows because 
I can't build or test it directly myself.  I have a feeling I'll keep most/all 
of the existing interfaces for creating a StopInfo etc so the Windows code can 
continue to work unmodified.

https://github.com/llvm/llvm-project/pull/68845
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-vscode] Allow specifying a custom escape prefix for LLDB commands (PR #69238)

2023-10-24 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/69238

>From 09cd46a63b1fb68e3c5c03273cbc90825b09d027 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 16 Oct 2023 15:08:20 -0400
Subject: [PATCH] [lldb-vscode] Allow specifying a custom escape character for
 LLDB commands

We've been using the backtick as our escape character, however that leads to a 
weird experience on VS Code, because on most hosts, as soon as you type the 
backtick on VS Code, the IDE will introduce another backtick. As changing the 
default escape character might be out of question because other plugins might 
rely on it, we can instead introduce an option to change this variable upon 
lldb-vscode initialization.
FWIW, my users will be using : instead ot the backtick.
---
 .../test/tools/lldb-dap/dap_server.py |  9 +++-
 .../test/tools/lldb-dap/lldbdap_testcase.py   |  4 ++
 .../tools/lldb-dap/console/TestDAP_console.py | 44 +--
 lldb/tools/lldb-dap/DAP.cpp   | 11 +++--
 lldb/tools/lldb-dap/DAP.h |  1 +
 lldb/tools/lldb-dap/JSONUtils.cpp | 10 +++--
 lldb/tools/lldb-dap/JSONUtils.h   | 11 +++--
 lldb/tools/lldb-dap/lldb-dap.cpp  |  4 ++
 lldb/tools/lldb-dap/package.json  | 10 +
 9 files changed, 88 insertions(+), 16 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 8c645e0fdca72f8..d1fb478bc8bb9ee 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -731,6 +731,7 @@ def request_launch(
 postRunCommands=None,
 enableAutoVariableSummaries=False,
 enableSyntheticChildDebugging=False,
+commandEscapePrefix="`",
 ):
 args_dict = {"program": program}
 if args:
@@ -774,6 +775,7 @@ def request_launch(
 args_dict["postRunCommands"] = postRunCommands
 args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries
 args_dict["enableSyntheticChildDebugging"] = 
enableSyntheticChildDebugging
+args_dict["commandEscapePrefix"] = commandEscapePrefix
 command_dict = {"command": "launch", "type": "request", "arguments": 
args_dict}
 response = self.send_recv(command_dict)
 
@@ -1015,7 +1017,12 @@ def terminate(self):
 
 class DebugAdaptorServer(DebugCommunication):
 def __init__(
-self, executable=None, port=None, init_commands=[], log_file=None, 
env=None
+self,
+executable=None,
+port=None,
+init_commands=[],
+log_file=None,
+env=None,
 ):
 self.process = None
 if executable is not None:
diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index 3094b66af4792db..aa89ffe24c3e026 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -351,6 +351,7 @@ def launch(
 postRunCommands=None,
 enableAutoVariableSummaries=False,
 enableSyntheticChildDebugging=False,
+commandEscapePrefix="`",
 ):
 """Sending launch request to dap"""
 
@@ -389,6 +390,7 @@ def cleanup():
 postRunCommands=postRunCommands,
 enableAutoVariableSummaries=enableAutoVariableSummaries,
 enableSyntheticChildDebugging=enableSyntheticChildDebugging,
+commandEscapePrefix=commandEscapePrefix,
 )
 
 if expectFailure:
@@ -425,6 +427,7 @@ def build_and_launch(
 lldbDAPEnv=None,
 enableAutoVariableSummaries=False,
 enableSyntheticChildDebugging=False,
+commandEscapePrefix="`",
 ):
 """Build the default Makefile target, create the DAP debug adaptor,
 and launch the process.
@@ -455,4 +458,5 @@ def build_and_launch(
 postRunCommands=postRunCommands,
 enableAutoVariableSummaries=enableAutoVariableSummaries,
 enableSyntheticChildDebugging=enableSyntheticChildDebugging,
+commandEscapePrefix=commandEscapePrefix,
 )
diff --git a/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py 
b/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
index 47c706f2ca72106..ffa0dc943e06933 100644
--- a/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
+++ b/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
@@ -3,16 +3,18 @@
 """
 
 import dap_server
+import lldbdap_testcase
+from lldbsuite.test import lldbutil
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-import lldbdap_testcase
 
 
 class TestDAP_console(lldbdap_testcase.DAPTestCaseBase):
-def check

[Lldb-commits] [lldb] [lldb/Interpreter] Make ScriptedInterface Object creation more generic (PR #68052)

2023-10-24 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben edited 
https://github.com/llvm/llvm-project/pull/68052
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Part 2 of 2 - Refactor `CommandObject::DoExecute(...)` return `void` (not `bool`) (PR #69991)

2023-10-24 Thread Pete Lawrence via lldb-commits

PortalPete wrote:

> I think I looked at every changed line, looks good to me overall. Found one 
> place with a small style issue but it's not a blocker. Thanks!

Thanks @bulbazord!
Do you know why the `code_formatter` check/bot didn't flag that or the other 
one-line `if` statements?

https://github.com/llvm/llvm-project/pull/69991
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb/Interpreter] Make ScriptedInterface Object creation more generic (PR #68052)

2023-10-24 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben updated 
https://github.com/llvm/llvm-project/pull/68052

>From 4942cb5209298b5e4a1819885d1f680381c0bb16 Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Tue, 24 Oct 2023 20:39:34 -0700
Subject: [PATCH] [lldb/Interpreter] Make ScriptedInterface Object creation
 more generic

This patch changes the way plugin objects used with Scripted Interfaces
are created.

Instead of implementing a different SWIG method to create the object for
every scripted interface, this patch makes the creation more generic by
re-using some of the ScriptedPythonInterface templated Dispatch code.

This patch also improves error handling of the object creation by
returning an `llvm::Expected`.

Signed-off-by: Med Ismail Bennani 
---
 lldb/bindings/python/python-wrapper.swig  |  43 ---
 .../Interfaces/ScriptedInterface.h|   5 -
 .../Interfaces/ScriptedPlatformInterface.h|   7 +-
 .../Interfaces/ScriptedProcessInterface.h |   7 +-
 .../Interfaces/ScriptedThreadInterface.h  |   7 +-
 .../Process/scripted/ScriptedProcess.cpp  |   9 +-
 .../Process/scripted/ScriptedThread.cpp   |  12 +-
 .../ScriptedPlatformPythonInterface.cpp   |  26 +
 .../ScriptedPlatformPythonInterface.h |   2 +-
 .../ScriptedProcessPythonInterface.cpp|  26 +
 .../ScriptedProcessPythonInterface.h  |   2 +-
 .../Interfaces/ScriptedPythonInterface.h  | 107 +-
 .../ScriptedThreadPythonInterface.cpp |  36 ++
 .../ScriptedThreadPythonInterface.h   |   2 +-
 .../Python/SWIGPythonBridge.h |   6 -
 .../Python/PythonTestSuite.cpp|  18 +--
 16 files changed, 162 insertions(+), 153 deletions(-)

diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index cb54901e66d03c6..17bc7b1f2198709 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -229,49 +229,6 @@ PythonObject 
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateCommandObject
   return pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger_sp)), dict);
 }
 
-PythonObject 
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedObject(
-const char *python_class_name, const char *session_dictionary_name,
-lldb::ExecutionContextRefSP exe_ctx_sp,
-const lldb_private::StructuredDataImpl &args_impl,
-std::string &error_string) {
-  if (python_class_name == NULL || python_class_name[0] == '\0' ||
-  !session_dictionary_name)
-return PythonObject();
-
-  PyErr_Cleaner py_err_cleaner(true);
-
-  auto dict = PythonModule::MainModule().ResolveName(
-  session_dictionary_name);
-  auto pfunc = PythonObject::ResolveNameWithDictionary(
-  python_class_name, dict);
-
-  if (!pfunc.IsAllocated()) {
-error_string.append("could not find script class: ");
-error_string.append(python_class_name);
-return PythonObject();
-  }
-
-  llvm::Expected arg_info = pfunc.GetArgInfo();
-  if (!arg_info) {
-llvm::handleAllErrors(
-arg_info.takeError(),
-[&](PythonException &E) { error_string.append(E.ReadBacktrace()); },
-[&](const llvm::ErrorInfoBase &E) {
-  error_string.append(E.message());
-});
-return PythonObject();
-  }
-
-  PythonObject result = {};
-  if (arg_info.get().max_positional_args == 2) {
-  result = pfunc(SWIGBridge::ToSWIGWrapper(exe_ctx_sp), 
SWIGBridge::ToSWIGWrapper(args_impl));
-  } else {
-error_string.assign("wrong number of arguments in __init__, should be 2 "
-"(not including self)");
-  }
-  return result;
-}
-
 PythonObject 
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedThreadPlan(
 const char *python_class_name, const char *session_dictionary_name,
 const lldb_private::StructuredDataImpl &args_impl,
diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
index 948f763e95ecea4..2406f0f1f9aee27 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
@@ -25,11 +25,6 @@ class ScriptedInterface {
   ScriptedInterface() = default;
   virtual ~ScriptedInterface() = default;
 
-  virtual StructuredData::GenericSP
-  CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
- StructuredData::DictionarySP args_sp,
- StructuredData::Generic *script_obj = nullptr) = 0;
-
   StructuredData::GenericSP GetScriptObjectInstance() {
 return m_object_instance_sp;
   }
diff --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
index c687cabfe0c1278..dc3630fc75d9e1a 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/Scri

[Lldb-commits] [lldb] [lldb/Interpreter] Make ScriptedInterface Object creation more generic (PR #68052)

2023-10-24 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben updated 
https://github.com/llvm/llvm-project/pull/68052

>From ef90c8a7f2f555cf312807d2bc83ffda45e8c2af Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Tue, 24 Oct 2023 20:40:43 -0700
Subject: [PATCH] [lldb/Interpreter] Make ScriptedInterface Object creation
 more generic

This patch changes the way plugin objects used with Scripted Interfaces
are created.

Instead of implementing a different SWIG method to create the object for
every scripted interface, this patch makes the creation more generic by
re-using some of the ScriptedPythonInterface templated Dispatch code.

This patch also improves error handling of the object creation by
returning an `llvm::Expected`.

Signed-off-by: Med Ismail Bennani 
---
 lldb/bindings/python/python-wrapper.swig  |  43 ---
 .../Interfaces/ScriptedInterface.h|   5 -
 .../Interfaces/ScriptedPlatformInterface.h|   7 +-
 .../Interfaces/ScriptedProcessInterface.h |   7 +-
 .../Interfaces/ScriptedThreadInterface.h  |   7 +-
 .../Process/scripted/ScriptedProcess.cpp  |   9 +-
 .../Process/scripted/ScriptedThread.cpp   |  12 +-
 .../ScriptedPlatformPythonInterface.cpp   |  26 +
 .../ScriptedPlatformPythonInterface.h |   2 +-
 .../ScriptedProcessPythonInterface.cpp|  26 +
 .../ScriptedProcessPythonInterface.h  |   2 +-
 .../Interfaces/ScriptedPythonInterface.h  | 106 +-
 .../ScriptedThreadPythonInterface.cpp |  36 ++
 .../ScriptedThreadPythonInterface.h   |   2 +-
 .../Python/SWIGPythonBridge.h |   6 -
 .../Python/PythonTestSuite.cpp|  18 +--
 16 files changed, 161 insertions(+), 153 deletions(-)

diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index cb54901e66d03c6..17bc7b1f2198709 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -229,49 +229,6 @@ PythonObject 
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateCommandObject
   return pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger_sp)), dict);
 }
 
-PythonObject 
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedObject(
-const char *python_class_name, const char *session_dictionary_name,
-lldb::ExecutionContextRefSP exe_ctx_sp,
-const lldb_private::StructuredDataImpl &args_impl,
-std::string &error_string) {
-  if (python_class_name == NULL || python_class_name[0] == '\0' ||
-  !session_dictionary_name)
-return PythonObject();
-
-  PyErr_Cleaner py_err_cleaner(true);
-
-  auto dict = PythonModule::MainModule().ResolveName(
-  session_dictionary_name);
-  auto pfunc = PythonObject::ResolveNameWithDictionary(
-  python_class_name, dict);
-
-  if (!pfunc.IsAllocated()) {
-error_string.append("could not find script class: ");
-error_string.append(python_class_name);
-return PythonObject();
-  }
-
-  llvm::Expected arg_info = pfunc.GetArgInfo();
-  if (!arg_info) {
-llvm::handleAllErrors(
-arg_info.takeError(),
-[&](PythonException &E) { error_string.append(E.ReadBacktrace()); },
-[&](const llvm::ErrorInfoBase &E) {
-  error_string.append(E.message());
-});
-return PythonObject();
-  }
-
-  PythonObject result = {};
-  if (arg_info.get().max_positional_args == 2) {
-  result = pfunc(SWIGBridge::ToSWIGWrapper(exe_ctx_sp), 
SWIGBridge::ToSWIGWrapper(args_impl));
-  } else {
-error_string.assign("wrong number of arguments in __init__, should be 2 "
-"(not including self)");
-  }
-  return result;
-}
-
 PythonObject 
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedThreadPlan(
 const char *python_class_name, const char *session_dictionary_name,
 const lldb_private::StructuredDataImpl &args_impl,
diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
index 948f763e95ecea4..2406f0f1f9aee27 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
@@ -25,11 +25,6 @@ class ScriptedInterface {
   ScriptedInterface() = default;
   virtual ~ScriptedInterface() = default;
 
-  virtual StructuredData::GenericSP
-  CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
- StructuredData::DictionarySP args_sp,
- StructuredData::Generic *script_obj = nullptr) = 0;
-
   StructuredData::GenericSP GetScriptObjectInstance() {
 return m_object_instance_sp;
   }
diff --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
index c687cabfe0c1278..dc3630fc75d9e1a 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/Scri

[Lldb-commits] [lldb] [lldb][AArch64] Invalidate SVG prior to reconfiguring ZA regdef (PR #66768)

2023-10-24 Thread Omair Javaid via lldb-commits


@@ -783,6 +783,11 @@ void GDBRemoteRegisterContext::AArch64Reconfigure() {
   std::optional svg_reg_value;
   const RegisterInfo *svg_reg_info = m_reg_info_sp->GetRegisterInfo("svg");
   if (svg_reg_info) {
+// When vg is written it is automatically made invalid. Writing vg will 
also
+// change svg if we're in streaming mode but it will not be made invalid
+// so do this manually so the following read gets the latest svg value.

omjavaid wrote:

Sorry for the delay on this PR. I agree with your approach.

https://github.com/llvm/llvm-project/pull/66768
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][AArch64] Invalidate SVG prior to reconfiguring ZA regdef (PR #66768)

2023-10-24 Thread Omair Javaid via lldb-commits

https://github.com/omjavaid approved this pull request.


https://github.com/llvm/llvm-project/pull/66768
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][AArch64] Read mte_ctrl register from core files (PR #69689)

2023-10-24 Thread Omair Javaid via lldb-commits

https://github.com/omjavaid approved this pull request.

Looks good to me.

https://github.com/llvm/llvm-project/pull/69689
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 1066481 - [lldb-vscode] Allow specifying a custom escape prefix for LLDB commands (#69238)

2023-10-24 Thread via lldb-commits

Author: Walter Erquinigo
Date: 2023-10-25T00:05:54-04:00
New Revision: 10664813fca8d5ccbfd90bae9e791b7062dabd7c

URL: 
https://github.com/llvm/llvm-project/commit/10664813fca8d5ccbfd90bae9e791b7062dabd7c
DIFF: 
https://github.com/llvm/llvm-project/commit/10664813fca8d5ccbfd90bae9e791b7062dabd7c.diff

LOG: [lldb-vscode] Allow specifying a custom escape prefix for LLDB commands 
(#69238)

We've been using the backtick as our escape character, however that
leads to a weird experience on VS Code, because on most hosts, as soon
as you type the backtick on VS Code, the IDE will introduce another
backtick. As changing the default escape character might be out of
question because other plugins might rely on it, we can instead
introduce an option to change this variable upon lldb-vscode
initialization.
FWIW, my users will be using : instead ot the backtick.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
lldb/tools/lldb-dap/DAP.cpp
lldb/tools/lldb-dap/DAP.h
lldb/tools/lldb-dap/JSONUtils.cpp
lldb/tools/lldb-dap/JSONUtils.h
lldb/tools/lldb-dap/lldb-dap.cpp
lldb/tools/lldb-dap/package.json

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 8c645e0fdca72f8..d1fb478bc8bb9ee 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -731,6 +731,7 @@ def request_launch(
 postRunCommands=None,
 enableAutoVariableSummaries=False,
 enableSyntheticChildDebugging=False,
+commandEscapePrefix="`",
 ):
 args_dict = {"program": program}
 if args:
@@ -774,6 +775,7 @@ def request_launch(
 args_dict["postRunCommands"] = postRunCommands
 args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries
 args_dict["enableSyntheticChildDebugging"] = 
enableSyntheticChildDebugging
+args_dict["commandEscapePrefix"] = commandEscapePrefix
 command_dict = {"command": "launch", "type": "request", "arguments": 
args_dict}
 response = self.send_recv(command_dict)
 
@@ -1015,7 +1017,12 @@ def terminate(self):
 
 class DebugAdaptorServer(DebugCommunication):
 def __init__(
-self, executable=None, port=None, init_commands=[], log_file=None, 
env=None
+self,
+executable=None,
+port=None,
+init_commands=[],
+log_file=None,
+env=None,
 ):
 self.process = None
 if executable is not None:

diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index 3094b66af4792db..aa89ffe24c3e026 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -351,6 +351,7 @@ def launch(
 postRunCommands=None,
 enableAutoVariableSummaries=False,
 enableSyntheticChildDebugging=False,
+commandEscapePrefix="`",
 ):
 """Sending launch request to dap"""
 
@@ -389,6 +390,7 @@ def cleanup():
 postRunCommands=postRunCommands,
 enableAutoVariableSummaries=enableAutoVariableSummaries,
 enableSyntheticChildDebugging=enableSyntheticChildDebugging,
+commandEscapePrefix=commandEscapePrefix,
 )
 
 if expectFailure:
@@ -425,6 +427,7 @@ def build_and_launch(
 lldbDAPEnv=None,
 enableAutoVariableSummaries=False,
 enableSyntheticChildDebugging=False,
+commandEscapePrefix="`",
 ):
 """Build the default Makefile target, create the DAP debug adaptor,
 and launch the process.
@@ -455,4 +458,5 @@ def build_and_launch(
 postRunCommands=postRunCommands,
 enableAutoVariableSummaries=enableAutoVariableSummaries,
 enableSyntheticChildDebugging=enableSyntheticChildDebugging,
+commandEscapePrefix=commandEscapePrefix,
 )

diff  --git a/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py 
b/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
index 47c706f2ca72106..ffa0dc943e06933 100644
--- a/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
+++ b/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
@@ -3,16 +3,18 @@
 """
 
 import dap_server
+import lldbdap_testcase
+from lldbsuite.test import lldbutil
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-import lldbdap_testcase
 
 
 class TestDAP_console(lldbdap_testcase.DAPTest

[Lldb-commits] [lldb] [lldb-vscode] Allow specifying a custom escape prefix for LLDB commands (PR #69238)

2023-10-24 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo closed 
https://github.com/llvm/llvm-project/pull/69238
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB][NFC] Remove DWARFASTParserClang as friend from SymbolFileDWARF (PR #70157)

2023-10-24 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo created 
https://github.com/llvm/llvm-project/pull/70157

This effectively moves a few functions from protected to public. In any case, 
for the sake of having a cleaner SymbolFileDWARF API, it's better if it's not a 
friend of a one of its consumers, DWARFASTParserClang.
Another effect of this change is that I can use SymbolFileDWARF for the 
out-of-tree mojo dwarf parser, which relies on pretty much the same functions 
that DWARFASTParserClang needs from SymbolFileDWARF.


>From 98c80871a753c58a49e8ba0d535e03e99d633109 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Tue, 24 Oct 2023 22:32:38 -0400
Subject: [PATCH] [LLDB][NFC] Remove DWARFASTParserClang as friend from
 SymbolFileDWARF

This effectively moves a few functions from protected to public. In any case, 
for the sake of having a cleaner SymbolFileDWARF API, it's better if it's not a 
friend of a one of its consumers, DWARFASTParserClang.
Another effect of this change is that I can use SymbolFileDWARF for the 
out-of-tree mojo dwarf parser, which relies on pretty much the same functions 
that DWARFASTParserClang needs from SymbolFileDWARF.
---
 .../SymbolFile/DWARF/SymbolFileDWARF.h| 65 ++-
 1 file changed, 34 insertions(+), 31 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 1ce62e6a6bb9e44..5b651a910e6deca 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -83,7 +83,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
   friend class DWARFCompileUnit;
   friend class DWARFDIE;
   friend class DWARFASTParser;
-  friend class ::DWARFASTParserClang;
 
   // Static Functions
   static void Initialize();
@@ -138,7 +137,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
 
   size_t ParseVariablesForContext(const SymbolContext &sc) override;
 
-  Type *ResolveTypeUID(lldb::user_id_t type_uid) override;
   std::optional
   GetDynamicArrayInfoForUID(lldb::user_id_t type_uid,
 const ExecutionContext *exe_ctx) override;
@@ -325,15 +323,46 @@ class SymbolFileDWARF : public SymbolFileCommon {
 m_file_index = file_index;
   }
 
-protected:
   typedef llvm::DenseMap DIEToTypePtr;
-  typedef llvm::DenseMap
-  DIEToVariableSP;
+
+  virtual DIEToTypePtr &GetDIEToType() { return m_die_to_type; }
+
   typedef llvm::DenseMap
   DIEToClangType;
+
+  virtual DIEToClangType &GetForwardDeclDieToClangType() {
+return m_forward_decl_die_to_clang_type;
+  }
+
   typedef llvm::DenseMap ClangTypeToDIE;
 
+  virtual ClangTypeToDIE &GetForwardDeclClangTypeToDie() {
+return m_forward_decl_clang_type_to_die;
+  }
+
+  virtual UniqueDWARFASTTypeMap &GetUniqueDWARFASTTypeMap();
+
+  bool ClassOrStructIsVirtual(const DWARFDIE &die);
+
+  SymbolFileDWARFDebugMap *GetDebugMapSymfile();
+
+  virtual lldb::TypeSP
+  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die);
+
+  virtual lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
+  const DWARFDIE &die, ConstString type_name, bool must_be_implementation);
+
+  Type *ResolveTypeUID(lldb::user_id_t type_uid) override;
+
+  Type *ResolveTypeUID(const DWARFDIE &die, bool assert_not_being_parsed);
+
+  Type *ResolveTypeUID(const DIERef &die_ref);
+
+protected:
+  typedef llvm::DenseMap
+  DIEToVariableSP;
+
   SymbolFileDWARF(const SymbolFileDWARF &) = delete;
   const SymbolFileDWARF &operator=(const SymbolFileDWARF &) = delete;
 
@@ -371,10 +400,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
   bool ParseSupportFiles(DWARFUnit &dwarf_cu, const lldb::ModuleSP &module,
  FileSpecList &support_files);
 
-  Type *ResolveTypeUID(const DWARFDIE &die, bool assert_not_being_parsed);
-
-  Type *ResolveTypeUID(const DIERef &die_ref);
-
   lldb::VariableSP ParseVariableDIE(const SymbolContext &sc,
 const DWARFDIE &die,
 const lldb::addr_t func_low_pc);
@@ -402,8 +427,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
   DIEArray MergeBlockAbstractParameters(const DWARFDIE &block_die,
 DIEArray &&variable_dies);
 
-  bool ClassOrStructIsVirtual(const DWARFDIE &die);
-
   // Given a die_offset, figure out the symbol context representing that die.
   bool ResolveFunction(const DWARFDIE &die, bool include_inlines,
SymbolContextList &sc_list);
@@ -415,12 +438,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
   void ResolveFunctionAndBlock(lldb::addr_t file_vm_addr, bool lookup_block,
SymbolContext &sc);
 
-  virtual lldb::TypeSP
-  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die);
-
-  virtual lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
-  const DWARFDIE &die, ConstString type_name, bool must_be_implementation);
-
   

[Lldb-commits] [lldb] [LLDB][NFC] Remove DWARFASTParserClang as friend from SymbolFileDWARF (PR #70157)

2023-10-24 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo ready_for_review 
https://github.com/llvm/llvm-project/pull/70157
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB][NFC] Remove DWARFASTParserClang as friend from SymbolFileDWARF (PR #70157)

2023-10-24 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Walter Erquinigo (walter-erquinigo)


Changes

This effectively moves a few functions from protected to public. In any case, 
for the sake of having a cleaner SymbolFileDWARF API, it's better if it's not a 
friend of a one of its consumers, DWARFASTParserClang.
Another effect of this change is that I can use SymbolFileDWARF for the 
out-of-tree mojo dwarf parser, which relies on pretty much the same functions 
that DWARFASTParserClang needs from SymbolFileDWARF.


---
Full diff: https://github.com/llvm/llvm-project/pull/70157.diff


1 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (+34-31) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 1ce62e6a6bb9e44..5b651a910e6deca 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -83,7 +83,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
   friend class DWARFCompileUnit;
   friend class DWARFDIE;
   friend class DWARFASTParser;
-  friend class ::DWARFASTParserClang;
 
   // Static Functions
   static void Initialize();
@@ -138,7 +137,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
 
   size_t ParseVariablesForContext(const SymbolContext &sc) override;
 
-  Type *ResolveTypeUID(lldb::user_id_t type_uid) override;
   std::optional
   GetDynamicArrayInfoForUID(lldb::user_id_t type_uid,
 const ExecutionContext *exe_ctx) override;
@@ -325,15 +323,46 @@ class SymbolFileDWARF : public SymbolFileCommon {
 m_file_index = file_index;
   }
 
-protected:
   typedef llvm::DenseMap DIEToTypePtr;
-  typedef llvm::DenseMap
-  DIEToVariableSP;
+
+  virtual DIEToTypePtr &GetDIEToType() { return m_die_to_type; }
+
   typedef llvm::DenseMap
   DIEToClangType;
+
+  virtual DIEToClangType &GetForwardDeclDieToClangType() {
+return m_forward_decl_die_to_clang_type;
+  }
+
   typedef llvm::DenseMap ClangTypeToDIE;
 
+  virtual ClangTypeToDIE &GetForwardDeclClangTypeToDie() {
+return m_forward_decl_clang_type_to_die;
+  }
+
+  virtual UniqueDWARFASTTypeMap &GetUniqueDWARFASTTypeMap();
+
+  bool ClassOrStructIsVirtual(const DWARFDIE &die);
+
+  SymbolFileDWARFDebugMap *GetDebugMapSymfile();
+
+  virtual lldb::TypeSP
+  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die);
+
+  virtual lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
+  const DWARFDIE &die, ConstString type_name, bool must_be_implementation);
+
+  Type *ResolveTypeUID(lldb::user_id_t type_uid) override;
+
+  Type *ResolveTypeUID(const DWARFDIE &die, bool assert_not_being_parsed);
+
+  Type *ResolveTypeUID(const DIERef &die_ref);
+
+protected:
+  typedef llvm::DenseMap
+  DIEToVariableSP;
+
   SymbolFileDWARF(const SymbolFileDWARF &) = delete;
   const SymbolFileDWARF &operator=(const SymbolFileDWARF &) = delete;
 
@@ -371,10 +400,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
   bool ParseSupportFiles(DWARFUnit &dwarf_cu, const lldb::ModuleSP &module,
  FileSpecList &support_files);
 
-  Type *ResolveTypeUID(const DWARFDIE &die, bool assert_not_being_parsed);
-
-  Type *ResolveTypeUID(const DIERef &die_ref);
-
   lldb::VariableSP ParseVariableDIE(const SymbolContext &sc,
 const DWARFDIE &die,
 const lldb::addr_t func_low_pc);
@@ -402,8 +427,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
   DIEArray MergeBlockAbstractParameters(const DWARFDIE &block_die,
 DIEArray &&variable_dies);
 
-  bool ClassOrStructIsVirtual(const DWARFDIE &die);
-
   // Given a die_offset, figure out the symbol context representing that die.
   bool ResolveFunction(const DWARFDIE &die, bool include_inlines,
SymbolContextList &sc_list);
@@ -415,12 +438,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
   void ResolveFunctionAndBlock(lldb::addr_t file_vm_addr, bool lookup_block,
SymbolContext &sc);
 
-  virtual lldb::TypeSP
-  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die);
-
-  virtual lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
-  const DWARFDIE &die, ConstString type_name, bool must_be_implementation);
-
   Symbol *GetObjCClassSymbol(ConstString objc_class_name);
 
   lldb::TypeSP GetTypeForDIE(const DWARFDIE &die,
@@ -430,8 +447,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
 m_debug_map_module_wp = module_sp;
   }
 
-  SymbolFileDWARFDebugMap *GetDebugMapSymfile();
-
   DWARFDIE
   FindBlockContainingSpecification(const DIERef &func_die_ref,
dw_offset_t spec_block_die_offset);
@@ -440,8 +455,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
   FindBlockContainingSpecification(const DWARFDIE &die,
  

[Lldb-commits] [lldb] [lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)` return `void` (not `bool`) (PR #69989)

2023-10-24 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

LGTM!

https://github.com/llvm/llvm-project/pull/69989
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-24 Thread Med Ismail Bennani via lldb-commits


@@ -0,0 +1,140 @@
+//===-- WatchpointResource.h *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+#define LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+
+#include "lldb/Breakpoint/WatchpointCollection.h"
+#include "lldb/lldb-public.h"
+
+#include 
+
+namespace lldb_private {
+
+class WatchpointResource
+: public std::enable_shared_from_this {
+
+public:
+  // Constructors and Destructors
+  WatchpointResource(lldb::addr_t addr, size_t size, bool read, bool write);
+
+  ~WatchpointResource();
+
+  void GetMemoryRange(lldb::addr_t &addr, size_t &size) const;
+
+  lldb::addr_t GetAddress() const;
+
+  size_t GetByteSize() const;
+
+  void GetType(bool &read, bool &write) const;
+
+  void SetType(bool read, bool write);
+
+  /// The "Owners" are the watchpoints that share this resource.
+  /// The method adds the \a owner to this resource's owner list.
+  ///
+  /// \param[in] owner
+  ///\a owner is the Wachpoint to add.
+  void AddOwner(const lldb::WatchpointSP &owner);
+
+  /// The method removes the owner at \a owner from this watchpoint
+  /// resource.
+  void RemoveOwner(lldb::WatchpointSP &owner);
+
+  /// This method returns the number of Watchpoints currently using
+  /// watchpoint resource.
+  ///
+  /// \return
+  ///The number of owners.
+  size_t GetNumberOfOwners();
+
+  /// This method returns the Watchpoint at index \a index using this
+  /// Resource.  The owners are listed ordinally from 0 to
+  /// GetNumberOfOwners() - 1 so you can use this method to iterate over the
+  /// owners.
+  ///
+  /// \param[in] idx
+  /// The index in the list of owners for which you wish the owner 
location.
+  ///
+  /// \return
+  ///The Watchpoint at that index.
+  lldb::WatchpointSP GetOwnerAtIndex(size_t idx);
+
+  /// Check if the owners includes a watchpoint.
+  ///
+  /// \param[in] wp_sp
+  /// The WatchpointSP to search for.
+  ///
+  /// \result
+  /// true if this resource's owners includes the watchpoint.
+  bool OwnersContains(lldb::WatchpointSP &wp_sp);
+
+  /// Check if the owners includes a watchpoint.
+  ///
+  /// \param[in] wp
+  /// The Watchpoint to search for.
+  ///
+  /// \result
+  /// true if this resource's owners includes the watchpoint.
+  bool OwnersContains(const lldb_private::Watchpoint *wp);
+
+  /// This method copies the watchpoint resource's owners into a new 
collection.
+  /// It does this while the owners mutex is locked.
+  ///
+  /// \param[out] out_collection
+  ///The BreakpointLocationCollection into which to put the owners
+  ///of this breakpoint site.
+  ///
+  /// \return
+  ///The number of elements copied into out_collection.
+  size_t CopyOwnersList(WatchpointCollection &out_collection);
+
+  // The ID of the WatchpointResource is set by the WatchpointResourceList
+  // when the Resource has been set in the inferior and is being added
+  // to the List, in an attempt to match the hardware watchpoint register
+  // ordering.  If a Process can correctly identify the hardware watchpoint
+  // register index when it has created the Resource, it may initialize it
+  // before it is inserted in the WatchpointResourceList.
+  void SetID(lldb::wp_resource_id_t);

medismailben wrote:

Thanks for the explanation, that makes more sense to me now.

https://github.com/llvm/llvm-project/pull/68845
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Part 2 of 2 - Refactor `CommandObject::DoExecute(...)` return `void` (not `bool`) (PR #69991)

2023-10-24 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

> > I think I looked at every changed line, looks good to me overall. Found one 
> > place with a small style issue but it's not a blocker. Thanks!
> 
> Thanks @bulbazord! Do you know why the `code_formatter` check/bot didn't flag 
> that or the other one-line `if` statements?

This could be because it's part of the LLVM style guide but not enforced in the 
`.clang-format`.

Also looked at most of the lines, LGTM. I wonder however why did you decide to 
make 2 separate PRs for this ? Is there any reason for this ? It could have 
been 2 commits in the same PR.

https://github.com/llvm/llvm-project/pull/69991
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits