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"
18 #include "lldb/Utility/Log.h"
19 
20 #include <memory>
21 
22 using namespace lldb;
23 using namespace lldb_private;
24 
25 // Constructor
26 
27 HistoryThread::HistoryThread(lldb_private::Process &process, lldb::tid_t tid,
28  std::vector<lldb::addr_t> pcs,
29  bool pcs_are_call_addresses)
30  : Thread(process, tid, true), m_framelist_mutex(), m_framelist(),
31  m_pcs(pcs), m_extended_unwind_token(LLDB_INVALID_ADDRESS), m_queue_name(),
32  m_thread_name(), m_originating_unique_thread_id(tid),
33  m_queue_id(LLDB_INVALID_QUEUE_ID) {
35  std::make_unique<HistoryUnwind>(*this, pcs, pcs_are_call_addresses);
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());
46  DestroyThread();
47 }
48 
49 lldb::RegisterContextSP HistoryThread::GetRegisterContext() {
50  RegisterContextSP rctx;
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 
58 lldb::RegisterContextSP
60  return m_unwinder_up->CreateRegisterContextForFrame(frame);
61 }
62 
63 lldb::StackFrameListSP HistoryThread::GetStackFrameList() {
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) {
68  m_framelist =
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 }
lldb_private::HistoryThread::GetRegisterContext
lldb::RegisterContextSP GetRegisterContext() override
Definition: HistoryThread.cpp:49
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:249
lldb_private::Process
Definition: Process.h:342
HistoryThread.h
Process.h
lldb_private::Thread::GetProcess
lldb::ProcessSP GetProcess() const
Definition: Thread.h:154
lldb_private::Thread::DestroyThread
virtual void DestroyThread()
Definition: Thread.cpp:248
lldb_private::HistoryThread::m_originating_unique_thread_id
lldb::tid_t m_originating_unique_thread_id
Definition: HistoryThread.h:86
lldb_private::HistoryThread::~HistoryThread
~HistoryThread() override
Definition: HistoryThread.cpp:42
lldb_private::HistoryThread::GetExtendedBacktraceOriginatingIndexID
uint32_t GetExtendedBacktraceOriginatingIndexID() override
Definition: HistoryThread.cpp:75
Log.h
lldb_private::Thread
Definition: Thread.h:62
StackFrameList.h
lldb_private::HistoryThread::CreateRegisterContextForFrame
lldb::RegisterContextSP CreateRegisterContextForFrame(StackFrame *frame) override
Definition: HistoryThread.cpp:59
lldb_private::GetLogIfAllCategoriesSet
Log * GetLogIfAllCategoriesSet(uint32_t mask)
Definition: Logging.cpp:58
lldb_private::Thread::m_unwinder_up
std::unique_ptr< lldb_private::Unwind > m_unwinder_up
It gets set in Thread::ShouldResume.
Definition: Thread.h:1270
LLDB_INVALID_QUEUE_ID
#define LLDB_INVALID_QUEUE_ID
Definition: lldb-defines.h:100
lldb_private::UserID::GetID
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47
lldb-private.h
LIBLLDB_LOG_OBJECT
#define LIBLLDB_LOG_OBJECT
Definition: Logging.h:25
uint32_t
lldb_private::HistoryThread::m_pcs
std::vector< lldb::addr_t > m_pcs
Definition: HistoryThread.h:81
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:86
lldb_private::HistoryThread::GetStackFrameList
virtual lldb::StackFrameListSP GetStackFrameList()
Definition: HistoryThread.cpp:63
lldb_private::HistoryThread::m_framelist
lldb::StackFrameListSP m_framelist
Definition: HistoryThread.h:80
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
LLDB_INVALID_THREAD_ID
#define LLDB_INVALID_THREAD_ID
Definition: lldb-defines.h:94
lldb_private::Log
Definition: Log.h:49
HistoryUnwind.h
lldb_private::HistoryThread::m_framelist_mutex
std::mutex m_framelist_mutex
Definition: HistoryThread.h:79
lldb_private::StackFrame
Definition: StackFrame.h:40
lldb
Definition: SBAddress.h:15
RegisterContextHistory.h
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86