From 3ad2f1bfd1402ea6eac4c77767a09fbb34b1e864 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Wed, 11 Aug 2021 01:30:47 +0430 Subject: [PATCH] Profiler: Disassemble the entire function if the symbol is a function Previously the view would've cut off at the last instruction that was hit in the profile, which is not the right behaviour for functions. --- .../DevTools/Profiler/DisassemblyModel.cpp | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Userland/DevTools/Profiler/DisassemblyModel.cpp b/Userland/DevTools/Profiler/DisassemblyModel.cpp index 88cd5d2fc1..e0db4e7434 100644 --- a/Userland/DevTools/Profiler/DisassemblyModel.cpp +++ b/Userland/DevTools/Profiler/DisassemblyModel.cpp @@ -65,12 +65,16 @@ DisassemblyModel::DisassemblyModel(Profile& profile, ProfileNode& node) VERIFY(elf != nullptr); FlatPtr function_address = node.address() - base_address; + auto is_function_address = false; Debug::DebugInfo debug_info { *elf, {}, base_address }; auto function = debug_info.get_containing_function(function_address); - if (function.has_value()) + if (function.has_value()) { + if (function_address == function->address_low) + is_function_address = true; function_address = function->address_low; - else + } else { dbgln("DisassemblyModel: Function containing {:p} ({}) not found", node.address() - base_address, node.symbol()); + } auto symbol = elf->find_symbol(function_address); if (!symbol.has_value()) { @@ -87,13 +91,15 @@ DisassemblyModel::DisassemblyModel(Profile& profile, ProfileNode& node) X86::Disassembler disassembler(stream); size_t offset_into_symbol = 0; - FlatPtr last_instruction_address = 0; - for (auto& event : node.events_per_address()) - last_instruction_address = max(event.key, last_instruction_address); - - auto last_instruction_offset = last_instruction_address - node.address(); + FlatPtr last_instruction_offset = 0; + if (!is_function_address) { + FlatPtr last_instruction_address = 0; + for (auto& event : node.events_per_address()) + last_instruction_address = max(event.key, last_instruction_address); + last_instruction_offset = last_instruction_address - node.address(); + } for (;;) { - if (offset_into_symbol > last_instruction_offset) + if (!is_function_address && offset_into_symbol > last_instruction_offset) break; auto insn = disassembler.next();