1 //===-- MachThreadList.h ----------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //  Created by Greg Clayton on 6/19/07.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef __MachThreadList_h__
15 #define __MachThreadList_h__
16 
17 #include "MachThread.h"
18 
19 class DNBThreadResumeActions;
20 
21 class MachThreadList
22 {
23 public:
24                     MachThreadList ();
25                     ~MachThreadList ();
26 
27     void            Clear ();
28     void            Dump () const;
29     void            GetRegisterState (int flavor, bool force);
30     void            SetRegisterState (int flavor);
31     bool            GetRegisterValue (nub_thread_t tid, uint32_t reg_set_idx, uint32_t reg_idx, DNBRegisterValue *reg_value) const;
32     bool            SetRegisterValue (nub_thread_t tid, uint32_t reg_set_idx, uint32_t reg_idx, const DNBRegisterValue *reg_value) const;
33     nub_size_t      GetRegisterContext (nub_thread_t tid, void *buf, size_t buf_len);
34     nub_size_t      SetRegisterContext (nub_thread_t tid, const void *buf, size_t buf_len);
35     const char *    GetThreadInfo (nub_thread_t tid) const;
36     void            ProcessWillResume (MachProcess *process, const DNBThreadResumeActions &thread_actions);
37     uint32_t        ProcessDidStop (MachProcess *process);
38     bool            NotifyException (MachException::Data& exc);
39     bool            ShouldStop (bool &step_more);
40     const char *    GetName (thread_t tid);
41     nub_state_t     GetState (thread_t tid);
42     nub_thread_t    SetCurrentThread (thread_t tid);
43     bool            GetThreadStoppedReason (nub_thread_t tid, struct DNBThreadStopInfo *stop_info) const;
44     void            DumpThreadStoppedReason (nub_thread_t tid) const;
45     bool            GetIdentifierInfo (nub_thread_t tid, thread_identifier_info_data_t *ident_info);
46     nub_size_t      NumThreads () const;
47     nub_thread_t    ThreadIDAtIndex (nub_size_t idx) const;
48     nub_thread_t    CurrentThreadID ();
49     uint32_t        GetThreadIndexByID (thread_t tid) const;
50     void            CurrentThread (MachThreadSP& threadSP);
51     void            NotifyBreakpointChanged (const DNBBreakpoint *bp);
52     uint32_t        EnableHardwareBreakpoint (const DNBBreakpoint *bp) const;
53     bool            DisableHardwareBreakpoint (const DNBBreakpoint *bp) const;
54     uint32_t        EnableHardwareWatchpoint (const DNBBreakpoint *wp) const;
55     bool            DisableHardwareWatchpoint (const DNBBreakpoint *wp) const;
56     uint32_t        GetThreadIndexForThreadStoppedWithSignal (const int signo) const;
57 
58     MachThread *    GetThreadByID (nub_thread_t tid) const;
59 
60 protected:
61     typedef std::vector<MachThreadSP>   collection;
62     typedef collection::iterator        iterator;
63     typedef collection::const_iterator  const_iterator;
64 
65     uint32_t        UpdateThreadList (MachProcess *process, bool update);
66 //  const_iterator  FindThreadByID (thread_t tid) const;
67 
68     collection      m_threads;
69     PThreadMutex    m_threads_mutex;
70     MachThreadSP    m_current_thread;
71 };
72 
73 #endif // #ifndef __MachThreadList_h__
74 
75