1 //===-- ABI.h ---------------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_ABI_h_
11 #define liblldb_ABI_h_
15 // Other libraries and framework includes
17 #include "lldb/Core/Error.h"
18 #include "lldb/Core/PluginInterface.h"
19 #include "lldb/lldb-private.h"
21 #include "llvm/ADT/ArrayRef.h"
23 // forward define the llvm::Type class
24 namespace llvm { class Type; }
26 namespace lldb_private {
29 public PluginInterface
37 HostPointer = 0, /* pointer to host data */
38 TargetValue , /* value is on the target or literal */
40 eType type; /* value of eType */
41 size_t size; /* size in bytes of this argument */
43 lldb::addr_t value; /* literal value */
44 uint8_t *data; /* host data pointer */
52 GetRedZoneSize () const = 0;
55 PrepareTrivialCall ( lldb_private::Thread &thread,
57 lldb::addr_t functionAddress,
58 lldb::addr_t returnAddress,
59 llvm::ArrayRef<lldb::addr_t> args) const = 0;
61 // Prepare trivial call used from ThreadPlanFunctionCallGDB
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
66 // . Two PrepareTrivialCall's is not good design so perhaps this should be combined.
69 PrepareTrivialCall ( lldb_private::Thread &thread,
71 lldb::addr_t functionAddress,
72 lldb::addr_t returnAddress,
73 llvm::Type &prototype,
74 llvm::ArrayRef<CallArgument> args) const;
77 GetArgumentValues (Thread &thread,
78 ValueList &values) const = 0;
81 GetReturnValueObject (Thread &thread,
83 bool persistent = true) const;
85 // specialized to work with llvm IR types
87 GetReturnValueObject (Thread &thread,
89 bool persistent = true) const;
91 // Set the Return value object in the current frame as though a function with
93 SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) = 0;
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;
101 // specialized to work with llvm IR types
102 virtual lldb::ValueObjectSP
103 GetReturnValueObjectImpl( Thread &thread, llvm::Type &ir_type ) const;
107 CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) = 0;
110 CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) = 0;
113 RegisterIsVolatile (const RegisterInfo *reg_info) = 0;
115 // Should return true if your ABI uses frames when doing stack backtraces. This
116 // means a frame pointer is used that points to the previous stack frame in some
119 StackUsesFrames () = 0;
121 // Should take a look at a call frame address (CFA) which is just the stack
122 // pointer value upon entry to a function. ABIs usually impose alignment
123 // restrictions (4, 8 or 16 byte aligned), and zero is usually not allowed.
124 // This function should return true if "cfa" is valid call frame address for
125 // the ABI, and false otherwise. This is used by the generic stack frame unwinding
126 // code to help determine when a stack ends.
128 CallFrameAddressIsValid (lldb::addr_t cfa) = 0;
130 // Validates a possible PC value and returns true if an opcode can be at "pc".
132 CodeAddressIsValid (lldb::addr_t pc) = 0;
135 FixCodeAddress (lldb::addr_t pc)
137 // Some targets might use bits in a code address to indicate
138 // a mode switch. ARM uses bit zero to signify a code address is
139 // thumb, so any ARM ABI plug-ins would strip those bits.
143 virtual const RegisterInfo *
144 GetRegisterInfoArray (uint32_t &count) = 0;
146 // Some architectures (e.g. x86) will push the return address on the stack and decrement
147 // the stack pointer when making a function call. This means that every stack frame will
148 // have a unique CFA.
149 // Other architectures (e.g. arm) pass the return address in a register so it is possible
150 // to have a frame on a backtrace that does not push anything on the stack or change the
153 FunctionCallsChangeCFA () = 0;
156 GetRegisterInfoByName (const ConstString &name, RegisterInfo &info);
159 GetRegisterInfoByKind (lldb::RegisterKind reg_kind,
164 FindPlugin (const ArchSpec &arch);
167 //------------------------------------------------------------------
168 // Classes that inherit from ABI can see and modify these
169 //------------------------------------------------------------------
172 DISALLOW_COPY_AND_ASSIGN (ABI);
175 } // namespace lldb_private
177 #endif // liblldb_ABI_h_