1#include "attach.h"
2#include <chrono>
3#include <cstdio>
4#include <fstream>
5#include <string>
6#include <thread>
7
8volatile bool wait_for_attach = true;
9
10void handle_attach(char *sync_file_path) {
11 lldb_enable_attach();
12
13 {
14 // Create a file to signal that this process has started up.
15 std::ofstream sync_file;
16 sync_file.open(s: sync_file_path);
17 }
18
19 while (wait_for_attach)
20 std::this_thread::sleep_for(rtime: std::chrono::milliseconds(10));
21}
22
23int main(int argc, char **args) {
24 if (argc == 2)
25 handle_attach(sync_file_path: args[1]);
26
27 // We let the binary live a little bit to see if it executed after detaching
28 // from // breakpoint
29
30 // Create a file to signal that this process has started up.
31 std::ofstream out_file; // breakpoint
32 out_file.open(s: std::string(args[0]) + ".side_effect");
33 return 0;
34}
35

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of lldb/test/API/tools/lldb-dap/disconnect/main.cpp