[Lldb-commits] [lldb] [lldb][test] Increase polling frequency in ProcessAttach (PR #201532)

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Thu Jun 4 01:56:43 PDT 2026


https://github.com/Teemperor created https://github.com/llvm/llvm-project/pull/201532

The test_attach_to_process_by_id_correct_executable_offset subtest requires us to hit a breakpoint in an attached process. For this we implement a loop that hits the breakpoint location every 2 seconds.

This patch increases the rate at which we hit this breakpoint to 50ms. The reason is that a 2s interval means that this test is waiting on any fast system for nearly 2 seconds on the first breakpoint hit. With a 50ms interval this subtest passed immediately.

>From 491e1f8c5b5776d3225096286a022b69227f8f92 Mon Sep 17 00:00:00 2001
From: Raphael Isemann <rise at apple.com>
Date: Thu, 4 Jun 2026 09:49:26 +0100
Subject: [PATCH] [lldb][test] Increase polling frequency in ProcessAttach

The test_attach_to_process_by_id_correct_executable_offset subtest
requires us to hit a breakpoint in an attached process. For this we
implement a loop that hits the breakpoint location every 2 seconds.

This patch increases the rate at which we hit this breakpoint to 50ms.
The reason is that a 2s interval means that this test is waiting on
any fast system for nearly 2 seconds on the first breakpoint hit. With
a 50ms interval this subtest passed immediately.
---
 lldb/test/API/commands/process/attach/main.cpp | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/lldb/test/API/commands/process/attach/main.cpp b/lldb/test/API/commands/process/attach/main.cpp
index 034e80ed5f2b3..24cd954c5af3e 100644
--- a/lldb/test/API/commands/process/attach/main.cpp
+++ b/lldb/test/API/commands/process/attach/main.cpp
@@ -1,21 +1,17 @@
 #include "attach.h"
 #include <chrono>
-#include <cstdio>
 #include <thread>
 
 volatile int g_val = 12345;
 
 int main(int argc, char const *argv[]) {
-    int temp;
     lldb_enable_attach();
 
-    // Waiting to be attached by the debugger.
-    temp = 0;
+    // This provides a breakpoint we hit every 50ms that the tests can hit.
+    std::chrono::milliseconds poll_time(50);
+    unsigned total_wait_in_sec = 60;
+    unsigned total_wait_time = total_wait_in_sec * (1000 / poll_time.count());
 
-    while (temp < 30) {
-        std::this_thread::sleep_for(std::chrono::seconds(2)); // Waiting to be attached...
-        temp++;
-    }
-
-    printf("Exiting now\n");
+    for (unsigned wait = 0; wait < total_wait_time; wait++)
+        std::this_thread::sleep_for(poll_time); // Waiting to be attached...
 }



More information about the lldb-commits mailing list