View | Details | Raw Unified | Return to bug 6110
Collapse All | Expand All

(-)b/extras/MonoDevelop.Debugger.Gdb/GdbBacktrace.cs (+8 lines)
Lines 240-245 namespace MonoDevelop.Debugger.Gdb Link Here
240
			return val;
240
			return val;
241
		}
241
		}
242
242
243
		public bool HasChildren (ObjectPath path, EvaluationOptions options)
244
		{
245
			session.SelectThread (threadId);
246
			GdbCommandResult res = session.RunCommand ("-var-info-num-children", path.Join ("."));
247
248
			return res.GetInt ("numchild") > 0;
249
		}
250
243
		public ObjectValue[] GetChildren (ObjectPath path, int index, int count, EvaluationOptions options)
251
		public ObjectValue[] GetChildren (ObjectPath path, int index, int count, EvaluationOptions options)
244
		{
252
		{
245
			List<ObjectValue> children = new List<ObjectValue> ();
253
			List<ObjectValue> children = new List<ObjectValue> ();
(-)b/main/src/core/Mono.Debugging/Mono.Debugging.Backend/IObjectValueSource.cs (+1 lines)
Lines 33-38 namespace Mono.Debugging.Backend Link Here
33
{
33
{
34
	public interface IObjectValueSource
34
	public interface IObjectValueSource
35
	{
35
	{
36
		bool HasChildren (ObjectPath path, EvaluationOptions options);
36
		ObjectValue[] GetChildren (ObjectPath path, int index, int count, EvaluationOptions options);
37
		ObjectValue[] GetChildren (ObjectPath path, int index, int count, EvaluationOptions options);
37
		EvaluationResult SetValue (ObjectPath path, string value, EvaluationOptions options);
38
		EvaluationResult SetValue (ObjectPath path, string value, EvaluationOptions options);
38
		ObjectValue GetValue (ObjectPath path, EvaluationOptions options);
39
		ObjectValue GetValue (ObjectPath path, EvaluationOptions options);
(-)b/main/src/core/Mono.Debugging/Mono.Debugging.Client/ObjectValue.cs (-1 / +1 lines)
Lines 402-408 namespace Mono.Debugging.Client Link Here
402
				else if (IsArray)
402
				else if (IsArray)
403
					return arrayCount > 0;
403
					return arrayCount > 0;
404
				else if (IsObject)
404
				else if (IsObject)
405
					return true;
405
					return source.HasChildren (path, parentFrame.DebuggerSession.EvaluationOptions);
406
				else
406
				else
407
					return false;
407
					return false;
408
			}
408
			}
(-)b/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/ArrayElementGroup.cs (+19 lines)
Lines 93-98 namespace Mono.Debugging.Evaluation Link Here
93
			return res;
93
			return res;
94
		}
94
		}
95
95
96
		public bool HasChildren (EvaluationOptions options)
97
		{
98
			return HasChildren (new ObjectPath ("this"), options);
99
		}
100
101
		public bool HasChildren (ObjectPath path, EvaluationOptions options)
102
		{
103
			EvaluationContext cctx = ctx.WithOptions (options);
104
105
			if (path.Length > 1) {
106
				// Looking for children of an array element
107
				int[] idx = StringToIndices (path [1]);
108
				object obj = array.GetElement (idx);
109
				return cctx.Adapter.ObjectValueHasChildren (cctx, new ArrayObjectSource (array, path[1]), obj);
110
			}
111
112
			return true;
113
		}
114
96
		public ObjectValue[] GetChildren (EvaluationOptions options)
115
		public ObjectValue[] GetChildren (EvaluationOptions options)
97
		{
116
		{
98
			return GetChildren (new ObjectPath ("this"), -1, -1, options);
117
			return GetChildren (new ObjectPath ("this"), -1, -1, options);
(-)b/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/BaseTypeViewSource.cs (+5 lines)
Lines 57-62 namespace Mono.Debugging.Evaluation Link Here
57
		}
57
		}
58
		
58
		
59
		#region IObjectValueSource implementation
59
		#region IObjectValueSource implementation
60
		public bool HasChildren (ObjectPath path, EvaluationOptions options)
61
		{
62
			EvaluationContext cctx = ctx.WithOptions (options);
63
			return cctx.Adapter.ObjectValueHasChildren (cctx, objectSource, type, obj, false);
64
		}
60
65
61
		public ObjectValue[] GetChildren (ObjectPath path, int index, int count, EvaluationOptions options)
66
		public ObjectValue[] GetChildren (ObjectPath path, int index, int count, EvaluationOptions options)
62
		{
67
		{
(-)b/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/EvaluationContext.cs (+5 lines)
Lines 114-119 namespace Mono.Debugging.Evaluation Link Here
114
			this.ctx = ctx;
114
			this.ctx = ctx;
115
			Connect ();
115
			Connect ();
116
		}
116
		}
117
118
		public bool HasChildren (ObjectPath path, EvaluationOptions options)
119
		{
120
			return false;
121
		}
117
		
122
		
118
		public ObjectValue[] GetChildren (ObjectPath path, int index, int count, EvaluationOptions options)
123
		public ObjectValue[] GetChildren (ObjectPath path, int index, int count, EvaluationOptions options)
119
		{
124
		{
(-)b/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/FilteredMembersSource.cs (+26 lines)
Lines 72-77 namespace Mono.Debugging.Evaluation Link Here
72
			return val;
72
			return val;
73
		}
73
		}
74
74
75
		public bool HasChildren (ObjectPath path, EvaluationOptions options)
76
		{
77
			EvaluationContext cctx = ctx.WithOptions (options);
78
			TypeDisplayData tdata = null;
79
			object tdataType = null;
80
81
			foreach (ValueReference val in cctx.Adapter.GetMembersSorted (cctx, objectSource, type, obj, bindingFlags)) {
82
				object decType = val.DeclaringType;
83
				if (decType != null && decType != tdataType) {
84
					tdataType = decType;
85
					tdata = cctx.Adapter.GetTypeDisplayData (cctx, decType);
86
				}
87
88
				DebuggerBrowsableState state = tdata.GetMemberBrowsableState (val.Name);
89
				if (state == DebuggerBrowsableState.Never)
90
					continue;
91
92
				return true;
93
			}
94
			
95
			if ((bindingFlags & BindingFlags.NonPublic) == 0)
96
				return true;
97
98
			return false;
99
		}
100
75
		public ObjectValue[] GetChildren (ObjectPath path, int index, int count, EvaluationOptions options)
101
		public ObjectValue[] GetChildren (ObjectPath path, int index, int count, EvaluationOptions options)
76
		{
102
		{
77
			EvaluationContext cctx = ctx.WithOptions (options);
103
			EvaluationContext cctx = ctx.WithOptions (options);
(-)b/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/NamespaceValueReference.cs (+5 lines)
Lines 98-103 namespace Mono.Debugging.Evaluation Link Here
98
			return new NamespaceValueReference (ctx, newNs);
98
			return new NamespaceValueReference (ctx, newNs);
99
		}
99
		}
100
100
101
		public override bool HasChildren (ObjectPath path, EvaluationOptions options)
102
		{
103
			return true;
104
		}
105
101
		public override ObjectValue[] GetChildren (ObjectPath path, int index, int count, EvaluationOptions options)
106
		public override ObjectValue[] GetChildren (ObjectPath path, int index, int count, EvaluationOptions options)
102
		{
107
		{
103
			List<ObjectValue> obs = new List<ObjectValue> ();
108
			List<ObjectValue> obs = new List<ObjectValue> ();
(-)b/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/NullValueReference.cs (+5 lines)
Lines 90-95 namespace Mono.Debugging.Evaluation Link Here
90
			return null;
90
			return null;
91
		}
91
		}
92
92
93
		public override bool HasChildren (ObjectPath path, EvaluationOptions options)
94
		{
95
			return false;
96
		}
97
93
		public override ObjectValue[] GetChildren (Mono.Debugging.Client.ObjectPath path, int index, int count, EvaluationOptions options)
98
		public override ObjectValue[] GetChildren (Mono.Debugging.Client.ObjectPath path, int index, int count, EvaluationOptions options)
94
		{
99
		{
95
			return new ObjectValue [0];
100
			return new ObjectValue [0];
(-)b/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/ObjectValueAdaptor.cs (+71 lines)
Lines 397-402 namespace Mono.Debugging.Evaluation Link Here
397
			}
397
			}
398
		}
398
		}
