Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Krüger <mkrueger@xamarin.com>2011-10-26 15:57:32 +0400
committerMike Krüger <mkrueger@xamarin.com>2011-10-26 15:57:32 +0400
commit5ba64e4f967e49c0ddc96179fe919a0837463e27 (patch)
tree284278e01c75bd78f6054e39ae5bead0bc7f7cb2 /main/contrib
parent6cf6e34954b32247d8970a0712e1a12cebe4b52d (diff)
parent21ad778ec4c166c9e06218ccc173a547c2c0f6ec (diff)
Merge branch 'master' into newresolver
Conflicts: main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpTextEditorCompletion.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/MemberCompletionData.cs main/src/addins/MonoDevelop.MacDev/ObjCIntegration/NSObjectInfoService.cs
Diffstat (limited to 'main/contrib')
-rw-r--r--main/contrib/Mono.Debugger.Soft/Makefile.am1
-rw-r--r--main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft.csproj1
-rw-r--r--main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/ArrayMirror.cs3
-rw-r--r--main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs195
-rw-r--r--main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/CustomAttributeDataMirror.cs2
-rw-r--r--main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/FieldInfoMirror.cs22
-rw-r--r--main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/ObjectMirror.cs29
-rw-r--r--main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/PropertyInfoMirror.cs22
-rw-r--r--main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/StringMirror.cs3
-rw-r--r--main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/ThreadMirror.cs8
-rw-r--r--main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/TypeLoadEventRequest.cs43
-rw-r--r--main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/TypeMirror.cs34
-rw-r--r--main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs55
13 files changed, 391 insertions, 27 deletions
diff --git a/main/contrib/Mono.Debugger.Soft/Makefile.am b/main/contrib/Mono.Debugger.Soft/Makefile.am
index 4eb69719b0..e32fc147c2 100644
--- a/main/contrib/Mono.Debugger.Soft/Makefile.am
+++ b/main/contrib/Mono.Debugger.Soft/Makefile.am
@@ -67,6 +67,7 @@ FILES = \
Mono.Debugger.Soft/ThreadMirror.cs \
Mono.Debugger.Soft/ThreadStartEvent.cs \
Mono.Debugger.Soft/TypeLoadEvent.cs \
+ Mono.Debugger.Soft/TypeLoadEventRequest.cs \
Mono.Debugger.Soft/TypeMirror.cs \
Mono.Debugger.Soft/UserBreakEvent.cs \
Mono.Debugger.Soft/UserLogEvent.cs \
diff --git a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft.csproj b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft.csproj
index 2113ac51d8..1a84d282d1 100644
--- a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft.csproj
+++ b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft.csproj
@@ -92,6 +92,7 @@
<Compile Include="Mono.Debugger.Soft\ThreadMirror.cs" />
<Compile Include="Mono.Debugger.Soft\ThreadStartEvent.cs" />
<Compile Include="Mono.Debugger.Soft\TypeLoadEvent.cs" />
+ <Compile Include="Mono.Debugger.Soft\TypeLoadEventRequest.cs" />
<Compile Include="Mono.Debugger.Soft\TypeMirror.cs" />
<Compile Include="Mono.Debugger.Soft\UserBreakEvent.cs" />
<Compile Include="Mono.Debugger.Soft\UserLogEvent.cs" />
diff --git a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/ArrayMirror.cs b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/ArrayMirror.cs
index c58b2f0192..57a7951b7a 100644
--- a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/ArrayMirror.cs
+++ b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/ArrayMirror.cs
@@ -13,6 +13,9 @@ namespace Mono.Debugger.Soft
internal ArrayMirror (VirtualMachine vm, long id) : base (vm, id) {
}
+ internal ArrayMirror (VirtualMachine vm, long id, TypeMirror type, AppDomainMirror domain) : base (vm, id, type, domain) {
+ }
+
public int Length {
get {
GetLengths ();
diff --git a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs
index 865a41300e..c8b3132f1a 100644
--- a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs
+++ b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs
@@ -5,6 +5,7 @@ using System.Net.Sockets;
using System.Threading;
using System.Collections.Generic;
using System.Text;
+using System.Diagnostics;
using Mono.Cecil.Metadata;
namespace Mono.Debugger.Soft
@@ -102,6 +103,11 @@ namespace Mono.Debugger.Soft
public bool is_thread_pool;
}
+ struct ObjectRefInfo {
+ public long type_id;
+ public long domain_id;
+ }
+
enum ValueTypeId {
VALUE_TYPE_ID_NULL = 0xf0,
VALUE_TYPE_ID_TYPE = 0xf1
@@ -245,6 +251,18 @@ namespace Mono.Debugger.Soft
}
}
+ class SourceFileModifier : Modifier {
+ public string[] SourceFiles {
+ get; set;
+ }
+ }
+
+ class TypeNameModifier : Modifier {
+ public string[] TypeNames {
+ get; set;
+ }
+ }
+
class EventInfo {
public EventType EventType {
get; set;
@@ -322,6 +340,11 @@ namespace Mono.Debugger.Soft
internal const int HEADER_LENGTH = 11;
+ static readonly bool EnableConnectionLogging = !String.IsNullOrEmpty (Environment.GetEnvironmentVariable ("MONO_SDB_LOG"));
+ static int ConnectionId;
+ readonly StreamWriter LoggingStream = EnableConnectionLogging ?
+ new StreamWriter (string.Format ("/tmp/sdb_conn_log_{0}", ConnectionId++), false) : null;
+
/*
* Th version of the wire-protocol implemented by the library. The library
* and the debuggee can communicate if they implement the same major version.
@@ -330,7 +353,7 @@ namespace Mono.Debugger.Soft
* with newer runtimes, and vice versa.
*/
internal const int MAJOR_VERSION = 2;
- internal const int MINOR_VERSION = 3;
+ internal const int MINOR_VERSION = 9;
enum WPSuspendPolicy {
NONE = 0,
@@ -380,7 +403,9 @@ namespace Mono.Debugger.Soft
LOCATION_ONLY = 7,
EXCEPTION_ONLY = 8,
STEP = 10,
- ASSEMBLY_ONLY = 11
+ ASSEMBLY_ONLY = 11,
+ SOURCE_FILE_ONLY = 12,
+ TYPE_NAME_ONLY = 13
}
enum CmdVM {
@@ -393,7 +418,9 @@ namespace Mono.Debugger.Soft
INVOKE_METHOD = 7,
SET_PROTOCOL_VERSION = 8,
ABORT_INVOKE = 9,
- SET_KEEPALIVE = 10
+ SET_KEEPALIVE = 10,
+ GET_TYPES_FOR_SOURCE_FILE = 11,
+ GET_TYPES = 12
}
enum CmdEvent {
@@ -467,7 +494,12 @@ namespace Mono.Debugger.Soft
/* FIXME: Merge into GET_SOURCE_FILES when the major protocol version is increased */
GET_SOURCE_FILES_2 = 13,
/* FIXME: Merge into GET_VALUES when the major protocol version is increased */
- GET_VALUES_2 = 14
+ GET_VALUES_2 = 14,
+ CMD_TYPE_GET_METHODS_BY_NAME_FLAGS = 15,
+ }
+
+ enum BindingFlagsExtensions {
+ BINDING_FLAGS_IGNORE_CASE = 0x70000000,
}
enum CmdStackFrame {
@@ -492,7 +524,8 @@ namespace Mono.Debugger.Soft
IS_COLLECTED = 3,
GET_ADDRESS = 4,
GET_DOMAIN = 5,
- SET_VALUES = 6
+ SET_VALUES = 6,
+ GET_INFO = 7,
}
class Header {
@@ -822,6 +855,9 @@ namespace Mono.Debugger.Soft
}
public PacketWriter WriteString (string s) {
+ if (s == null)
+ return WriteInt (-1);
+
encode_int (data, s.Length, ref offset);
byte[] b = Encoding.UTF8.GetBytes (s);
MakeRoom (b.Length);
@@ -1210,36 +1246,118 @@ namespace Mono.Debugger.Soft
get; set;
}
+ static String CommandString (CommandSet command_set, int command)
+ {
+ string cmd;
+ switch (command_set) {
+ case CommandSet.VM:
+ cmd = ((CmdVM)command).ToString ();
+ break;
+ case CommandSet.OBJECT_REF:
+ cmd = ((CmdObjectRef)command).ToString ();
+ break;
+ case CommandSet.STRING_REF:
+ cmd = ((CmdStringRef)command).ToString ();
+ break;
+ case CommandSet.THREAD:
+ cmd = ((CmdThread)command).ToString ();
+ break;
+ case CommandSet.ARRAY_REF:
+ cmd = ((CmdArrayRef)command).ToString ();
+ break;
+ case CommandSet.EVENT_REQUEST:
+ cmd = ((CmdEventRequest)command).ToString ();
+ break;
+ case CommandSet.STACK_FRAME:
+ cmd = ((CmdStackFrame)command).ToString ();
+ break;
+ case CommandSet.APPDOMAIN:
+ cmd = ((CmdAppDomain)command).ToString ();
+ break;
+ case CommandSet.ASSEMBLY:
+ cmd = ((CmdAssembly)command).ToString ();
+ break;
+ case CommandSet.METHOD:
+ cmd = ((CmdMethod)command).ToString ();
+ break;
+ case CommandSet.TYPE:
+ cmd = ((CmdType)command).ToString ();
+ break;
+ case CommandSet.MODULE:
+ cmd = ((CmdModule)command).ToString ();
+ break;
+ case CommandSet.EVENT:
+ cmd = ((CmdEvent)command).ToString ();
+ break;
+ default:
+ cmd = command.ToString ();
+ break;
+ }
+ return string.Format ("[{0} {1}]", command_set, cmd);
+ }
+
+ long total_protocol_ticks;
+
+ void LogPacket (int packet_id, byte[] encoded_packet, byte[] reply_packet, CommandSet command_set, int command, Stopwatch watch) {
+ watch.Stop ();
+ total_protocol_ticks += watch.ElapsedTicks;
+ var ts = TimeSpan.FromTicks (total_protocol_ticks);
+ string msg = string.Format ("Packet: {0} sent: {1} received: {2} ms: {3} total ms: {4} {5}",
+ packet_id, encoded_packet.Length, reply_packet.Length, watch.ElapsedMilliseconds,
+ (ts.Seconds * 1000) + ts.Milliseconds,
+ CommandString (command_set, command));
+
+ LoggingStream.WriteLine (msg);
+ LoggingStream.Flush ();
+ }
+
/* Send a request and call cb when a result is received */
int Send (CommandSet command_set, int command, PacketWriter packet, Action<PacketReader> cb) {
int id = IdGenerator;
+ Stopwatch watch = null;
+ if (EnableConnectionLogging)
+ watch = Stopwatch.StartNew ();
+
+ byte[] encoded_packet;
+ if (packet == null)
+ encoded_packet = EncodePacket (id, (int)command_set, command, null, 0);
+ else
+ encoded_packet = EncodePacket (id, (int)command_set, command, packet.Data, packet.Offset);
+
lock (reply_packets_monitor) {
reply_cbs [id] = delegate (int packet_id, byte[] p) {
+ if (EnableConnectionLogging)
+ LogPacket (packet_id, encoded_packet, p, command_set, command, watch);
/* Run the callback on a tp thread to avoid blocking the receive thread */
PacketReader r = new PacketReader (p);
cb.BeginInvoke (r, null, null);
};
}
-
- if (packet == null)
- WritePacket (EncodePacket (id, (int)command_set, command, null, 0));
- else
- WritePacket (EncodePacket (id, (int)command_set, command, packet.Data, packet.Offset));
+
+ WritePacket (encoded_packet);
return id;
}
PacketReader SendReceive (CommandSet command_set, int command, PacketWriter packet) {
int id = IdGenerator;
+ Stopwatch watch = null;
if (disconnected)
throw new VMDisconnectedException ();
+ if (EnableConnectionLogging)
+ watch = Stopwatch.StartNew ();
+
+ byte[] encoded_packet;
+
if (packet == null)
- WritePacket (EncodePacket (id, (int)command_set, command, null, 0));
+ encoded_packet = EncodePacket (id, (int)command_set, command, null, 0);
else
- WritePacket (EncodePacket (id, (int)command_set, command, packet.Data, packet.Offset));
+ encoded_packet = EncodePacket (id, (int)command_set, command, packet.Data, packet.Offset);
+
+ WritePacket (encoded_packet);
int packetId = id;
@@ -1250,6 +1368,9 @@ namespace Mono.Debugger.Soft
byte[] reply = reply_packets [packetId];
reply_packets.Remove (packetId);
PacketReader r = new PacketReader (reply);
+
+ if (EnableConnectionLogging)
+ LogPacket (packetId, encoded_packet, reply, command_set, command, watch);
if (r.ErrorCode != 0) {
if (ErrorHandler != null)
ErrorHandler (this, new ErrorHandlerEventArgs () { ErrorCode = (ErrorCode)r.ErrorCode });
@@ -1418,6 +1539,24 @@ namespace Mono.Debugger.Soft
SendReceive (CommandSet.VM, (int)CmdVM.SET_KEEPALIVE, new PacketWriter ().WriteId (keepalive_interval));
}
+ internal long[] VM_GetTypesForSourceFile (string fname, bool ignoreCase) {
+ var res = SendReceive (CommandSet.VM, (int)CmdVM.GET_TYPES_FOR_SOURCE_FILE, new PacketWriter ().WriteString (fname).WriteBool (ignoreCase));
+ int count = res.ReadInt ();
+ long[] types = new long [count];
+ for (int i = 0; i < count; ++i)
+ types [i] = res.ReadId ();
+ return types;
+ }
+
+ internal long[] VM_GetTypes (string name, bool ignoreCase) {
+ var res = SendReceive (CommandSet.VM, (int)CmdVM.GET_TYPES, new PacketWriter ().WriteString (name).WriteBool (ignoreCase));
+ int count = res.ReadInt ();
+ long[] types = new long [count];
+ for (int i = 0; i < count; ++i)
+ types [i] = res.ReadId ();
+ return types;
+ }
+
/*
* DOMAIN
*/
@@ -1772,7 +1911,16 @@ namespace Mono.Debugger.Soft
PacketReader r = SendReceive (CommandSet.TYPE, (int)CmdType.GET_PROPERTY_CATTRS, new PacketWriter ().WriteId (id).WriteId (field_id).WriteId (attr_type_id));
return ReadCattrs (r);
}
-
+
+ public long[] Type_GetMethodsByNameFlags (long id, string name, int flags, bool ignoreCase) {
+ flags |= ignoreCase ? (int)BindingFlagsExtensions.BINDING_FLAGS_IGNORE_CASE : 0;
+ PacketReader r = SendReceive (CommandSet.TYPE, (int)CmdType.CMD_TYPE_GET_METHODS_BY_NAME_FLAGS, new PacketWriter ().WriteId (id).WriteString (name).WriteInt (flags));
+ int len = r.ReadInt ();
+ long[] res = new long [len];
+ for (int i = 0; i < len; ++i)
+ res [i] = r.ReadId ();
+ return res;
+ }
/*
* EVENTS
*/
@@ -1816,6 +1964,18 @@ namespace Mono.Debugger.Soft
w.WriteInt (amod.Assemblies.Length);
foreach (var id in amod.Assemblies)
w.WriteId (id);
+ } else if (mod is SourceFileModifier) {
+ w.WriteByte ((byte)ModifierKind.SOURCE_FILE_ONLY);
+ var smod = (mod as SourceFileModifier);
+ w.WriteInt (smod.SourceFiles.Length);
+ foreach (var s in smod.SourceFiles)
+ w.WriteString (s);
+ } else if (mod is TypeNameModifier) {
+ w.WriteByte ((byte)ModifierKind.TYPE_NAME_ONLY);
+ var tmod = (mod as TypeNameModifier);
+ w.WriteInt (tmod.TypeNames.Length);
+ foreach (var s in tmod.TypeNames)
+ w.WriteString (s);
} else {
throw new NotImplementedException ();
}
@@ -1928,6 +2088,15 @@ namespace Mono.Debugger.Soft
return SendReceive (CommandSet.OBJECT_REF, (int)CmdObjectRef.GET_ADDRESS, new PacketWriter ().WriteId (id)).ReadLong ();
}
+ internal ObjectRefInfo Object_GetInfo (long id) {
+ ObjectRefInfo res = new ObjectRefInfo ();
+ PacketReader r = SendReceive (CommandSet.OBJECT_REF, (int)CmdObjectRef.GET_INFO, new PacketWriter ().WriteId (id));
+
+ res.type_id = r.ReadId ();
+ res.domain_id = r.ReadId ();
+ return res;
+ }
+
}
class TcpConnection : Connection
diff --git a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/CustomAttributeDataMirror.cs b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/CustomAttributeDataMirror.cs
index 69f039be63..d1ab7e68ce 100644
--- a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/CustomAttributeDataMirror.cs
+++ b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/CustomAttributeDataMirror.cs
@@ -133,7 +133,7 @@ namespace Mono.Debugger.Soft {
if (named_args [j] == null)
throw new NotImplementedException ();
}
- res [i] = new CustomAttributeDataMirror (vm.GetMethod (attr.ctor_id), ctor_args, named_args);
+ res [i] = new CustomAttributeDataMirror (ctor, ctor_args, named_args);
}
return res;
diff --git a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/FieldInfoMirror.cs b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/FieldInfoMirror.cs
index c0e444d75c..bb71ee3ab1 100644
--- a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/FieldInfoMirror.cs
+++ b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/FieldInfoMirror.cs
@@ -14,6 +14,7 @@ namespace Mono.Debugger.Soft
TypeMirror type;
FieldAttributes attrs;
CustomAttributeDataMirror[] cattrs;
+ C.FieldDefinition meta;
public FieldInfoMirror (TypeMirror parent, long id, string name, TypeMirror type, FieldAttributes attrs) : base (parent.VirtualMachine, id) {
this.parent = parent;
@@ -142,7 +143,28 @@ namespace Mono.Debugger.Soft
return GetCAttrs (attributeType, inherit);
}
+ public C.FieldDefinition Metadata {
+ get {
+ if (parent.Metadata == null)
+ return null;
+ // FIXME: Speed this up
+ foreach (var fd in parent.Metadata.Fields) {
+ if (fd.Name == Name) {
+ meta = fd;
+ break;
+ }
+ }
+ if (meta == null)
+ /* Shouldn't happen */
+ throw new NotImplementedException ();
+ return meta;
+ }
+ }
+
CustomAttributeDataMirror[] GetCAttrs (TypeMirror type, bool inherit) {
+ if (cattrs == null && Metadata != null && !Metadata.HasCustomAttributes)
+ cattrs = new CustomAttributeDataMirror [0];
+
// FIXME: Handle inherit
if (cattrs == null) {
CattrInfo[] info = vm.conn.Type_GetFieldCustomAttributes (DeclaringType.Id, id, 0, false);
diff --git a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/ObjectMirror.cs b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/ObjectMirror.cs
index 8b0db99982..f252fb6b1c 100644
--- a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/ObjectMirror.cs
+++ b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/ObjectMirror.cs
@@ -6,19 +6,44 @@ using System.Threading;
namespace Mono.Debugger.Soft
{
public class ObjectMirror : Value {
+ TypeMirror type;
+ AppDomainMirror domain;
internal ObjectMirror (VirtualMachine vm, long id) : base (vm, id) {
}
+ internal ObjectMirror (VirtualMachine vm, long id, TypeMirror type, AppDomainMirror domain) : base (vm, id) {
+ this.type = type;
+ this.domain = domain;
+ }
+
+ void GetInfo () {
+ var info = vm.conn.Object_GetInfo (id);
+ type = vm.GetType (info.type_id);
+ domain = vm.GetDomain (info.domain_id);
+ }
+
public TypeMirror Type {
get {
- return vm.GetType (vm.conn.Object_GetType (id));
+ if (type == null) {
+ if (vm.conn.Version.AtLeast (2, 5))
+ GetInfo ();
+ else
+ type = vm.GetType (vm.conn.Object_GetType (id));
+ }
+ return type;
}
}
public AppDomainMirror Domain {
get {
- return vm.GetDomain (vm.conn.Object_GetDomain (id));
+ if (domain == null) {
+ if (vm.conn.Version.AtLeast (2, 5))
+ GetInfo ();
+ else
+ domain = vm.GetDomain (vm.conn.Object_GetDomain (id));
+ }
+ return domain;
}
}
diff --git a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/PropertyInfoMirror.cs b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/PropertyInfoMirror.cs
index c97ebbc8ce..32f87d1826 100644
--- a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/PropertyInfoMirror.cs
+++ b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/PropertyInfoMirror.cs
@@ -14,6 +14,7 @@ namespace Mono.Debugger.Soft
PropertyAttributes attrs;
MethodMirror get_method, set_method;
CustomAttributeDataMirror[] cattrs;
+ C.PropertyDefinition meta;
public PropertyInfoMirror (TypeMirror parent, long id, string name, MethodMirror get_method, MethodMirror set_method, PropertyAttributes attrs) : base (parent.VirtualMachine, id) {
this.parent = parent;
@@ -90,6 +91,24 @@ namespace Mono.Debugger.Soft
return new ParameterInfoMirror [0];
}
+ public C.PropertyDefinition Metadata {
+ get {
+ if (parent.Metadata == null)
+ return null;
+ // FIXME: Speed this up
+ foreach (var def in parent.Metadata.Properties) {
+ if (def.Name == Name) {
+ meta = def;
+ break;
+ }
+ }
+ if (meta == null)
+ /* Shouldn't happen */
+ throw new NotImplementedException ();
+ return meta;
+ }
+ }
+
public CustomAttributeDataMirror[] GetCustomAttributes (bool inherit) {
return GetCAttrs (null, inherit);
}
@@ -101,6 +120,9 @@ namespace Mono.Debugger.Soft
}
CustomAttributeDataMirror[] GetCAttrs (TypeMirror type, bool inherit) {
+ if (cattrs == null && Metadata != null && !Metadata.HasCustomAttributes)
+ cattrs = new CustomAttributeDataMirror [0];
+
// FIXME: Handle inherit
if (cattrs == null) {
CattrInfo[] info = vm.conn.Type_GetPropertyCustomAttributes (DeclaringType.Id, id, 0, false);
diff --git a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/StringMirror.cs b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/StringMirror.cs
index 30cc9a43c3..e2e65f68d6 100644
--- a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/StringMirror.cs
+++ b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/StringMirror.cs
@@ -8,6 +8,9 @@ namespace Mono.Debugger.Soft
internal StringMirror (VirtualMachine vm, long id) : base (vm, id) {
}
+ internal StringMirror (VirtualMachine vm, long id, TypeMirror type, AppDomainMirror domain) : base (vm, id, type, domain) {
+ }
+
public string Value {
get {
return vm.conn.String_GetValue (id);
diff --git a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/ThreadMirror.cs b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/ThreadMirror.cs
index 617613d060..6eebafdb6d 100644
--- a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/ThreadMirror.cs
+++ b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/ThreadMirror.cs
@@ -10,6 +10,9 @@ namespace Mono.Debugger.Soft
internal ThreadMirror (VirtualMachine vm, long id) : base (vm, id) {
}
+ internal ThreadMirror (VirtualMachine vm, long id, TypeMirror type, AppDomainMirror domain) : base (vm, id, type, domain) {
+ }
+
// FIXME: Cache, invalidate when the thread/runtime is resumed
public StackFrame[] GetFrames () {
FrameInfo[] frame_info = vm.conn.Thread_GetFrameInfo (id, 0, -1);
@@ -52,13 +55,16 @@ namespace Mono.Debugger.Soft
}
}
+ long? thread_id;
/*
* Return a unique identifier for this thread, multiple ThreadMirror objects
* may have the same ThreadId because of appdomains.
*/
public long ThreadId {
get {
- return vm.conn.Thread_GetId (id);
+ if (thread_id == null)
+ thread_id = vm.conn.Thread_GetId (id);
+ return (long)thread_id;
}
}
diff --git a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/TypeLoadEventRequest.cs b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/TypeLoadEventRequest.cs
new file mode 100644
index 0000000000..130742b4c8
--- /dev/null
+++ b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/TypeLoadEventRequest.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Mono.Debugger.Soft
+{
+ public sealed class TypeLoadEventRequest : EventRequest {
+ string[] sourceFiles;
+ string[] typeNames;
+
+ internal TypeLoadEventRequest (VirtualMachine vm) : base (vm, EventType.TypeLoad) {
+ }
+
+ public string[] SourceFileFilter {
+ get {
+ return sourceFiles;
+ }
+ set {
+ CheckDisabled ();
+ sourceFiles = value;
+ }
+ }
+
+ public string[] TypeNameFilter {
+ get {
+ return typeNames;
+ }
+ set {
+ CheckDisabled ();
+ typeNames = value;
+ }
+ }
+
+ public override void Enable () {
+ var mods = new List <Modifier> ();
+ if (SourceFileFilter != null && SourceFileFilter.Length != 0)
+ mods.Add (new SourceFileModifier () { SourceFiles = SourceFileFilter });
+ if (TypeNameFilter != null && TypeNameFilter.Length != 0)
+ mods.Add (new TypeNameModifier () { TypeNames = TypeNameFilter });
+ SendReq (mods);
+ }
+ }
+} \ No newline at end of file
diff --git a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/TypeMirror.cs b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/TypeMirror.cs
index d17fac5dd8..803783cbc6 100644
--- a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/TypeMirror.cs
+++ b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/TypeMirror.cs
@@ -525,8 +525,18 @@ namespace Mono.Debugger.Soft
return GetSourceFiles (false);
}
+ string[] source_files;
+ string[] source_files_full_path;
public string[] GetSourceFiles (bool return_full_paths) {
- return vm.conn.Type_GetSourceFiles (id, return_full_paths);
+ string[] res = return_full_paths ? source_files_full_path : source_files;
+ if (res == null) {
+ res = vm.conn.Type_GetSourceFiles (id, return_full_paths);
+ if (return_full_paths)
+ source_files_full_path = res;
+ else
+ source_files = res;
+ }
+ return res;
}
public C.TypeDefinition Metadata {
@@ -620,6 +630,9 @@ namespace Mono.Debugger.Soft
}
CustomAttributeDataMirror[] GetCAttrs (TypeMirror type, bool inherit) {
+ if (cattrs == null && Metadata != null && !Metadata.HasCustomAttributes)
+ cattrs = new CustomAttributeDataMirror [0];
+
// FIXME: Handle inherit
if (cattrs == null) {
CattrInfo[] info = vm.conn.Type_GetCustomAttributes (id, 0, false);
@@ -632,6 +645,25 @@ namespace Mono.Debugger.Soft
return res.ToArray ();
}
+ public MethodMirror[] GetMethodsByNameFlags (string name, BindingFlags flags, bool ignoreCase) {
+ if (vm.conn.Version.AtLeast (2, 6)) {
+ long[] ids = vm.conn.Type_GetMethodsByNameFlags (id, name, (int)flags, ignoreCase);
+ MethodMirror[] m = new MethodMirror [ids.Length];
+ for (int i = 0; i < ids.Length; ++i)
+ m [i] = vm.GetMethod (ids [i]);
+ return m;
+ } else {
+ if (flags != (BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance|BindingFlags.NonPublic))
+ throw new NotImplementedException ();
+ var res = new List<MethodMirror> ();
+ foreach (MethodMirror m in GetMethods ()) {
+ if ((!ignoreCase && m.Name == name) || (ignoreCase && m.Name.Equals (name, StringComparison.CurrentCultureIgnoreCase)))
+ res.Add (m);
+ }
+ return res.ToArray ();
+ }
+ }
+
public Value InvokeMethod (ThreadMirror thread, MethodMirror method, IList<Value> arguments) {
return ObjectMirror.InvokeMethod (vm, thread, method, null, arguments, InvokeOptions.None);
}
diff --git a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs
index 277de4a655..0a19a7f717 100644
--- a/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs
+++ b/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs
@@ -211,6 +211,10 @@ namespace Mono.Debugger.Soft
return new AssemblyLoadEventRequest (this);
}
+ public TypeLoadEventRequest CreateTypeLoadRequest () {
+ return new TypeLoadEventRequest (this);
+ }
+
public void EnableEvents (params EventType[] events) {
foreach (EventType etype in events) {
if (etype == EventType.Breakpoint)
@@ -234,6 +238,32 @@ namespace Mono.Debugger.Soft
public void Disconnect () {
conn.Close ();
}
+
+ //
+ // Return a list of TypeMirror objects for all loaded types which reference the
+ // source file FNAME. Might return false positives.
+ // Since protocol version 2.7.
+ //
+ public IList<TypeMirror> GetTypesForSourceFile (string fname, bool ignoreCase) {
+ long[] ids = conn.VM_GetTypesForSourceFile (fname, ignoreCase);
+ var res = new TypeMirror [ids.Length];
+ for (int i = 0; i < ids.Length; ++i)
+ res [i] = GetType (ids [i]);
+ return res;
+ }
+
+ //
+ // Return a list of TypeMirror objects for all loaded types named 'NAME'.
+ // NAME should be in the the same for as with Assembly.GetType ().
+ // Since protocol version 2.9.
+ //
+ public IList<TypeMirror> GetTypes (string name, bool ignoreCase) {
+ long[] ids = conn.VM_GetTypes (name, ignoreCase);
+ var res = new TypeMirror [ids.Length];
+ for (int i = 0; i < ids.Length; ++i)
+ res [i] = GetType (ids [i]);
+ return res;
+ }
internal void queue_event_set (EventSet es) {
lock (queue_monitor) {
@@ -428,22 +458,29 @@ namespace Mono.Debugger.Soft
* Obtain the domain/type of the object to determine the type of
* object we need to create.
*/
- if (domain_id == 0)
- domain_id = conn.Object_GetDomain (id);
+ if (domain_id == 0 || type_id == 0) {
+ if (conn.Version.AtLeast (2, 5)) {
+ var info = conn.Object_GetInfo (id);
+ domain_id = info.domain_id;
+ type_id = info.type_id;
+ } else {
+ if (domain_id == 0)
+ domain_id = conn.Object_GetDomain (id);
+ if (type_id == 0)
+ type_id = conn.Object_GetType (id);
+ }
+ }
AppDomainMirror d = GetDomain (domain_id);
-
- if (type_id == 0)
- type_id = conn.Object_GetType (id);
TypeMirror t = GetType (type_id);
if (t.Assembly == d.Corlib && t.Namespace == "System.Threading" && t.Name == "Thread")
- obj = new ThreadMirror (this, id);
+ obj = new ThreadMirror (this, id, t, d);
else if (t.Assembly == d.Corlib && t.Namespace == "System" && t.Name == "String")
- obj = new StringMirror (this, id);
+ obj = new StringMirror (this, id, t, d);
else if (typeof (T) == typeof (ArrayMirror))
- obj = new ArrayMirror (this, id);
+ obj = new ArrayMirror (this, id, t, d);
else
- obj = new ObjectMirror (this, id);
+ obj = new ObjectMirror (this, id, t, d);
objects [id] = obj;
}
return (T)obj;