]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/llvm/tools/lldb/include/lldb/Target/ABI.h
Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.
[FreeBSD/stable/10.git] / contrib / llvm / tools / lldb / include / lldb / Target / ABI.h
1 //===-- ABI.h ---------------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_ABI_h_
11 #define liblldb_ABI_h_
12
13 // C Includes
14 // C++ Includes
15 // Other libraries and framework includes
16 // Project includes
17 #include "lldb/Core/Error.h"
18 #include "lldb/Core/PluginInterface.h"
19 #include "lldb/lldb-private.h"
20
21 namespace lldb_private {
22
23 class ABI :
24     public PluginInterface
25 {
26 public:
27     virtual
28     ~ABI();
29
30     virtual size_t
31     GetRedZoneSize () const = 0;
32
33     virtual bool
34     PrepareTrivialCall (Thread &thread, 
35                         lldb::addr_t sp,
36                         lldb::addr_t functionAddress,
37                         lldb::addr_t returnAddress, 
38                         lldb::addr_t *arg1_ptr = NULL,
39                         lldb::addr_t *arg2_ptr = NULL,
40                         lldb::addr_t *arg3_ptr = NULL,
41                         lldb::addr_t *arg4_ptr = NULL,
42                         lldb::addr_t *arg5_ptr = NULL,
43                         lldb::addr_t *arg6_ptr = NULL) const = 0;
44
45     virtual bool
46     GetArgumentValues (Thread &thread,
47                        ValueList &values) const = 0;
48     
49     lldb::ValueObjectSP
50     GetReturnValueObject (Thread &thread,
51                           ClangASTType &type,
52                           bool persistent = true) const;
53     
54     // Set the Return value object in the current frame as though a function with 
55     virtual Error
56     SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) = 0;
57
58 protected:    
59     // This is the method the ABI will call to actually calculate the return value.
60     // Don't put it in a persistant value object, that will be done by the ABI::GetReturnValueObject.
61     virtual lldb::ValueObjectSP
62     GetReturnValueObjectImpl (Thread &thread,
63                           ClangASTType &type) const = 0;
64 public:
65     virtual bool
66     CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) = 0;
67
68     virtual bool
69     CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) = 0;
70
71     virtual bool
72     RegisterIsVolatile (const RegisterInfo *reg_info) = 0;
73
74     // Should return true if your ABI uses frames when doing stack backtraces. This
75     // means a frame pointer is used that points to the previous stack frame in some
76     // way or another.
77     virtual bool
78     StackUsesFrames () = 0;
79
80     // Should take a look at a call frame address (CFA) which is just the stack
81     // pointer value upon entry to a function. ABIs usually impose alignment
82     // restrictions (4, 8 or 16 byte aligned), and zero is usually not allowed.
83     // This function should return true if "cfa" is valid call frame address for
84     // the ABI, and false otherwise. This is used by the generic stack frame unwinding
85     // code to help determine when a stack ends.
86     virtual bool
87     CallFrameAddressIsValid (lldb::addr_t cfa) = 0;
88
89     // Validates a possible PC value and returns true if an opcode can be at "pc".
90     virtual bool
91     CodeAddressIsValid (lldb::addr_t pc) = 0;    
92
93     virtual lldb::addr_t
94     FixCodeAddress (lldb::addr_t pc)
95     {
96         // Some targets might use bits in a code address to indicate
97         // a mode switch. ARM uses bit zero to signify a code address is
98         // thumb, so any ARM ABI plug-ins would strip those bits.
99         return pc;
100     }
101
102     virtual const RegisterInfo *
103     GetRegisterInfoArray (uint32_t &count) = 0;
104
105     // Some architectures (e.g. x86) will push the return address on the stack and decrement
106     // the stack pointer when making a function call.  This means that every stack frame will
107     // have a unique CFA.
108     // Other architectures (e.g. arm) pass the return address in a register so it is possible
109     // to have a frame on a backtrace that does not push anything on the stack or change the 
110     // CFA.
111     virtual bool
112     FunctionCallsChangeCFA () = 0;
113
114     
115     bool
116     GetRegisterInfoByName (const ConstString &name, RegisterInfo &info);
117
118     bool
119     GetRegisterInfoByKind (lldb::RegisterKind reg_kind, 
120                            uint32_t reg_num, 
121                            RegisterInfo &info);
122
123     static lldb::ABISP
124     FindPlugin (const ArchSpec &arch);
125     
126 protected:
127     //------------------------------------------------------------------
128     // Classes that inherit from ABI can see and modify these
129     //------------------------------------------------------------------
130     ABI();
131 private:
132     DISALLOW_COPY_AND_ASSIGN (ABI);
133 };
134
135 } // namespace lldb_private
136
137 #endif  // liblldb_ABI_h_