ABIMacOSX_i386.h revision 263367
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
21class ABIMacOSX_i386 :
22    public lldb_private::ABI
23{
24public:
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
52protected:
53    virtual lldb::ValueObjectSP
54    GetReturnValueObjectImpl (lldb_private::Thread &thread,
55                    lldb_private::ClangASTType &ast_type) const;
56
57public:
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    virtual bool
69    StackUsesFrames ()
70    {
71        return true;
72    }
73
74    virtual bool
75    CallFrameAddressIsValid (lldb::addr_t cfa)
76    {
77        // Darwin call frame addresses must be 16-byte aligned, but other OS's
78        // only need 4-byte alignment.  Otherwise the ABI matches, so we have
79        // this one minor override here.
80        if (target_is_darwin)
81        {
82            // Make sure the stack call frame addresses are are 16 byte aligned
83            if (cfa & (16ull - 1ull))
84                return false;   // Not 16 byte aligned
85        }
86        else
87        {
88            // Make sure the stack call frame addresses are are 4 byte aligned
89            if (cfa & (4ull - 1ull))
90                return false;   // Not 4 byte aligned
91        }
92        if (cfa == 0)
93            return false;   // Zero is not a valid stack address
94        return true;
95    }
96
97    virtual bool
98    CodeAddressIsValid (lldb::addr_t pc)
99    {
100        // Just make sure the address is a valid 32 bit address.
101        return pc <= UINT32_MAX;
102    }
103
104    virtual bool
105    FunctionCallsChangeCFA ()
106    {
107        return true;
108    }
109
110    virtual const lldb_private::RegisterInfo *
111    GetRegisterInfoArray (uint32_t &count);
112
113    //------------------------------------------------------------------
114    // Static Functions
115    //------------------------------------------------------------------
116    static void
117    Initialize();
118
119    static void
120    Terminate();
121
122    static lldb::ABISP
123    CreateInstance (const lldb_private::ArchSpec &arch);
124
125    //------------------------------------------------------------------
126    // PluginInterface protocol
127    //------------------------------------------------------------------
128    static lldb_private::ConstString
129    GetPluginNameStatic ();
130
131    virtual lldb_private::ConstString
132    GetPluginName();
133
134    virtual uint32_t
135    GetPluginVersion();
136
137protected:
138    bool
139    RegisterIsCalleeSaved (const lldb_private::RegisterInfo *reg_info);
140
141private:
142    ABIMacOSX_i386(bool is_darwin) : lldb_private::ABI(),
143                                     target_is_darwin(is_darwin)
144                                   { } // Call CreateInstance instead.
145
146    bool target_is_darwin;
147};
148
149
150#endif  // liblldb_ABI_h_
151