~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« back to all changes in this revision

Viewing changes to contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/ThreadMirror.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
using System.Threading;
 
3
 
 
4
namespace Mono.Debugger.Soft
 
5
{
 
6
        public class ThreadMirror : ObjectMirror
 
7
        {
 
8
                string name;
 
9
 
 
10
                internal ThreadMirror (VirtualMachine vm, long id) : base (vm, id) {
 
11
                }
 
12
 
 
13
                // FIXME: Cache, invalidate when the thread/runtime is resumed
 
14
                public StackFrame[] GetFrames () {
 
15
                        FrameInfo[] frame_info = vm.conn.Thread_GetFrameInfo (id, 0, -1);
 
16
 
 
17
                        StackFrame[] frames = new StackFrame [frame_info.Length];
 
18
                        for (int i = 0; i < frame_info.Length; ++i) {
 
19
                                FrameInfo info = (FrameInfo)frame_info [i];
 
20
                                MethodMirror method = vm.GetMethod (info.method);
 
21
                                frames [i] = new StackFrame (vm, info.id, this, method, info.il_offset, info.flags);
 
22
                        }
 
23
 
 
24
                        return frames;
 
25
            }
 
26
 
 
27
                public string Name {
 
28
                        get {
 
29
                                if (name == null)
 
30
                                        name = vm.conn.Thread_GetName (id);
 
31
                                return name;
 
32
                        }
 
33
            }
 
34
 
 
35
                public new long Id {
 
36
                        get {
 
37
                                return id;
 
38
                        }
 
39
                }
 
40
 
 
41
                public ThreadState ThreadState {
 
42
                        get {
 
43
                                return (ThreadState)vm.conn.Thread_GetState (id);
 
44
                        }
 
45
                }
 
46
 
 
47
                public bool IsThreadPoolThread {
 
48
                        get {
 
49
                                ThreadInfo info = vm.conn.Thread_GetInfo (id);
 
50
 
 
51
                                return info.is_thread_pool;
 
52
                        }
 
53
                }
 
54
 
 
55
                /*
 
56
                 * Return a unique identifier for this thread, multiple ThreadMirror objects
 
57
                 * may have the same ThreadId because of appdomains.
 
58
                 */
 
59
                public long ThreadId {
 
60
                        get {
 
61
                                return vm.conn.Thread_GetId (id);
 
62
                        }
 
63
                }
 
64
 
 
65
                /*
 
66
                 * Return the system thread id (TID) for this thread, this id is not unique since
 
67
                 * a newly started thread might reuse a dead thread's id.
 
68
                 */
 
69
                public long TID {
 
70
                        get {
 
71
                                return vm.conn.Thread_GetTID (id);
 
72
                        }
 
73
                }
 
74
    }
 
75
}