LLDB mainline
Architecture.h
Go to the documentation of this file.
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
16
17namespace lldb_private {
18
20public:
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".
25 ///
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
30 /// ARM CPUs.
31 virtual void OverrideStopInfo(Thread &thread) const = 0;
32
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.
38 ///
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.
42 ///
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 {
49 return 0;
50 }
51
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.
55 ///
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 {}
62
63
64 /// Get \a load_addr as a callable code load address for this target
65 ///
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
72 /// returned.
74 lldb::addr_t addr, AddressClass addr_class = AddressClass::eInvalid) const {
75 return addr;
76 }
77
78 /// Get \a load_addr as an opcode for this target.
79 ///
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
87 /// returned.
88
90 lldb::addr_t addr, AddressClass addr_class = AddressClass::eInvalid) const {
91 return addr;
92 }
93
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.
100 Target &target) const {
101 return addr;
102 }
103
104 // Returns a pointer to an object that can manage memory tags for this
105 // Architecture E.g. masking out tags, unpacking tag streams etc. Returns
106 // nullptr if the architecture does not have a memory tagging extension.
107 //
108 // The return pointer being valid does not mean that the current process has
109 // memory tagging enabled, just that a tagging technology exists for this
110 // architecture.
111 virtual const MemoryTagManager *GetMemoryTagManager() const {
112 return nullptr;
113 }
114
115 // This returns true if a write to the named register should cause lldb to
116 // reconfigure its register information. For example on AArch64 writing to vg
117 // to change the vector length means lldb has to change the size of registers.
118 virtual bool
119 RegisterWriteCausesReconfigure(const llvm::StringRef name) const {
120 return false;
121 }
122
123 // Call this after writing a register for which RegisterWriteCausesReconfigure
124 // returns true. This method will update the layout of registers according to
125 // the new state e.g. the new length of scalable vector registers.
126 // Returns true if anything changed, which means existing register values must
127 // be invalidated.
129 DataExtractor &reg_data,
130 RegisterContext &reg_context) const {
131 return false;
132 }
133
134 /// Return an UnwindPlan that allows architecture-defined rules for finding
135 /// saved registers, given a particular set of register values.
138 std::shared_ptr<const UnwindPlan> current_unwindplan) {
139 return lldb::UnwindPlanSP();
140 }
141};
142
143} // namespace lldb_private
144
145#endif // LLDB_CORE_ARCHITECTURE_H
A section + offset based address class.
Definition Address.h:62
virtual void AdjustBreakpointAddress(const Symbol &func, Address &addr) const
Adjust function breakpoint address, if needed.
virtual lldb::addr_t GetCallableLoadAddress(lldb::addr_t addr, AddressClass addr_class=AddressClass::eInvalid) const
Get load_addr as a callable code load address for this target.
virtual bool ReconfigureRegisterInfo(DynamicRegisterInfo &reg_info, DataExtractor &reg_data, RegisterContext &reg_context) const
virtual lldb::addr_t GetOpcodeLoadAddress(lldb::addr_t addr, AddressClass addr_class=AddressClass::eInvalid) const
Get load_addr as an opcode for this target.
virtual const MemoryTagManager * GetMemoryTagManager() const
virtual lldb::UnwindPlanSP GetArchitectureUnwindPlan(lldb_private::Thread &thread, lldb_private::RegisterContextUnwind *regctx, std::shared_ptr< const UnwindPlan > current_unwindplan)
Return an UnwindPlan that allows architecture-defined rules for finding saved registers,...
virtual bool RegisterWriteCausesReconfigure(const llvm::StringRef name) const
virtual size_t GetBytesToSkip(Symbol &func, const Address &curr_addr) const
This method is used to get the number of bytes that should be skipped, from function start address,...
virtual void OverrideStopInfo(Thread &thread) const =0
This is currently intended to handle cases where a program stops at an instruction that won't get exe...
virtual lldb::addr_t GetBreakableLoadAddress(lldb::addr_t addr, Target &target) const
An data extractor class.
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::UnwindPlan > UnwindPlanSP
uint64_t addr_t
Definition lldb-types.h:80