[Lldb-commits] [lldb] [lldb] Add timed callbacks to the MainLoop class (PR #112895)

via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 18 05:28:08 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 1a871b2122470491f73b51f3e57718bc3bda08f1 cc3a4a94e9e2eb8b4cf763d4c8c477c71776ee93 --extensions h,cpp -- lldb/include/lldb/Host/MainLoopBase.h lldb/include/lldb/Host/posix/MainLoopPosix.h lldb/include/lldb/Host/windows/MainLoopWindows.h lldb/source/Host/common/MainLoopBase.cpp lldb/source/Host/posix/MainLoopPosix.cpp lldb/source/Host/windows/MainLoopWindows.cpp lldb/unittests/Host/MainLoopTest.cpp
``````````

</details>

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

``````````diff
diff --git a/lldb/include/lldb/Host/MainLoopBase.h b/lldb/include/lldb/Host/MainLoopBase.h
index 0b79c52a35..be9a2676e7 100644
--- a/lldb/include/lldb/Host/MainLoopBase.h
+++ b/lldb/include/lldb/Host/MainLoopBase.h
@@ -63,8 +63,7 @@ public:
 
   // Add a callback that will be executed after a certain amount of time has
   // passed.
-  void AddCallback(const Callback &callback,
-                   std::chrono::nanoseconds delay) {
+  void AddCallback(const Callback &callback, std::chrono::nanoseconds delay) {
     AddCallback(callback, std::chrono::steady_clock::now() + delay);
   }
 
diff --git a/lldb/source/Host/posix/MainLoopPosix.cpp b/lldb/source/Host/posix/MainLoopPosix.cpp
index 788c6c2300..0461b0f414 100644
--- a/lldb/source/Host/posix/MainLoopPosix.cpp
+++ b/lldb/source/Host/posix/MainLoopPosix.cpp
@@ -43,7 +43,6 @@ static void SignalHandler(int signo, siginfo_t *info, void *) {
   g_signal_flags[signo] = 1;
 }
 
-
 class ToTimeSpec {
 public:
   explicit ToTimeSpec(std::optional<MainLoopPosix::TimePoint> point) {
@@ -259,16 +258,16 @@ MainLoopPosix::MainLoopPosix() {
   Status error = m_interrupt_pipe.CreateNew(/*child_process_inherit=*/false);
   assert(error.Success());
   const int interrupt_pipe_fd = m_interrupt_pipe.GetReadFileDescriptor();
-  m_read_fds.insert({interrupt_pipe_fd,
-                     [interrupt_pipe_fd](MainLoopBase &loop) {
-                       char c;
-                       ssize_t bytes_read = llvm::sys::RetryAfterSignal(
-                           -1, ::read, interrupt_pipe_fd, &c, 1);
-                       assert(bytes_read == 1);
-                       UNUSED_IF_ASSERT_DISABLED(bytes_read);
-                       // NB: This implicitly causes another loop iteration
-                       // and therefore the execution of pending callbacks.
-                     }});
+  m_read_fds.insert(
+      {interrupt_pipe_fd, [interrupt_pipe_fd](MainLoopBase &loop) {
+         char c;
+         ssize_t bytes_read =
+             llvm::sys::RetryAfterSignal(-1, ::read, interrupt_pipe_fd, &c, 1);
+         assert(bytes_read == 1);
+         UNUSED_IF_ASSERT_DISABLED(bytes_read);
+         // NB: This implicitly causes another loop iteration
+         // and therefore the execution of pending callbacks.
+       }});
 #if HAVE_SYS_EVENT_H
   m_kqueue = kqueue();
   assert(m_kqueue >= 0);
diff --git a/lldb/source/Host/windows/MainLoopWindows.cpp b/lldb/source/Host/windows/MainLoopWindows.cpp
index 2f2249b108..0a5a35e9db 100644
--- a/lldb/source/Host/windows/MainLoopWindows.cpp
+++ b/lldb/source/Host/windows/MainLoopWindows.cpp
@@ -149,6 +149,4 @@ Status MainLoopWindows::Run() {
   return Status();
 }
 
-void MainLoopWindows::Interrupt() {
-  WSASetEvent(m_interrupt_event);
-}
+void MainLoopWindows::Interrupt() { WSASetEvent(m_interrupt_event); }

``````````

</details>


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


More information about the lldb-commits mailing list