From 863ac3af9787d4c269ac99f2287c29a257aa474a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 22 May 2021 22:21:56 +0200 Subject: [PATCH] Profiler: Add some helpful debug output if a process is missing I've had a couple of instances where a profile was missing process creation events for a PID. I don't know how to reproduce it yet, so this patch merely adds a helpful debug message so you know why Profiler is failing to load the file. --- Userland/DevTools/Profiler/Profile.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Userland/DevTools/Profiler/Profile.cpp b/Userland/DevTools/Profiler/Profile.cpp index ce89740bd4..d48e18f6aa 100644 --- a/Userland/DevTools/Profiler/Profile.cpp +++ b/Userland/DevTools/Profiler/Profile.cpp @@ -62,12 +62,16 @@ void Profile::rebuild_tree() Vector> roots; auto find_or_create_process_node = [this, &roots](pid_t pid, u64 timestamp) -> ProfileNode& { - auto& process = *find_process(pid, timestamp); + auto* process = find_process(pid, timestamp); + if (!process) { + dbgln("Profile contains event for unknown process with pid={}, timestamp={}", pid, timestamp); + VERIFY_NOT_REACHED(); + } for (auto root : roots) { - if (&root->process() == &process) + if (&root->process() == process) return root; } - auto new_root = ProfileNode::create_process_node(process); + auto new_root = ProfileNode::create_process_node(*process); roots.append(new_root); return new_root; };