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<RegisterInfoPOSIX_arm64>(arch, 0),
71 break;
72 case llvm::Triple::arm:
74 std::make_shared<RegisterContextFreeBSDKernelCore_arm>(
75 *this, std::make_unique<RegisterInfoPOSIX_arm>(arch), m_pcb_addr);
76 break;
77 case llvm::Triple::ppc64le:
79 std::make_shared<RegisterContextFreeBSDKernelCore_ppc64le>(
80 *this, new RegisterInfoPOSIX_ppc64le(arch), m_pcb_addr);
81 break;
82 case llvm::Triple::riscv64:
84 std::make_shared<RegisterContextFreeBSDKernelCore_riscv64>(
85 *this, std::make_unique<RegisterInfoPOSIX_riscv64>(arch, 0),
87 break;
88 case llvm::Triple::x86:
90 std::make_shared<RegisterContextFreeBSDKernelCore_i386>(
91 *this, new RegisterContextFreeBSD_i386(arch), m_pcb_addr);
92 break;
93 case llvm::Triple::x86_64:
95 std::make_shared<RegisterContextFreeBSDKernelCore_x86_64>(
97 break;
98 default:
99 assert(false &&
100 "Unsupported architecture passed to ThreadFreeBSDKernelCore");
101 break;
102 }
103
104 reg_ctx_sp = m_thread_reg_ctx_sp;
105 } else {
106 reg_ctx_sp = GetUnwinder().CreateRegisterContextForFrame(frame);
107 }
108 return reg_ctx_sp;
109}
110
112 if (m_is_crashed) {
113 // Set a stop reason for crashing threads only so that they get selected
114 // preferentially.
116 return true;
117 }
118 return false;
119}
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:673
A plug-in interface definition class for debugging a process.
Definition Process.h:354
Target & GetTarget()
Get the target object pointer for this module.
Definition Process.h:1250
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:470
static lldb::StopInfoSP CreateStopReasonWithException(Thread &thread, const char *description)
const ArchSpec & GetArchitecture() const
Definition Target.h:1182
void SetStopInfo(const lldb::StopInfoSP &stop_info_sp)
Definition Thread.cpp:474
virtual Unwind & GetUnwinder()
Definition Thread.cpp:2121
Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id=false)
Constructor.
Definition Thread.cpp:225
lldb::ProcessSP GetProcess() const
Definition Thread.h:160
friend class StackFrame
Definition Thread.h:1323
lldb::RegisterContextSP m_reg_context_sp
The register context for this thread's current register state.
Definition Thread.h:1388
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