1#include <chrono>
2#include <cstdio>
3#include <thread>
4
5struct Foo {
6 bool enable = true;
7 uint32_t offset = 0;
8
9 void usleep_helper(uint32_t usec) {
10 [this, &usec] {
11 puts(s: "Break here in the helper");
12 std::this_thread::sleep_for(
13 rtime: std::chrono::duration<unsigned int, std::milli>(offset + usec));
14 }();
15 }
16};
17
18void *background_thread(void *) {
19 Foo f;
20 for (;;) {
21 f.usleep_helper(usec: 2);
22 }
23}
24
25int main() {
26 std::puts(s: "First break");
27 std::thread main_thread(background_thread, nullptr);
28 Foo f;
29 for (;;) {
30 f.usleep_helper(usec: 1);
31 }
32}
33

source code of lldb/test/API/functionalities/breakpoint/breakpoint_on_lambda_capture/main.cpp