399
399
400
		public bool ObjectValueHasChildren (EvaluationContext ctx, IObjectSource objectSource, object obj)
401
		{
402
			return ObjectValueHasChildren (ctx, objectSource, GetValueType (ctx, obj), obj, true);
403
		}
404
405
		public virtual bool ObjectValueHasChildren (EvaluationContext ctx, IObjectSource objectSource, object type, object obj, bool dereferenceProxy)
406
		{
407
			if (obj is EvaluationResult)
408
				return false;
409
410
			if (IsArray (ctx, obj))
411
				return true;
412
413
			if (IsPrimitive (ctx, obj))
414
				return false;
415
			
416
			// If there is a proxy, it has to show the members of the proxy
417
			object proxy = obj;
418
			if (dereferenceProxy) {
419
				proxy = GetProxyObject (ctx, obj);
420
				if (proxy != obj)
421
					return true;
422
			}
423
424
			bool groupPrivateMembers = ctx.Options.GroupPrivateMembers && (ctx.Options.GroupUserPrivateMembers || IsExternalType (ctx, type));
425
			BindingFlags flattenFlag = ctx.Options.FlattenHierarchy ? (BindingFlags)0 : BindingFlags.DeclaredOnly;
426
			BindingFlags staticFlag = ctx.Options.GroupStaticMembers ? (BindingFlags)0 : BindingFlags.Static;
427
428
			if (ctx.Options.GroupStaticMembers && HasMembers (ctx, type, proxy, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | flattenFlag))
429
				return true;
430
			
431
			if (groupPrivateMembers && HasMembers (ctx, type, proxy, BindingFlags.Instance | BindingFlags.NonPublic | flattenFlag | staticFlag))
432
				return true;
433
			
434
			if (!ctx.Options.FlattenHierarchy) {
435
				object baseType = GetBaseType (ctx, type, false);
436
				if (baseType != null)
437
					return true;
438
			}
439
440
			BindingFlags nonNonPublicFlag = groupPrivateMembers ? (BindingFlags)0 : BindingFlags.NonPublic;
441
			BindingFlags access = BindingFlags.Public | BindingFlags.Instance | flattenFlag | nonNonPublicFlag | staticFlag;
442
			TypeDisplayData tdata = GetTypeDisplayData (ctx, type);
443
444
			// Load all members to a list before creating the object values,
445
			// to avoid problems with objects being invalidated due to evaluations in the target,
446
			List<ValueReference> list = new List<ValueReference> ();
447
			list.AddRange (GetMembersSorted (ctx, objectSource, type, proxy, access));
448
			object tdataType = type;
449
			
450
			foreach (ValueReference val in list) {
451
				try {
452
					object decType = val.DeclaringType;
453
					if (decType != null && decType != tdataType) {
454
						tdataType = decType;
455
						tdata = GetTypeDisplayData (ctx, decType);
456
					}
457
458
					DebuggerBrowsableState state = tdata.GetMemberBrowsableState (val.Name);
459
					if (state == DebuggerBrowsableState.Never)
460
						continue;
461
462
					return true;
463
				} catch (Exception ex) {
464
					ctx.WriteDebuggerError (ex);
465
				}
466
			}
467
468
			return false;
469
		}
