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

via lldb-commits lldb-commits at lists.llvm.org
Wed May 8 15:43:01 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


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

<details>
<summary>
You can test this locally with the following command:
</summary>

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

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````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 &s, UserIDResolver &resolver) 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 &ProcessInfo,
   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",
-             &stat_fields.pid, stat_fields.comm, &stat_fields.state,
-             &stat_fields.ppid, &stat_fields.pgrp, &stat_fields.session,
-             &stat_fields.tty_nr, &stat_fields.tpgid, &stat_fields.flags,
-             &stat_fields.minflt, &stat_fields.cminflt, &stat_fields.majflt,
-             &stat_fields.cmajflt, &stat_fields.utime, &stat_fields.stime,
-             &stat_fields.cutime, &stat_fields.cstime, &stat_fields.priority,
-             &stat_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",
+          &stat_fields.pid, stat_fields.comm, &stat_fields.state,
+          &stat_fields.ppid, &stat_fields.pgrp, &stat_fields.session,
+          &stat_fields.tty_nr, &stat_fields.tpgid, &stat_fields.flags,
+          &stat_fields.minflt, &stat_fields.cminflt, &stat_fields.majflt,
+          &stat_fields.cmajflt, &stat_fields.utime, &stat_fields.stime,
+          &stat_fields.cutime, &stat_fields.cstime, &stat_fields.priority,
+          &stat_fields.nice) < 0) {
     return false;
   }
 
@@ -110,9 +111,8 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo &ProcessInfo,
 
   // nice values run from 19 to -20 inclusive (in linux). In the prpsinfo struct
   // pr_nice is a char
-  auto nice_value = static_cast<int8_t>(
-    (stat_fields.nice < 0 ? 0x80 : 0x00) | (stat_fields.nice & 0x7f)
-  );
+  auto nice_value = static_cast<int8_t>((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 <sys/resource.h>
 #include <climits>
 #include <optional>
+#include <sys/resource.h>
 
 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 <iostream>
 #include <cerrno>
+#include <iostream>
 #include <sys/resource.h>
 
 using namespace lldb_private;

``````````

</details>


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


More information about the lldb-commits mailing list