LLDB mainline
ThreadFreeBSDKernel.cpp
Go to the documentation of this file.
1//===-- ThreadFreeBSDKernel.cpp -------------------------------------------===//
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
10
11#include "lldb/Target/Unwind.h"
12#include "lldb/Utility/Log.h"
13
21
22using namespace lldb;
23using namespace lldb_private;
24
26 lldb::addr_t pcb_addr,
27 std::string thread_name)
28 : Thread(process, tid), m_thread_name(std::move(thread_name)),
29 m_pcb_addr(pcb_addr) {}
30
32
34
40
43 RegisterContextSP reg_ctx_sp;
44 uint32_t concrete_frame_idx = 0;
45
46 if (frame)
47 concrete_frame_idx = frame->GetConcreteFrameIndex();
48
49 if (concrete_frame_idx == 0) {
52
53 ProcessFreeBSDKernel *process =
54 static_cast<ProcessFreeBSDKernel *>(GetProcess().get());
55 ArchSpec arch = process->GetTarget().GetArchitecture();
56
57 switch (arch.GetMachine()) {
58 case llvm::Triple::aarch64:
60 std::make_shared<RegisterContextFreeBSDKernel_arm64>(
61 *this, std::make_unique<RegisterInfoPOSIX_arm64>(arch, 0),
63 break;
64 case llvm::Triple::x86:
65 m_thread_reg_ctx_sp = std::make_shared<RegisterContextFreeBSDKernel_i386>(
66 *this, new RegisterContextFreeBSD_i386(arch), m_pcb_addr);
67 break;
68 case llvm::Triple::x86_64:
70 std::make_shared<RegisterContextFreeBSDKernel_x86_64>(
72 break;
73 default:
74 assert(false && "Unsupported architecture passed to ThreadFreeBSDKernel");
75 break;
76 }
77
78 reg_ctx_sp = m_thread_reg_ctx_sp;
79 } else {
80 reg_ctx_sp = GetUnwinder().CreateRegisterContextForFrame(frame);
81 }
82 return reg_ctx_sp;
83}
84
lldb::RegisterContextSP m_thread_reg_ctx_sp
lldb::RegisterContextSP CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override
void RefreshStateAfterStop() override
lldb::RegisterContextSP GetRegisterContext() override
bool CalculateStopInfo() override
Ask the thread subclass to set its stop info.
ThreadFreeBSDKernel(lldb_private::Process &process, lldb::tid_t tid, lldb::addr_t pcb_addr, std::string thread_name)
An architecture specification class.
Definition ArchSpec.h:31
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition ArchSpec.cpp:677
A plug-in interface definition class for debugging a process.
Definition Process.h:357
Target & GetTarget()
Get the target object pointer for this module.
Definition Process.h:1270
uint32_t GetConcreteFrameIndex() const
Query this frame to find what frame it is in this Thread's StackFrameList, not counting inlined frame...
Definition StackFrame.h:455
const ArchSpec & GetArchitecture() const
Definition Target.h:1056
virtual Unwind & GetUnwinder()
Definition Thread.cpp:1934
Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id=false)
Constructor.
Definition Thread.cpp:219
lldb::ProcessSP GetProcess() const
Definition Thread.h:158
friend class StackFrame
Definition Thread.h:1303
lldb::RegisterContextSP m_reg_context_sp
The register context for this thread's current register state.
Definition Thread.h:1370
lldb::RegisterContextSP CreateRegisterContextForFrame(StackFrame *frame)
Definition Unwind.h:56
A class that represents a running process on the host machine.
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
uint64_t tid_t
Definition lldb-types.h:84