Skip to content

Commit

Permalink
PreciseLeakSanitizer: Add destructor
Browse files Browse the repository at this point in the history
  • Loading branch information
purplepig4657 committed Jan 19, 2024
1 parent 8c465c9 commit 370fccc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion RuntimeLibrary/plsan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@

#include <cstddef>

__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) {
/* TODO: initialize references */
}
Expand Down
2 changes: 2 additions & 0 deletions RuntimeLibrary/plsan_shadow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ 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) {}
Expand Down
1 change: 1 addition & 0 deletions RuntimeLibrary/plsan_shadow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 370fccc

Please sign in to comment.