LLDB mainline
HistoryThread.cpp
Go to the documentation of this file.
1//===-- HistoryThread.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
9#include "lldb/lldb-private.h"
10
12
15
16#include "lldb/Target/Process.h"
19#include "lldb/Utility/Log.h"
20
21#include <memory>
22
23using namespace lldb;
24using namespace lldb_private;
25
26// Constructor
27
29 std::vector<lldb::addr_t> pcs,
30 bool pcs_are_call_addresses)
31 : Thread(process, tid, true), m_framelist_mutex(), m_framelist(),
32 m_pcs(pcs), m_extended_unwind_token(LLDB_INVALID_ADDRESS), m_queue_name(),
33 m_thread_name(), m_originating_unique_thread_id(tid),
34 m_queue_id(LLDB_INVALID_QUEUE_ID) {
36 std::make_unique<HistoryUnwind>(*this, pcs, pcs_are_call_addresses);
38 LLDB_LOGF(log, "%p HistoryThread::HistoryThread", static_cast<void *>(this));
39}
40
41// Destructor
42
45 LLDB_LOGF(log, "%p HistoryThread::~HistoryThread (tid=0x%" PRIx64 ")",
46 static_cast<void *>(this), GetID());
48}
49
52 if (m_pcs.size() > 0) {
53 rctx = std::make_shared<RegisterContextHistory>(
54 *this, 0, GetProcess()->GetAddressByteSize(), m_pcs[0]);
55 }
56 return rctx;
57}
58
61 return m_unwinder_up->CreateRegisterContextForFrame(frame);
62}
63
65 // FIXME do not throw away the lock after we acquire it..
66 std::unique_lock<std::mutex> lock(m_framelist_mutex);
67 lock.unlock();
68 if (m_framelist.get() == nullptr) {
70 std::make_shared<StackFrameList>(*this, StackFrameListSP(), true);
71 }
72
73 return m_framelist;
74}
75
78 if (GetProcess()->HasAssignedIndexIDToThread(
80 return GetProcess()->AssignIndexIDToThread(
82 }
83 }
85}
#define LLDB_LOGF(log,...)
Definition: Log.h:349
lldb::RegisterContextSP GetRegisterContext() override
virtual lldb::StackFrameListSP GetStackFrameList()
uint32_t GetExtendedBacktraceOriginatingIndexID() override
HistoryThread(lldb_private::Process &process, lldb::tid_t tid, std::vector< lldb::addr_t > pcs, bool pcs_are_call_addresses=false)
lldb::RegisterContextSP CreateRegisterContextForFrame(StackFrame *frame) override
std::vector< lldb::addr_t > m_pcs
Definition: HistoryThread.h:81
lldb::tid_t m_originating_unique_thread_id
Definition: HistoryThread.h:86
lldb::StackFrameListSP m_framelist
Definition: HistoryThread.h:80
A plug-in interface definition class for debugging a process.
Definition: Process.h:341
This base class provides an interface to stack frames.
Definition: StackFrame.h:42
virtual void DestroyThread()
Definition: Thread.cpp:245
std::unique_ptr< lldb_private::Unwind > m_unwinder_up
It gets set in Thread::ShouldResume.
Definition: Thread.h:1340
lldb::ProcessSP GetProcess() const
Definition: Thread.h:154
#define LLDB_INVALID_QUEUE_ID
Definition: lldb-defines.h:96
#define LLDB_INVALID_THREAD_ID
Definition: lldb-defines.h:90
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:82
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:314
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
Definition: lldb-forward.h:386
uint64_t tid_t
Definition: lldb-types.h:82
std::shared_ptr< lldb_private::StackFrameList > StackFrameListSP
Definition: lldb-forward.h:414
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47