diff options
author | Andreas Kling <kling@serenityos.org> | 2021-08-13 21:04:52 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-14 01:28:26 +0200 |
commit | f5db92448dbe7ec212adca9da465845d0373f751 (patch) | |
tree | 994ad40d5e2199ca8f7d364093be8fc81a21d0da /Userland/DevTools/Profiler/Profile.h | |
parent | f51f5e135a8767c4e8ea4c104a35892e5f2eafcd (diff) | |
download | serenity-f5db92448dbe7ec212adca9da465845d0373f751.zip |
Profiler: Use AK::Variant for type-specific data in Profile::Event
Each event has a different set of data depending on the event type.
Diffstat (limited to 'Userland/DevTools/Profiler/Profile.h')
-rw-r--r-- | Userland/DevTools/Profiler/Profile.h | 74 |
1 files changed, 47 insertions, 27 deletions
diff --git a/Userland/DevTools/Profiler/Profile.h b/Userland/DevTools/Profiler/Profile.h index 37ddabc345..d7f07204d5 100644 --- a/Userland/DevTools/Profiler/Profile.h +++ b/Userland/DevTools/Profiler/Profile.h @@ -20,6 +20,7 @@ #include <AK/NonnullRefPtrVector.h> #include <AK/OwnPtr.h> #include <AK/Result.h> +#include <AK/Variant.h> #include <LibELF/Image.h> #include <LibGUI/Forward.h> #include <LibGUI/ModelIndex.h> @@ -163,38 +164,57 @@ public: }; struct Event { - enum class Type { - Free, - Malloc, - Mmap, - Munmap, - ProcessCreate, - ProcessExec, - ProcessExit, - Sample, - Signpost, - ThreadCreate, - ThreadExit, - }; - Type type {}; - EventSerialNumber serial; u64 timestamp { 0 }; - FlatPtr ptr { 0 }; - size_t size { 0 }; - String name; - int parent_pid { 0 }; - int parent_tid { 0 }; - String executable; - int pid { 0 }; - int tid { 0 }; + EventSerialNumber serial; + pid_t pid { 0 }; + pid_t tid { 0 }; u32 lost_samples { 0 }; bool in_kernel { false }; - // FIXME: Put event type-specific arguments in a union to save memory. - String signpost_string; - FlatPtr arg2 {}; - Vector<Frame> frames; + + struct SampleData { + }; + + struct MallocData { + FlatPtr ptr {}; + size_t size {}; + }; + + struct FreeData { + FlatPtr ptr {}; + }; + + struct SignpostData { + String string; + FlatPtr arg {}; + }; + + struct MmapData { + FlatPtr ptr {}; + size_t size {}; + String name; + }; + + struct MunmapData { + FlatPtr ptr {}; + size_t size {}; + }; + + struct ProcessCreateData { + pid_t parent_pid { 0 }; + String executable; + }; + + struct ProcessExecData { + String executable; + }; + + struct ThreadCreateData { + pid_t parent_tid {}; + }; + + Variant<std::nullptr_t, SampleData, MallocData, FreeData, SignpostData, MmapData, MunmapData, ProcessCreateData, ProcessExecData, ThreadCreateData> data { nullptr }; }; const Vector<Event>& events() const { return m_events; } |