Add architecture function for retrieving the stack growth direction.

Also add corresponding implementation for x86.
This commit is contained in:
Rene Gollent
2011-12-12 08:40:49 -05:00
parent 673c1e4d07
commit 4b64cd3de3
3 changed files with 20 additions and 0 deletions
+9
View File
@@ -1,5 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, [email protected]. * Copyright 2009, Ingo Weinhold, [email protected].
* Copyright 2011, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef ARCHITECTURE_H #ifndef ARCHITECTURE_H
@@ -31,6 +32,12 @@ class Team;
class TeamMemory; class TeamMemory;
enum {
STACK_GROWTH_DIRECTION_POSITIVE = 0,
STACK_GROWTH_DIRECTION_NEGATIVE
};
class Architecture : public BReferenceable { class Architecture : public BReferenceable {
public: public:
Architecture(TeamMemory* teamMemory, Architecture(TeamMemory* teamMemory,
@@ -44,6 +51,8 @@ public:
inline bool IsBigEndian() const { return fBigEndian; } inline bool IsBigEndian() const { return fBigEndian; }
inline bool IsHostEndian() const; inline bool IsHostEndian() const;
virtual int32 StackGrowthDirection() const = 0;
virtual int32 CountRegisters() const = 0; virtual int32 CountRegisters() const = 0;
virtual const Register* Registers() const = 0; virtual const Register* Registers() const = 0;
virtual status_t InitRegisterRules(CfaContext& context) const; virtual status_t InitRegisterRules(CfaContext& context) const;
@@ -1,5 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, [email protected]. * Copyright 2009, Ingo Weinhold, [email protected].
* Copyright 2011, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -180,6 +181,13 @@ ArchitectureX86::Init()
} }
int32
ArchitectureX86::StackGrowthDirection() const
{
return STACK_GROWTH_DIRECTION_NEGATIVE;
}
int32 int32
ArchitectureX86::CountRegisters() const ArchitectureX86::CountRegisters() const
{ {
@@ -1,5 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, [email protected]. * Copyright 2009, Ingo Weinhold, [email protected].
* Copyright 2011, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef ARCHITECTURE_X86_H #ifndef ARCHITECTURE_X86_H
@@ -22,6 +23,8 @@ public:
virtual status_t Init(); virtual status_t Init();
virtual int32 StackGrowthDirection() const;
virtual int32 CountRegisters() const; virtual int32 CountRegisters() const;
virtual const Register* Registers() const; virtual const Register* Registers() const;
virtual status_t InitRegisterRules(CfaContext& context) const; virtual status_t InitRegisterRules(CfaContext& context) const;