blob: 0666b75d4afe0772ef9a384c070164625554f6fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "ThreadWasm.h"
#include "ProcessWasm.h"
#include "RegisterContextWasm.h"
#include "UnwindWasm.h"
#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::wasm;
Unwind &ThreadWasm::GetUnwinder() {
if (!m_unwinder_up) {
assert(CalculateTarget()->GetArchitecture().GetMachine() ==
llvm::Triple::wasm32);
m_unwinder_up.reset(new wasm::UnwindWasm(*this));
}
return *m_unwinder_up;
}
llvm::Expected<std::vector<lldb::addr_t>> ThreadWasm::GetWasmCallStack() {
if (ProcessSP process_sp = GetProcess()) {
ProcessWasm *wasm_process = static_cast<ProcessWasm *>(process_sp.get());
return wasm_process->GetWasmCallStack(GetID());
}
return llvm::createStringError("no process");
}
lldb::RegisterContextSP
ThreadWasm::CreateRegisterContextForFrame(StackFrame *frame) {
uint32_t concrete_frame_idx = 0;
ProcessSP process_sp(GetProcess());
ProcessWasm *wasm_process = static_cast<ProcessWasm *>(process_sp.get());
if (frame)
concrete_frame_idx = frame->GetConcreteFrameIndex();
if (concrete_frame_idx == 0)
return std::make_shared<RegisterContextWasm>(
*this, concrete_frame_idx, wasm_process->GetRegisterInfo());
return GetUnwinder().CreateRegisterContextForFrame(frame);
}
|