470
400
		public ObjectValue[] GetObjectValueChildren (EvaluationContext ctx, IObjectSource objectSource, object obj, int firstItemIndex, int count)
471
		public ObjectValue[] GetObjectValueChildren (EvaluationContext ctx, IObjectSource objectSource, object obj, int firstItemIndex, int count)
401
		{
472
		{
402
			return GetObjectValueChildren (ctx, objectSource, GetValueType (ctx, obj), obj, firstItemIndex, count, true);
473
			return GetObjectValueChildren (ctx, objectSource, GetValueType (ctx, obj), obj, firstItemIndex, count, true);
(-)b/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/RawViewSource.cs (+6 lines)
Lines 53-58 namespace Mono.Debugging.Evaluation Link Here
53
			val.ChildSelector = "";
53
			val.ChildSelector = "";
54
			return val;
54
			return val;
55
		}
55
		}
56
57
		public bool HasChildren (ObjectPath path, EvaluationOptions options)
58
		{
59
			EvaluationContext cctx = ctx.WithOptions (options);
60
			return cctx.Adapter.ObjectValueHasChildren (cctx, objectSource, cctx.Adapter.GetValueType (cctx, obj), obj, false);
61
		}
56
		
62
		
57
		public ObjectValue[] GetChildren (ObjectPath path, int index, int count, EvaluationOptions options)
