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