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 2933467
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion RuntimeLibrary/plsan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +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) {
Expand Down
4 changes: 4 additions & 0 deletions RuntimeLibrary/plsan_shadow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
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 2933467

Please sign in to comment.