diff --git a/RuntimeLibrary/plsan.cpp b/RuntimeLibrary/plsan.cpp index fc16293e8..7891ff3cd 100644 --- a/RuntimeLibrary/plsan.cpp +++ b/RuntimeLibrary/plsan.cpp @@ -7,9 +7,16 @@ #include +__plsan::Plsan *plsan; + /* Initialization routines called before main() */ __attribute__((constructor)) void __plsan_init() { /* TODO: */ - __plsan::Plsan *plsan; + plsan = new __plsan::Plsan(); +} + +/* finialization routines called after main()*/ +__attribute__((destructor)) void __plsan_fini() { + delete plsan; } void __plsan_alloc(void *addr, size_t size) { diff --git a/RuntimeLibrary/plsan_shadow.cpp b/RuntimeLibrary/plsan_shadow.cpp index 53f440dcc..117e82ff1 100644 --- a/RuntimeLibrary/plsan_shadow.cpp +++ b/RuntimeLibrary/plsan_shadow.cpp @@ -11,6 +11,10 @@ PlsanShadow::PlsanShadow() { throw "mmap failed\n"; } +PlsanShadow::~PlsanShadow() { + munmap(shadow_addr, MMAP_SIZE); +} + void PlsanShadow::alloc_shadow(void *addr, size_t size) {} void PlsanShadow::update_reference(void **lhs, void *rhs) {} diff --git a/RuntimeLibrary/plsan_shadow.h b/RuntimeLibrary/plsan_shadow.h index 1d9f72556..a0e395a15 100644 --- a/RuntimeLibrary/plsan_shadow.h +++ b/RuntimeLibrary/plsan_shadow.h @@ -10,6 +10,7 @@ namespace __plsan { class PlsanShadow { public: PlsanShadow(); + ~PlsanShadow(); void alloc_shadow(void *addr, size_t size); void update_reference(void **lhs, void *rhs);