File: AddressDomain.cs

package info (click to toggle)
mono-debugger 0.60%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 9,556 kB
  • ctags: 22,787
  • sloc: ansic: 99,407; cs: 42,429; sh: 9,192; makefile: 376
file content (93 lines) | stat: -rw-r--r-- 2,360 bytes parent folder | download | duplicates (2)
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
using System;

namespace Mono.Debugger
{
	// <summary>
	//   This is the "domain" of a TargetAddress - you cannot compare addresses from
	//   different domains.  See TargetAddress.cs for details.
	//
	//   The debugger has the following address domains:
	//
	//   * the global address domain
	//
	//     This is used to do symbol lookups and to store addresses which are independent
	//     from the execution of a particular thread.
	//
	//   * the local address domain
	//
	//     Each thread has its own local address domain.  Technically, all threads share
	//     the same memory space, but this is to enforce the policy that you may not share
	//     any information about variables across thread boundaries.
	//
	//   * the frame address domain
	//
	//     Each stack frame has its own address domain (which is only constructed when it's
	//     actually used) which has the same lifetime than its corresponding frame.
	//
	//     This is normally used when reading an address from the stack or from a register,
	//     for instance the address of a variable which is stored on the stack.  Since the
	//     object such an address is pointing to becomes invalid when the target leaves the
	//     stack frame, the address will also become invalid.
	//
	// </summary>
	[Serializable]
	public struct AddressDomain : IComparable
	{
		// <summary>
		//   `name' is just used in the error messages.
		// </summary>
		public AddressDomain (string name, int id)
		{
			this.id = id;
			this.name = name;
		}

		public static readonly AddressDomain Global = new AddressDomain ("global", 0);

		int id;
		string name;

		public int ID {
			get { return id; }
		}

		public string Name {
			get { return name; }
		}

		public bool IsGlobal {
			get { return (id == 0) && (name == "global"); }
		}

		public int CompareTo (object obj)
		{
			AddressDomain domain = (AddressDomain) obj;

			if (id < domain.id)
				return -1;
			else if (id > domain.id)
				return 1;
			else
				return 0;
		}

		public override bool Equals (object o)
		{
			if (o == null || !(o is AddressDomain))
				return false;

			AddressDomain b = (AddressDomain) o;
			return (id == b.id) && (name == b.name);
		}

		public override int GetHashCode ()
		{
			return id;
		}

		public override string ToString ()
		{
			return String.Format ("AddressDomain ({0}:{1})", ID, Name);
		}
	}
}