summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorItamar <itamar8910@gmail.com>2021-06-19 11:32:08 +0300
committerAndreas Kling <kling@serenityos.org>2021-06-19 14:51:18 +0200
commita45ce0c6ebb5a3230a84da3a8646b8c541e0eb14 (patch)
tree21d58891136fab51d5a688e436aa687fdc4899b3 /Userland
parentd26f4f9e8c3f8552f53ae563248260f4ad27e568 (diff)
downloadserenity-a45ce0c6ebb5a3230a84da3a8646b8c541e0eb14.zip
LibCoreDump: Use "eip - 1" when creating backtrace entries
We need to do this because the return address from a function frame is the instruction that comes after the 'call' instruction.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibCoreDump/Backtrace.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/Userland/Libraries/LibCoreDump/Backtrace.cpp b/Userland/Libraries/LibCoreDump/Backtrace.cpp
index 52378e33d0..ea16b7c68b 100644
--- a/Userland/Libraries/LibCoreDump/Backtrace.cpp
+++ b/Userland/Libraries/LibCoreDump/Backtrace.cpp
@@ -54,7 +54,10 @@ Backtrace::Backtrace(const Reader& coredump, const ELF::Core::ThreadInfo& thread
uint32_t* ebp = (uint32_t*)m_thread_info.regs.ebp;
uint32_t* eip = (uint32_t*)m_thread_info.regs.eip;
while (ebp && eip) {
- add_entry(coredump, (FlatPtr)eip);
+ // We use eip - 1 because the return address from a function frame
+ // is the instruction that comes after the 'call' instruction.
+ VERIFY((FlatPtr)eip > 0);
+ add_entry(coredump, (FlatPtr)eip - 1);
auto next_eip = coredump.peek_memory((FlatPtr)(ebp + 1));
auto next_ebp = coredump.peek_memory((FlatPtr)(ebp));
if (!next_eip.has_value() || !next_ebp.has_value())