remove debug output and add volatile test program
This commit is contained in:
parent
04e359f710
commit
d4459a949f
@ -1,4 +1,6 @@
|
|||||||
#include "tracer.hpp"
|
#include "tracer.hpp"
|
||||||
|
#include <cerrno>
|
||||||
|
#include <cstring>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <format>
|
#include <format>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -104,10 +106,11 @@ void Tracer::watch_variable(const std::string &exec_path, uint64_t address, size
|
|||||||
waitpid(pid, &status, 0);
|
waitpid(pid, &status, 0);
|
||||||
|
|
||||||
if (!WIFSTOPPED(status)) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The process is stopped after exec due to PTRACE_TRACEME
|
||||||
// Get the actual load address (for PIE binaries)
|
// Get the actual load address (for PIE binaries)
|
||||||
uint64_t load_addr = get_load_address(pid, exec_path);
|
uint64_t load_addr = get_load_address(pid, exec_path);
|
||||||
uint64_t runtime_addr = load_addr + address;
|
uint64_t runtime_addr = load_addr + address;
|
||||||
|
|||||||
20
test_access.c
Normal file
20
test_access.c
Normal 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;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user