63
		public ObjectValue[] GetChildren (ObjectPath path, int index, int count, EvaluationOptions options)
58
		{
64
		{
(-)b/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/TypeValueReference.cs (+48 lines)
Lines 120-125 namespace Mono.Debugging.Evaluation Link Here
120
			return null;
120
			return null;
121
		}
121
		}
122
122
123
		public override bool HasChildren (ObjectPath path, EvaluationOptions options)
124
		{
125
			EvaluationContext ctx = GetContext (options);
126
127
			try {
128
				BindingFlags flattenFlag = options.FlattenHierarchy ? (BindingFlags)0 : BindingFlags.DeclaredOnly;
129
				BindingFlags flags = BindingFlags.Static | BindingFlags.Public | flattenFlag;
130
				bool groupPrivateMembers = options.GroupPrivateMembers && (options.GroupUserPrivateMembers || ctx.Adapter.IsExternalType (ctx, type));
131
				if (!groupPrivateMembers)
132
					flags |= BindingFlags.NonPublic;
133
134
				TypeDisplayData tdata = ctx.Adapter.GetTypeDisplayData (ctx, type);
135
				object tdataType = type;
136
				
137
				foreach (ValueReference val in ctx.Adapter.GetMembersSorted (ctx, this, type, null, flags)) {
138
					object decType = val.DeclaringType;
139
					if (decType != null && decType != tdataType) {
140
						tdataType = decType;
141
						tdata = ctx.Adapter.GetTypeDisplayData (ctx, decType);
142
					}
143
144
					DebuggerBrowsableState state = tdata.GetMemberBrowsableState (val.Name);
145
					if (state == DebuggerBrowsableState.Never)
146
						continue;
147
148
					return true;
149
				}
150
151
				if (ctx.Adapter.GetNestedTypes (ctx, type).Count () > 0)
152
					return true;
153
				
154
				if (groupPrivateMembers)
155
					return true;
156
				
157
				if (!options.FlattenHierarchy) {
158
					object baseType = ctx.Adapter.GetBaseType (ctx, type, false);
159
					if (baseType != null)
160
						return true;
161
				}
162
				
163
				return false;
164
			} catch (Exception ex) {
165
				Console.WriteLine (ex);
166
				ctx.WriteDebuggerOutput (ex.Message);
167
				return false;
168
			}
169
		}
170
123
		public override ObjectValue[] GetChildren (ObjectPath path, int index, int count, EvaluationOptions options)
171
		public override ObjectValue[] GetChildren (ObjectPath path, int index, int count, EvaluationOptions options)
124
		{
172
		{
125
			EvaluationContext ctx = GetContext (options);
173
			EvaluationContext ctx = GetContext (options);
(-)b/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/ValueReference.cs (+14 lines)
Lines 185-190 namespace Mono.Debugging.Evaluation Link Here
185
			Value = ctx.Adapter.FromRawValue (GetContext (options), value);
185
			Value = ctx.Adapter.FromRawValue (GetContext (options), value);
186
		}
186
		}
187
187
188
		bool IObjectValueSource.HasChildren (ObjectPath path, EvaluationOptions options)
189
		{
190
			return HasChildren (path, options);
191
		}
192
188
		ObjectValue[] IObjectValueSource.GetChildren (ObjectPath path, int index, int count, EvaluationOptions options)
193
		ObjectValue[] IObjectValueSource.GetChildren (ObjectPath path, int index, int count, EvaluationOptions options)
189
		{
194
		{
190
			return GetChildren (path, index, count, options);
195
			return GetChildren (path, index, count, options);
Lines 195-200 namespace Mono.Debugging.Evaluation Link Here
195
			return ctx.Adapter.CallToString (ctx, Value);
200
			return ctx.Adapter.CallToString (ctx, Value);
196
		}
201
		}
197
202
203
		public virtual bool HasChildren (ObjectPath path, EvaluationOptions options)
204
		{
205
			try {
206
				return ctx.Adapter.ObjectValueHasChildren (GetChildrenContext (options), this, Value);
207
			} catch {
208
				return false;
209
			}
210
		}
211
198
		public virtual ObjectValue[] GetChildren (ObjectPath path, int index, int count, EvaluationOptions options)
212
		public virtual ObjectValue[] GetChildren (ObjectPath path, int index, int count, EvaluationOptions options)
199
		{
213
		{
200
			try {
214
			try {

Return to bug 6110