Skip to content

Commit

Permalink
PreciseLeakSanitizer: Add instrumentation functions and fix something…
Browse files Browse the repository at this point in the history
… wrong
  • Loading branch information
purplepig4657 committed Jan 22, 2024
1 parent 07e9927 commit 3696a54
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
12 changes: 11 additions & 1 deletion RuntimeLibrary/plsan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ __attribute__((constructor)) void __plsan_init() { /* TODO: */
/* finialization routines called after main()*/
__attribute__((destructor)) void __plsan_fini() { delete plsan; }

void __plsan_align(long size) {}

void __plsan_alloc(void *addr, size_t size) {
/* TODO: initialize references */
}

void __plsan_store(void **addr, void *value) { /* TODO: update references */
void __plsan_store(void **lhs, void *rhs) { /* TODO: update references */
}

void __plsan_enter_func() {}

void __plsan_exit_func() {
/*
* TODO: check if
Expand All @@ -41,6 +45,12 @@ Plsan::Plsan() {
handler = new PlsanHandler();
}

long Plsan::align_size(long size) { return 0; }

void Plsan::init_refcnt(void *addr, size_t size) {}

void Plsan::reference_count(void **lhs, void *rhs) {}

void Plsan::enter_func() {
// enter_func
}
Expand Down
5 changes: 4 additions & 1 deletion RuntimeLibrary/plsan.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ namespace __plsan {
class Plsan {
public:
Plsan();
// long align_size(long size);

// Instrumentation function
long align_size(long size);
void init_refcnt(void *addr, size_t size);
void reference_count(void **lhs, void *rhs);
void enter_func();
void exit_func();

Expand Down
3 changes: 2 additions & 1 deletion RuntimeLibrary/plsan_shadow.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

namespace __plsan {

#define MMAP_SIZE ((1L << 48) / 16)
#define MIN_DYN_ALLOC_SIZE 16
#define MMAP_SIZE ((1L << 48) / MIN_DYN_ALLOC_SIZE)

class PlsanShadow {
public:
Expand Down
9 changes: 8 additions & 1 deletion RuntimeLibrary/plsan_storage.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#include "plsan_storage.h"

namespace __plsan {

PlsanStorage::PlsanStorage() {}

void PlsanStorage::push_function() {}

void PlsanStorage::pop_function() {}

void PlsanStorage::add_mem_addr() {}
// Not shadow memmory address, but origin address is needed.
void PlsanStorage::add_mem_addr(void *addr) {}

LocalDynAllocStorage PlsanStorage::get_function_stack() {
return function_stack;
}

} // namespace __plsan
7 changes: 6 additions & 1 deletion RuntimeLibrary/plsan_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@

#include <stack>

namespace __plsan {

using LocalDynAllocStorage = std::stack<std::stack<void *>>;

class PlsanStorage {
public:
PlsanStorage();
void push_function();
void pop_function();
void add_mem_addr();
void add_mem_addr(void *addr);
LocalDynAllocStorage get_function_stack();

private:
LocalDynAllocStorage function_stack;
};

} // namespace __plsan

#endif

0 comments on commit 3696a54

Please sign in to comment.