summaryrefslogtreecommitdiff
path: root/DevTools/UserspaceEmulator/MallocTracer.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-07-16 17:04:27 +0200
committerAndreas Kling <kling@serenityos.org>2020-07-16 19:21:45 +0200
commitf6584bfc360a3605b84fcfa343791224925fa415 (patch)
treebb833d23efad6143f21120666f43da73b0beb90b /DevTools/UserspaceEmulator/MallocTracer.h
parent7e132442387e42a96c4f9ea4a0a1fe22ce5cc30e (diff)
downloadserenity-f6584bfc360a3605b84fcfa343791224925fa415.zip
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. :^)
Diffstat (limited to 'DevTools/UserspaceEmulator/MallocTracer.h')
-rw-r--r--DevTools/UserspaceEmulator/MallocTracer.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/DevTools/UserspaceEmulator/MallocTracer.h b/DevTools/UserspaceEmulator/MallocTracer.h
index 706b63fadc..6e28d5c882 100644
--- a/DevTools/UserspaceEmulator/MallocTracer.h
+++ b/DevTools/UserspaceEmulator/MallocTracer.h
@@ -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 };
};
}