diff options
Diffstat (limited to 'DevTools/UserspaceEmulator')
-rw-r--r-- | DevTools/UserspaceEmulator/Emulator.cpp | 10 | ||||
-rw-r--r-- | DevTools/UserspaceEmulator/SoftCPU.h | 4 |
2 files changed, 8 insertions, 6 deletions
diff --git a/DevTools/UserspaceEmulator/Emulator.cpp b/DevTools/UserspaceEmulator/Emulator.cpp index b07aa15e1a..1a2aaee0a7 100644 --- a/DevTools/UserspaceEmulator/Emulator.cpp +++ b/DevTools/UserspaceEmulator/Emulator.cpp @@ -167,14 +167,12 @@ int Emulator::exec() bool trace = false; while (!m_shutdown) { - u32 base_eip = 0; - if (trace) - base_eip = m_cpu.eip(); + m_cpu.save_base_eip(); auto insn = X86::Instruction::from_stream(m_cpu, true, true); if (trace) - out() << (const void*)base_eip << " \033[33;1m" << insn.to_string(base_eip, &symbol_provider) << "\033[0m"; + out() << (const void*)m_cpu.base_eip() << " \033[33;1m" << insn.to_string(m_cpu.base_eip(), &symbol_provider) << "\033[0m"; (m_cpu.*insn.handler())(insn); @@ -190,13 +188,13 @@ int Emulator::exec() bool Emulator::is_in_malloc_or_free() const { - return (m_cpu.eip() >= m_malloc_symbol_start && m_cpu.eip() < m_malloc_symbol_end) || (m_cpu.eip() >= m_free_symbol_start && m_cpu.eip() < m_free_symbol_end); + return (m_cpu.base_eip() >= m_malloc_symbol_start && m_cpu.base_eip() < m_malloc_symbol_end) || (m_cpu.base_eip() >= m_free_symbol_start && m_cpu.base_eip() < m_free_symbol_end); } Vector<FlatPtr> Emulator::raw_backtrace() { Vector<FlatPtr> backtrace; - backtrace.append(m_cpu.eip()); + backtrace.append(m_cpu.base_eip()); // FIXME: Maybe do something if the backtrace has uninitialized data in the frame chain. diff --git a/DevTools/UserspaceEmulator/SoftCPU.h b/DevTools/UserspaceEmulator/SoftCPU.h index 925a8d46b2..e954873edf 100644 --- a/DevTools/UserspaceEmulator/SoftCPU.h +++ b/DevTools/UserspaceEmulator/SoftCPU.h @@ -56,6 +56,9 @@ public: explicit SoftCPU(Emulator&); void dump() const; + u32 base_eip() const { return m_base_eip; } + void save_base_eip() { m_base_eip = m_eip; } + u32 eip() const { return m_eip; } void set_eip(u32 eip) { @@ -981,6 +984,7 @@ private: bool m_flags_tainted { false }; u32 m_eip { 0 }; + u32 m_base_eip { 0 }; const u8* m_cached_code_ptr { nullptr }; const u8* m_cached_code_end { nullptr }; |