[Lldb-commits] [lldb] [lldb] Unify CalculateMD5 return types (PR #91029)

2024-05-08 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Unify CalculateMD5 return types (PR #91029)

2024-05-08 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> @JDevlieghere , do you know if there's a way to run buildbot on a merge of 
> this PR and main branch - just to validate the build/tests work before this 
> merge?

Not that I know. When failures are macOS specific I'm happy to apply a PR 
locally and run the test suite and other folks with specific configurations 
might do the same, but that's about all I can think of.

> The [llvm contributing 
> guide](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr)
>  says this is normal workflow - but I worry since I am using a lot of the 
> maintainers' time to merge / revert the changes for me since I don't have 
> write access.

No worries, it's totally normal and we're happy to help with that!



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


[Lldb-commits] [lldb] [lldb] Fixed SyntaxWarning: invalid escape sequence \[ \d \s (PR #91146)

2024-05-08 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Adds additional fields to ProcessInfo (PR #91544)

2024-05-08 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Adds additional fields to ProcessInfo (PR #91544)

2024-05-08 Thread Greg Clayton via lldb-commits


@@ -12,6 +12,9 @@
 #include "lldb/Utility/ProcessInfo.h"
 #include "gtest/gtest.h"
 
+#include 
+#include 

clayborg wrote:

it is ok to include this header file here because this is a linux specific host 
test.

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


[Lldb-commits] [lldb] [lldb] Adds additional fields to ProcessInfo (PR #91544)

2024-05-08 Thread Greg Clayton via lldb-commits


@@ -17,6 +17,7 @@
 
 #include 
 #include 
+#include 

clayborg wrote:

Not every OS will have this header file, so I am not sure we can/should be 
importing this header. Windows build will most likely fail and any non unix 
based OS as well.

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


[Lldb-commits] [lldb] [lldb] Adds additional fields to ProcessInfo (PR #91544)

2024-05-08 Thread Greg Clayton via lldb-commits


@@ -144,6 +144,19 @@ class ProcessInstanceInfo : public ProcessInfo {
 long int tv_usec = 0;
   };
 
+  enum class ProcessState {
+Unknown,
+Dead,
+DiskSleep,
+Idle,
+Paging,
+Parked,
+Running,
+Sleeping,
+TracedOrStopped,
+Zombie,
+  };
+

clayborg wrote:

This isn't used in this header file. Any reason this was moved here?

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


[Lldb-commits] [lldb] [lldb] Adds additional fields to ProcessInfo (PR #91544)

2024-05-08 Thread Greg Clayton via lldb-commits


@@ -254,6 +277,8 @@ class ProcessInstanceInfo : public ProcessInfo {
   struct timespec m_system_time {};
   struct timespec m_cumulative_user_time {};
   struct timespec m_cumulative_system_time {};
+  int8_t m_nice_value = INT8_MAX;

clayborg wrote:

maybe make this a `std::optional`? It would be nice to know when/if 
things in `ProcessInstanceInfo` are set to value values or just defaulted. it 
might be nice to make many things in this class be std::optional as well so we 
know when we have a valid value and when we don't

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


[Lldb-commits] [lldb] [lldb] Adds additional fields to ProcessInfo (PR #91544)

2024-05-08 Thread Greg Clayton via lldb-commits

https://github.com/clayborg requested changes to this pull request.

So `ProcessInstanceInfo` is already very OS specific, so I can't object to 
adding more OS specific information to this structure. It would be nice to 
abstract OS specific things into a dictionary so allow OS specific things to be 
added with OS specific key/value pairs, but since it is already very unix 
centric these changes are ok. We have to be careful to not include OS specific 
header files like `` as they won't be available on windows or 
other non linux OS versions. See inline comments for details.

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


[Lldb-commits] [lldb] [lldb] Adds additional fields to ProcessInfo (PR #91544)

2024-05-08 Thread Greg Clayton via lldb-commits


@@ -117,6 +118,10 @@ bool ProcessInfo::IsScriptedProcess() const {
   return m_scripted_metadata_sp && *m_scripted_metadata_sp;
 }
 
+bool ProcessInstanceInfo::NiceValueIsValid() const {
+  return m_nice_value >= PRIO_MIN && m_nice_value <= PRIO_MAX;

clayborg wrote:

`PRIO_MIN` and `PRIO_MAX` come from linux/unix header and won't be available on 
other systems. I am also wondering if the `PRIO_MIN` and `PRIO_MAX` will differ 
from one linux OS to another? Probably best to not rely on these defines from 
OS specific header files, so I would suggest either manually defining them in 
this file or not checking the values.

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


[Lldb-commits] [lldb] [lldb] Adds additional fields to ProcessInfo (PR #91544)

2024-05-08 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Adds additional fields to ProcessInfo (PR #91544)

2024-05-08 Thread Alex Langford via lldb-commits


@@ -237,6 +250,16 @@ class ProcessInstanceInfo : public ProcessInfo {
m_cumulative_system_time.tv_usec > 0;
   }
 
+  int8_t GetNiceValue() const { return m_nice_value; }
+
+  void SetNiceValue(int8_t nice_value) { m_nice_value = nice_value; }
+
+  bool NiceValueIsValid() const;
+
+  void SetIsZombie() { m_zombie = true; }

bulbazord wrote:

Is there a way to unset it being a zombie?

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


[Lldb-commits] [lldb] [lldb] Adds additional fields to ProcessInfo (PR #91544)

2024-05-08 Thread Alex Langford via lldb-commits


@@ -237,6 +250,16 @@ class ProcessInstanceInfo : public ProcessInfo {
m_cumulative_system_time.tv_usec > 0;
   }
 
+  int8_t GetNiceValue() const { return m_nice_value; }

bulbazord wrote:

Suggestion: `nice` -> `priority_level` or something similar. The unix world 
uses the words `nice` and `niceness` but Windows and other platforms do not. 
It's also not a very obvious word if you lack the domain expertise.

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


[Lldb-commits] [lldb] [lldb/crashlog] Enforce image loading policy (PR #91109)

2024-05-08 Thread Med Ismail Bennani via lldb-commits


@@ -526,6 +526,47 @@ def create_target(self):
 def get_target(self):
 return self.target
 
+def load_images(self, options, loaded_images=[]):

medismailben wrote:

Good point

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


[Lldb-commits] [lldb] [lldb] Adds additional fields to ProcessInfo (PR #91544)

2024-05-08 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 1aeb64c8ec7b96b2301929d8a325a6e1d9ddaa2f 
8355e9f14b898572d81721118e6a842d63652a33 -- 
lldb/include/lldb/Utility/ProcessInfo.h lldb/source/Host/linux/Host.cpp 
lldb/source/Utility/ProcessInfo.cpp lldb/unittests/Host/linux/HostTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/include/lldb/Utility/ProcessInfo.h 
b/lldb/include/lldb/Utility/ProcessInfo.h
index ddaa93c6d5..fb0fca2ccc 100644
--- a/lldb/include/lldb/Utility/ProcessInfo.h
+++ b/lldb/include/lldb/Utility/ProcessInfo.h
@@ -250,23 +250,15 @@ public:
m_cumulative_system_time.tv_usec > 0;
   }
 
-  int8_t GetNiceValue() const {
-return m_nice_value;
-  }
+  int8_t GetNiceValue() const { return m_nice_value; }
 
-  void SetNiceValue(int8_t nice_value) {
-m_nice_value = nice_value;
-  }
+  void SetNiceValue(int8_t nice_value) { m_nice_value = nice_value; }
 
   bool NiceValueIsValid() const;
 
-  void SetIsZombie() {
-m_zombie = true;
-  }
+  void SetIsZombie() { m_zombie = true; }
 
-  bool IsZombie() const {
-return m_zombie;
-  }
+  bool IsZombie() const { return m_zombie; }
 
   void Dump(Stream , UserIDResolver ) const;
 
diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp
index c12bd259c5..ba2323990a 100644
--- a/lldb/source/Host/linux/Host.cpp
+++ b/lldb/source/Host/linux/Host.cpp
@@ -83,15 +83,16 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo 
,
   if (Rest.empty())
 return false;
   StatFields stat_fields;
-  if (sscanf(Rest.data(),
- "%d %s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld 
%ld",
- _fields.pid, stat_fields.comm, _fields.state,
- _fields.ppid, _fields.pgrp, _fields.session,
- _fields.tty_nr, _fields.tpgid, _fields.flags,
- _fields.minflt, _fields.cminflt, _fields.majflt,
- _fields.cmajflt, _fields.utime, _fields.stime,
- _fields.cutime, _fields.cstime, _fields.priority,
- _fields.nice) < 0) {
+  if (sscanf(
+  Rest.data(),
+  "%d %s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld",
+  _fields.pid, stat_fields.comm, _fields.state,
+  _fields.ppid, _fields.pgrp, _fields.session,
+  _fields.tty_nr, _fields.tpgid, _fields.flags,
+  _fields.minflt, _fields.cminflt, _fields.majflt,
+  _fields.cmajflt, _fields.utime, _fields.stime,
+  _fields.cutime, _fields.cstime, _fields.priority,
+  _fields.nice) < 0) {
 return false;
   }
 
@@ -110,9 +111,8 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo 
,
 
   // nice values run from 19 to -20 inclusive (in linux). In the prpsinfo 
struct
   // pr_nice is a char
-  auto nice_value = static_cast(
-(stat_fields.nice < 0 ? 0x80 : 0x00) | (stat_fields.nice & 0x7f)
-  );
+  auto nice_value = static_cast((stat_fields.nice < 0 ? 0x80 : 0x00) |
+(stat_fields.nice & 0x7f));
 
   ProcessInfo.SetParentProcessID(stat_fields.ppid);
   ProcessInfo.SetProcessGroupID(stat_fields.pgrp);
diff --git a/lldb/source/Utility/ProcessInfo.cpp 
b/lldb/source/Utility/ProcessInfo.cpp
index de9992ec12..5add5fc8a8 100644
--- a/lldb/source/Utility/ProcessInfo.cpp
+++ b/lldb/source/Utility/ProcessInfo.cpp
@@ -15,9 +15,9 @@
 #include "lldb/Utility/UserIDResolver.h"
 #include "llvm/ADT/SmallString.h"
 
-#include 
 #include 
 #include 
+#include 
 
 using namespace lldb;
 using namespace lldb_private;
diff --git a/lldb/unittests/Host/linux/HostTest.cpp 
b/lldb/unittests/Host/linux/HostTest.cpp
index 310e6fe3e6..c1cc2d5277 100644
--- a/lldb/unittests/Host/linux/HostTest.cpp
+++ b/lldb/unittests/Host/linux/HostTest.cpp
@@ -12,8 +12,8 @@
 #include "lldb/Utility/ProcessInfo.h"
 #include "gtest/gtest.h"
 
-#include 
 #include 
+#include 
 #include 
 
 using namespace lldb_private;

``




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


[Lldb-commits] [lldb] [lldb] Adds additional fields to ProcessInfo (PR #91544)

2024-05-08 Thread Fred Grim via lldb-commits

https://github.com/feg208 updated 
https://github.com/llvm/llvm-project/pull/91544

>From 57e47b53682d43d2b1febba721688c6931c43291 Mon Sep 17 00:00:00 2001
From: Fred Grim 
Date: Wed, 8 May 2024 15:36:16 -0700
Subject: [PATCH] [lldb] Adds additional fields to ProcessInfo

To implement SaveCore for elf binaries we need to populate some
additional fields in the prpsinfo struct. Those fields are the nice
value of the process whose core is to be taken as well as a boolean
flag indicating whether or not that process is a zombie. This commit
adds those as well as tests to ensure that the values are consistent
with expectations
---
 lldb/include/lldb/Utility/ProcessInfo.h | 25 +++
 lldb/source/Host/linux/Host.cpp | 41 +
 lldb/source/Utility/ProcessInfo.cpp |  5 +++
 lldb/unittests/Host/linux/HostTest.cpp  | 20 
 4 files changed, 71 insertions(+), 20 deletions(-)

diff --git a/lldb/include/lldb/Utility/ProcessInfo.h 
b/lldb/include/lldb/Utility/ProcessInfo.h
index 54ac000dc7fc2..fb0fca2cccbe3 100644
--- a/lldb/include/lldb/Utility/ProcessInfo.h
+++ b/lldb/include/lldb/Utility/ProcessInfo.h
@@ -144,6 +144,19 @@ class ProcessInstanceInfo : public ProcessInfo {
 long int tv_usec = 0;
   };
 
+  enum class ProcessState {
+Unknown,
+Dead,
+DiskSleep,
+Idle,
+Paging,
+Parked,
+Running,
+Sleeping,
+TracedOrStopped,
+Zombie,
+  };
+
   ProcessInstanceInfo() = default;
 
   ProcessInstanceInfo(const char *name, const ArchSpec , lldb::pid_t pid)
@@ -237,6 +250,16 @@ class ProcessInstanceInfo : public ProcessInfo {
m_cumulative_system_time.tv_usec > 0;
   }
 
+  int8_t GetNiceValue() const { return m_nice_value; }
+
+  void SetNiceValue(int8_t nice_value) { m_nice_value = nice_value; }
+
+  bool NiceValueIsValid() const;
+
+  void SetIsZombie() { m_zombie = true; }
+
+  bool IsZombie() const { return m_zombie; }
+
   void Dump(Stream , UserIDResolver ) const;
 
   static void DumpTableHeader(Stream , bool show_args, bool verbose);
@@ -254,6 +277,8 @@ class ProcessInstanceInfo : public ProcessInfo {
   struct timespec m_system_time {};
   struct timespec m_cumulative_user_time {};
   struct timespec m_cumulative_system_time {};
+  int8_t m_nice_value = INT8_MAX;
+  bool m_zombie = false;
 };
 
 typedef std::vector ProcessInstanceInfoList;
diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp
index c6490f2fc9e2f..ba2323990adac 100644
--- a/lldb/source/Host/linux/Host.cpp
+++ b/lldb/source/Host/linux/Host.cpp
@@ -37,18 +37,8 @@ using namespace lldb;
 using namespace lldb_private;
 
 namespace {
-enum class ProcessState {
-  Unknown,
-  Dead,
-  DiskSleep,
-  Idle,
-  Paging,
-  Parked,
-  Running,
-  Sleeping,
-  TracedOrStopped,
-  Zombie,
-};
+
+using ProcessState = typename ProcessInstanceInfo::ProcessState;
 
 constexpr int task_comm_len = 16;
 
@@ -70,6 +60,8 @@ struct StatFields {
   long unsigned stime;
   long cutime;
   long cstime;
+  long priority;
+  long nice;
   //  other things. We don't need them below
 };
 }
@@ -91,14 +83,16 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo 
,
   if (Rest.empty())
 return false;
   StatFields stat_fields;
-  if (sscanf(Rest.data(),
- "%d %s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld",
- _fields.pid, stat_fields.comm, _fields.state,
- _fields.ppid, _fields.pgrp, _fields.session,
- _fields.tty_nr, _fields.tpgid, _fields.flags,
- _fields.minflt, _fields.cminflt, _fields.majflt,
- _fields.cmajflt, _fields.utime, _fields.stime,
- _fields.cutime, _fields.cstime) < 0) {
+  if (sscanf(
+  Rest.data(),
+  "%d %s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld",
+  _fields.pid, stat_fields.comm, _fields.state,
+  _fields.ppid, _fields.pgrp, _fields.session,
+  _fields.tty_nr, _fields.tpgid, _fields.flags,
+  _fields.minflt, _fields.cminflt, _fields.majflt,
+  _fields.cmajflt, _fields.utime, _fields.stime,
+  _fields.cutime, _fields.cstime, _fields.priority,
+  _fields.nice) < 0) {
 return false;
   }
 
@@ -115,6 +109,11 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo 
,
 return ts;
   };
 
+  // nice values run from 19 to -20 inclusive (in linux). In the prpsinfo 
struct
+  // pr_nice is a char
+  auto nice_value = static_cast((stat_fields.nice < 0 ? 0x80 : 0x00) |
+(stat_fields.nice & 0x7f));
+
   ProcessInfo.SetParentProcessID(stat_fields.ppid);
   ProcessInfo.SetProcessGroupID(stat_fields.pgrp);
   ProcessInfo.SetProcessSessionID(stat_fields.session);
@@ -122,6 +121,7 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo 
,
   ProcessInfo.SetSystemTime(convert(stat_fields.stime));
   ProcessInfo.SetCumulativeUserTime(convert(stat_fields.cutime));
   

[Lldb-commits] [lldb] [lldb] Adds additional fields to ProcessInfo (PR #91544)

2024-05-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Fred Grim (feg208)


Changes

To implement SaveCore for elf binaries we need to populate some additional 
fields in the prpsinfo struct. Those fields are the nice value of the process 
whose core is to be taken as well as a boolean flag indicating whether or not 
that process is a zombie. This commit adds those as well as tests to ensure 
that the values are consistent with expectations

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


4 Files Affected:

- (modified) lldb/include/lldb/Utility/ProcessInfo.h (+33) 
- (modified) lldb/source/Host/linux/Host.cpp (+15-14) 
- (modified) lldb/source/Utility/ProcessInfo.cpp (+5) 
- (modified) lldb/unittests/Host/linux/HostTest.cpp (+21) 


``diff
diff --git a/lldb/include/lldb/Utility/ProcessInfo.h 
b/lldb/include/lldb/Utility/ProcessInfo.h
index 54ac000dc7fc2..ddaa93c6d5c91 100644
--- a/lldb/include/lldb/Utility/ProcessInfo.h
+++ b/lldb/include/lldb/Utility/ProcessInfo.h
@@ -144,6 +144,19 @@ class ProcessInstanceInfo : public ProcessInfo {
 long int tv_usec = 0;
   };
 
+  enum class ProcessState {
+Unknown,
+Dead,
+DiskSleep,
+Idle,
+Paging,
+Parked,
+Running,
+Sleeping,
+TracedOrStopped,
+Zombie,
+  };
+
   ProcessInstanceInfo() = default;
 
   ProcessInstanceInfo(const char *name, const ArchSpec , lldb::pid_t pid)
@@ -237,6 +250,24 @@ class ProcessInstanceInfo : public ProcessInfo {
m_cumulative_system_time.tv_usec > 0;
   }
 
+  int8_t GetNiceValue() const {
+return m_nice_value;
+  }
+
+  void SetNiceValue(int8_t nice_value) {
+m_nice_value = nice_value;
+  }
+
+  bool NiceValueIsValid() const;
+
+  void SetIsZombie() {
+m_zombie = true;
+  }
+
+  bool IsZombie() const {
+return m_zombie;
+  }
+
   void Dump(Stream , UserIDResolver ) const;
 
   static void DumpTableHeader(Stream , bool show_args, bool verbose);
@@ -254,6 +285,8 @@ class ProcessInstanceInfo : public ProcessInfo {
   struct timespec m_system_time {};
   struct timespec m_cumulative_user_time {};
   struct timespec m_cumulative_system_time {};
+  int8_t m_nice_value = INT8_MAX;
+  bool m_zombie = false;
 };
 
 typedef std::vector ProcessInstanceInfoList;
diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp
index c6490f2fc9e2f..c12bd259c5a7d 100644
--- a/lldb/source/Host/linux/Host.cpp
+++ b/lldb/source/Host/linux/Host.cpp
@@ -37,18 +37,8 @@ using namespace lldb;
 using namespace lldb_private;
 
 namespace {
-enum class ProcessState {
-  Unknown,
-  Dead,
-  DiskSleep,
-  Idle,
-  Paging,
-  Parked,
-  Running,
-  Sleeping,
-  TracedOrStopped,
-  Zombie,
-};
+
+using ProcessState = typename ProcessInstanceInfo::ProcessState;
 
 constexpr int task_comm_len = 16;
 
@@ -70,6 +60,8 @@ struct StatFields {
   long unsigned stime;
   long cutime;
   long cstime;
+  long priority;
+  long nice;
   //  other things. We don't need them below
 };
 }
@@ -92,13 +84,14 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo 
,
 return false;
   StatFields stat_fields;
   if (sscanf(Rest.data(),
- "%d %s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld",
+ "%d %s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld 
%ld",
  _fields.pid, stat_fields.comm, _fields.state,
  _fields.ppid, _fields.pgrp, _fields.session,
  _fields.tty_nr, _fields.tpgid, _fields.flags,
  _fields.minflt, _fields.cminflt, _fields.majflt,
  _fields.cmajflt, _fields.utime, _fields.stime,
- _fields.cutime, _fields.cstime) < 0) {
+ _fields.cutime, _fields.cstime, _fields.priority,
+ _fields.nice) < 0) {
 return false;
   }
 
@@ -115,6 +108,12 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo 
,
 return ts;
   };
 
+  // nice values run from 19 to -20 inclusive (in linux). In the prpsinfo 
struct
+  // pr_nice is a char
+  auto nice_value = static_cast(
+(stat_fields.nice < 0 ? 0x80 : 0x00) | (stat_fields.nice & 0x7f)
+  );
+
   ProcessInfo.SetParentProcessID(stat_fields.ppid);
   ProcessInfo.SetProcessGroupID(stat_fields.pgrp);
   ProcessInfo.SetProcessSessionID(stat_fields.session);
@@ -122,6 +121,7 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo 
,
   ProcessInfo.SetSystemTime(convert(stat_fields.stime));
   ProcessInfo.SetCumulativeUserTime(convert(stat_fields.cutime));
   ProcessInfo.SetCumulativeSystemTime(convert(stat_fields.cstime));
+  ProcessInfo.SetNiceValue(nice_value);
   switch (stat_fields.state) {
   case 'R':
 State = ProcessState::Running;
@@ -134,6 +134,7 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo 
,
 break;
   case 'Z':
 State = ProcessState::Zombie;
+ProcessInfo.SetIsZombie();
 break;
   case 'X':
 State = ProcessState::Dead;
diff --git a/lldb/source/Utility/ProcessInfo.cpp 
b/lldb/source/Utility/ProcessInfo.cpp
index 

[Lldb-commits] [lldb] [lldb] Adds additional fields to ProcessInfo (PR #91544)

2024-05-08 Thread Fred Grim via lldb-commits

https://github.com/feg208 created 
https://github.com/llvm/llvm-project/pull/91544

To implement SaveCore for elf binaries we need to populate some additional 
fields in the prpsinfo struct. Those fields are the nice value of the process 
whose core is to be taken as well as a boolean flag indicating whether or not 
that process is a zombie. This commit adds those as well as tests to ensure 
that the values are consistent with expectations

>From 8355e9f14b898572d81721118e6a842d63652a33 Mon Sep 17 00:00:00 2001
From: Fred Grim 
Date: Wed, 8 May 2024 15:36:16 -0700
Subject: [PATCH] [lldb] Adds additional fields to ProcessInfo

To implement SaveCore for elf binaries we need to populate some
additional fields in the prpsinfo struct. Those fields are the nice
value of the process whose core is to be taken as well as a boolean
flag indicating whether or not that process is a zombie. This commit
adds those as well as tests to ensure that the values are consistent
with expectations
---
 lldb/include/lldb/Utility/ProcessInfo.h | 33 +
 lldb/source/Host/linux/Host.cpp | 29 +++---
 lldb/source/Utility/ProcessInfo.cpp |  5 
 lldb/unittests/Host/linux/HostTest.cpp  | 21 
 4 files changed, 74 insertions(+), 14 deletions(-)

diff --git a/lldb/include/lldb/Utility/ProcessInfo.h 
b/lldb/include/lldb/Utility/ProcessInfo.h
index 54ac000dc7fc2..ddaa93c6d5c91 100644
--- a/lldb/include/lldb/Utility/ProcessInfo.h
+++ b/lldb/include/lldb/Utility/ProcessInfo.h
@@ -144,6 +144,19 @@ class ProcessInstanceInfo : public ProcessInfo {
 long int tv_usec = 0;
   };
 
+  enum class ProcessState {
+Unknown,
+Dead,
+DiskSleep,
+Idle,
+Paging,
+Parked,
+Running,
+Sleeping,
+TracedOrStopped,
+Zombie,
+  };
+
   ProcessInstanceInfo() = default;
 
   ProcessInstanceInfo(const char *name, const ArchSpec , lldb::pid_t pid)
@@ -237,6 +250,24 @@ class ProcessInstanceInfo : public ProcessInfo {
m_cumulative_system_time.tv_usec > 0;
   }
 
+  int8_t GetNiceValue() const {
+return m_nice_value;
+  }
+
+  void SetNiceValue(int8_t nice_value) {
+m_nice_value = nice_value;
+  }
+
+  bool NiceValueIsValid() const;
+
+  void SetIsZombie() {
+m_zombie = true;
+  }
+
+  bool IsZombie() const {
+return m_zombie;
+  }
+
   void Dump(Stream , UserIDResolver ) const;
 
   static void DumpTableHeader(Stream , bool show_args, bool verbose);
@@ -254,6 +285,8 @@ class ProcessInstanceInfo : public ProcessInfo {
   struct timespec m_system_time {};
   struct timespec m_cumulative_user_time {};
   struct timespec m_cumulative_system_time {};
+  int8_t m_nice_value = INT8_MAX;
+  bool m_zombie = false;
 };
 
 typedef std::vector ProcessInstanceInfoList;
diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp
index c6490f2fc9e2f..c12bd259c5a7d 100644
--- a/lldb/source/Host/linux/Host.cpp
+++ b/lldb/source/Host/linux/Host.cpp
@@ -37,18 +37,8 @@ using namespace lldb;
 using namespace lldb_private;
 
 namespace {
-enum class ProcessState {
-  Unknown,
-  Dead,
-  DiskSleep,
-  Idle,
-  Paging,
-  Parked,
-  Running,
-  Sleeping,
-  TracedOrStopped,
-  Zombie,
-};
+
+using ProcessState = typename ProcessInstanceInfo::ProcessState;
 
 constexpr int task_comm_len = 16;
 
@@ -70,6 +60,8 @@ struct StatFields {
   long unsigned stime;
   long cutime;
   long cstime;
+  long priority;
+  long nice;
   //  other things. We don't need them below
 };
 }
@@ -92,13 +84,14 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo 
,
 return false;
   StatFields stat_fields;
   if (sscanf(Rest.data(),
- "%d %s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld",
+ "%d %s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld 
%ld",
  _fields.pid, stat_fields.comm, _fields.state,
  _fields.ppid, _fields.pgrp, _fields.session,
  _fields.tty_nr, _fields.tpgid, _fields.flags,
  _fields.minflt, _fields.cminflt, _fields.majflt,
  _fields.cmajflt, _fields.utime, _fields.stime,
- _fields.cutime, _fields.cstime) < 0) {
+ _fields.cutime, _fields.cstime, _fields.priority,
+ _fields.nice) < 0) {
 return false;
   }
 
@@ -115,6 +108,12 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo 
,
 return ts;
   };
 
+  // nice values run from 19 to -20 inclusive (in linux). In the prpsinfo 
struct
+  // pr_nice is a char
+  auto nice_value = static_cast(
+(stat_fields.nice < 0 ? 0x80 : 0x00) | (stat_fields.nice & 0x7f)
+  );
+
   ProcessInfo.SetParentProcessID(stat_fields.ppid);
   ProcessInfo.SetProcessGroupID(stat_fields.pgrp);
   ProcessInfo.SetProcessSessionID(stat_fields.session);
@@ -122,6 +121,7 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo 
,
   ProcessInfo.SetSystemTime(convert(stat_fields.stime));
   

[Lldb-commits] [lldb] [lldb] Display breakpoint locations using display name (PR #90297)

2024-05-08 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] 7ec8a33 - [lldb] Display breakpoint locations using display name (#90297)

2024-05-08 Thread via lldb-commits

Author: Dave Lee
Date: 2024-05-08T15:07:14-07:00
New Revision: 7ec8a333b5fdf1ee78426fe3557c330aa920aa5f

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

LOG: [lldb] Display breakpoint locations using display name (#90297)

Adds a `show_function_display_name` parameter to
`SymbolContext::DumpStopContext`. This
parameter defaults to false, but `BreakpointLocation::GetDescription`
sets it to true.

This is NFC in mainline lldb, and will be used to modify how Swift
breakpoint locations are printed.

Added: 


Modified: 
lldb/include/lldb/Symbol/SymbolContext.h
lldb/source/Breakpoint/BreakpointLocation.cpp
lldb/source/Core/Address.cpp
lldb/source/Symbol/SymbolContext.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/SymbolContext.h 
b/lldb/include/lldb/Symbol/SymbolContext.h
index bd33a71b46ca..0bc707070f85 100644
--- a/lldb/include/lldb/Symbol/SymbolContext.h
+++ b/lldb/include/lldb/Symbol/SymbolContext.h
@@ -158,6 +158,7 @@ class SymbolContext {
   Stream *s, ExecutionContextScope *exe_scope, const Address _addr,
   bool show_fullpaths, bool show_module, bool show_inlined_frames,
   bool show_function_arguments, bool show_function_name,
+  bool show_function_display_name = false,
   std::optional settings = std::nullopt) const;
 
   /// Get the address range contained within a symbol context.

diff  --git a/lldb/source/Breakpoint/BreakpointLocation.cpp 
b/lldb/source/Breakpoint/BreakpointLocation.cpp
index b48ec1398d63..41911fad41c6 100644
--- a/lldb/source/Breakpoint/BreakpointLocation.cpp
+++ b/lldb/source/Breakpoint/BreakpointLocation.cpp
@@ -507,7 +507,7 @@ void BreakpointLocation::GetDescription(Stream *s,
   else
 s->PutCString("where = ");
   sc.DumpStopContext(s, m_owner.GetTarget().GetProcessSP().get(), 
m_address,
- false, true, false, true, true);
+ false, true, false, true, true, true);
 } else {
   if (sc.module_sp) {
 s->EOL();

diff  --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp
index b23398883fa5..5a4751bd5256 100644
--- a/lldb/source/Core/Address.cpp
+++ b/lldb/source/Core/Address.cpp
@@ -645,7 +645,8 @@ bool Address::Dump(Stream *s, ExecutionContextScope 
*exe_scope, DumpStyle style,
 pointer_sc.symbol != nullptr) {
   s->PutCString(": ");
   pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, 
false,
- false, true, true, settings);
+ false, true, true, false,
+ settings);
 }
   }
 }
@@ -685,7 +686,7 @@ bool Address::Dump(Stream *s, ExecutionContextScope 
*exe_scope, DumpStyle style,
   sc.DumpStopContext(s, exe_scope, *this, show_fullpaths,
  show_module, show_inlined_frames,
  show_function_arguments, show_function_name,
- settings);
+ false, settings);
 } else {
   // We found a symbol but it was in a 
diff erent section so it
   // isn't the symbol we should be showing, just show the section

diff  --git a/lldb/source/Symbol/SymbolContext.cpp 
b/lldb/source/Symbol/SymbolContext.cpp
index f368896fbad4..8f26e41d1920 100644
--- a/lldb/source/Symbol/SymbolContext.cpp
+++ b/lldb/source/Symbol/SymbolContext.cpp
@@ -73,6 +73,7 @@ bool SymbolContext::DumpStopContext(
 Stream *s, ExecutionContextScope *exe_scope, const Address ,
 bool show_fullpaths, bool show_module, bool show_inlined_frames,
 bool show_function_arguments, bool show_function_name,
+bool show_function_display_name,
 std::optional settings) const {
   bool dumped_something = false;
   if (show_module && module_sp) {
@@ -93,6 +94,8 @@ bool SymbolContext::DumpStopContext(
   ConstString name;
   if (!show_function_arguments)
 name = function->GetNameNoArguments();
+  if (!name && show_function_display_name)
+name = function->GetDisplayName();
   if (!name)
 name = function->GetName();
   if (name)
@@ -146,7 +149,8 @@ bool SymbolContext::DumpStopContext(
 const bool show_function_name = true;
 return inline_parent_sc.DumpStopContext(
 s, exe_scope, inline_parent_addr, show_fullpaths, show_module,
-show_inlined_frames, show_function_arguments, show_function_name);
+show_inlined_frames, show_function_arguments, show_function_name,
+show_function_display_name);
   }
 } else {
   if (line_entry.IsValid()) {
@@ -164,7 +168,12 @@ bool 

[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)

2024-05-08 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)

2024-05-08 Thread Michael Buch via lldb-commits


@@ -1411,3 +1414,35 @@ clang::Decl *
 ClangASTImporter::ASTImporterDelegate::GetOriginalDecl(clang::Decl *To) {
   return m_main.GetDeclOrigin(To).decl;
 }
+
+void ClangASTImporter::ASTImporterDelegate::UpdateImportProgress(
+clang::Decl const *From) {
+  assert(From &&
+ "Trying to report import progress using an invalid clang::Decl.");
+
+  // If we can't determine the decl's name, we don't know what to
+  // update the progress bar with. So bail out.
+  auto const *ND = dyn_cast(From);
+  if (!ND)
+return;
+
+  if (!m_import_progress_up) {
+auto const *from_ast =
+TypeSystemClang::GetASTContext(>getASTContext());
+auto const *to_ast = TypeSystemClang::GetASTContext(());
+
+assert(from_ast && to_ast);
+
+llvm::SmallVector from_name_parts;
+llvm::SplitString(from_ast->getDisplayName(), from_name_parts, "/");
+auto from_name = from_name_parts.back();
+
+llvm::SmallVector to_name_parts;
+llvm::SplitString(to_ast->getDisplayName(), to_name_parts, "/");

Michael137 wrote:

> What does an ast's DisplayName look like?

It's one of three:
* `Expression ASTContext for '" + m_filename + "'` (expression AST)
* `scratch ASTContext`
* a module name

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


[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)

2024-05-08 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)

2024-05-08 Thread Michael Buch via lldb-commits


@@ -1411,3 +1414,35 @@ clang::Decl *
 ClangASTImporter::ASTImporterDelegate::GetOriginalDecl(clang::Decl *To) {
   return m_main.GetDeclOrigin(To).decl;
 }
+
+void ClangASTImporter::ASTImporterDelegate::UpdateImportProgress(

Michael137 wrote:

These asserts should never ever actually occur unless something about 
TypeSystemClang gets redesigned, at which point the intention was that these 
would flag in development builds/tests. But definitely valid question. For the 
cases where a `nullptr` would occur I did try to be consistent with early 
returns. I usually try to express the preconditions of the function in terms of 
asserts, but in this case I don't have strong opinion, I think doing an early 
return would make sense here. I remember some time last year @DavidSpickett 
proposed an assert macro that would fire in debug builds but early-return in 
release. Can't find that atm, not sure if it ever landed.

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


[Lldb-commits] [lldb] [lldb] Consult Language plugin in GetDisplayDemangledName (PR #90294)

2024-05-08 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] b52160d - [lldb] Consult Language plugin in GetDisplayDemangledName (#90294)

2024-05-08 Thread via lldb-commits

Author: Dave Lee
Date: 2024-05-08T13:07:07-07:00
New Revision: b52160dbae268cc87cb8f6cdf75553ca095e26a9

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

LOG: [lldb] Consult Language plugin in GetDisplayDemangledName (#90294)

Give language plugins the opportunity to provide a language specific
display name.

This will be used in a follow up commit. The purpose of this change is
to ultimately display breakpoint locations with a more human friendly
demangling of Swift symbols.

Added: 


Modified: 
lldb/include/lldb/Target/Language.h
lldb/source/Core/Mangled.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index 67714e6fdf942..ff7c60bf68bfc 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -281,6 +281,10 @@ class Language : public PluginInterface {
 return mangled.GetMangledName();
   }
 
+  virtual ConstString GetDisplayDemangledName(Mangled mangled) const {
+return mangled.GetDemangledName();
+  }
+
   virtual void GetExceptionResolverDescription(bool catch_on, bool throw_on,
Stream );
 

diff  --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp
index b167c51fdce24..8efc4c639cca5 100644
--- a/lldb/source/Core/Mangled.cpp
+++ b/lldb/source/Core/Mangled.cpp
@@ -310,6 +310,8 @@ ConstString Mangled::GetDemangledName() const {
 }
 
 ConstString Mangled::GetDisplayDemangledName() const {
+  if (Language *lang = Language::FindPlugin(GuessLanguage()))
+return lang->GetDisplayDemangledName(*this);
   return GetDemangledName();
 }
 



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


[Lldb-commits] [lldb] [lldb] Unify CalculateMD5 return types (PR #91029)

2024-05-08 Thread Anthony Ha via lldb-commits

Awfa wrote:

> ⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️
> 
> You can test this locally with the following command:
> View the diff from clang-format here.

This formatter alert is outdated - by the time this arrived, my PR had the 
issue fixed already.

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


[Lldb-commits] [lldb] [lldb][breakpointoptions] Make disabled keyword red (PR #91404)

2024-05-08 Thread Chelsea Cassanova via lldb-commits


@@ -534,7 +534,8 @@ void BreakpointOptions::GetDescription(Stream *s,
 
 if (m_ignore_count > 0)
   s->Printf("ignore: %d ", m_ignore_count);
-s->Printf("%sabled ", m_enabled ? "en" : "dis");
+s->PutCStringColorHighlighted(m_enabled ? "enabled " : "disabled ",
+  m_disbaled_breakpoint_highlight_settings);

chelcassanova wrote:

I was speaking to Ismail about this and seems like it would be nice if we had a 
`Stream::GetUseColor` for this given that you can set whether or not the stream 
has colours at construction but you can't query the state of it after that.

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


[Lldb-commits] [lldb] [lldb/crashlog] Enforce image loading policy (PR #91109)

2024-05-08 Thread Alex Langford via lldb-commits


@@ -526,6 +526,47 @@ def create_target(self):
 def get_target(self):
 return self.target
 
+def load_images(self, options, loaded_images=[]):

bulbazord wrote:

Suggestion: Default `loaded_images` to `None`. You probably don't want 
`loaded_images` to default to `[]`. It will persist between calls, e.g.:
```
>>> def foo(x, lst=[]):
... lst.append(x)
... print(lst)
...
>>> foo(1)
[1]
>>> foo(2)
[1, 2]
```

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


[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)

2024-05-08 Thread Alex Langford via lldb-commits


@@ -1411,3 +1414,35 @@ clang::Decl *
 ClangASTImporter::ASTImporterDelegate::GetOriginalDecl(clang::Decl *To) {
   return m_main.GetDeclOrigin(To).decl;
 }
+
+void ClangASTImporter::ASTImporterDelegate::UpdateImportProgress(

bulbazord wrote:

The assertions in this code are going to blow up only in development builds. In 
release builds, you'll fall through the first assertion, and return because you 
try to cast `nullptr` to a NamedDecl (which will give you `nullptr`) and the 
function will fail silently. The second assertion will fail if `from_ast` or 
`to_ast` is `nullptr`, but the function doesn't return early there. It will 
call `getDisplayName` on `from_ast` and `to_ast`, one of which will crash 
anyway. Maybe we should consider an early return here too? Or maybe the 
function should return an `llvm::Error`?

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


[Lldb-commits] [lldb] [lldb][DWARF] Sort ranges list in dwarf 5. (PR #91343)

2024-05-08 Thread Greg Clayton via lldb-commits

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


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


[Lldb-commits] [lldb] lldb create API folder if it does not exist, before creating SBLangua… (PR #91128)

2024-05-08 Thread via lldb-commits

github-actions[bot] wrote:



@smurfd Congratulations on having your first Pull Request (PR) merged into the 
LLVM Project!

Your changes will be combined with recent changes from other authors, then 
tested
by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with 
a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as
the builds can include changes from many authors. It is not uncommon for your
change to be included in a build that fails due to someone else's changes, or
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail 
[here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr).

If your change does cause a problem, it may be reverted, or you can revert it 
yourself.
This is a normal part of [LLVM 
development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy).
 You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are 
working as expected, well done!


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


[Lldb-commits] [lldb] lldb create API folder if it does not exist, before creating SBLangua… (PR #91128)

2024-05-08 Thread Adrian Prantl via lldb-commits

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


[Lldb-commits] [lldb] dbcfa29 - lldb create API folder if it does not exist, before creating SBLangua… (#91128)

2024-05-08 Thread via lldb-commits

Author: Nicklas Boman
Date: 2024-05-08T10:57:16-07:00
New Revision: dbcfa2957d9f99de62fc86db12a857caf929583c

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

LOG: lldb create API folder if it does not exist, before creating SBLangua… 
(#91128)

Create API folder if it does not exist, before creating SBLanguages.h

Added: 


Modified: 
lldb/scripts/generate-sbapi-dwarf-enum.py

Removed: 




diff  --git a/lldb/scripts/generate-sbapi-dwarf-enum.py 
b/lldb/scripts/generate-sbapi-dwarf-enum.py
index 464eb2afff7d6..f7a13e5efffef 100755
--- a/lldb/scripts/generate-sbapi-dwarf-enum.py
+++ b/lldb/scripts/generate-sbapi-dwarf-enum.py
@@ -2,6 +2,7 @@
 
 import argparse
 import re
+import os
 
 HEADER = """\
 //===-- SBLanguages.h -*- C++ -*-===//
@@ -37,6 +38,9 @@ def emit_enum(input, output):
 with open(input, "r") as f:
 lines = f.readlines()
 
+# Create output folder if it does not exist
+os.makedirs(os.path.dirname(output), exist_ok=True)
+
 # Write the output.
 with open(output, "w") as f:
 # Emit the header.



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


[Lldb-commits] [lldb] lldb create API folder if it does not exist, before creating SBLangua… (PR #91128)

2024-05-08 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl approved this pull request.


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


[Lldb-commits] [lldb] [lldb][DWARF] Sort ranges list in dwarf 5. (PR #91343)

2024-05-08 Thread Alex Langford via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb/crashlog] Enforce image loading policy (PR #91109)

2024-05-08 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] Add a dependency from lldb-sbapi-dwarf-enums as a dependency of libll… (PR #91511)

2024-05-08 Thread Adrian Prantl via lldb-commits

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


[Lldb-commits] [lldb] fcfc15b - Add a dependency from lldb-sbapi-dwarf-enums as a dependency of libll… (#91511)

2024-05-08 Thread via lldb-commits

Author: Adrian Prantl
Date: 2024-05-08T10:38:09-07:00
New Revision: fcfc15b7052a311b7a045e2c6bd26fb5d0b7122c

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

LOG: Add a dependency from lldb-sbapi-dwarf-enums as a dependency of libll… 
(#91511)

…db-resource-headers

The Xcode build otherwise fails with
```
CMake Error in source/API/CMakeLists.txt:
  The custom command generating


/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-standalone/lldb-xcode-build/include/lldb/API/SBLanguages.h

  is attached to multiple targets:

lldb-sbapi-dwarf-enums
liblldb-resource-headers

  but none of these is a common dependency of the other(s).  This is not
  allowed by the Xcode "new build system".

CMake Generate step failed.  Build files cannot be regenerated correctly.
```

Added: 


Modified: 
lldb/cmake/modules/LLDBFramework.cmake

Removed: 




diff  --git a/lldb/cmake/modules/LLDBFramework.cmake 
b/lldb/cmake/modules/LLDBFramework.cmake
index df2f8ddf54a3d..dd8c36bba0e97 100644
--- a/lldb/cmake/modules/LLDBFramework.cmake
+++ b/lldb/cmake/modules/LLDBFramework.cmake
@@ -105,7 +105,7 @@ foreach(header
 endforeach()
 
 # Wrap output in a target, so lldb-framework can depend on it.
-add_custom_target(liblldb-resource-headers DEPENDS ${lldb_staged_headers})
+add_custom_target(liblldb-resource-headers DEPENDS lldb-sbapi-dwarf-enums 
${lldb_staged_headers})
 set_target_properties(liblldb-resource-headers PROPERTIES FOLDER "lldb misc")
 add_dependencies(liblldb liblldb-resource-headers)
 



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


[Lldb-commits] [lldb] Add a dependency from lldb-sbapi-dwarf-enums as a dependency of libll… (PR #91511)

2024-05-08 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] Add a dependency from lldb-sbapi-dwarf-enums as a dependency of libll… (PR #91511)

2024-05-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Adrian Prantl (adrian-prantl)


Changes

…db-resource-headers

The Xcode build otherwise fails with
```
CMake Error in source/API/CMakeLists.txt:
  The custom command generating


/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-standalone/lldb-xcode-build/include/lldb/API/SBLanguages.h

  is attached to multiple targets:

lldb-sbapi-dwarf-enums
liblldb-resource-headers

  but none of these is a common dependency of the other(s).  This is not
  allowed by the Xcode "new build system".

CMake Generate step failed.  Build files cannot be regenerated correctly.
```

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


1 Files Affected:

- (modified) lldb/cmake/modules/LLDBFramework.cmake (+1-1) 


``diff
diff --git a/lldb/cmake/modules/LLDBFramework.cmake 
b/lldb/cmake/modules/LLDBFramework.cmake
index df2f8ddf54a3d..dd8c36bba0e97 100644
--- a/lldb/cmake/modules/LLDBFramework.cmake
+++ b/lldb/cmake/modules/LLDBFramework.cmake
@@ -105,7 +105,7 @@ foreach(header
 endforeach()
 
 # Wrap output in a target, so lldb-framework can depend on it.
-add_custom_target(liblldb-resource-headers DEPENDS ${lldb_staged_headers})
+add_custom_target(liblldb-resource-headers DEPENDS lldb-sbapi-dwarf-enums 
${lldb_staged_headers})
 set_target_properties(liblldb-resource-headers PROPERTIES FOLDER "lldb misc")
 add_dependencies(liblldb liblldb-resource-headers)
 

``




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


[Lldb-commits] [lldb] Add a dependency from lldb-sbapi-dwarf-enums as a dependency of libll… (PR #91511)

2024-05-08 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl created 
https://github.com/llvm/llvm-project/pull/91511

…db-resource-headers

The Xcode build otherwise fails with
```
CMake Error in source/API/CMakeLists.txt:
  The custom command generating


/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-standalone/lldb-xcode-build/include/lldb/API/SBLanguages.h

  is attached to multiple targets:

lldb-sbapi-dwarf-enums
liblldb-resource-headers

  but none of these is a common dependency of the other(s).  This is not
  allowed by the Xcode "new build system".

CMake Generate step failed.  Build files cannot be regenerated correctly.
```

>From a8551acd4094784c0e03fbb943e0ad0be1e2c800 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Wed, 8 May 2024 10:31:42 -0700
Subject: [PATCH] Add a dependency from lldb-sbapi-dwarf-enums as a dependency
 of liblldb-resource-headers

The Xcode build otherwise fails with
```
CMake Error in source/API/CMakeLists.txt:
  The custom command generating


/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-standalone/lldb-xcode-build/include/lldb/API/SBLanguages.h

  is attached to multiple targets:

lldb-sbapi-dwarf-enums
liblldb-resource-headers

  but none of these is a common dependency of the other(s).  This is not
  allowed by the Xcode "new build system".

CMake Generate step failed.  Build files cannot be regenerated correctly.
```
---
 lldb/cmake/modules/LLDBFramework.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/cmake/modules/LLDBFramework.cmake 
b/lldb/cmake/modules/LLDBFramework.cmake
index df2f8ddf54a3d..dd8c36bba0e97 100644
--- a/lldb/cmake/modules/LLDBFramework.cmake
+++ b/lldb/cmake/modules/LLDBFramework.cmake
@@ -105,7 +105,7 @@ foreach(header
 endforeach()
 
 # Wrap output in a target, so lldb-framework can depend on it.
-add_custom_target(liblldb-resource-headers DEPENDS ${lldb_staged_headers})
+add_custom_target(liblldb-resource-headers DEPENDS lldb-sbapi-dwarf-enums 
${lldb_staged_headers})
 set_target_properties(liblldb-resource-headers PROPERTIES FOLDER "lldb misc")
 add_dependencies(liblldb liblldb-resource-headers)
 

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


[Lldb-commits] [lldb] [lldb][breakpointoptions] Make disabled keyword red (PR #91404)

2024-05-08 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

More of a styling preference, but I wouldn't use red as the color for disabled 
breakpoint, I think it would be more suited for unresolved ones (that could be 
done in a follow-up). Instead, I'd use the `ANSI_CTRL_FAINT` escape code to 
match what you can find in many IDEs.

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


[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)

2024-05-08 Thread Chelsea Cassanova via lldb-commits


@@ -1240,7 +1241,13 @@ TypeSP 
SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE(
 void SymbolFileDWARFDebugMap::FindTypes(const TypeQuery ,
 TypeResults ) {
   std::lock_guard guard(GetModuleMutex());
+  Progress progress(
+  llvm::formatv("Searching for type '{0}'",
+query.GetTypeBasename().AsCString("<>")));
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) {
+if (auto *obj = oso_dwarf->GetObjectFile())
+  progress.Increment(1, obj->GetFileSpec().GetPath());

chelcassanova wrote:

It would probably get rendered as `Searching for type 'Foo': main.o` if that 
filename is used as the details for `Increment`.

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


[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)

2024-05-08 Thread Adrian Prantl via lldb-commits


@@ -1411,3 +1414,35 @@ clang::Decl *
 ClangASTImporter::ASTImporterDelegate::GetOriginalDecl(clang::Decl *To) {
   return m_main.GetDeclOrigin(To).decl;
 }
+
+void ClangASTImporter::ASTImporterDelegate::UpdateImportProgress(
+clang::Decl const *From) {
+  assert(From &&
+ "Trying to report import progress using an invalid clang::Decl.");
+
+  // If we can't determine the decl's name, we don't know what to
+  // update the progress bar with. So bail out.
+  auto const *ND = dyn_cast(From);
+  if (!ND)
+return;
+
+  if (!m_import_progress_up) {
+auto const *from_ast =
+TypeSystemClang::GetASTContext(>getASTContext());
+auto const *to_ast = TypeSystemClang::GetASTContext(());
+
+assert(from_ast && to_ast);
+
+llvm::SmallVector from_name_parts;
+llvm::SplitString(from_ast->getDisplayName(), from_name_parts, "/");
+auto from_name = from_name_parts.back();
+
+llvm::SmallVector to_name_parts;
+llvm::SplitString(to_ast->getDisplayName(), to_name_parts, "/");

adrian-prantl wrote:

`StringRef::rsplit` is going to be more efficient for this.

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


[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)

2024-05-08 Thread Adrian Prantl via lldb-commits


@@ -1240,7 +1241,13 @@ TypeSP 
SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE(
 void SymbolFileDWARFDebugMap::FindTypes(const TypeQuery ,
 TypeResults ) {
   std::lock_guard guard(GetModuleMutex());
+  Progress progress(
+  llvm::formatv("Searching for type '{0}'",
+query.GetTypeBasename().AsCString("<>")));

adrian-prantl wrote:

``?

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


[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)

2024-05-08 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl commented:

Nice!

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


[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)

2024-05-08 Thread Adrian Prantl via lldb-commits


@@ -1411,3 +1414,35 @@ clang::Decl *
 ClangASTImporter::ASTImporterDelegate::GetOriginalDecl(clang::Decl *To) {
   return m_main.GetDeclOrigin(To).decl;
 }
+
+void ClangASTImporter::ASTImporterDelegate::UpdateImportProgress(
+clang::Decl const *From) {
+  assert(From &&
+ "Trying to report import progress using an invalid clang::Decl.");
+
+  // If we can't determine the decl's name, we don't know what to
+  // update the progress bar with. So bail out.
+  auto const *ND = dyn_cast(From);
+  if (!ND)
+return;
+
+  if (!m_import_progress_up) {
+auto const *from_ast =
+TypeSystemClang::GetASTContext(>getASTContext());
+auto const *to_ast = TypeSystemClang::GetASTContext(());
+
+assert(from_ast && to_ast);
+
+llvm::SmallVector from_name_parts;
+llvm::SplitString(from_ast->getDisplayName(), from_name_parts, "/");
+auto from_name = from_name_parts.back();
+
+llvm::SmallVector to_name_parts;
+llvm::SplitString(to_ast->getDisplayName(), to_name_parts, "/");

adrian-prantl wrote:

What does an ast's DisplayName look like?

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


[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)

2024-05-08 Thread Adrian Prantl via lldb-commits

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


[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)

2024-05-08 Thread Adrian Prantl via lldb-commits


@@ -1240,7 +1241,13 @@ TypeSP 
SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE(
 void SymbolFileDWARFDebugMap::FindTypes(const TypeQuery ,
 TypeResults ) {
   std::lock_guard guard(GetModuleMutex());
+  Progress progress(
+  llvm::formatv("Searching for type '{0}'",
+query.GetTypeBasename().AsCString("<>")));
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) {
+if (auto *obj = oso_dwarf->GetObjectFile())
+  progress.Increment(1, obj->GetFileSpec().GetPath());

adrian-prantl wrote:

What does this get rendered to?

It would be nice if it were:

Searching type "Foo" in "main.o"

but it almost looks like this would become

Searching for type "main.o"

?

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


[Lldb-commits] [lldb] LLDB Debuginfod tests and a fix or two (PR #90622)

2024-05-08 Thread David Spickett via lldb-commits


@@ -87,8 +105,15 @@ SymbolVendorELF::CreateInstance(const lldb::ModuleSP 
_sp,
   FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
   FileSpec dsym_fspec =
   PluginManager::LocateExecutableSymbolFile(module_spec, search_paths);
-  if (!dsym_fspec)
-return nullptr;
+  if (!dsym_fspec || IsDwpSymbolFile(module_sp, dsym_fspec)) {
+// If we have a stripped binary or if we got a DWP file, we should prefer
+// symbols in the executable acquired through a plugin.
+ModuleSpec unstripped_spec =
+PluginManager::LocateExecutableObjectFile(module_spec);
+if (!unstripped_spec)
+  return nullptr;
+dsym_fspec = unstripped_spec.GetFileSpec();
+  }

DavidSpickett wrote:

This is what I've figured out so far. It's like the previous issue I mentioned, 
except it's related to the program file, not `ld.so`.

If we look at the memory regions before this PR we see:
```
[0xf7fe2000-0xf7fe9000) ---
[0xf7fe9000-0xf7fea000) rw-
[0xf7fea000-0xf7feb000) r-- objc_imageinfo
[0xf7feb000-0xf7fec000) r-x .text
```

After we just have:
```
[0xf7fe2000-0xf7fec000) ---
```

Which means we have lost, or never loaded, the section information for this 
program file. Which makes sense given that it's compiled without debug 
information. We'll ask a plugin for the debug info and none of those will have 
it, so we exit early.

Problem is, Arm has 2 execution modes. Arm and Thumb. To know how to break 
properly in different code we look at markers on the sections. These set the 
`AddressClass` of the address value in LLDB to the right value.

In this case, we need to call `mmap`. This is in a Thumb section in `ld.so`, 
and we have it's section information. We don't need to break here though, only 
set the control register (cpsr) bit to indicate we want to run in Thumb mode, 
then write the PC to point to this location.

For the end of `mmap`, we need to return somewhere. So lldb says, why not 
`_start`, it's something we can count on existing on Linux. So LLDB needs to 
set the link register to that address, then place a breakpoint on the address 
to catch the program just as `mmap` finishes.

Problem is, after this PR we don't have section information to tell us that 
this area is Thumb. This means that `Platform::GetSoftwareBreakpointTrapOpcode` 
chooses an Arm breakpoint code. Now I don't know exactly what goes wrong there, 
I think in Thumb mode the program sees this encoding as some kind of backwards 
branch, and it ends up basically in the zero page and segfaults from there. 
This is why the call to `mmap` fails and we fall back to the interpreter.

So ideally we want to split the two concepts of 1. Section information and 2. 
Symbol file. So that we can load both without resetting the other. I'm going to 
look into that next.

And for some context, I think Arm is the only platform this section information 
is crucial. Potentially MIPS but also we dropped Linux MIPS support, and I 
don't know if those platforms mixed modes ever. So it's not surprising you 
didn't see this testing on more modern platforms.

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


[Lldb-commits] [lldb] [llvm] [AArch64] move extension information into tablgen (PR #90987)

2024-05-08 Thread Tomas Matheson via lldb-commits


@@ -426,30 +532,40 @@ def FeatureSpecRestrict : 
SubtargetFeature<"specrestrict", "HasSpecRestrict",
   "true", "Enable architectural speculation restriction (FEAT_CSV2_2)">;
 
 def FeatureSB : Extension<"sb", "SB",
-  "Enable v8.5 Speculation Barrier (FEAT_SB)" >;
+  "Enable v8.5 Speculation Barrier (FEAT_SB)", [],
+  "FEAT_SB", "+sb", 470>;
 
 def FeatureSSBS : Extension<"ssbs", "SSBS",
-  "Enable Speculative Store Bypass Safe bit (FEAT_SSBS, FEAT_SSBS2)" >;
+  "Enable Speculative Store Bypass Safe bit (FEAT_SSBS, FEAT_SSBS2)", [],
+  "FEAT_SSBS", "", 490>;
 
 def FeaturePredRes : Extension<"predres", "PredRes",
-  "Enable v8.5a execution and data prediction invalidation instructions 
(FEAT_SPECRES)" >;
+  "Enable v8.5a execution and data prediction invalidation instructions 
(FEAT_SPECRES)", [],
+  "FEAT_PREDRES", "+predres", 480>;
 
-def FeatureCacheDeepPersist : Extension<"ccdp", "CCDP",
+def FeatureCacheDeepPersist : SubtargetFeature<"ccdp", "CCDP", "true",
 "Enable v8.5 Cache Clean to Point of Deep Persistence (FEAT_DPB2)" >;
 
+// NOTE: BTI now has posfeat/negfeat, which it didn't before
+let ArchExtKindSpelling = "AEK_NONE" in
 def FeatureBranchTargetId : Extension<"bti", "BTI",
-"Enable Branch Target Identification (FEAT_BTI)" >;
+"Enable Branch Target Identification (FEAT_BTI)", [],
+"FEAT_BTI", "+bti", 510>;
 
+let ArchExtKindSpelling = "AEK_RAND", MArchName = "rng" in
 def FeatureRandGen : Extension<"rand", "RandGen",
-"Enable Random Number generation instructions (FEAT_RNG)" >;
+"Enable Random Number generation instructions (FEAT_RNG)", [],
+"FEAT_RNG", "+rand", 10>;
 
+let MArchName = "memtag" in
 def FeatureMTE : Extension<"mte", "MTE",
-"Enable Memory Tagging Extension (FEAT_MTE, FEAT_MTE2)" >;
+"Enable Memory Tagging Extension (FEAT_MTE, FEAT_MTE2)", [],
+"FEAT_MEMTAG", "", 440>;

tmatheson-arm wrote:

Good point. There should be no behaviour change here caused by this patch. I've 
added a comment in f1d287a75139bd8a09ee9d596b10aa77a2b672b7 explaining that 
`"memtag"` means different things for FMV and non-FMV extensions. I've left the 
`SubtargetFeature` description as-is because I think it is most likely to be 
used for printing command line help in the future, and the FMV difference will 
not be relevant there.


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


[Lldb-commits] [lldb] [llvm] [AArch64] move extension information into tablgen (PR #90987)

2024-05-08 Thread Tomas Matheson via lldb-commits

https://github.com/tmatheson-arm updated 
https://github.com/llvm/llvm-project/pull/90987

>From 4b8b776348438847c2eb238dac973e93fe93294e Mon Sep 17 00:00:00 2001
From: Tomas Matheson 
Date: Mon, 29 Apr 2024 19:57:17 +0100
Subject: [PATCH 1/5] [AArch64] move extension information into tablgen

Generate target features and FMVExtensions from tablegen.

Use MArchName/ArchKindEnumSpelling to avoid renamings.
Cases where there is simply a case difference are handled by
consistently uppercasing the AEK_ name in the emitted code.

Remove some Extensions which were not needed.
These had AEK entries but were never actually used for anything.
They are not present in Extensions[] data.
---
 .../command-disassemble-aarch64-extensions.s  |   2 +-
 .../llvm/TargetParser/AArch64TargetParser.h   | 139 +--
 llvm/lib/Target/AArch64/AArch64Features.td| 216 ++
 .../TargetParser/TargetParserTest.cpp |   8 +-
 llvm/utils/TableGen/ARMTargetDefEmitter.cpp   |  60 -
 5 files changed, 236 insertions(+), 189 deletions(-)

diff --git a/lldb/test/Shell/Commands/command-disassemble-aarch64-extensions.s 
b/lldb/test/Shell/Commands/command-disassemble-aarch64-extensions.s
index e154f544e7cc6..685d0a84ec289 100644
--- a/lldb/test/Shell/Commands/command-disassemble-aarch64-extensions.s
+++ b/lldb/test/Shell/Commands/command-disassemble-aarch64-extensions.s
@@ -59,7 +59,7 @@ fn:
   bdep z0.b, z1.b, z31.b// AEK_SVE2BITPERM
   rax1 z0.d, z0.d, z0.d // AEK_SVE2SHA3
   sm4e z0.s, z0.s, z0.s // AEK_SVE2SM4
-  addqv   v0.8h, p0, z0.h   // AEK_SVE2p1 / AEK_SME2p1
+  addqv   v0.8h, p0, z0.h   // AEK_SVE2P1 / AEK_SME2P1
   rcwswp x0, x1, [x2]   // AEK_THE
   tcommit   // AEK_TME
 lbl:
diff --git a/llvm/include/llvm/TargetParser/AArch64TargetParser.h 
b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
index 04fbaf07adfbc..1124420daf8d8 100644
--- a/llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -104,29 +104,9 @@ static_assert(FEAT_MAX < 62,
   "Number of features in CPUFeatures are limited to 62 entries");
 
 // Each ArchExtKind correponds directly to a possible -target-feature.
-enum ArchExtKind : unsigned {
-  AEK_NONE = 1,
-#define ARM_EXTENSION(NAME, ENUM) ENUM,
+#define EMIT_ARCHEXTKIND_ENUM
 #include "llvm/TargetParser/AArch64TargetParserDef.inc"
-  AEK_NUM_EXTENSIONS,
-
-  // FIXME temporary fixes for inconsistent naming.
-  AEK_F32MM = AEK_MATMULFP32,
-  AEK_F64MM = AEK_MATMULFP64,
-  AEK_FCMA = AEK_COMPLXNUM,
-  AEK_FP = AEK_FPARMV8,
-  AEK_FP16 = AEK_FULLFP16,
-  AEK_I8MM = AEK_MATMULINT8,
-  AEK_JSCVT = AEK_JS,
-  AEK_PROFILE = AEK_SPE,
-  AEK_RASv2 = AEK_RASV2,
-  AEK_RAND = AEK_RANDGEN,
-  AEK_SIMD = AEK_NEON,
-  AEK_SME2p1 = AEK_SME2P1,
-  AEK_SVE2p1 = AEK_SVE2P1,
-  AEK_SME_LUTv2 = AEK_SME_LUTV2,
 
-};
 using ExtensionBitset = Bitset;
 
 // Represents an extension that can be enabled with -march=+.
@@ -148,111 +128,8 @@ struct ExtensionInfo {
   1000; // Maximum priority for FMV feature
 };
 
-// NOTE: If adding a new extension here, consider adding it to ExtensionMap
-// in AArch64AsmParser too, if supported as an extension name by binutils.
-// clang-format off
-inline constexpr ExtensionInfo Extensions[] = {
-{"aes", AArch64::AEK_AES, "+aes", "-aes", FEAT_AES, "+fp-armv8,+neon", 
150},
-{"b16b16", AArch64::AEK_B16B16, "+b16b16", "-b16b16", FEAT_INIT, "", 0},
-{"bf16", AArch64::AEK_BF16, "+bf16", "-bf16", FEAT_BF16, "+bf16", 280},
-{"brbe", AArch64::AEK_BRBE, "+brbe", "-brbe", FEAT_INIT, "", 0},
-{"bti", AArch64::AEK_NONE, {}, {}, FEAT_BTI, "+bti", 510},
-{"crc", AArch64::AEK_CRC, "+crc", "-crc", FEAT_CRC, "+crc", 110},
-{"crypto", AArch64::AEK_CRYPTO, "+crypto", "-crypto", FEAT_INIT, 
"+aes,+sha2", 0},
-{"cssc", AArch64::AEK_CSSC, "+cssc", "-cssc", FEAT_INIT, "", 0},
-{"d128", AArch64::AEK_D128, "+d128", "-d128", FEAT_INIT, "", 0},
-{"dgh", AArch64::AEK_NONE, {}, {}, FEAT_DGH, "", 260},
-{"dit", AArch64::AEK_NONE, {}, {}, FEAT_DIT, "+dit", 180},
-{"dotprod", AArch64::AEK_DOTPROD, "+dotprod", "-dotprod", FEAT_DOTPROD, 
"+dotprod,+fp-armv8,+neon", 104},
-{"dpb", AArch64::AEK_NONE, {}, {}, FEAT_DPB, "+ccpp", 190},
-{"dpb2", AArch64::AEK_NONE, {}, {}, FEAT_DPB2, "+ccpp,+ccdp", 200},
-{"ebf16", AArch64::AEK_NONE, {}, {}, FEAT_EBF16, "+bf16", 290},
-{"f32mm", AArch64::AEK_F32MM, "+f32mm", "-f32mm", FEAT_SVE_F32MM, 
"+sve,+f32mm,+fullfp16,+fp-armv8,+neon", 350},
-{"f64mm", AArch64::AEK_F64MM, "+f64mm", "-f64mm", FEAT_SVE_F64MM, 
"+sve,+f64mm,+fullfp16,+fp-armv8,+neon", 360},
-{"fcma", AArch64::AEK_FCMA, "+complxnum", "-complxnum", FEAT_FCMA, 
"+fp-armv8,+neon,+complxnum", 220},
-{"flagm", AArch64::AEK_FLAGM, "+flagm", "-flagm", FEAT_FLAGM, "+flagm", 
20},
-{"flagm2", AArch64::AEK_NONE, {}, {}, FEAT_FLAGM2, 

[Lldb-commits] [lldb] [llvm] [AArch64] move extension information into tablgen (PR #90987)

2024-05-08 Thread Tomas Matheson via lldb-commits

https://github.com/tmatheson-arm updated 
https://github.com/llvm/llvm-project/pull/90987

>From 4b8b776348438847c2eb238dac973e93fe93294e Mon Sep 17 00:00:00 2001
From: Tomas Matheson 
Date: Mon, 29 Apr 2024 19:57:17 +0100
Subject: [PATCH 1/4] [AArch64] move extension information into tablgen

Generate target features and FMVExtensions from tablegen.

Use MArchName/ArchKindEnumSpelling to avoid renamings.
Cases where there is simply a case difference are handled by
consistently uppercasing the AEK_ name in the emitted code.

Remove some Extensions which were not needed.
These had AEK entries but were never actually used for anything.
They are not present in Extensions[] data.
---
 .../command-disassemble-aarch64-extensions.s  |   2 +-
 .../llvm/TargetParser/AArch64TargetParser.h   | 139 +--
 llvm/lib/Target/AArch64/AArch64Features.td| 216 ++
 .../TargetParser/TargetParserTest.cpp |   8 +-
 llvm/utils/TableGen/ARMTargetDefEmitter.cpp   |  60 -
 5 files changed, 236 insertions(+), 189 deletions(-)

diff --git a/lldb/test/Shell/Commands/command-disassemble-aarch64-extensions.s 
b/lldb/test/Shell/Commands/command-disassemble-aarch64-extensions.s
index e154f544e7cc6..685d0a84ec289 100644
--- a/lldb/test/Shell/Commands/command-disassemble-aarch64-extensions.s
+++ b/lldb/test/Shell/Commands/command-disassemble-aarch64-extensions.s
@@ -59,7 +59,7 @@ fn:
   bdep z0.b, z1.b, z31.b// AEK_SVE2BITPERM
   rax1 z0.d, z0.d, z0.d // AEK_SVE2SHA3
   sm4e z0.s, z0.s, z0.s // AEK_SVE2SM4
-  addqv   v0.8h, p0, z0.h   // AEK_SVE2p1 / AEK_SME2p1
+  addqv   v0.8h, p0, z0.h   // AEK_SVE2P1 / AEK_SME2P1
   rcwswp x0, x1, [x2]   // AEK_THE
   tcommit   // AEK_TME
 lbl:
diff --git a/llvm/include/llvm/TargetParser/AArch64TargetParser.h 
b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
index 04fbaf07adfbc..1124420daf8d8 100644
--- a/llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -104,29 +104,9 @@ static_assert(FEAT_MAX < 62,
   "Number of features in CPUFeatures are limited to 62 entries");
 
 // Each ArchExtKind correponds directly to a possible -target-feature.
-enum ArchExtKind : unsigned {
-  AEK_NONE = 1,
-#define ARM_EXTENSION(NAME, ENUM) ENUM,
+#define EMIT_ARCHEXTKIND_ENUM
 #include "llvm/TargetParser/AArch64TargetParserDef.inc"
-  AEK_NUM_EXTENSIONS,
-
-  // FIXME temporary fixes for inconsistent naming.
-  AEK_F32MM = AEK_MATMULFP32,
-  AEK_F64MM = AEK_MATMULFP64,
-  AEK_FCMA = AEK_COMPLXNUM,
-  AEK_FP = AEK_FPARMV8,
-  AEK_FP16 = AEK_FULLFP16,
-  AEK_I8MM = AEK_MATMULINT8,
-  AEK_JSCVT = AEK_JS,
-  AEK_PROFILE = AEK_SPE,
-  AEK_RASv2 = AEK_RASV2,
-  AEK_RAND = AEK_RANDGEN,
-  AEK_SIMD = AEK_NEON,
-  AEK_SME2p1 = AEK_SME2P1,
-  AEK_SVE2p1 = AEK_SVE2P1,
-  AEK_SME_LUTv2 = AEK_SME_LUTV2,
 
-};
 using ExtensionBitset = Bitset;
 
 // Represents an extension that can be enabled with -march=+.
@@ -148,111 +128,8 @@ struct ExtensionInfo {
   1000; // Maximum priority for FMV feature
 };
 
-// NOTE: If adding a new extension here, consider adding it to ExtensionMap
-// in AArch64AsmParser too, if supported as an extension name by binutils.
-// clang-format off
-inline constexpr ExtensionInfo Extensions[] = {
-{"aes", AArch64::AEK_AES, "+aes", "-aes", FEAT_AES, "+fp-armv8,+neon", 
150},
-{"b16b16", AArch64::AEK_B16B16, "+b16b16", "-b16b16", FEAT_INIT, "", 0},
-{"bf16", AArch64::AEK_BF16, "+bf16", "-bf16", FEAT_BF16, "+bf16", 280},
-{"brbe", AArch64::AEK_BRBE, "+brbe", "-brbe", FEAT_INIT, "", 0},
-{"bti", AArch64::AEK_NONE, {}, {}, FEAT_BTI, "+bti", 510},
-{"crc", AArch64::AEK_CRC, "+crc", "-crc", FEAT_CRC, "+crc", 110},
-{"crypto", AArch64::AEK_CRYPTO, "+crypto", "-crypto", FEAT_INIT, 
"+aes,+sha2", 0},
-{"cssc", AArch64::AEK_CSSC, "+cssc", "-cssc", FEAT_INIT, "", 0},
-{"d128", AArch64::AEK_D128, "+d128", "-d128", FEAT_INIT, "", 0},
-{"dgh", AArch64::AEK_NONE, {}, {}, FEAT_DGH, "", 260},
-{"dit", AArch64::AEK_NONE, {}, {}, FEAT_DIT, "+dit", 180},
-{"dotprod", AArch64::AEK_DOTPROD, "+dotprod", "-dotprod", FEAT_DOTPROD, 
"+dotprod,+fp-armv8,+neon", 104},
-{"dpb", AArch64::AEK_NONE, {}, {}, FEAT_DPB, "+ccpp", 190},
-{"dpb2", AArch64::AEK_NONE, {}, {}, FEAT_DPB2, "+ccpp,+ccdp", 200},
-{"ebf16", AArch64::AEK_NONE, {}, {}, FEAT_EBF16, "+bf16", 290},
-{"f32mm", AArch64::AEK_F32MM, "+f32mm", "-f32mm", FEAT_SVE_F32MM, 
"+sve,+f32mm,+fullfp16,+fp-armv8,+neon", 350},
-{"f64mm", AArch64::AEK_F64MM, "+f64mm", "-f64mm", FEAT_SVE_F64MM, 
"+sve,+f64mm,+fullfp16,+fp-armv8,+neon", 360},
-{"fcma", AArch64::AEK_FCMA, "+complxnum", "-complxnum", FEAT_FCMA, 
"+fp-armv8,+neon,+complxnum", 220},
-{"flagm", AArch64::AEK_FLAGM, "+flagm", "-flagm", FEAT_FLAGM, "+flagm", 
20},
-{"flagm2", AArch64::AEK_NONE, {}, {}, FEAT_FLAGM2, 

[Lldb-commits] [lldb] [llvm] [AArch64] move extension information into tablgen (PR #90987)

2024-05-08 Thread Tomas Matheson via lldb-commits


@@ -426,30 +532,40 @@ def FeatureSpecRestrict : 
SubtargetFeature<"specrestrict", "HasSpecRestrict",
   "true", "Enable architectural speculation restriction (FEAT_CSV2_2)">;
 
 def FeatureSB : Extension<"sb", "SB",
-  "Enable v8.5 Speculation Barrier (FEAT_SB)" >;
+  "Enable v8.5 Speculation Barrier (FEAT_SB)", [],
+  "FEAT_SB", "+sb", 470>;
 
 def FeatureSSBS : Extension<"ssbs", "SSBS",
-  "Enable Speculative Store Bypass Safe bit (FEAT_SSBS, FEAT_SSBS2)" >;
+  "Enable Speculative Store Bypass Safe bit (FEAT_SSBS, FEAT_SSBS2)", [],
+  "FEAT_SSBS", "", 490>;
 
 def FeaturePredRes : Extension<"predres", "PredRes",
-  "Enable v8.5a execution and data prediction invalidation instructions 
(FEAT_SPECRES)" >;
+  "Enable v8.5a execution and data prediction invalidation instructions 
(FEAT_SPECRES)", [],
+  "FEAT_PREDRES", "+predres", 480>;
 
-def FeatureCacheDeepPersist : Extension<"ccdp", "CCDP",
+def FeatureCacheDeepPersist : SubtargetFeature<"ccdp", "CCDP", "true",
 "Enable v8.5 Cache Clean to Point of Deep Persistence (FEAT_DPB2)" >;
 
+// NOTE: BTI now has posfeat/negfeat, which it didn't before
+let ArchExtKindSpelling = "AEK_NONE" in
 def FeatureBranchTargetId : Extension<"bti", "BTI",
-"Enable Branch Target Identification (FEAT_BTI)" >;
+"Enable Branch Target Identification (FEAT_BTI)", [],
+"FEAT_BTI", "+bti", 510>;

tmatheson-arm wrote:

Yes that would work, in a separate PR though.

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


[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)

2024-05-08 Thread Michael Buch via lldb-commits

Michael137 wrote:

Example of what the DIE parsing progress looks like:

https://github.com/llvm/llvm-project/assets/14071464/bd589ddd-c933-4e14-a380-f4db177e33d4





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


[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)

2024-05-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

This is an attempt at displaying the work that's being done by LLDB when 
waiting on type-completion events, e.g., when running an expression. We add 
three new progress reports (across three commits):
1. When moving decls between ASTs.
2. When creating Clang ASTs from DWARF.
3. When doing a FindTypes lookup on a debug map.

Some remaining questions:
1. When do we want to destroy these `Progress` objects? Since the progress 
completed event is only sent on object destruction
2. How expensive is it to do this reporting unconditionally?
3. Are there more interesting places to report progress on?

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


5 Files Affected:

- (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
(+35) 
- (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h (+4) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (+19) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h (+4) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
(+7) 


``diff
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 30b50df79da90..cf9f1a2d47922 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "lldb/Core/Module.h"
+#include "lldb/Core/Progress.h"
 #include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
@@ -17,6 +18,7 @@
 #include "clang/AST/RecordLayout.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Sema.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/raw_ostream.h"
 
 #include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
@@ -1131,6 +1133,7 @@ ClangASTImporter::ASTImporterDelegate::ImportImpl(Decl 
*From) {
 LLDB_LOG(log, "[ClangASTImporter] Complete definition not found");
   }
 
+  UpdateImportProgress(From);
   return ASTImporter::ImportImpl(From);
 }
 
@@ -1411,3 +1414,35 @@ clang::Decl *
 ClangASTImporter::ASTImporterDelegate::GetOriginalDecl(clang::Decl *To) {
   return m_main.GetDeclOrigin(To).decl;
 }
+
+void ClangASTImporter::ASTImporterDelegate::UpdateImportProgress(
+clang::Decl const *From) {
+  assert(From &&
+ "Trying to report import progress using an invalid clang::Decl.");
+
+  // If we can't determine the decl's name, we don't know what to
+  // update the progress bar with. So bail out.
+  auto const *ND = dyn_cast(From);
+  if (!ND)
+return;
+
+  if (!m_import_progress_up) {
+auto const *from_ast =
+TypeSystemClang::GetASTContext(>getASTContext());
+auto const *to_ast = TypeSystemClang::GetASTContext(());
+
+assert(from_ast && to_ast);
+
+llvm::SmallVector from_name_parts;
+llvm::SplitString(from_ast->getDisplayName(), from_name_parts, "/");
+auto from_name = from_name_parts.back();
+
+llvm::SmallVector to_name_parts;
+llvm::SplitString(to_ast->getDisplayName(), to_name_parts, "/");
+auto to_name = to_name_parts.back();
+m_import_progress_up = std::make_unique(
+llvm::formatv("Importing '{0}' to '{1}'", from_name, to_name));
+  }
+
+  m_import_progress_up->Increment(1, ND->getNameAsString());
+}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
index bc962e544d2f1..f666d0c0fc52c 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
@@ -22,6 +22,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
 
+#include "lldb/Core/Progress.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Symbol/CompilerDeclContext.h"
 #include "lldb/Utility/LLDBAssert.h"
@@ -346,6 +347,8 @@ class ClangASTImporter {
 llvm::Expected ImportImpl(clang::Decl *From) override;
 
   private:
+void UpdateImportProgress(clang::Decl const *From);
+
 /// Decls we should ignore when mapping decls back to their original
 /// ASTContext. Used by the CxxModuleHandler to mark declarations that
 /// were created from the 'std' C++ module to prevent that the Importer
@@ -356,6 +359,7 @@ class ClangASTImporter {
 CxxModuleHandler *m_std_handler = nullptr;
 /// The currently attached listener.
 NewDeclListener *m_new_decl_listener = nullptr;
+std::unique_ptr m_import_progress_up = nullptr;
   };
 
   typedef std::shared_ptr ImporterDelegateSP;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 

[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)

2024-05-08 Thread Michael Buch via lldb-commits

https://github.com/Michael137 created 
https://github.com/llvm/llvm-project/pull/91452

This is an attempt at displaying the work that's being done by LLDB when 
waiting on type-completion events, e.g., when running an expression. We add 
three new progress reports (across three commits):
1. When moving decls between ASTs.
2. When creating Clang ASTs from DWARF.
3. When doing a FindTypes lookup on a debug map.

Some remaining questions:
1. When do we want to destroy these `Progress` objects? Since the progress 
completed event is only sent on object destruction
2. How expensive is it to do this reporting unconditionally?
3. Are there more interesting places to report progress on?

>From 18303da3e0b318860df9f13d6309cbf94d795f5b Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 8 May 2024 10:47:07 +0100
Subject: [PATCH 1/3] [lldb][ClangASTImporter] Report progress when importing
 decls

---
 .../Clang/ClangASTImporter.cpp| 35 +++
 .../ExpressionParser/Clang/ClangASTImporter.h |  4 +++
 2 files changed, 39 insertions(+)

diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 30b50df79da90..cf9f1a2d47922 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "lldb/Core/Module.h"
+#include "lldb/Core/Progress.h"
 #include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
@@ -17,6 +18,7 @@
 #include "clang/AST/RecordLayout.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Sema.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/raw_ostream.h"
 
 #include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
@@ -1131,6 +1133,7 @@ ClangASTImporter::ASTImporterDelegate::ImportImpl(Decl 
*From) {
 LLDB_LOG(log, "[ClangASTImporter] Complete definition not found");
   }
 
+  UpdateImportProgress(From);
   return ASTImporter::ImportImpl(From);
 }
 
@@ -1411,3 +1414,35 @@ clang::Decl *
 ClangASTImporter::ASTImporterDelegate::GetOriginalDecl(clang::Decl *To) {
   return m_main.GetDeclOrigin(To).decl;
 }
+
+void ClangASTImporter::ASTImporterDelegate::UpdateImportProgress(
+clang::Decl const *From) {
+  assert(From &&
+ "Trying to report import progress using an invalid clang::Decl.");
+
+  // If we can't determine the decl's name, we don't know what to
+  // update the progress bar with. So bail out.
+  auto const *ND = dyn_cast(From);
+  if (!ND)
+return;
+
+  if (!m_import_progress_up) {
+auto const *from_ast =
+TypeSystemClang::GetASTContext(>getASTContext());
+auto const *to_ast = TypeSystemClang::GetASTContext(());
+
+assert(from_ast && to_ast);
+
+llvm::SmallVector from_name_parts;
+llvm::SplitString(from_ast->getDisplayName(), from_name_parts, "/");
+auto from_name = from_name_parts.back();
+
+llvm::SmallVector to_name_parts;
+llvm::SplitString(to_ast->getDisplayName(), to_name_parts, "/");
+auto to_name = to_name_parts.back();
+m_import_progress_up = std::make_unique(
+llvm::formatv("Importing '{0}' to '{1}'", from_name, to_name));
+  }
+
+  m_import_progress_up->Increment(1, ND->getNameAsString());
+}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
index bc962e544d2f1..f666d0c0fc52c 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
@@ -22,6 +22,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
 
+#include "lldb/Core/Progress.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Symbol/CompilerDeclContext.h"
 #include "lldb/Utility/LLDBAssert.h"
@@ -346,6 +347,8 @@ class ClangASTImporter {
 llvm::Expected ImportImpl(clang::Decl *From) override;
 
   private:
+void UpdateImportProgress(clang::Decl const *From);
+
 /// Decls we should ignore when mapping decls back to their original
 /// ASTContext. Used by the CxxModuleHandler to mark declarations that
 /// were created from the 'std' C++ module to prevent that the Importer
@@ -356,6 +359,7 @@ class ClangASTImporter {
 CxxModuleHandler *m_std_handler = nullptr;
 /// The currently attached listener.
 NewDeclListener *m_new_decl_listener = nullptr;
+std::unique_ptr m_import_progress_up = nullptr;
   };
 
   typedef std::shared_ptr ImporterDelegateSP;

>From 99d505d6ec7de91f48df06da1109f1206d410c38 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 8 May 2024 10:47:54 +0100
Subject: [PATCH 2/3] [lldb][DWARFASTParserClang] Report progress when parsing
 types from DWARF

---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 19 +++
 

[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)

2024-05-08 Thread Greg Clayton via lldb-commits


@@ -289,3 +292,35 @@ void 
StructuredData::Null::GetDescription(lldb_private::Stream ) const {
 void StructuredData::Generic::GetDescription(lldb_private::Stream ) const {
   s.Printf("%p", m_object);
 }
+
+/// This is the same implementation as `StringRef::split`. Not depending on
+/// `StringRef::split` because it will involve a temporary `SmallVectorImpl`.
+StructuredData::ArraySP StructuredData::Array::SplitString(llvm::StringRef s,

clayborg wrote:

This whole function is a small wrapper around StringRef::split(). I am not sure 
this specialized method belongs in StructuredData (and I would like to not 
split the strings for output and error if possible).

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


[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)

2024-05-08 Thread Greg Clayton via lldb-commits

https://github.com/clayborg requested changes to this pull request.

Needs a few changes. See inline comments.

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


[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)

2024-05-08 Thread Greg Clayton via lldb-commits


@@ -2044,6 +2052,15 @@ bool CommandInterpreter::HandleCommand(const char 
*command_line,
   m_transcript_stream << result.GetOutputData();
   m_transcript_stream << result.GetErrorData();
 
+  // Add output and error to the transcript item after splitting lines. In the
+  // future, other aspects of the command (e.g. perf) can be added, too.
+  transcript_item->AddItem(
+  "output", StructuredData::Array::SplitString(result.GetOutputData(), 
'\n',
+   -1, false));
+  transcript_item->AddItem(
+  "error", StructuredData::Array::SplitString(result.GetErrorData(), '\n',
+  -1, false));

clayborg wrote:

Do we really need to split the lines here? I would rather get all of the output 
in a single string if possible for both output and errors. 

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


[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)

2024-05-08 Thread Greg Clayton via lldb-commits


@@ -85,3 +86,91 @@ def test_command_output(self):
 self.assertEqual(res.GetOutput(), "")
 self.assertIsNotNone(res.GetError())
 self.assertEqual(res.GetError(), "")
+
+def test_structured_transcript(self):
+"""Test structured transcript generation and retrieval."""
+# Get command interpreter and create a target
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+ci = self.dbg.GetCommandInterpreter()
+self.assertTrue(ci, VALID_COMMAND_INTERPRETER)
+
+# Send a few commands through the command interpreter
+res = lldb.SBCommandReturnObject()
+ci.HandleCommand("version", res)
+ci.HandleCommand("an-unknown-command", res)
+ci.HandleCommand("breakpoint set -f main.c -l %d" % self.line, res)
+ci.HandleCommand("r", res)
+ci.HandleCommand("p a", res)

clayborg wrote:

Add an example that gets some JSON as outoput like "statistics dump". We need 
to test that a command can output anything, including things that contain JSON 
itself and we need to make sure the output string or error string that contains 
JSON doesn't mess up the structured data (the strings for output need to be 
sanitized to desensitize any JSON reserved characters (like '{' and '"', etc).

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


[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)

2024-05-08 Thread Greg Clayton via lldb-commits


@@ -290,6 +290,31 @@ class StructuredData {
 
 void GetDescription(lldb_private::Stream ) const override;
 
+/// Creates an Array of substrings by splitting a string around the
+/// occurrences of a separator character.
+///
+/// \param[in] s
+///   The input string.
+///
+/// \param[in] separator
+///   The character to split on.
+///
+/// \param[in] maxSplit
+///   The maximum number of times the string is split. If \a maxSplit is >=
+///   0, at most \a maxSplit splits are done and consequently <= \a 
maxSplit
+///   + 1 elements are returned.
+///
+/// \param[in] keepEmpty
+///   True if empty substrings should be returned. Empty substrings still
+///   count when considering \a maxSplit.
+///
+/// \return
+///   An array containing the substrings. If \a maxSplit == -1 and \a
+///   keepEmpty == true, then the concatination of the array forms the 
input
+///   string.
+static ArraySP SplitString(llvm::StringRef s, char separator,
+   int maxSplit = -1, bool keepEmpty = true);
+

clayborg wrote:

This API doesn't seem like it belongs in StructuredData. Also see the comment 
below about not splitting up the output and error into separate strings.

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


[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)

2024-05-08 Thread Greg Clayton via lldb-commits

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