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 HistoryPCType pc_type)
31 : Thread(process, tid, true), m_framelist_mutex(), m_framelist(),
35 m_unwinder_up = std::make_unique<HistoryUnwind>(*this, pcs, pc_type);
37 LLDB_LOGF(log, "%p HistoryThread::HistoryThread", static_cast<void *>(this));
38}
39
40// Destructor
41
44 LLDB_LOGF(log, "%p HistoryThread::~HistoryThread (tid=0x%" PRIx64 ")",
45 static_cast<void *>(this), GetID());
47}
48
51 if (m_pcs.size() > 0) {
52 rctx = std::make_shared<RegisterContextHistory>(
53 *this, 0, GetProcess()->GetAddressByteSize(), m_pcs[0]);
54 }
55 return rctx;
56}
57
60 return m_unwinder_up->CreateRegisterContextForFrame(frame);
61}
62
64 // FIXME do not throw away the lock after we acquire it..
65 std::unique_lock<std::mutex> lock(m_framelist_mutex);
66 lock.unlock();
67 if (m_framelist.get() == nullptr) {
69 std::make_shared<StackFrameList>(*this, StackFrameListSP(), true);
70 }
71
72 return m_framelist;
73}
74
77 if (GetProcess()->HasAssignedIndexIDToThread(
79 return GetProcess()->AssignIndexIDToThread(
81 }
82 }
84}
#define LLDB_LOGF(log,...)
Definition Log.h:376
lldb::queue_id_t m_queue_id
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, HistoryPCType pc_type=HistoryPCType::Returns)
lldb::RegisterContextSP CreateRegisterContextForFrame(StackFrame *frame) override
std::vector< lldb::addr_t > m_pcs
lldb::tid_t m_originating_unique_thread_id
lldb::StackFrameListSP m_framelist
A plug-in interface definition class for debugging a process.
Definition Process.h:357
virtual void DestroyThread()
Definition Thread.cpp:252
Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id=false)
Constructor.
Definition Thread.cpp:219
std::unique_ptr< lldb_private::Unwind > m_unwinder_up
It gets set in Thread::ShouldResume.
Definition Thread.h:1394
lldb::ProcessSP GetProcess() const
Definition Thread.h:158
friend class StackFrame
Definition Thread.h:1303
#define LLDB_INVALID_QUEUE_ID
#define LLDB_INVALID_THREAD_ID
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition Log.h:332
HistoryPCType
Specifies the type of PCs when creating a HistoryThread.
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
uint64_t tid_t
Definition lldb-types.h:84
std::shared_ptr< lldb_private::StackFrameList > StackFrameListSP
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition UserID.h:47