diff options
author | Andreas Kling <kling@serenityos.org> | 2020-07-21 18:47:05 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-21 19:08:01 +0200 |
commit | 0f91dfa1390806a4d0d907b19f575d801e5a5a84 (patch) | |
tree | 8f3a15c3f0fe01f59dc2c35648d365e556fd926a /DevTools/UserspaceEmulator/Emulator.cpp | |
parent | d1dd5013ead09bf123e95d40404c970829190ad2 (diff) | |
download | serenity-0f91dfa1390806a4d0d907b19f575d801e5a5a84.zip |
UserspaceEmulator: Show file and line numbers in backtraces :^)
This was super easy thanks to the awesome LibDebug work by @itamar8910!
Diffstat (limited to 'DevTools/UserspaceEmulator/Emulator.cpp')
-rw-r--r-- | DevTools/UserspaceEmulator/Emulator.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/DevTools/UserspaceEmulator/Emulator.cpp b/DevTools/UserspaceEmulator/Emulator.cpp index 15f80f6d52..b07aa15e1a 100644 --- a/DevTools/UserspaceEmulator/Emulator.cpp +++ b/DevTools/UserspaceEmulator/Emulator.cpp @@ -139,6 +139,8 @@ bool Emulator::load_elf() m_malloc_symbol_end = m_malloc_symbol_start + malloc_symbol.value().size(); m_free_symbol_start = free_symbol.value().value(); m_free_symbol_end = m_free_symbol_start + free_symbol.value().size(); + + m_debug_info = make<DebugInfo>(m_elf); return true; } @@ -214,7 +216,11 @@ void Emulator::dump_backtrace(const Vector<FlatPtr>& backtrace) for (auto& address : backtrace) { u32 offset = 0; String symbol = m_elf->symbolicate(address, &offset); - dbgprintf("==%d== %#08x %s +%#x\n", s_pid, address, symbol.characters(), offset); + auto source_position = m_debug_info->get_source_position(address); + dbgprintf("==%d== %#08x %s +%#x", getpid(), address, symbol.characters(), offset); + if (source_position.has_value()) + dbgprintf(" (%s:%zu)", LexicalPath(source_position.value().file_path).basename().characters(), source_position.value().line_number); + dbgprintf("\n"); } } |