]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / source / Plugins / ABI / SysV-x86_64 / ABISysV_x86_64.h
1 //===-- ABISysV_x86_64.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_ABISysV_x86_64_h_
11 #define liblldb_ABISysV_x86_64_h_
12
13 // C Includes
14 // C++ Includes
15 // Other libraries and framework includes
16 // Project includes
17 #include "lldb/Target/ABI.h"
18 #include "lldb/lldb-private.h"
19
20 class ABISysV_x86_64 : public lldb_private::ABI {
21 public:
22   ~ABISysV_x86_64() override = default;
23
24   size_t GetRedZoneSize() const override;
25
26   bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp,
27                           lldb::addr_t functionAddress,
28                           lldb::addr_t returnAddress,
29                           llvm::ArrayRef<lldb::addr_t> args) const override;
30
31   bool GetArgumentValues(lldb_private::Thread &thread,
32                          lldb_private::ValueList &values) const override;
33
34   lldb_private::Error
35   SetReturnValueObject(lldb::StackFrameSP &frame_sp,
36                        lldb::ValueObjectSP &new_value) override;
37
38   lldb::ValueObjectSP
39   GetReturnValueObjectImpl(lldb_private::Thread &thread,
40                            lldb_private::CompilerType &type) const override;
41
42   bool
43   CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
44
45   bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
46
47   bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
48
49   // The SysV x86_64 ABI requires that stack frames be 16 byte aligned.
50   // When there is a trap handler on the stack, e.g. _sigtramp in userland
51   // code, we've seen that the stack pointer is often not aligned properly
52   // before the handler is invoked.  This means that lldb will stop the unwind
53   // early -- before the function which caused the trap.
54   //
55   // To work around this, we relax that alignment to be just word-size
56   // (8-bytes).
57   // Whitelisting the trap handlers for user space would be easy (_sigtramp) but
58   // in other environments there can be a large number of different functions
59   // involved in async traps.
60   bool CallFrameAddressIsValid(lldb::addr_t cfa) override {
61     // Make sure the stack call frame addresses are 8 byte aligned
62     if (cfa & (8ull - 1ull))
63       return false; // Not 8 byte aligned
64     if (cfa == 0)
65       return false; // Zero is not a valid stack address
66     return true;
67   }
68
69   bool CodeAddressIsValid(lldb::addr_t pc) override {
70     // We have a 64 bit address space, so anything is valid as opcodes
71     // aren't fixed width...
72     return true;
73   }
74
75   const lldb_private::RegisterInfo *
76   GetRegisterInfoArray(uint32_t &count) override;
77
78   bool GetPointerReturnRegister(const char *&name) override;
79
80   //------------------------------------------------------------------
81   // Static Functions
82   //------------------------------------------------------------------
83
84   static void Initialize();
85
86   static void Terminate();
87
88   static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch);
89
90   static lldb_private::ConstString GetPluginNameStatic();
91
92   //------------------------------------------------------------------
93   // PluginInterface protocol
94   //------------------------------------------------------------------
95
96   lldb_private::ConstString GetPluginName() override;
97
98   uint32_t GetPluginVersion() override;
99
100 protected:
101   void CreateRegisterMapIfNeeded();
102
103   lldb::ValueObjectSP
104   GetReturnValueObjectSimple(lldb_private::Thread &thread,
105                              lldb_private::CompilerType &ast_type) const;
106
107   bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
108
109 private:
110   ABISysV_x86_64() : lldb_private::ABI() {
111     // Call CreateInstance instead.
112   }
113 };
114
115 #endif // liblldb_ABISysV_x86_64_h_