]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h
Update LLDB snapshot to upstream r225923 (git 2b588ecd)
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Plugins / ABI / MacOSX-i386 / ABIMacOSX_i386.h
1 //===-- ABIMacOSX_i386.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_ABIMacOSX_i386_h_
11 #define liblldb_ABIMacOSX_i386_h_
12
13 // C Includes
14 // C++ Includes
15 // Other libraries and framework includes
16 // Project includes
17 #include "lldb/lldb-private.h"
18 #include "lldb/Target/ABI.h"
19 #include "lldb/Core/Value.h"
20     
21 class ABIMacOSX_i386 :
22     public lldb_private::ABI
23 {
24 public:
25
26     ~ABIMacOSX_i386() { }
27     
28     virtual size_t 
29     GetRedZoneSize () const;
30     
31     virtual bool
32     PrepareTrivialCall (lldb_private::Thread &thread, 
33                         lldb::addr_t sp,
34                         lldb::addr_t func_addr,
35                         lldb::addr_t return_addr, 
36                         llvm::ArrayRef<lldb::addr_t> args) const;
37     
38     virtual bool
39     PrepareNormalCall (lldb_private::Thread &thread,
40                        lldb::addr_t sp,
41                        lldb::addr_t func_addr,
42                        lldb::addr_t return_addr,
43                        lldb_private::ValueList &args) const;
44     
45     virtual bool
46     GetArgumentValues (lldb_private::Thread &thread,
47                        lldb_private::ValueList &values) const;
48     
49     virtual lldb_private::Error
50     SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value);
51
52 protected:
53     virtual lldb::ValueObjectSP
54     GetReturnValueObjectImpl (lldb_private::Thread &thread,
55                     lldb_private::ClangASTType &ast_type) const;
56
57 public:
58
59     virtual bool
60     CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
61     
62     virtual bool
63     CreateDefaultUnwindPlan (lldb_private::UnwindPlan &unwind_plan);
64     
65     virtual bool
66     RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info);
67
68     // The Darwin i386 ABI requires that stack frames be 16 byte aligned.
69     // When there is a trap handler on the stack, e.g. _sigtramp in userland
70     // code, we've seen that the stack pointer is often not aligned properly
71     // before the handler is invoked.  This means that lldb will stop the unwind
72     // early -- before the function which caused the trap.
73     //
74     // To work around this, we relax that alignment to be just word-size (4-bytes).
75     // Whitelisting the trap handlers for user space would be easy (_sigtramp) but
76     // in other environments there can be a large number of different functions
77     // involved in async traps.
78     //
79     // If we were to enforce 16-byte alignment, we also need to relax to 4-byte
80     // alignment for non-darwin i386 targets.
81     virtual bool
82     CallFrameAddressIsValid (lldb::addr_t cfa)
83     {
84         // Make sure the stack call frame addresses are are 4 byte aligned
85         if (cfa & (4ull - 1ull))
86             return false;   // Not 4 byte aligned
87         if (cfa == 0)
88             return false;   // Zero is not a valid stack address
89         return true;
90     }
91
92     virtual bool
93     CodeAddressIsValid (lldb::addr_t pc)
94     {
95         // Just make sure the address is a valid 32 bit address. 
96         return pc <= UINT32_MAX;
97     }
98
99     virtual const lldb_private::RegisterInfo *
100     GetRegisterInfoArray (uint32_t &count);
101
102     //------------------------------------------------------------------
103     // Static Functions
104     //------------------------------------------------------------------
105     static void
106     Initialize();
107     
108     static void
109     Terminate();
110     
111     static lldb::ABISP
112     CreateInstance (const lldb_private::ArchSpec &arch);
113     
114     //------------------------------------------------------------------
115     // PluginInterface protocol
116     //------------------------------------------------------------------
117     static lldb_private::ConstString
118     GetPluginNameStatic ();
119
120     virtual lldb_private::ConstString
121     GetPluginName();
122     
123     virtual uint32_t
124     GetPluginVersion();
125     
126 protected:
127     bool
128     RegisterIsCalleeSaved (const lldb_private::RegisterInfo *reg_info);
129
130 private:
131     ABIMacOSX_i386() : lldb_private::ABI() { } // Call CreateInstance instead.
132 };
133
134
135 #endif  // liblldb_ABI_h_