LLDB mainline
ThreadFreeBSDKernelCore.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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
12#include "lldb/Target/Unwind.h"
13#include "lldb/Utility/Log.h"
14
28
29using namespace lldb;
30using namespace lldb_private;
31
33 lldb::tid_t tid,
34 lldb::addr_t pcb_addr,
35 std::string thread_name)
36 : Thread(process, tid), m_thread_name(std::move(thread_name)),
37 m_pcb_addr(pcb_addr) {}
38
40
42
48
51 RegisterContextSP reg_ctx_sp;
52 uint32_t concrete_frame_idx = 0;
53
54 if (frame)
55 concrete_frame_idx = frame->GetConcreteFrameIndex();
56
57 if (concrete_frame_idx == 0) {
60
62 static_cast<ProcessFreeBSDKernelCore *>(GetProcess().get());
63 ArchSpec arch = process->GetTarget().GetArchitecture();
64
65 switch (arch.GetMachine()) {
66 case llvm::Triple::aarch64:
68 std::make_shared<RegisterContextFreeBSDKernelCore_arm64>(
69 *this, std::make_unique<RegisterInfo_arm64>(arch, 0), m_pcb_addr);
70 break;
71 case llvm::Triple::arm:
73 std::make_shared<RegisterContextFreeBSDKernelCore_arm>(
74 *this, std::make_unique<RegisterInfo_arm>(arch), m_pcb_addr);
75 break;
76 case llvm::Triple::ppc64le:
78 std::make_shared<RegisterContextFreeBSDKernelCore_ppc64le>(
79 *this, new RegisterInfo_ppc64le(arch), m_pcb_addr);
80 break;
81 case llvm::Triple::riscv64:
83 std::make_shared<RegisterContextFreeBSDKernelCore_riscv64>(
84 *this, std::make_unique<RegisterInfo_riscv64>(arch, 0),
86 break;
87 case llvm::Triple::x86:
89 std::make_shared<RegisterContextFreeBSDKernelCore_i386>(
90 *this, new RegisterInfoFreeBSD_i386(arch), m_pcb_addr);
91 break;
92 case llvm::Triple::x86_64:
94 std::make_shared<RegisterContextFreeBSDKernelCore_x86_64>(
95 *this, new RegisterInfoFreeBSD_x86_64(arch), m_pcb_addr);
96 break;
97 default:
98 assert(false &&
99 "Unsupported architecture passed to ThreadFreeBSDKernelCore");
100 break;
101 }
102
103 reg_ctx_sp = m_thread_reg_ctx_sp;
104 } else {
105 reg_ctx_sp = GetUnwinder().CreateRegisterContextForFrame(frame);
106 }
107 return reg_ctx_sp;
108}
109
111 if (m_is_crashed) {
112 // Set a stop reason for crashing threads only so that they get selected
113 // preferentially.
115 return true;
116 }
117 return false;
118}
lldb::RegisterContextSP m_thread_reg_ctx_sp
ThreadFreeBSDKernelCore(lldb_private::Process &process, lldb::tid_t tid, lldb::addr_t pcb_addr, std::string thread_name)
lldb::RegisterContextSP CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override
bool CalculateStopInfo() override
Ask the thread subclass to set its stop info.
lldb::RegisterContextSP GetRegisterContext() override
An architecture specification class.
Definition ArchSpec.h:32
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition ArchSpec.cpp:702
A plug-in interface definition class for debugging a process.
Definition Process.h:370
Target & GetTarget()
Get the target object pointer for this module.
Definition Process.h:1271
virtual uint32_t GetConcreteFrameIndex()
Query this frame to find what frame it is in this Thread's StackFrameList, not counting inlined frame...
Definition StackFrame.h:492
static lldb::StopInfoSP CreateStopReasonWithException(Thread &thread, const char *description)
const ArchSpec & GetArchitecture() const
Definition Target.h:1337
void SetStopInfo(const lldb::StopInfoSP &stop_info_sp)
Definition Thread.cpp:480
virtual Unwind & GetUnwinder()
Definition Thread.cpp:2264
Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id=false)
Constructor.
Definition Thread.cpp:226
lldb::ProcessSP GetProcess() const
Definition Thread.h:178
friend class StackFrame
Definition Thread.h:1387
lldb::RegisterContextSP m_reg_context_sp
The register context for this thread's current register state.
Definition Thread.h:1452
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:85