Repo-Init
 
Loading...
Searching...
No Matches
Tracer.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "client/crashpad_client.h"
4
5#include <thread>
6
10class Tracer {
11 private:
12 std::unique_ptr<std::thread> _thread;
13 std::atomic_flag _shouldStop{false};
14 std::shared_ptr<std::atomic_flag> _checkFlag;
15
16 std::string _serverPath;
17 std::string _serverProxy;
18 std::string _handlerPath;
19 std::map<std::string, std::string> _annotations;
20 std::vector<base::FilePath> _attachments;
21 std::string _reportPath;
22 std::unique_ptr<crashpad::CrashpadClient> _clientHandler;
23
27 void startHandler();
28
32 void threadFunc() noexcept;
33
39 static bool checkPidIsRunning(pid_t processId);
40
46 static bool checkSocketIsRunning(int sockId);
47
52 static inline std::string getSelfExecutableDir();
53
58 static void dumpSharedLibraryInfo(const std::string &filePath);
59
60 public:
70 explicit Tracer(std::shared_ptr<std::atomic_flag> checkFlag, std::string serverPath = "",
71 std::string serverProxy = "", const std::string &crashpadHandlerPath = "",
72 const std::string &reportPath = "", std::vector<base::FilePath> attachments = {});
73
75 Tracer(const Tracer & /*unused*/) = delete;
76
78 Tracer(Tracer && /*unused*/) = delete;
79
81 Tracer &operator=(Tracer /*unused*/) = delete;
82
84 Tracer &operator=(Tracer && /*unused*/) = delete;
85
89 ~Tracer();
90
95 [[nodiscard]] bool isRunning() const;
96
100 void restart();
101};
static bool checkSocketIsRunning(int sockId)
Definition Tracer.cpp:82
std::atomic_flag _shouldStop
Definition Tracer.hpp:13
Tracer & operator=(Tracer &&)=delete
Move assignment operator.
std::string _reportPath
Definition Tracer.hpp:21
Tracer & operator=(Tracer)=delete
Copy assignment operator.
static void dumpSharedLibraryInfo(const std::string &filePath)
Definition Tracer.cpp:131
void threadFunc() noexcept
Definition Tracer.cpp:56
void restart()
Definition Tracer.cpp:123
Tracer(Tracer &&)=delete
Move constructor.
Tracer(const Tracer &)=delete
Copy constructor.
void startHandler()
Definition Tracer.cpp:22
std::unique_ptr< crashpad::CrashpadClient > _clientHandler
Definition Tracer.hpp:22
std::string _serverPath
Definition Tracer.hpp:16
bool isRunning() const
Definition Tracer.cpp:102
std::string _serverProxy
Definition Tracer.hpp:17
~Tracer()
Definition Tracer.cpp:196
std::vector< base::FilePath > _attachments
Definition Tracer.hpp:20
std::shared_ptr< std::atomic_flag > _checkFlag
Definition Tracer.hpp:14
static std::string getSelfExecutableDir()
Definition Tracer.cpp:92
std::map< std::string, std::string > _annotations
Definition Tracer.hpp:19
std::string _handlerPath
Definition Tracer.hpp:18
std::unique_ptr< std::thread > _thread
Definition Tracer.hpp:12
static bool checkPidIsRunning(pid_t processId)
Definition Tracer.cpp:80