diff --git a/src/tracer.cpp b/src/tracer.cpp index 65f356c..5bec9ba 100644 --- a/src/tracer.cpp +++ b/src/tracer.cpp @@ -1,4 +1,6 @@ #include "tracer.hpp" +#include +#include #include #include #include @@ -104,10 +106,11 @@ void Tracer::watch_variable(const std::string &exec_path, uint64_t address, size waitpid(pid, &status, 0); if (!WIFSTOPPED(status)) { - std::cerr << "Error: Child process not stopped" << std::endl; + std::cerr << "Error: Child process not stopped after PTRACE_TRACEME" << std::endl; return; } + // The process is stopped after exec due to PTRACE_TRACEME // Get the actual load address (for PIE binaries) uint64_t load_addr = get_load_address(pid, exec_path); uint64_t runtime_addr = load_addr + address; diff --git a/test_access.c b/test_access.c new file mode 100644 index 0000000..b81dead --- /dev/null +++ b/test_access.c @@ -0,0 +1,20 @@ +#include + +volatile int global_counter = 0; + +int main() { + int temp; + + temp = global_counter; + printf("Initial value: %d\n", temp); + + global_counter = 42; + temp = global_counter; + printf("After write: %d\n", temp); + + global_counter = global_counter + 10; + temp = global_counter; + printf("After increment: %d\n", temp); + + return 0; +}