]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Core/Architecture.h
MFV: r349861
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Core / Architecture.h
1 //===-- Architecture.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 LLDB_CORE_ARCHITECTURE_H
11 #define LLDB_CORE_ARCHITECTURE_H
12
13 #include "lldb/Core/PluginInterface.h"
14
15 namespace lldb_private {
16
17 class Architecture : public PluginInterface {
18 public:
19   Architecture() = default;
20   virtual ~Architecture() = default;
21
22   //------------------------------------------------------------------
23   /// This is currently intended to handle cases where a
24   /// program stops at an instruction that won't get executed and it
25   /// allows the stop reason, like "breakpoint hit", to be replaced
26   /// with a different stop reason like "no stop reason".
27   ///
28   /// This is specifically used for ARM in Thumb code when we stop in
29   /// an IT instruction (if/then/else) where the instruction won't get
30   /// executed and therefore it wouldn't be correct to show the program
31   /// stopped at the current PC. The code is generic and applies to all
32   /// ARM CPUs.
33   //------------------------------------------------------------------
34   virtual void OverrideStopInfo(Thread &thread) const = 0;
35
36   //------------------------------------------------------------------
37   /// This method is used to get the number of bytes that should be
38   /// skipped, from function start address, to reach the first
39   /// instruction after the prologue. If overrode, it must return
40   /// non-zero only if the current address matches one of the known
41   /// function entry points.
42   ///
43   /// This method is called only if the standard platform-independent
44   /// code fails to get the number of bytes to skip, giving the plugin
45   /// a chance to try to find the missing info.
46   ///
47   /// This is specifically used for PPC64, where functions may have
48   /// more than one entry point, global and local, so both should
49   /// be compared with current address, in order to find out the
50   /// number of bytes that should be skipped, in case we are stopped
51   /// at either function entry point.
52   //------------------------------------------------------------------
53   virtual size_t GetBytesToSkip(Symbol &func, const Address &curr_addr) const {
54     return 0;
55   }
56
57   //------------------------------------------------------------------
58   /// Adjust function breakpoint address, if needed. In some cases,
59   /// the function start address is not the right place to set the
60   /// breakpoint, specially in functions with multiple entry points.
61   ///
62   /// This is specifically used for PPC64, for functions that have
63   /// both a global and a local entry point. In this case, the
64   /// breakpoint is adjusted to the first function address reached
65   /// by both entry points.
66   //------------------------------------------------------------------
67   virtual void AdjustBreakpointAddress(const Symbol &func,
68                                        Address &addr) const {}
69
70
71   //------------------------------------------------------------------
72   /// Get \a load_addr as a callable code load address for this target
73   ///
74   /// Take \a load_addr and potentially add any address bits that are
75   /// needed to make the address callable. For ARM this can set bit
76   /// zero (if it already isn't) if \a load_addr is a thumb function.
77   /// If \a addr_class is set to AddressClass::eInvalid, then the address
78   /// adjustment will always happen. If it is set to an address class
79   /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
80   /// returned.
81   //------------------------------------------------------------------
82   virtual lldb::addr_t GetCallableLoadAddress(
83       lldb::addr_t addr, AddressClass addr_class = AddressClass::eInvalid) const {
84     return addr;
85   }
86
87   //------------------------------------------------------------------
88   /// Get \a load_addr as an opcode for this target.
89   ///
90   /// Take \a load_addr and potentially strip any address bits that are
91   /// needed to make the address point to an opcode. For ARM this can
92   /// clear bit zero (if it already isn't) if \a load_addr is a
93   /// thumb function and load_addr is in code.
94   /// If \a addr_class is set to AddressClass::eInvalid, then the address
95   /// adjustment will always happen. If it is set to an address class
96   /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
97   /// returned.
98   //------------------------------------------------------------------
99
100   virtual lldb::addr_t GetOpcodeLoadAddress(
101       lldb::addr_t addr, AddressClass addr_class = AddressClass::eInvalid) const {
102     return addr;
103   }
104
105   // Get load_addr as breakable load address for this target. Take a addr and
106   // check if for any reason there is a better address than this to put a
107   // breakpoint on. If there is then return that address. For MIPS, if
108   // instruction at addr is a delay slot instruction then this method will find
109   // the address of its previous instruction and return that address.
110   virtual lldb::addr_t GetBreakableLoadAddress(lldb::addr_t addr,
111                                                Target &target) const {
112     return addr;
113   }
114
115 private:
116   Architecture(const Architecture &) = delete;
117   void operator=(const Architecture &) = delete;
118 };
119
120 } // namespace lldb_private
121
122 #endif // LLDB_CORE_ARCHITECTURE_H