• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     bool            GetRegisterValue (nub_thread_t tid, uint32_t reg_set_idx, uint32_t reg_idx, DNBRegisterValue *reg_value) const;
30     bool            SetRegisterValue (nub_thread_t tid, uint32_t reg_set_idx, uint32_t reg_idx, const DNBRegisterValue *reg_value) const;
31     nub_size_t      GetRegisterContext (nub_thread_t tid, void *buf, size_t buf_len);
32     nub_size_t      SetRegisterContext (nub_thread_t tid, const void *buf, size_t buf_len);
33     const char *    GetThreadInfo (nub_thread_t tid) const;
34     void            ProcessWillResume (MachProcess *process, const DNBThreadResumeActions &thread_actions);
35     uint32_t        ProcessDidStop (MachProcess *process);
36     bool            NotifyException (MachException::Data& exc);
37     bool            ShouldStop (bool &step_more);
38     const char *    GetName (nub_thread_t tid);
39     nub_state_t     GetState (nub_thread_t tid);
40     nub_thread_t    SetCurrentThread (nub_thread_t tid);
41     bool            GetThreadStoppedReason (nub_thread_t tid, struct DNBThreadStopInfo *stop_info) const;
42     void            DumpThreadStoppedReason (nub_thread_t tid) const;
43     bool            GetIdentifierInfo (nub_thread_t tid, thread_identifier_info_data_t *ident_info);
44     nub_size_t      NumThreads () const;
45     nub_thread_t    ThreadIDAtIndex (nub_size_t idx) const;
46     nub_thread_t    CurrentThreadID ();
47     void            CurrentThread (MachThreadSP& threadSP);
48     void            NotifyBreakpointChanged (const DNBBreakpoint *bp);
49     uint32_t        EnableHardwareBreakpoint (const DNBBreakpoint *bp) const;
50     bool            DisableHardwareBreakpoint (const DNBBreakpoint *bp) const;
51     uint32_t        EnableHardwareWatchpoint (const DNBBreakpoint *wp) const;
52     bool            DisableHardwareWatchpoint (const DNBBreakpoint *wp) const;
53     uint32_t        NumSupportedHardwareWatchpoints () const;
54 
55     uint32_t        GetThreadIndexForThreadStoppedWithSignal (const int signo) const;
56 
57     MachThreadSP    GetThreadByID (nub_thread_t tid) const;
58 
59     MachThreadSP    GetThreadByMachPortNumber (thread_t mach_port_number) const;
60     nub_thread_t    GetThreadIDByMachPortNumber (thread_t mach_port_number) const;
61     thread_t        GetMachPortNumberByThreadID (nub_thread_t globally_unique_id) const;
62 
63 protected:
64     typedef std::vector<MachThreadSP>   collection;
65     typedef collection::iterator        iterator;
66     typedef collection::const_iterator  const_iterator;
67 
68     uint32_t        UpdateThreadList (MachProcess *process, bool update, collection *num_threads = NULL);
69 //  const_iterator  FindThreadByID (thread_t tid) const;
70 
71     collection      m_threads;
72     mutable PThreadMutex m_threads_mutex;
73     MachThreadSP    m_current_thread;
74 };
75 
76 #endif // #ifndef __MachThreadList_h__
77 
78