LLDB mainline
ThreadMemory.cpp
Go to the documentation of this file.
1//===-- ThreadMemory.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
13#include "lldb/Target/Process.h"
16#include "lldb/Target/Unwind.h"
17
18#include <memory>
19
20using namespace lldb;
21using namespace lldb_private;
22
24 const ValueObjectSP &thread_info_valobj_sp)
25 : Thread(process, tid), m_backing_thread_sp(),
26 m_thread_info_valobj_sp(thread_info_valobj_sp), m_name(), m_queue(),
27 m_register_data_addr(LLDB_INVALID_ADDRESS) {}
28
30 llvm::StringRef name, llvm::StringRef queue,
31 lldb::addr_t register_data_addr)
32 : Thread(process, tid), m_backing_thread_sp(), m_thread_info_valobj_sp(),
33 m_name(std::string(name)), m_queue(std::string(queue)),
34 m_register_data_addr(register_data_addr) {}
35
37
40 m_backing_thread_sp->WillResume(resume_state);
41}
42
45 m_backing_thread_sp->ClearStackFrames();
47}
48
51 m_reg_context_sp = std::make_shared<RegisterContextThreadMemory>(
53 return m_reg_context_sp;
54}
55
56RegisterContextSP
58 uint32_t concrete_frame_idx = 0;
59
60 if (frame)
61 concrete_frame_idx = frame->GetConcreteFrameIndex();
62
63 if (concrete_frame_idx == 0)
64 return GetRegisterContext();
66}
67
70 lldb::StopInfoSP backing_stop_info_sp(
71 m_backing_thread_sp->GetPrivateStopInfo());
72 if (backing_stop_info_sp &&
73 backing_stop_info_sp->IsValidForOperatingSystemThread(*this)) {
74 backing_stop_info_sp->SetThread(shared_from_this());
75 SetStopInfo(backing_stop_info_sp);
76 return true;
77 }
78 } else {
79 ProcessSP process_sp(GetProcess());
80
81 if (process_sp) {
82 OperatingSystem *os = process_sp->GetOperatingSystem();
83 if (os) {
85 return true;
86 }
87 }
88 }
89 return false;
90}
91
94 return m_backing_thread_sp->RefreshStateAfterStop();
95
97 m_reg_context_sp->InvalidateAllRegisters();
98}
lldb::addr_t m_register_data_addr
Definition: ThreadMemory.h:100
lldb::ThreadSP m_backing_thread_sp
Definition: ThreadMemory.h:96
lldb::RegisterContextSP GetRegisterContext() override
void RefreshStateAfterStop() override
lldb::RegisterContextSP CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override
bool CalculateStopInfo() override
~ThreadMemory() override
void WillResume(lldb::StateType resume_state) override
void ClearStackFrames() override
ThreadMemory(lldb_private::Process &process, lldb::tid_t tid, const lldb::ValueObjectSP &thread_info_valobj_sp)
A plug-in interface definition class for halted OS helpers.
virtual lldb::StopInfoSP CreateThreadStopReason(Thread *thread)=0
A plug-in interface definition class for debugging a process.
Definition: Process.h:343
This base class provides an interface to stack frames.
Definition: StackFrame.h:41
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:412
void SetStopInfo(const lldb::StopInfoSP &stop_info_sp)
Definition: Thread.cpp:446
virtual void DestroyThread()
Definition: Thread.cpp:251
virtual void ClearStackFrames()
Definition: Thread.cpp:1434
virtual Unwind & GetUnwinder()
Definition: Thread.cpp:1882
lldb::ProcessSP GetProcess() const
Definition: Thread.h:153
lldb::RegisterContextSP m_reg_context_sp
The register context for this thread's current register state.
Definition: Thread.h:1271
lldb::RegisterContextSP CreateRegisterContextForFrame(StackFrame *frame)
Definition: Unwind.h:56
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Definition: SBAddress.h:15
StateType
Process and Thread States.
uint64_t addr_t
Definition: lldb-types.h:79
uint64_t tid_t
Definition: lldb-types.h:82