1 //===-- Architecture.h ------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_CORE_ARCHITECTURE_H
10 #define LLDB_CORE_ARCHITECTURE_H
12 #include "lldb/Core/PluginInterface.h"
14 namespace lldb_private {
16 class Architecture : public PluginInterface {
18 Architecture() = default;
19 ~Architecture() override = default;
21 /// This is currently intended to handle cases where a
22 /// program stops at an instruction that won't get executed and it
23 /// allows the stop reason, like "breakpoint hit", to be replaced
24 /// with a different stop reason like "no stop reason".
26 /// This is specifically used for ARM in Thumb code when we stop in
27 /// an IT instruction (if/then/else) where the instruction won't get
28 /// executed and therefore it wouldn't be correct to show the program
29 /// stopped at the current PC. The code is generic and applies to all
31 virtual void OverrideStopInfo(Thread &thread) const = 0;
33 /// This method is used to get the number of bytes that should be
34 /// skipped, from function start address, to reach the first
35 /// instruction after the prologue. If overrode, it must return
36 /// non-zero only if the current address matches one of the known
37 /// function entry points.
39 /// This method is called only if the standard platform-independent
40 /// code fails to get the number of bytes to skip, giving the plugin
41 /// a chance to try to find the missing info.
43 /// This is specifically used for PPC64, where functions may have
44 /// more than one entry point, global and local, so both should
45 /// be compared with current address, in order to find out the
46 /// number of bytes that should be skipped, in case we are stopped
47 /// at either function entry point.
48 virtual size_t GetBytesToSkip(Symbol &func, const Address &curr_addr) const {
52 /// Adjust function breakpoint address, if needed. In some cases,
53 /// the function start address is not the right place to set the
54 /// breakpoint, specially in functions with multiple entry points.
56 /// This is specifically used for PPC64, for functions that have
57 /// both a global and a local entry point. In this case, the
58 /// breakpoint is adjusted to the first function address reached
59 /// by both entry points.
60 virtual void AdjustBreakpointAddress(const Symbol &func,
61 Address &addr) const {}
64 /// Get \a load_addr as a callable code load address for this target
66 /// Take \a load_addr and potentially add any address bits that are
67 /// needed to make the address callable. For ARM this can set bit
68 /// zero (if it already isn't) if \a load_addr is a thumb function.
69 /// If \a addr_class is set to AddressClass::eInvalid, then the address
70 /// adjustment will always happen. If it is set to an address class
71 /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
73 virtual lldb::addr_t GetCallableLoadAddress(
74 lldb::addr_t addr, AddressClass addr_class = AddressClass::eInvalid) const {
78 /// Get \a load_addr as an opcode for this target.
80 /// Take \a load_addr and potentially strip any address bits that are
81 /// needed to make the address point to an opcode. For ARM this can
82 /// clear bit zero (if it already isn't) if \a load_addr is a
83 /// thumb function and load_addr is in code.
84 /// If \a addr_class is set to AddressClass::eInvalid, then the address
85 /// adjustment will always happen. If it is set to an address class
86 /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be
89 virtual lldb::addr_t GetOpcodeLoadAddress(
90 lldb::addr_t addr, AddressClass addr_class = AddressClass::eInvalid) const {
94 // Get load_addr as breakable load address for this target. Take a addr and
95 // check if for any reason there is a better address than this to put a
96 // breakpoint on. If there is then return that address. For MIPS, if
97 // instruction at addr is a delay slot instruction then this method will find
98 // the address of its previous instruction and return that address.
99 virtual lldb::addr_t GetBreakableLoadAddress(lldb::addr_t addr,
100 Target &target) const {
105 Architecture(const Architecture &) = delete;
106 void operator=(const Architecture &) = delete;
109 } // namespace lldb_private
111 #endif // LLDB_CORE_ARCHITECTURE_H