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

« back to all changes in this revision

Viewing changes to contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.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:
43
43
                public int max_il_offset;
44
44
                public int[] il_offsets;
45
45
                public int[] line_numbers;
 
46
                public int[] column_numbers;
46
47
                public SourceInfo[] source_files;
47
48
        }
48
49
 
79
80
 
80
81
        class MethodBodyInfo {
81
82
                public byte[] il;
 
83
                public ExceptionClauseInfo[] clauses;
 
84
        }
 
85
 
 
86
        struct ExceptionClauseInfo {
 
87
                public ExceptionClauseFlags flags;
 
88
                public int try_offset;
 
89
                public int try_length;
 
90
                public int handler_offset;
 
91
                public int handler_length;
 
92
                public int filter_offset;
 
93
                public long catch_type_id;
 
94
        }
 
95
 
 
96
        enum ExceptionClauseFlags {
 
97
                None = 0x0,
 
98
                Filter = 0x1,
 
99
                Finally = 0x2,
 
100
                Fault = 0x4,
82
101
        }
83
102
 
84
103
        struct ParamInfo {
376
395
                 * with newer runtimes, and vice versa.
377
396
                 */
378
397
                internal const int MAJOR_VERSION = 2;
379
 
                internal const int MINOR_VERSION = 17;
 
398
                internal const int MINOR_VERSION = 23;
380
399
 
381
400
                enum WPSuspendPolicy {
382
401
                        NONE = 0,
443
462
                        ABORT_INVOKE = 9,
444
463
                        SET_KEEPALIVE = 10,
445
464
                        GET_TYPES_FOR_SOURCE_FILE = 11,
446
 
                        GET_TYPES = 12
 
465
                        GET_TYPES = 12,
 
466
                        INVOKE_METHODS = 13
447
467
                }
448
468
 
449
469
                enum CmdEvent {
498
518
                        GET_LOCALS_INFO = 5,
499
519
                        GET_INFO = 6,
500
520
                        GET_BODY = 7,
501
 
                        RESOLVE_TOKEN = 8
 
521
                        RESOLVE_TOKEN = 8,
 
522
                        GET_CATTRS = 9
502
523
                }
503
524
 
504
525
                enum CmdType {
520
541
                        GET_VALUES_2 = 14,
521
542
                        CMD_TYPE_GET_METHODS_BY_NAME_FLAGS = 15,
522
543
                        GET_INTERFACES = 16,
523
 
                        GET_INTERFACE_MAP = 17
 
544
                        GET_INTERFACE_MAP = 17,
 
545
                        IS_INITIALIZED = 18
524
546
                }
525
547
 
526
548
                enum BindingFlagsExtensions {
1002
1024
                Thread receiver_thread;
1003
1025
                Dictionary<int, byte[]> reply_packets;
1004
1026
                Dictionary<int, ReplyCallback> reply_cbs;
 
1027
                Dictionary<int, int> reply_cb_counts;
1005
1028
                object reply_packets_monitor;
1006
1029
 
1007
1030
                internal event EventHandler<ErrorHandlerEventArgs> ErrorHandler;
1010
1033
                        closed = false;
1011
1034
                        reply_packets = new Dictionary<int, byte[]> ();
1012
1035
                        reply_cbs = new Dictionary<int, ReplyCallback> ();
 
1036
                        reply_cb_counts = new Dictionary<int, int> ();
1013
1037
                        reply_packets_monitor = new Object ();
1014
1038
                }
1015
1039
                
1052
1076
                        TransportSend (buf, 0, buf.Length);
1053
1077
 
1054
1078
                        receiver_thread = new Thread (new ThreadStart (receiver_thread_main));
 
1079
                        receiver_thread.Name = "SDB Receiver";
 
1080
                        receiver_thread.IsBackground = true;
1055
1081
                        receiver_thread.Start ();
1056
1082
 
1057
1083
                        Version = VM_GetVersion ();
1162
1188
                                                if (cb == null) {
1163
1189
                                                        reply_packets [id] = packet;
1164
1190
                                                        Monitor.PulseAll (reply_packets_monitor);
 
1191
                                                } else {
 
1192
                                                        int c = reply_cb_counts [id];
 
1193
                                                        c --;
 
1194
                                                        if (c == 0) {
 
1195
                                                                reply_cbs.Remove (id);
 
1196
                                                                reply_cb_counts.Remove (id);
 
1197
                                                        }
1165
1198
                                                }
1166
1199
                                        }
1167
1200
 
1349
1382
                }
1350
1383
 
1351
1384
                /* Send a request and call cb when a result is received */
1352
 
                int Send (CommandSet command_set, int command, PacketWriter packet, Action<PacketReader> cb) {
 
1385
                int Send (CommandSet command_set, int command, PacketWriter packet, Action<PacketReader> cb, int count) {
1353
1386
                        int id = IdGenerator;
1354
1387
 
1355
1388
                        Stopwatch watch = null;
1370
1403
                                        PacketReader r = new PacketReader (p);
1371
1404
                                        cb.BeginInvoke (r, null, null);
1372
1405
                                };
 
1406
                                reply_cb_counts [id] = count;
1373
1407
                        }
1374
1408
 
1375
1409
                        WritePacket (encoded_packet);
1562
1596
 
