LLDB mainline
ABISysV_msp430.cpp
Go to the documentation of this file.
1//===-- ABISysV_msp430.cpp --------------------------------------*- 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#include "ABISysV_msp430.h"
11
12#include "lldb/Core/Module.h"
14#include "lldb/Core/Value.h"
19#include "lldb/Target/Process.h"
22#include "lldb/Target/Target.h"
23#include "lldb/Target/Thread.h"
26#include "lldb/Utility/Log.h"
28
29#include "llvm/IR/DerivedTypes.h"
30#include "llvm/TargetParser/Triple.h"
31
32using namespace lldb;
33using namespace lldb_private;
34
36
54};
55
57 {"r0",
58 "pc",
59 2,
60 0,
65 nullptr,
66 nullptr,
67 nullptr,
68 },
69 {"r1",
70 "sp",
71 2,
72 0,
77 nullptr,
78 nullptr,
79 nullptr,
80 },
81 {"r2",
82 "",
83 2,
84 0,
89 nullptr,
90 nullptr,
91 nullptr,
92 },
93 {"r3",
94 "",
95 2,
96 0,
101 nullptr,
102 nullptr,
103 nullptr,
104 },
105 {"r4",
106 "fp",
107 2,
108 0,
113 nullptr,
114 nullptr,
115 nullptr,
116 },
117 {"r5",
118 "",
119 2,
120 0,
125 nullptr,
126 nullptr,
127 nullptr,
128 },
129 {"r6",
130 "",
131 2,
132 0,
137 nullptr,
138 nullptr,
139 nullptr,
140 },
141 {"r7",
142 "",
143 2,
144 0,
149 nullptr,
150 nullptr,
151 nullptr,
152 },
153 {"r8",
154 "",
155 2,
156 0,
161 nullptr,
162 nullptr,
163 nullptr,
164 },
165 {"r9",
166 "",
167 2,
168 0,
173 nullptr,
174 nullptr,
175 nullptr,
176 },
177 {"r10",
178 "",
179 2,
180 0,
185 nullptr,
186 nullptr,
187 nullptr,
188 },
189 {"r11",
190 "",
191 2,
192 0,
197 nullptr,
198 nullptr,
199 nullptr,
200 },
201 {"r12",
202 "",
203 2,
204 0,
209 nullptr,
210 nullptr,
211 nullptr,
212 },
213 {"r13",
214 "",
215 2,
216 0,
221 nullptr,
222 nullptr,
223 nullptr,
224 },
225 {"r14",
226 "",
227 2,
228 0,
233 nullptr,
234 nullptr,
235 nullptr,
236 },
237 {"r15",
238 "",
239 2,
240 0,
245 nullptr,
246 nullptr,
247 nullptr,
248 }};
249
250static const uint32_t k_num_register_infos =
251 sizeof(g_register_infos) / sizeof(RegisterInfo);
252
255 // Make the C-string names and alt_names for the register infos into const
256 // C-string values by having the ConstString unique the names in the global
257 // constant C-string pool.
258 count = k_num_register_infos;
259 return g_register_infos;
260}
261
262size_t ABISysV_msp430::GetRedZoneSize() const { return 0; }
263
264//------------------------------------------------------------------
265// Static Functions
266//------------------------------------------------------------------
267
268ABISP
270 const ArchSpec &arch) {
271 if (arch.GetTriple().getArch() == llvm::Triple::msp430) {
272 return ABISP(
273 new ABISysV_msp430(std::move(process_sp), MakeMCRegisterInfo(arch)));
274 }
275 return ABISP();
276}
277
280 llvm::ArrayRef<addr_t> args) const {
281 // we don't use the traditional trivial call specialized for jit
282 return false;
283}
284
286 ValueList &values) const {
287 return false;
288}
289
291 lldb::ValueObjectSP &new_value_sp) {
292 return Status();
293}
294
296 Thread &thread, CompilerType &return_compiler_type) const {
297 ValueObjectSP return_valobj_sp;
298 return return_valobj_sp;
299}
300
302 Thread &thread, CompilerType &return_compiler_type) const {
303 ValueObjectSP return_valobj_sp;
304 return return_valobj_sp;
305}
306
307// called when we are on the first instruction of a new function
309 unwind_plan.Clear();
311
312 uint32_t sp_reg_num = dwarf_sp;
313 uint32_t pc_reg_num = dwarf_pc;
314
316 row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 2);
317 row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, -2, true);
318 row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true);
319
320 unwind_plan.AppendRow(row);
321 unwind_plan.SetSourceName("msp430 at-func-entry default");
323 return true;
324}
325
327 unwind_plan.Clear();
329
330 uint32_t fp_reg_num = dwarf_fp;
331 uint32_t sp_reg_num = dwarf_sp;
332 uint32_t pc_reg_num = dwarf_pc;
333
335 row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 2);
336 row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, -2, true);
337 row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true);
338 row->SetRegisterLocationToUnspecified(fp_reg_num, true);
339
340 unwind_plan.AppendRow(row);
341 unwind_plan.SetSourceName("msp430 default unwind plan");
344 return true;
345}
346
348 return !RegisterIsCalleeSaved(reg_info);
349}
350
352 int reg = ((reg_info->byte_offset) / 2);
353
354 bool save = (reg >= 4) && (reg <= 10);
355 return save;
356}
357
360 GetPluginNameStatic(), "System V ABI for msp430 targets", CreateInstance);
361}
362
365}
static const uint32_t k_num_register_infos
static const RegisterInfo g_register_infos[]
dwarf_regnums
@ dwarf_pc
@ dwarf_r7
@ dwarf_r12
@ dwarf_r3
@ dwarf_r13
@ dwarf_r2
@ dwarf_r8
@ dwarf_fp
@ dwarf_r11
@ dwarf_r9
@ dwarf_pc
@ dwarf_sp
@ dwarf_r15
@ dwarf_r10
@ dwarf_r14
@ dwarf_r6
@ dwarf_r5
static const uint32_t k_num_register_infos
static const RegisterInfo g_register_infos[]
#define LLDB_PLUGIN_DEFINE_ADV(ClassName, PluginName)
Definition: PluginManager.h:25
lldb::ValueObjectSP GetReturnValueObjectSimple(lldb_private::Thread &thread, lldb_private::CompilerType &ast_type) const
lldb_private::Status SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info)
bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp, lldb::addr_t functionAddress, lldb::addr_t returnAddress, llvm::ArrayRef< lldb::addr_t > args) const override
bool GetArgumentValues(lldb_private::Thread &thread, lldb_private::ValueList &values) const override
static llvm::StringRef GetPluginNameStatic()
bool CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override
bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override
static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch)
lldb::ValueObjectSP GetReturnValueObjectImpl(lldb_private::Thread &thread, lldb_private::CompilerType &type) const override
const lldb_private::RegisterInfo * GetRegisterInfoArray(uint32_t &count) override
size_t GetRedZoneSize() const override
bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override
static void Initialize()
static void Terminate()
static std::unique_ptr< llvm::MCRegisterInfo > MakeMCRegisterInfo(const ArchSpec &arch)
Utility function to construct a MCRegisterInfo using the ArchSpec triple.
Definition: ABI.cpp:234
An architecture specification class.
Definition: ArchSpec.h:31
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:450
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
An error handling class.
Definition: Status.h:44
void SetRegisterKind(lldb::RegisterKind kind)
Definition: UnwindPlan.h:437
void AppendRow(const RowSP &row_sp)
Definition: UnwindPlan.cpp:362
std::shared_ptr< Row > RowSP
Definition: UnwindPlan.h:395
void SetSourcedFromCompiler(lldb_private::LazyBool from_compiler)
Definition: UnwindPlan.h:478
void SetSourceName(const char *)
Definition: UnwindPlan.cpp:564
void SetUnwindPlanValidAtAllInstructions(lldb_private::LazyBool valid_at_all_insn)
Definition: UnwindPlan.h:490
#define LLDB_REGNUM_GENERIC_SP
Definition: lldb-defines.h:57
#define LLDB_INVALID_REGNUM
Definition: lldb-defines.h:87
#define LLDB_REGNUM_GENERIC_PC
Definition: lldb-defines.h:56
#define LLDB_REGNUM_GENERIC_FP
Definition: lldb-defines.h:58
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::ABI > ABISP
Definition: lldb-forward.h:310
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
Definition: lldb-forward.h:412
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:472
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:381
@ eEncodingUint
unsigned integer
uint64_t addr_t
Definition: lldb-types.h:79
@ eRegisterKindDWARF
the register numbers seen DWARF
Every register is described in detail including its name, alternate name (optional),...
uint32_t byte_offset
The byte offset in the register context data where this register's value is found.