~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
                TypeMirror declaring_type;
15
15
                DebugInfo debug_info;
16
16
                C.MethodDefinition meta;
 
17
                CustomAttributeDataMirror[] cattrs;
17
18
                ParameterInfoMirror[] param_info;
18
19
                ParameterInfoMirror ret_param;
19
20
                LocalVariable[] locals;
72
73
                        }
73
74
                }
74
75
 
 
76
                /*
 
77
                 * Creating the custom attributes themselves could modify the behavior of the
 
78
                 * debuggee, so we return objects similar to the CustomAttributeData objects
 
79
                 * used by the reflection-only functionality on .net.
 
80
                 * Since protocol version 2.21
 
81
                 */
 
82
                public CustomAttributeDataMirror[] GetCustomAttributes (bool inherit) {
 
83
                        return GetCAttrs (null, inherit);
 
84
                }
 
85
 
 
86
                /* Since protocol version 2.21 */
 
87
                public CustomAttributeDataMirror[] GetCustomAttributes (TypeMirror attributeType, bool inherit) {
 
88
                        if (attributeType == null)
 
89
                                throw new ArgumentNullException ("attributeType");
 
90
                        return GetCAttrs (attributeType, inherit);
 
91
                }
 
92
 
 
93
                CustomAttributeDataMirror[] GetCAttrs (TypeMirror type, bool inherit) {
 
94
                        if (cattrs == null && meta != null && !Metadata.HasCustomAttributes)
 
95
                                cattrs = new CustomAttributeDataMirror [0];
 
96
 
 
97
                        // FIXME: Handle inherit
 
98
                        if (cattrs == null) {
 
99
                                CattrInfo[] info = vm.conn.Method_GetCustomAttributes (id, 0, false);
 
100
                                cattrs = CustomAttributeDataMirror.Create (vm, info);
 
101
                        }
 
102
                        var res = new List<CustomAttributeDataMirror> ();
 
103
                        foreach (var attr in cattrs)
 
104
                                if (type == null || attr.Constructor.DeclaringType == type)
 
105
                                        res.Add (attr);
 
106
                        return res.ToArray ();
 
107
                }
 
108
 
75
109
                MethodInfo GetInfo () {
76
110
                        if (info == null)
77
111
                                info = vm.conn.Method_GetInfo (id);
206
240
 
207
241
                public LocalVariable[] GetLocals () {
208
242
                        if (locals == null) {
209
 
 
210
243
                                LocalsInfo li = new LocalsInfo ();
211
244
                                try {
212
245
                                        li = vm.conn.Method_GetLocalsInfo (id);
213
246
                                } catch (CommandException) {
214
 
                                        throw new ArgumentException ("Method doesn't have a body.");
 
247
                                        throw new AbsentInformationException ();
215
248
                                }
 
249
 
216
250
                                // Add the arguments as well
217
251
                                var pi = vm.conn.Method_GetParamInfo (id);
218
252
 
249
283
                        if (body == null) {
250
284
                                MethodBodyInfo info = vm.conn.Method_GetBody (id);
251
285
 
252
 
                                body = new MethodBodyMirror (vm, this, info.il);
 
286
                                body = new MethodBodyMirror (vm, this, info);
253
287
                        }
254
288
                        return body;
255
289
                }
303
337
                                        var line_numbers = LineNumbers;
304
338
                                        IList<Location> res = new Location [ILOffsets.Count];
305
339
                                        for (int i = 0; i < il_offsets.Count; ++i)
306
 
                                                res [i] = new Location (vm, this, -1, il_offsets [i], debug_info.source_files [i].source_file, line_numbers [i], 0, debug_info.source_files [i].hash);
 
340
                                                res [i] = new Location (vm, this, -1, il_offsets [i], debug_info.source_files [i].source_file, line_numbers [i], debug_info.column_numbers [i], debug_info.source_files [i].hash);
307
341
                                        locations = res;
308
342
                                }
309
343
                                return locations;
310
344
                        }
311
345
                }                               
312
346
 
313
 
                internal int il_offset_to_line_number (int il_offset, out string src_file, out byte[] src_hash) {
 
347
                internal int il_offset_to_line_number (int il_offset, out string src_file, out byte[] src_hash, out int column_number) {
314
348
                        if (debug_info == null)
315
349
                                debug_info = vm.conn.Method_GetDebugInfo (id);
316
350
 
317
351
                        // FIXME: Optimize this
318
352
                        src_file = null;
319
353
                        src_hash = null;
 
354
                        column_number = 0;
320
355
                        for (int i = debug_info.il_offsets.Length - 1; i >= 0; --i) {
321
356
                                if (debug_info.il_offsets [i] <= il_offset) {
322
357
                                        src_file = debug_info.source_files [i].source_file;
323
358
                                        src_hash = debug_info.source_files [i].hash;
 
359
                                        column_number = debug_info.column_numbers [i];
324
360
                                        return debug_info.line_numbers [i];
325
361
                                }
326
362
                        }