xref: /haiku/src/kits/debugger/dwarf/CfaContext.h (revision fce4895d1884da5ae6fb299d23c735c598e690b1)
1 /*
2  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef CFA_CONTEXT_H
6 #define CFA_CONTEXT_H
7 
8 
9 #include <ObjectList.h>
10 
11 #include "CfaRuleSet.h"
12 #include "Types.h"
13 
14 
15 class CfaContext {
16 public:
17 								CfaContext();
18 								~CfaContext();
19 
20 			void				SetLocation(target_addr_t targetLocation,
21 									target_addr_t initialLocation);
22 
23 			status_t			Init(uint32 registerCount);
24 			status_t			SaveInitialRuleSet();
25 
26 			status_t			PushRuleSet();
27 			status_t			PopRuleSet();
28 
TargetLocation()29 			target_addr_t		TargetLocation() const
30 									{ return fTargetLocation; }
31 
Location()32 			target_addr_t		Location() const
33 									{ return fLocation; }
34 			void				SetLocation(target_addr_t location);
35 
CodeAlignment()36 			uint32				CodeAlignment() const
37 									{ return fCodeAlignment; }
38 			void				SetCodeAlignment(uint32 alignment);
39 
DataAlignment()40 			int32				DataAlignment() const
41 									{ return fDataAlignment; }
42 			void				SetDataAlignment(int32 alignment);
43 
ReturnAddressRegister()44 			uint32				ReturnAddressRegister() const
45 									{ return fReturnAddressRegister; }
46 			void				SetReturnAddressRegister(uint32 reg);
47 
GetCfaCfaRule()48 			CfaCfaRule*			GetCfaCfaRule() const
49 									{ return fRuleSet->GetCfaCfaRule(); }
RegisterRule(uint32 index)50 			CfaRule*			RegisterRule(uint32 index) const
51 									{ return fRuleSet->RegisterRule(index); }
52 
53 			void				RestoreRegisterRule(uint32 reg);
54 
55 private:
56 			typedef BObjectList<CfaRuleSet> RuleSetList;
57 
58 private:
59 			target_addr_t		fTargetLocation;
60 			target_addr_t		fLocation;
61 			uint32				fCodeAlignment;
62 			int32				fDataAlignment;
63 			uint32				fReturnAddressRegister;
64 			CfaRuleSet*			fRuleSet;
65 			CfaRuleSet*			fInitialRuleSet;
66 			RuleSetList			fRuleSetStack;
67 };
68 
69 
70 
71 #endif	// CFA_CONTEXT_H
72