diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-08-11 01:30:47 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-10 23:19:33 +0200 |
commit | 3ad2f1bfd1402ea6eac4c77767a09fbb34b1e864 (patch) | |
tree | 7c7a629865b768c5ded2a3f70db0df60e145c97a /Userland | |
parent | b85b8ca3508a37b13133fcc15d5cdc6ef16997f8 (diff) | |
download | serenity-3ad2f1bfd1402ea6eac4c77767a09fbb34b1e864.zip |
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.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/DevTools/Profiler/DisassemblyModel.cpp | 22 |
1 files 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(); |