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