UserspaceEmulator: Implement very basic leak checking :^)

Upon exit, the emulator will now print a leak report of any malloc
allocations that are still live and don't have pointers to their base
address anywhere in either another live mallocation, or in one of the
non-malloc-block memory regions.

Note that the malloc-block memory region check is not fully functional
and this will work even better once we get that fixed.

This is pretty cool. :^)
This commit is contained in:
Andreas Kling 2020-07-16 17:04:27 +02:00
commit f6584bfc36
Notes: sideshowbarker 2024-07-19 04:45:43 +09:00
4 changed files with 78 additions and 2 deletions

View file

@ -44,6 +44,8 @@ public:
void audit_read(FlatPtr address, size_t);
void audit_write(FlatPtr address, size_t);
void dump_leak_report();
private:
struct Mallocation {
bool contains(FlatPtr a) const
@ -57,8 +59,11 @@ private:
};
Mallocation* find_mallocation(FlatPtr);
bool is_reachable(const Mallocation&) const;
Vector<Mallocation> m_mallocations;
bool m_auditing_enabled { true };
};
}