]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Target/ABI.h
Upgrade to OpenSSH 6.8p1.
[FreeBSD/FreeBSD.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 #include "llvm/ADT/ArrayRef.h"
22
23 // forward define the llvm::Type class
24 namespace llvm { class Type; }
25
26 namespace lldb_private {
27
28 class ABI :
29     public PluginInterface
30 {
31 public:
32     
33     struct CallArgument
34     {
35         enum eType
36         {
37             HostPointer = 0,        /* pointer to host data */
38             TargetValue ,           /* value is on the target or literal */
39         };
40         eType  type;                /* value of eType */
41         size_t size;                /* size in bytes of this argument */
42
43         lldb::addr_t  value;                    /* literal value */
44         std::unique_ptr<uint8_t[]> data_ap;     /* host data pointer */
45     };
46
47     virtual
48     ~ABI();
49
50     virtual size_t
51     GetRedZoneSize () const = 0;
52     
53     virtual bool
54     PrepareTrivialCall ( lldb_private::Thread &thread, 
55                          lldb::addr_t sp,
56                          lldb::addr_t functionAddress,
57                          lldb::addr_t returnAddress, 
58                          llvm::ArrayRef<lldb::addr_t> args) const = 0;
59
60     // Prepare trivial call used from ThreadPlanFunctionCallUsingABI
61     // AD:
62     //  . Because i don't want to change other ABI's this is not declared pure virtual.
63     //    The dummy implementation will simply fail.  Only HexagonABI will currently
64     //    use this method.
65     //  . Two PrepareTrivialCall's is not good design so perhaps this should be combined.
66     //
67     virtual bool
68     PrepareTrivialCall ( lldb_private::Thread &thread, 
69                          lldb::addr_t sp,
70                          lldb::addr_t functionAddress,
71                          lldb::addr_t returnAddress,
72                          llvm::Type &prototype,
73                          llvm::ArrayRef<CallArgument> args) const;
74
75     virtual bool
76     GetArgumentValues (Thread &thread,
77                        ValueList &values) const = 0;
78     
79     lldb::ValueObjectSP
80     GetReturnValueObject (Thread &thread,
81                           ClangASTType &type,
82                           bool persistent = true) const;
83     
84     // specialized to work with llvm IR types
85     lldb::ValueObjectSP
86     GetReturnValueObject (Thread &thread,
87                           llvm::Type &type,
88                           bool persistent = true) const;
89     
90     // Set the Return value object in the current frame as though a function with 
91     virtual Error
92     SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) = 0;
93
94 protected:    
95     // This is the method the ABI will call to actually calculate the return value.
96     // Don't put it in a persistent value object, that will be done by the ABI::GetReturnValueObject.
97     virtual lldb::ValueObjectSP
98     GetReturnValueObjectImpl (Thread &thread, ClangASTType &ast_type) const = 0;
99     
100     // specialized to work with llvm IR types
101     virtual lldb::ValueObjectSP
102     GetReturnValueObjectImpl( Thread &thread, llvm::Type &ir_type ) const;
103
104 public:
105     virtual bool
106     CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) = 0;
107
108     virtual bool
109     CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) = 0;
110
111     virtual bool
112     RegisterIsVolatile (const RegisterInfo *reg_info) = 0;
113
114     // Should take a look at a call frame address (CFA) which is just the stack
115     // pointer value upon entry to a function. ABIs usually impose alignment
116     // restrictions (4, 8 or 16 byte aligned), and zero is usually not allowed.
117     // This function should return true if "cfa" is valid call frame address for
118     // the ABI, and false otherwise. This is used by the generic stack frame unwinding
119     // code to help determine when a stack ends.
120     virtual bool
121     CallFrameAddressIsValid (lldb::addr_t cfa) = 0;
122
123     // Validates a possible PC value and returns true if an opcode can be at "pc".
124     virtual bool
125     CodeAddressIsValid (lldb::addr_t pc) = 0;    
126
127     virtual lldb::addr_t
128     FixCodeAddress (lldb::addr_t pc)
129     {
130         // Some targets might use bits in a code address to indicate
131         // a mode switch. ARM uses bit zero to signify a code address is
132         // thumb, so any ARM ABI plug-ins would strip those bits.
133         return pc;
134     }
135
136     virtual const RegisterInfo *
137     GetRegisterInfoArray (uint32_t &count) = 0;
138
139     bool
140     GetRegisterInfoByName (const ConstString &name, RegisterInfo &info);
141
142     bool
143     GetRegisterInfoByKind (lldb::RegisterKind reg_kind, 
144                            uint32_t reg_num, 
145                            RegisterInfo &info);
146
147     static lldb::ABISP
148     FindPlugin (const ArchSpec &arch);
149     
150 protected:
151     //------------------------------------------------------------------
152     // Classes that inherit from ABI can see and modify these
153     //------------------------------------------------------------------
154     ABI();
155 private:
156     DISALLOW_COPY_AND_ASSIGN (ABI);
157 };
158
159 } // namespace lldb_private
160
161 #endif  // liblldb_ABI_h_