aboutsummaryrefslogtreecommitdiff
path: root/source/Plugins/Process/Utility/HistoryThread.h
blob: f9a431d8340b9a2e809cecc4eb5fb31ebff3a365 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//===-- HistoryThread.h -----------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef liblldb_HistoryThread_h_
#define liblldb_HistoryThread_h_

#include "lldb/lldb-private.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Event.h"
#include "lldb/Core/UserID.h"
#include "lldb/Core/UserSettingsController.h"
#include "lldb/Target/ExecutionContextScope.h"
#include "lldb/Target/StackFrameList.h"
#include "lldb/Target/Thread.h"

namespace lldb_private {

//----------------------------------------------------------------------
/// @class HistoryThread HistoryThread.h "HistoryThread.h"
/// @brief A thread object representing a backtrace from a previous point in the process execution
///
/// This subclass of Thread is used to provide a backtrace from earlier in
/// process execution.  It is given a backtrace list of pc addresses and 
/// optionally a stop_id of when those pc addresses were collected, and it will
/// create stack frames for them.
//----------------------------------------------------------------------

class HistoryThread : public lldb_private::Thread
{
public:
    HistoryThread (lldb_private::Process &process, lldb::tid_t tid, std::vector<lldb::addr_t> pcs, uint32_t stop_id, bool stop_id_is_valid);

    virtual ~HistoryThread ();

    virtual lldb::RegisterContextSP
    GetRegisterContext ();

    virtual lldb::RegisterContextSP
    CreateRegisterContextForFrame (StackFrame *frame);

    virtual void
    RefreshStateAfterStop() { }

    bool
    CalculateStopInfo () { return false; }

    void 
    SetExtendedBacktraceToken (uint64_t token)
    {
        m_extended_unwind_token = token;
    }

    uint64_t
    GetExtendedBacktraceToken ()
    {
        return m_extended_unwind_token;
    }

    const char *
    GetQueueName ()
    {
        return m_queue_name.c_str();
    }

    void
    SetQueueName (const char *name)
    {
        m_queue_name = name;
    }

    lldb::queue_id_t
    GetQueueID ()
    {
        return m_queue_id;
    }

    void
    SetQueueID (lldb::queue_id_t queue)
    {
        m_queue_id = queue;
    }

    const char *
    GetThreadName ()
    {
        return m_thread_name.c_str();
    }

    uint32_t
    GetExtendedBacktraceOriginatingIndexID ();

    void
    SetThreadName (const char *name)
    {
        m_thread_name = name;
    }

protected:
    virtual lldb::StackFrameListSP
    GetStackFrameList ();

    mutable Mutex               m_framelist_mutex;
    lldb::StackFrameListSP      m_framelist;
    std::vector<lldb::addr_t>   m_pcs;
    uint32_t                    m_stop_id;
    bool                        m_stop_id_is_valid;

    uint64_t                    m_extended_unwind_token;
    std::string                 m_queue_name;
    std::string                 m_thread_name;
    lldb::tid_t                 m_originating_unique_thread_id;
    lldb::queue_id_t            m_queue_id;
};

} // namespace lldb_private

#endif  // liblldb_HistoryThread_h_