remove debug output and add volatile test program

This commit is contained in:
Gabriel Ionita 2025-10-26 14:25:00 +01:00
parent 04e359f710
commit d4459a949f
Signed by: gabi
SSH Key Fingerprint: SHA256:mrbYmB/SGtDvT3etRoS6pDrMYWxR0/B5GSF6rR3qhhc
2 changed files with 24 additions and 1 deletions

View File

@ -1,4 +1,6 @@
#include "tracer.hpp"
#include <cerrno>
#include <cstring>
#include <filesystem>
#include <format>
#include <fstream>
@ -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;

20
test_access.c Normal file
View File

@ -0,0 +1,20 @@
#include <stdio.h>
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;
}