mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 13:57:35 +00:00
UserspaceEmulator: Show file and line numbers in backtraces :^)
This was super easy thanks to the awesome LibDebug work by @itamar8910!
This commit is contained in:
parent
d1dd5013ea
commit
0f91dfa139
3 changed files with 10 additions and 2 deletions
|
@ -10,4 +10,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_bin(UserspaceEmulator)
|
||||
target_link_libraries(UserspaceEmulator LibX86 LibCore)
|
||||
target_link_libraries(UserspaceEmulator LibX86 LibDebug LibCore)
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "SoftCPU.h"
|
||||
#include "SoftMMU.h"
|
||||
#include <AK/Types.h>
|
||||
#include <LibDebug/DebugInfo.h>
|
||||
#include <LibELF/Loader.h>
|
||||
#include <LibX86/Instruction.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -60,6 +61,7 @@ public:
|
|||
|
||||
private:
|
||||
NonnullRefPtr<ELF::Loader> m_elf;
|
||||
OwnPtr<DebugInfo> m_debug_info;
|
||||
|
||||
SoftMMU m_mmu;
|
||||
SoftCPU m_cpu;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue