26 lines
723 B
C++
26 lines
723 B
C++
#ifndef GWATCH_TRACER_HPP
|
|
#define GWATCH_TRACER_HPP
|
|
|
|
#include <cstdint>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
class Tracer {
|
|
public:
|
|
int watch_variable(const std::string &var_name, const std::string &exec_path,
|
|
uint64_t address, size_t size,
|
|
const std::vector<std::string> &args = {});
|
|
|
|
private:
|
|
void setup_hardware_watchpoint(pid_t pid, uint64_t address, size_t size);
|
|
void handle_watchpoint_hit(pid_t pid, uint64_t address, size_t size);
|
|
uint64_t get_load_address(pid_t pid, const std::string &exec_path);
|
|
int64_t read_memory_value(pid_t pid, uint64_t address, size_t size);
|
|
|
|
std::string var_name_;
|
|
std::optional<int64_t> prev_value_;
|
|
};
|
|
|
|
#endif
|