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