1563
1597
                                                callback (v, exc, 0, state);
1564
1598
                                        }
1565
 
                                });
 
1599
                                }, 1);
 
1600
                }
 
1601
 
 
1602
                internal int VM_BeginInvokeMethods (long thread, long[] methods, ValueImpl this_arg, List<ValueImpl[]> arguments, InvokeFlags flags, InvokeMethodCallback callback, object state) {
 
1603
                        // FIXME: Merge this with INVOKE_METHOD
 
1604
                        var w = new PacketWriter ();
 
1605
                        w.WriteId (thread);
 
1606
                        w.WriteInt ((int)flags);
 
1607
                        w.WriteInt (methods.Length);
 
1608
                        for (int i = 0; i < methods.Length; ++i) {
 
1609
                                w.WriteId (methods [i]);
 
1610
                                w.WriteValue (this_arg);
 
1611
                                w.WriteInt (arguments [i].Length);
 
1612
                                w.WriteValues (arguments [i]);
 
1613
                        }
 
1614
                        return Send (CommandSet.VM, (int)CmdVM.INVOKE_METHODS, w, delegate (PacketReader r) {
 
1615
                                        ValueImpl v, exc;
 
1616
 
 
1617
                                        if (r.ErrorCode != 0) {
 
1618
                                                callback (null, null, (ErrorCode)r.ErrorCode, state);
 
1619
                                        } else {
 
1620
                                                if (r.ReadByte () == 0) {
 
1621
                                                        exc = r.ReadValue ();
 
1622
                                                        v = null;
 
1623
                                                } else {
 
1624
                                                        v = r.ReadValue ();
 
1625
                                                        exc = null;
 
1626
                                                }
 
1627
 
 
1628
                                                callback (v, exc, 0, state);
 
1629
                                        }
 
1630
                                }, methods.Length);
1566
1631
                }
1567
1632
 
1568
1633
                internal void VM_AbortInvoke (long thread, int id)
1672
1737
                        info.il_offsets = new int [n_il_offsets];
1673
1738
                        info.line_numbers = new int [n_il_offsets];
1674
1739
                        info.source_files = new SourceInfo [n_il_offsets];
 
1740
                        info.column_numbers = new int [n_il_offsets];
1675
1741
                        for (int i = 0; i < n_il_offsets; ++i) {
1676
1742
                                info.il_offsets [i] = res.ReadInt ();
1677
1743
                                info.line_numbers [i] = res.ReadInt ();
1681
1747
                                } else {
1682
1748
                                        info.source_files [i] = sources [0];
1683
1749
                                }
 
1750
                                if (Version.AtLeast (2, 19))
 
1751
                                        info.column_numbers [i] = res.ReadInt ();
 
1752
                                else
 
1753
                                        info.column_numbers [i] = 0;
1684
1754
                        }
1685
1755
 
1686
1756
                        return info;
1757
1827
                        for (int i = 0; i < info.il.Length; ++i)
1758
1828
                                info.il [i] = (byte)res.ReadByte ();
1759
1829
 
 
1830
                        if (Version.AtLeast (2, 18)) {
 
1831
                                info.clauses = new ExceptionClauseInfo [res.ReadInt ()];
 
1832
 
 
1833
                                for (int i = 0; i < info.clauses.Length; ++i) {
 
1834
                                        var clause = new ExceptionClauseInfo {
 
1835
                                                flags = (ExceptionClauseFlags) res.ReadInt (),
 
1836
                                                try_offset = res.ReadInt (),
 
1837
                                                try_length = res.ReadInt (),
 
1838
                                                handler_offset = res.ReadInt (),
 
1839
                                                handler_length = res.ReadInt (),
 
1840
                                        };
 
1841
 
 
1842
                                        if (clause.flags == ExceptionClauseFlags.None)
 
1843
                                                clause.catch_type_id = res.ReadId ();
 
1844
                                        else if (clause.flags == ExceptionClauseFlags.Filter)
 
1845
                                                clause.filter_offset = res.ReadInt ();
 
1846
 
 
1847
                                        info.clauses [i] = clause;
 
1848
                                }
 
1849
                        } else
 
1850
                                info.clauses = new ExceptionClauseInfo [0];
 
1851
 
1760
1852
                        return info;
1761
1853
                }
1762
1854
 
1778
1870
                        }
1779
1871
                }
1780
1872
 
 
1873
                internal CattrInfo[] Method_GetCustomAttributes (long id, long attr_type_id, bool inherit) {
 
1874
                        PacketReader r = SendReceive (CommandSet.METHOD, (int)CmdMethod.GET_CATTRS, new PacketWriter ().WriteId (id).WriteId (attr_type_id));
 
1875
                        return ReadCattrs (r);
 
1876
                }
 
1877
 
1781
1878
                /*
1782
1879
                 * THREAD
1783
1880
                 */
2027
2124
                        return res;
2028
2125
                }
2029
2126
 
 
2127
                internal bool Type_IsInitialized (long id) {
 
2128
                        PacketReader r = SendReceive (CommandSet.TYPE, (int)CmdType.IS_INITIALIZED, new PacketWriter ().WriteId (id));
 
2129
                        return r.ReadInt () == 1;
 
2130
                }
 
2131
 
2030
2132
                /*
2031
2133
                 * EVENTS
2032
2134
                 */