From 12b1aa817a215a054db9ff7548ae460eb096125d Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 11 Dec 2011 22:25:32 -0500 Subject: [PATCH] Expose the stack pointer and frame pointer via CPUState. --- src/apps/debugger/arch/CpuState.h | 3 +++ src/apps/debugger/arch/x86/CpuStateX86.cpp | 17 +++++++++++++++++ src/apps/debugger/arch/x86/CpuStateX86.h | 3 +++ 3 files changed, 23 insertions(+) diff --git a/src/apps/debugger/arch/CpuState.h b/src/apps/debugger/arch/CpuState.h index ad5b1854c7..44b845b649 100644 --- a/src/apps/debugger/arch/CpuState.h +++ b/src/apps/debugger/arch/CpuState.h @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2011, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef CPU_STATE_H @@ -21,6 +22,8 @@ public: virtual ~CpuState(); virtual target_addr_t InstructionPointer() const = 0; + virtual target_addr_t StackFramePointer() const = 0; + virtual target_addr_t StackPointer() const = 0; virtual bool GetRegisterValue(const Register* reg, BVariant& _value) const = 0; virtual bool SetRegisterValue(const Register* reg, diff --git a/src/apps/debugger/arch/x86/CpuStateX86.cpp b/src/apps/debugger/arch/x86/CpuStateX86.cpp index c0660be2df..c51ee9df40 100644 --- a/src/apps/debugger/arch/x86/CpuStateX86.cpp +++ b/src/apps/debugger/arch/x86/CpuStateX86.cpp @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2011, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -54,6 +55,22 @@ CpuStateX86::InstructionPointer() const } +target_addr_t +CpuStateX86::StackFramePointer() const +{ + return IsRegisterSet(X86_REGISTER_EBP) + ? IntRegisterValue(X86_REGISTER_EBP) : 0; +} + + +target_addr_t +CpuStateX86::StackPointer() const +{ + return IsRegisterSet(X86_REGISTER_ESP) + ? IntRegisterValue(X86_REGISTER_ESP) : 0; +} + + bool CpuStateX86::GetRegisterValue(const Register* reg, BVariant& _value) const { diff --git a/src/apps/debugger/arch/x86/CpuStateX86.h b/src/apps/debugger/arch/x86/CpuStateX86.h index d6befe95f8..dde5537ef5 100644 --- a/src/apps/debugger/arch/x86/CpuStateX86.h +++ b/src/apps/debugger/arch/x86/CpuStateX86.h @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2011, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef CPU_STATE_X86_H @@ -47,6 +48,8 @@ public: virtual ~CpuStateX86(); virtual target_addr_t InstructionPointer() const; + virtual target_addr_t StackFramePointer() const; + virtual target_addr_t StackPointer() const; virtual bool GetRegisterValue(const Register* reg, BVariant& _value) const; virtual bool SetRegisterValue(const Register* reg,