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
path: root/extras
diff options
context:
space:
mode:
authorTherzok <teromario@yahoo.com>2013-09-02 23:23:40 +0400
committerTherzok <teromario@yahoo.com>2013-09-02 23:25:18 +0400
commitc283cfdbb24ee87180fd10c1e0c66c4085075d00 (patch)
tree4c239f5b09ce4dfa086209b7a3376e99e07dc460 /extras
parent2d43aa564584dee5b09d35e37b61f8abd39425b5 (diff)
[CorDebug] Internal API changes.
Diffstat (limited to 'extras')
-rw-r--r--extras/MonoDevelop.Debugger.Win32/CorApi/ICorDebugWrappers.cs4
-rw-r--r--extras/MonoDevelop.Debugger.Win32/CorApi/IMetadataImport.cs139
-rw-r--r--extras/MonoDevelop.Debugger.Win32/CorApi2/Metadata/CorMetadata.cs252
-rw-r--r--extras/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataFieldInfo.cs46
-rw-r--r--extras/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataParameterInfo.cs6
-rw-r--r--extras/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataType.cs264
-rw-r--r--extras/MonoDevelop.Debugger.Win32/CorApi2/debug/CorAPIAssemblyAttributes.cs4
-rw-r--r--extras/MonoDevelop.Debugger.Win32/CorApi2/debug/Debugger.cs197
-rw-r--r--extras/MonoDevelop.Debugger.Win32/CorApi2/debug/Process.cs42
-rw-r--r--extras/MonoDevelop.Debugger.Win32/CorApi2/debug/Type.cs9
10 files changed, 834 insertions, 129 deletions
diff --git a/extras/MonoDevelop.Debugger.Win32/CorApi/ICorDebugWrappers.cs b/extras/MonoDevelop.Debugger.Win32/CorApi/ICorDebugWrappers.cs
index 596465dd06..5f8f793dba 100644
--- a/extras/MonoDevelop.Debugger.Win32/CorApi/ICorDebugWrappers.cs
+++ b/extras/MonoDevelop.Debugger.Win32/CorApi/ICorDebugWrappers.cs
@@ -156,6 +156,7 @@ namespace Microsoft.Samples.Debugging.CorDebug.NativeApi
USER_UNSAFE_POINT = 0x80
}
+ // [Xamarin] Expression evaluator.
[CLSCompliant(true)]
[Flags]
public enum CorElementType
@@ -170,6 +171,7 @@ namespace Microsoft.Samples.Debugging.CorDebug.NativeApi
ELEMENT_TYPE_CMOD_REQD = 0x1f,
ELEMENT_TYPE_END = 0,
ELEMENT_TYPE_FNPTR = 0x1b,
+ ELEMENT_TYPE_GENERICINST = 0x15,
ELEMENT_TYPE_I = 0x18,
ELEMENT_TYPE_I1 = 4,
ELEMENT_TYPE_I2 = 6,
@@ -178,6 +180,7 @@ namespace Microsoft.Samples.Debugging.CorDebug.NativeApi
ELEMENT_TYPE_INTERNAL = 0x21,
ELEMENT_TYPE_MAX = 0x22,
ELEMENT_TYPE_MODIFIER = 0x40,
+ ELEMENT_TYPE_MVAR = 0x1e,
ELEMENT_TYPE_OBJECT = 0x1c,
ELEMENT_TYPE_PINNED = 0x45,
ELEMENT_TYPE_PTR = 15,
@@ -193,6 +196,7 @@ namespace Microsoft.Samples.Debugging.CorDebug.NativeApi
ELEMENT_TYPE_U4 = 9,
ELEMENT_TYPE_U8 = 11,
ELEMENT_TYPE_VALUETYPE = 0x11,
+ ELEMENT_TYPE_VAR = 0x13,
ELEMENT_TYPE_VOID = 1
}
diff --git a/extras/MonoDevelop.Debugger.Win32/CorApi/IMetadataImport.cs b/extras/MonoDevelop.Debugger.Win32/CorApi/IMetadataImport.cs
index cad18a1e87..2e41ce78c9 100644
--- a/extras/MonoDevelop.Debugger.Win32/CorApi/IMetadataImport.cs
+++ b/extras/MonoDevelop.Debugger.Win32/CorApi/IMetadataImport.cs
@@ -42,13 +42,13 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
[ComAliasName("mdTypeDef*")] out int rTypeDefs,
uint cMax /*must be 1*/,
[ComAliasName("ULONG*")] out uint pcTypeDefs);
-
+#if !MDBG_FAKE_COM
//STDMETHOD(EnumInterfaceImpls)(HCORENUM *phEnum, mdTypeDef td, mdInterfaceImpl rImpls[], ULONG cMax, ULONG* pcImpls) PURE;
void EnumInterfaceImpls_(IntPtr phEnum, int td);
//STDMETHOD(EnumTypeRefs)(HCORENUM *phEnum, mdTypeRef rTypeRefs[], ULONG cMax, ULONG* pcTypeRefs) PURE;
void EnumTypeRefs_();
-
+#endif
// STDMETHOD(FindTypeDefByName)( // S_OK or error.
// LPCWSTR szTypeDef, // [IN] Name of the Type.
// mdToken tkEnclosingClass, // [IN] TypeDef/TypeRef for Enclosing class.
@@ -70,11 +70,11 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
[ComAliasName("ULONG*")] out int pchName,
out Guid mvid
);
-
+#if !MDBG_FAKE_COM
// STDMETHOD(GetModuleFromScope)( // S_OK.
// mdModule *pmd) PURE; // [OUT] Put mdModule token here.
void GetModuleFromScope_();
-
+#endif
// STDMETHOD(GetTypeDefProps)( // S_OK or error.
// mdTypeDef td, // [IN] TypeDef token for inquiry.
// LPWSTR szTypeDef, // [OUT] Put name here.
@@ -89,13 +89,13 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
[Out, MarshalAs(UnmanagedType.U4)] out System.Reflection.TypeAttributes pdwTypeDefFlags,
[ComAliasName("mdToken*")] [Out] out int ptkExtends
);
-
+#if !MDBG_FAKE_COM
// STDMETHOD(GetInterfaceImplProps)( // S_OK or error.
// mdInterfaceImpl iiImpl, // [IN] InterfaceImpl token.
// mdTypeDef *pClass, // [OUT] Put implementing class token here.
// mdToken *ptkIface) PURE; // [OUT] Put implemented interface token here.
void GetInterfaceImplProps_();
-
+#endif
// STDMETHOD(GetTypeRefProps)( // S_OK or error.
// mdTypeRef tr, // [IN] TypeRef token.
// mdToken *ptkResolutionScope, // [OUT] Resolution scope, ModuleRef or AssemblyRef.
@@ -109,7 +109,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
[In] int cchName,
[ComAliasName("ULONG*")] out int pchName
);
-
+#if !MDBG_FAKE_COM
// STDMETHOD(ResolveTypeRef)(mdTypeRef tr, REFIID riid, IUnknown **ppIScope, mdTypeDef *ptd) PURE;
void ResolveTypeRef_();
@@ -129,7 +129,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// ULONG cMax, // [IN] Max MemberDefs to put.
// ULONG *pcTokens) PURE; // [OUT] Put # put here.
void EnumMembersWithName_();
-
+#endif
// STDMETHOD(EnumMethods)( // S_OK, S_FALSE, or error.
// HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
// mdTypeDef cl, // [IN] TypeDef to scope the enumeration.
@@ -142,7 +142,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
int cMax, /*must be 1*/
[ComAliasName("ULONG*")] out int pcTokens
);
-
+#if !MDBG_FAKE_COM
// STDMETHOD(EnumMethodsWithName)( // S_OK, S_FALSE, or error.
// HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
// mdTypeDef cl, // [IN] TypeDef to scope the enumeration.
@@ -151,7 +151,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// ULONG cMax, // [IN] Max MethodDefs to put.
// ULONG *pcTokens) PURE; // [OUT] Put # put here.
void EnumMethodsWithName_();
-
+#endif
// STDMETHOD(EnumFields)( // S_OK, S_FALSE, or error.
// HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
// mdTypeDef cl, // [IN] TypeDef to scope the enumeration.
@@ -166,7 +166,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
int cMax /*must be 1*/,
[ComAliasName("ULONG*")] out uint pcTokens);
-
+#if !MDBG_FAKE_COM
// STDMETHOD(EnumFieldsWithName)( // S_OK, S_FALSE, or error.
// HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
// mdTypeDef cl, // [IN] TypeDef to scope the enumeration.
@@ -175,7 +175,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// ULONG cMax, // [IN] Max MemberDefs to put.
// ULONG *pcTokens) PURE; // [OUT] Put # put here.
void EnumFieldsWithName_();
-
+#endif
// STDMETHOD(EnumParams)( // S_OK, S_FALSE, or error.
// HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
// mdMethodDef mb, // [IN] MethodDef to scope the enumeration.
@@ -187,7 +187,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
[ComAliasName("mdParamDef*")] out int mdParamDef,
int cMax /*must be 1*/,
[ComAliasName("ULONG*")] out uint pcTokens);
-
+#if !MDBG_FAKE_COM
// STDMETHOD(EnumMemberRefs)( // S_OK, S_FALSE, or error.
// HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
// mdToken tkParent, // [IN] Parent token to scope the enumeration.
@@ -245,7 +245,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// ULONG cbSigBlob, // [IN] count of bytes in the signature blob
// mdMemberRef *pmr) PURE; // [OUT] matching memberref
void FindMemberRef_();
-
+#endif
// STDMETHOD (GetMethodProps)(
// mdMethodDef mb, // The method for which to get props.
// mdTypeDef *pClass, // Put method's class here.
@@ -292,8 +292,12 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// mdProperty rProperties[], // [OUT] Put Properties here.
// ULONG cMax, // [IN] Max properties to put.
// ULONG *pcProperties) PURE; // [OUT] Put # put here.
- void EnumProperties_();
-
+ void EnumProperties(ref IntPtr phEnum,
+ int td,
+ [ComAliasName("mdProperty*")] out int mdProperty,
+ int cMax /*must be 1*/,
+ [ComAliasName("ULONG*")] out uint pcProperties);
+#if !MDBG_FAKE_COM
// STDMETHOD(EnumEvents)( // S_OK, S_FALSE, or error.
// HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
// mdTypeDef td, // [IN] TypeDef to scope the enumeration.
@@ -398,7 +402,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// ULONG cMax, // [IN] Max MemberDefs to put.
// ULONG *pcTokens) PURE; // [OUT] Put # put here.
void EnumUnresolvedMethods_();
-
+#endif
// STDMETHOD(GetUserString)( // S_OK or error.
// mdString stk, // [IN] String token.
// LPWSTR szString, // [OUT] Copy of string.
@@ -409,7 +413,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
[In] int cchString,
[ComAliasName("ULONG*")] out int pchString
);
-
+#if !MDBG_FAKE_COM
// STDMETHOD(GetPinvokeMap)( // S_OK or error.
// mdToken tk, // [IN] FieldDef or MethodDef.
// DWORD *pdwMappingFlags, // [OUT] Flags used for mapping.
@@ -445,7 +449,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// ULONG ulParamSeq, // [IN] Parameter sequence.
// mdParamDef *ppd) PURE; // [IN] Put Param token here.
void GetParamForMethodIndex_();
-
+#endif
// STDMETHOD(EnumCustomAttributes)( // S_OK or error.
// HCORENUM *phEnum, // [IN, OUT] COR enumerator.
// mdToken tk, // [IN] Token to scope the enumeration, 0 for all.
@@ -460,7 +464,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
uint cMax /*must be 1*/,
[ComAliasName("ULONG*")]out uint pcTokens
);
-
+#if !MDBG_FAKE_COM
// STDMETHOD(GetCustomAttributeProps)( // S_OK or error.
// mdCustomAttribute cv, // [IN] CustomAttribute token.
// mdToken *ptkObj, // [OUT, OPTIONAL] Put object token here.
@@ -490,7 +494,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// void const **ppValue, // [OUT] constant value
// ULONG *pcchValue) PURE; // [OUT] size of constant string in chars, 0 for non-strings.
void GetMemberProps_();
-
+#endif
// STDMETHOD(GetFieldProps)(
// mdFieldDef mb, // The field for which to get props.
// mdTypeDef *pClass, // Put field's class here.
@@ -533,7 +537,23 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// mdMethodDef rmdOtherMethod[], // [OUT] other method of the property
// ULONG cMax, // [IN] size of rmdOtherMethod
// ULONG *pcOtherMethod) PURE; // [OUT] total number of other method of this property
- void GetPropertyProps_();
+ void GetPropertyProps(int prop,
+ [ComAliasName ("mdTypeDef*")] out int mdTypeDef,
+ [Out, MarshalAs (UnmanagedType.LPWStr)] StringBuilder szProperty,
+ int cchProperty,
+ [ComAliasName ("ULONG*")] out int pchProperty,
+ [ComAliasName ("DWORD*")] out int pdwPropFlags,
+ [ComAliasName ("PCCOR_SIGNATURE*")] out IntPtr ppvSig,
+ [ComAliasName ("ULONG*")] out int pbSig,
+ [ComAliasName ("DWORD*")] out int pdwCPlusTypeFlag,
+ [ComAliasName ("UVCP_CONSTANT*")] out IntPtr ppDefaultValue,
+ [ComAliasName ("ULONG*")] out int pcchDefaultValue,
+ [ComAliasName ("mdMethodDef*")] out int pmdSetter,
+ [ComAliasName ("mdMethodDef*")] out int pmdGetter,
+ [ComAliasName ("mdMethodDef*")] out int rmdOtherMethod,
+ [ComAliasName ("ULONG*")] int cMax, /* must be 1 */
+ [ComAliasName ("ULONG*")] out int pcOtherMethod
+ );
// STDMETHOD(GetParamProps)( // S_OK or error.
// mdParamDef tk, // [IN]The Parameter.
@@ -578,7 +598,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// mdTypeDef tdNestedClass, // [IN] NestedClass token.
// mdTypeDef *ptdEnclosingClass) PURE; // [OUT] EnclosingClass token.
void GetNestedClassProps(int tdNestedClass, [ComAliasName("mdTypeDef*")] out int tdEnclosingClass);
-
+#if !MDBG_FAKE_COM
// STDMETHOD(GetNativeCallConvFromSig)( // S_OK or error.
// void const *pvSig, // [IN] Pointer to signature.
// ULONG cbSig, // [IN] Count of signature bytes.
@@ -589,7 +609,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// mdToken pd, // [IN] Type, Field, or Method token.
// int *pbGlobal) PURE; // [OUT] Put 1 if global, 0 otherwise.
void IsGlobal_();
-
+#endif
} // IMetadataImport
@@ -620,13 +640,13 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
[ComAliasName("mdTypeDef*")] out int rTypeDefs,
uint cMax /*must be 1*/,
[ComAliasName("ULONG*")] out uint pcTypeDefs);
-
+#if !MDBG_FAKE_COM
//STDMETHOD(EnumInterfaceImpls)(HCORENUM *phEnum, mdTypeDef td, mdInterfaceImpl rImpls[], ULONG cMax, ULONG* pcImpls) PURE;
new void EnumInterfaceImpls_(IntPtr phEnum, int td);
//STDMETHOD(EnumTypeRefs)(HCORENUM *phEnum, mdTypeRef rTypeRefs[], ULONG cMax, ULONG* pcTypeRefs) PURE;
new void EnumTypeRefs_();
-
+#endif
// STDMETHOD(FindTypeDefByName)( // S_OK or error.
// LPCWSTR szTypeDef, // [IN] Name of the Type.
// mdToken tkEnclosingClass, // [IN] TypeDef/TypeRef for Enclosing class.
@@ -648,11 +668,11 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
[ComAliasName("ULONG*")] out int pchName,
out Guid mvid
);
-
+#if !MDBG_FAKE_COM
// STDMETHOD(GetModuleFromScope)( // S_OK.
// mdModule *pmd) PURE; // [OUT] Put mdModule token here.
new void GetModuleFromScope_();
-
+#endif
// STDMETHOD(GetTypeDefProps)( // S_OK or error.
// mdTypeDef td, // [IN] TypeDef token for inquiry.
// LPWSTR szTypeDef, // [OUT] Put name here.
@@ -667,13 +687,13 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
[Out, MarshalAs(UnmanagedType.U4)] out System.Reflection.TypeAttributes pdwTypeDefFlags,
[ComAliasName("mdToken*")] [Out] out int ptkExtends
);
-
+#if !MDBG_FAKE_COM
// STDMETHOD(GetInterfaceImplProps)( // S_OK or error.
// mdInterfaceImpl iiImpl, // [IN] InterfaceImpl token.
// mdTypeDef *pClass, // [OUT] Put implementing class token here.
// mdToken *ptkIface) PURE; // [OUT] Put implemented interface token here.
new void GetInterfaceImplProps_();
-
+#endif
// STDMETHOD(GetTypeRefProps)( // S_OK or error.
// mdTypeRef tr, // [IN] TypeRef token.
// mdToken *ptkResolutionScope, // [OUT] Resolution scope, ModuleRef or AssemblyRef.
@@ -687,7 +707,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
[In] int cchName,
[ComAliasName("ULONG*")] out int pchName
);
-
+#if !MDBG_FAKE_COM
// STDMETHOD(ResolveTypeRef)(mdTypeRef tr, REFIID riid, IUnknown **ppIScope, mdTypeDef *ptd) PURE;
new void ResolveTypeRef_();
@@ -707,7 +727,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// ULONG cMax, // [IN] Max MemberDefs to put.
// ULONG *pcTokens) PURE; // [OUT] Put # put here.
new void EnumMembersWithName_();
-
+#endif
// STDMETHOD(EnumMethods)( // S_OK, S_FALSE, or error.
// HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
// mdTypeDef cl, // [IN] TypeDef to scope the enumeration.
@@ -720,7 +740,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
int cMax, /*must be 1*/
[ComAliasName("ULONG*")] out int pcTokens
);
-
+#if !MDBG_FAKE_COM
// STDMETHOD(EnumMethodsWithName)( // S_OK, S_FALSE, or error.
// HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
// mdTypeDef cl, // [IN] TypeDef to scope the enumeration.
@@ -729,7 +749,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// ULONG cMax, // [IN] Max MethodDefs to put.
// ULONG *pcTokens) PURE; // [OUT] Put # put here.
new void EnumMethodsWithName_();
-
+#endif
// STDMETHOD(EnumFields)( // S_OK, S_FALSE, or error.
// HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
// mdTypeDef cl, // [IN] TypeDef to scope the enumeration.
@@ -742,7 +762,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
[ComAliasName("mdFieldDef*")] out int mdFieldDef,
int cMax /*must be 1*/,
[ComAliasName("ULONG*")] out uint pcTokens);
-
+#if !MDBG_FAKE_COM
// STDMETHOD(EnumFieldsWithName)( // S_OK, S_FALSE, or error.
// HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
// mdTypeDef cl, // [IN] TypeDef to scope the enumeration.
@@ -751,7 +771,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// ULONG cMax, // [IN] Max MemberDefs to put.
// ULONG *pcTokens) PURE; // [OUT] Put # put here.
new void EnumFieldsWithName_();
-
+#endif
// STDMETHOD(EnumParams)( // S_OK, S_FALSE, or error.
// HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
// mdMethodDef mb, // [IN] MethodDef to scope the enumeration.
@@ -763,7 +783,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
[ComAliasName("mdParamDef*")] out int mdParamDef,
int cMax /*must be 1*/,
[ComAliasName("ULONG*")] out uint pcTokens);
-
+#if !MDBG_FAKE_COM
// STDMETHOD(EnumMemberRefs)( // S_OK, S_FALSE, or error.
// HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
// mdToken tkParent, // [IN] Parent token to scope the enumeration.
@@ -821,7 +841,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// ULONG cbSigBlob, // [IN] count of bytes in the signature blob
// mdMemberRef *pmr) PURE; // [OUT] matching memberref
new void FindMemberRef_();
-
+#endif
// STDMETHOD (GetMethodProps)(
// mdMethodDef mb, // The method for which to get props.
// mdTypeDef *pClass, // Put method's class here.
@@ -868,8 +888,12 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// mdProperty rProperties[], // [OUT] Put Properties here.
// ULONG cMax, // [IN] Max properties to put.
// ULONG *pcProperties) PURE; // [OUT] Put # put here.
- new void EnumProperties_();
-
+ new void EnumProperties(ref IntPtr phEnum,
+ int td,
+ [ComAliasName("mdProperty*")] out int mdProperty,
+ int cMax /*must be 1*/,
+ [ComAliasName("ULONG*")] out uint pcProperties);
+#if !MDBG_FAKE_COM
// STDMETHOD(EnumEvents)( // S_OK, S_FALSE, or error.
// HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
// mdTypeDef td, // [IN] TypeDef to scope the enumeration.
@@ -974,7 +998,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// ULONG cMax, // [IN] Max MemberDefs to put.
// ULONG *pcTokens) PURE; // [OUT] Put # put here.
new void EnumUnresolvedMethods_();
-
+#endif
// STDMETHOD(GetUserString)( // S_OK or error.
// mdString stk, // [IN] String token.
// LPWSTR szString, // [OUT] Copy of string.
@@ -985,7 +1009,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
[In] int cchString,
[ComAliasName("ULONG*")] out int pchString
);
-
+#if !MDBG_FAKE_COM
// STDMETHOD(GetPinvokeMap)( // S_OK or error.
// mdToken tk, // [IN] FieldDef or MethodDef.
// DWORD *pdwMappingFlags, // [OUT] Flags used for mapping.
@@ -1021,7 +1045,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// ULONG ulParamSeq, // [IN] Parameter sequence.
// mdParamDef *ppd) PURE; // [IN] Put Param token here.
new void GetParamForMethodIndex_();
-
+#endif
// STDMETHOD(EnumCustomAttributes)( // S_OK or error.
// HCORENUM *phEnum, // [IN, OUT] COR enumerator.
// mdToken tk, // [IN] Token to scope the enumeration, 0 for all.
@@ -1036,7 +1060,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
uint cMax /*must be 1*/,
[ComAliasName("ULONG*")]out uint pcTokens
);
-
+#if !MDBG_FAKE_COM
// STDMETHOD(GetCustomAttributeProps)( // S_OK or error.
// mdCustomAttribute cv, // [IN] CustomAttribute token.
// mdToken *ptkObj, // [OUT, OPTIONAL] Put object token here.
@@ -1066,7 +1090,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// void const **ppValue, // [OUT] constant value
// ULONG *pcchValue) PURE; // [OUT] size of constant string in chars, 0 for non-strings.
new void GetMemberProps_();
-
+#endif
// STDMETHOD(GetFieldProps)(
// mdFieldDef mb, // The field for which to get props.
// mdTypeDef *pClass, // Put field's class here.
@@ -1109,7 +1133,23 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// mdMethodDef rmdOtherMethod[], // [OUT] other method of the property
// ULONG cMax, // [IN] size of rmdOtherMethod
// ULONG *pcOtherMethod) PURE; // [OUT] total number of other method of this property
- new void GetPropertyProps_();
+ new void GetPropertyProps(int prop,
+ [ComAliasName ("mdTypeDef*")] out int mdTypeDef,
+ [Out, MarshalAs (UnmanagedType.LPWStr)] StringBuilder szProperty,
+ int cchProperty,
+ [ComAliasName ("ULONG*")] out int pchProperty,
+ [ComAliasName ("DWORD*")] out int pdwPropFlags,
+ [ComAliasName ("PCCOR_SIGNATURE*")] out IntPtr ppvSig,
+ [ComAliasName ("ULONG*")] out int pbSig,
+ [ComAliasName ("DWORD*")] out int pdwCPlusTypeFlag,
+ [ComAliasName ("UVCP_CONSTANT*")] out IntPtr ppDefaultValue,
+ [ComAliasName ("ULONG*")] out int pcchDefaultValue,
+ [ComAliasName ("mdMethodDef*")] out int pmdSetter,
+ [ComAliasName ("mdMethodDef*")] out int pmdGetter,
+ [ComAliasName ("mdMethodDef*")] out int rmdOtherMethod,
+ [ComAliasName ("ULONG*")] int cMax, /* must be 1 */
+ [ComAliasName ("ULONG*")] out int pcOtherMethod
+ );
// STDMETHOD(GetParamProps)( // S_OK or error.
// mdParamDef tk, // [IN]The Parameter.
@@ -1154,7 +1194,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// mdTypeDef tdNestedClass, // [IN] NestedClass token.
// mdTypeDef *ptdEnclosingClass) PURE; // [OUT] EnclosingClass token.
new void GetNestedClassProps(int tdNestedClass, [ComAliasName("mdTypeDef*")] out int tdEnclosingClass);
-
+#if !MDBG_FAKE_COM
// STDMETHOD(GetNativeCallConvFromSig)( // S_OK or error.
// void const *pvSig, // [IN] Pointer to signature.
// ULONG cbSig, // [IN] Count of signature bytes.
@@ -1166,7 +1206,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// mdToken pd, // [IN] Type, Field, or Method token.
// int *pbGlobal) PURE; // [OUT] Put 1 if global, 0 otherwise.
new void IsGlobal_();
-
+#endif
//-----------------------------------------------------------------------------
// Begin IMetaDataImport2
//-----------------------------------------------------------------------------
@@ -1217,7 +1257,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
[ComAliasName("PCCOR_SIGNATURE*")] out IntPtr ppvSigBlob,
[ComAliasName("ULONG*")] out int pcbSigBlob
);
-
+#if !MDBG_FAKE_COM
// STDMETHOD(EnumGenericParamConstraints)(
// HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
// mdGenericParam tk, // [IN] GenericParam whose constraints are requested
@@ -1250,6 +1290,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata.NativeApi
// ULONG cMax, // [IN] Max tokens to put.
// ULONG *pcMethodSpecs) PURE; // [OUT] Put actual count here.
void EnumMethodSpecs_();
+#endif
}
// GUID Copied from Cor.h
diff --git a/extras/MonoDevelop.Debugger.Win32/CorApi2/Metadata/CorMetadata.cs b/extras/MonoDevelop.Debugger.Win32/CorApi2/Metadata/CorMetadata.cs
index c662fb6b4a..b4b2b9e083 100644
--- a/extras/MonoDevelop.Debugger.Win32/CorApi2/Metadata/CorMetadata.cs
+++ b/extras/MonoDevelop.Debugger.Win32/CorApi2/Metadata/CorMetadata.cs
@@ -4,11 +4,13 @@
// Copyright (C) Microsoft Corporation. All rights reserved.
//---------------------------------------------------------------------
using System;
+using System.IO;
using System.Reflection;
using System.Text;
using System.Runtime.InteropServices;
using System.Globalization;
using System.Collections;
+using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.Samples.Debugging.CorDebug;
@@ -19,6 +21,29 @@ namespace Microsoft.Samples.Debugging.CorMetadata
{
public sealed class CorMetadataImport
{
+ // [Xamarin] Expression evaluator.
+ public static Dictionary<CorElementType, Type> CoreTypes = new Dictionary<CorElementType, Type> ();
+
+ // [Xamarin] Expression evaluator.
+ static CorMetadataImport ()
+ {
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_BOOLEAN, typeof (bool));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_CHAR, typeof (char));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_I1, typeof (sbyte));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_U1, typeof (byte));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_I2, typeof (short));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_U2, typeof (ushort));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_I4, typeof (int));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_U4, typeof (uint));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_I8, typeof (long));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_U8, typeof (ulong));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_R4, typeof (float));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_R8, typeof (double));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_STRING, typeof (string));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_I, typeof (IntPtr));
+ CoreTypes.Add (CorElementType.ELEMENT_TYPE_U, typeof (UIntPtr));
+ }
+
public CorMetadataImport(CorModule managedModule)
{
m_importer = managedModule.GetMetaDataInterface <IMetadataImport>();
@@ -299,15 +324,19 @@ namespace Microsoft.Samples.Debugging.CorMetadata
out pulCodeRVA,
out pdwImplFlags);
- m_name = szMethodName.ToString();
+ // [Xamarin] Expression evaluator.
+ CorCallingConvention callingConv;
+ MetadataHelperFunctions.ReadMethodSignature (importer, ref ppvSigBlob, out callingConv, out m_retType, out m_argTypes);
+ m_name = szMethodName.ToString ();
m_methodAttributes = (MethodAttributes)pdwAttr;
}
+ // [Xamarin] Expression evaluator.
public override Type ReturnType
{
get
{
- throw new NotImplementedException();
+ return m_retType;
}
}
@@ -392,10 +421,12 @@ namespace Microsoft.Samples.Debugging.CorMetadata
throw new NotImplementedException();
}
+ // [Xamarin] Expression evaluator.
public override System.Reflection.ParameterInfo[] GetParameters()
{
ArrayList al = new ArrayList();
IntPtr hEnum = new IntPtr();
+ int nArg = 0;
try
{
while(true)
@@ -406,8 +437,10 @@ namespace Microsoft.Samples.Debugging.CorMetadata
m_methodToken, out paramToken,1,out count);
if(count!=1)
break;
- al.Add(new MetadataParameterInfo(m_importer,paramToken,
- this,DeclaringType));
+ MetadataParameterInfo mp = new MetadataParameterInfo (m_importer, paramToken,
+ this, DeclaringType, m_argTypes [nArg++]);
+ if (mp.Name != string.Empty)
+ al.Add(mp);
}
}
finally
@@ -435,7 +468,10 @@ namespace Microsoft.Samples.Debugging.CorMetadata
private int m_classToken;
private int m_methodToken;
private MethodAttributes m_methodAttributes;
- }
+ // [Xamarin] Expression evaluator.
+ private List<Type> m_argTypes;
+ private Type m_retType;
+ }
public enum MetadataTokenType
{
@@ -558,6 +594,119 @@ namespace Microsoft.Samples.Debugging.CorMetadata
{
private static uint TokenFromRid(uint rid, uint tktype) {return (rid) | (tktype);}
+ // [Xamarin] Expression evaluator.
+ public static void ReadMethodSignature (IMetadataImport importer, ref IntPtr pData, out CorCallingConvention cconv, out Type retType, out List<Type> argTypes)
+ {
+ cconv = MetadataHelperFunctions.CorSigUncompressCallingConv (ref pData);
+ uint numArgs = MetadataHelperFunctions.CorSigUncompressData (ref pData);
+ retType = MetadataHelperFunctions.ReadType (importer, ref pData);
+ argTypes = new List<Type> ();
+ for (int n = 0; n < numArgs; n++)
+ argTypes.Add (MetadataHelperFunctions.ReadType (importer, ref pData));
+ }
+
+ // [Xamarin] Expression evaluator.
+ class GenericType
+ {
+ // Used as marker for generic method args
+ }
+
+ // [Xamarin] Expression evaluator.
+ static Type ReadType (IMetadataImport importer, ref IntPtr pData)
+ {
+ CorElementType et;
+ unsafe {
+ byte* pBytes = (byte*)pData;
+ et = (CorElementType) (*pBytes);
+ pData = (IntPtr) (pBytes + 1);
+ }
+
+ switch (et)
+ {
+ case CorElementType.ELEMENT_TYPE_VOID: return typeof (void);
+ case CorElementType.ELEMENT_TYPE_BOOLEAN: return typeof (bool);
+ case CorElementType.ELEMENT_TYPE_CHAR: return typeof (char);
+ case CorElementType.ELEMENT_TYPE_I1: return typeof (sbyte);
+ case CorElementType.ELEMENT_TYPE_U1: return typeof (byte);
+ case CorElementType.ELEMENT_TYPE_I2: return typeof (short);
+ case CorElementType.ELEMENT_TYPE_U2: return typeof (ushort);
+ case CorElementType.ELEMENT_TYPE_I4: return typeof (int);
+ case CorElementType.ELEMENT_TYPE_U4: return typeof (uint);
+ case CorElementType.ELEMENT_TYPE_I8: return typeof (long);
+ case CorElementType.ELEMENT_TYPE_U8: return typeof (ulong);
+ case CorElementType.ELEMENT_TYPE_R4: return typeof (float);
+ case CorElementType.ELEMENT_TYPE_R8: return typeof (double);
+ case CorElementType.ELEMENT_TYPE_STRING: return typeof (string);
+ case CorElementType.ELEMENT_TYPE_I: return typeof (IntPtr);
+ case CorElementType.ELEMENT_TYPE_U: return typeof (UIntPtr);
+ case CorElementType.ELEMENT_TYPE_OBJECT: return typeof (object);
+
+ case CorElementType.ELEMENT_TYPE_VAR:
+ case CorElementType.ELEMENT_TYPE_MVAR:
+ // Generic args in methods not supported. Return a dummy type.
+ CorSigUncompressData (ref pData);
+ return typeof(GenericType);
+
+ case CorElementType.ELEMENT_TYPE_GENERICINST: {
+ Type t = ReadType (importer, ref pData);
+ List<Type> typeArgs = new List<Type> ();
+ uint num = CorSigUncompressData (ref pData);
+ for (int n=0; n<num; n++) {
+ typeArgs.Add (ReadType (importer, ref pData));
+ }
+ return MetadataType.MakeGeneric (t, typeArgs);
+ }
+
+ case CorElementType.ELEMENT_TYPE_PTR: {
+ Type t = ReadType (importer, ref pData);
+ return MetadataType.MakePointer (t);
+ }
+
+ case CorElementType.ELEMENT_TYPE_BYREF: {
+ Type t = ReadType (importer, ref pData);
+ return MetadataType.MakeByRef(t);
+ }
+
+ case CorElementType.ELEMENT_TYPE_VALUETYPE:
+ case CorElementType.ELEMENT_TYPE_CLASS: {
+ uint token = CorSigUncompressToken (ref pData);
+ return new MetadataType (importer, (int) token);
+ }
+
+ case CorElementType.ELEMENT_TYPE_ARRAY: {
+ Type t = ReadType (importer, ref pData);
+ uint rank = CorSigUncompressData (ref pData);
+ uint numSizes = CorSigUncompressData (ref pData);
+ List<int> sizes = new List<int> ();
+ for (int n = 0; n < numSizes; n++)
+ sizes.Add ((int)CorSigUncompressData (ref pData));
+ uint numLoBounds = CorSigUncompressData (ref pData);
+ List<int> loBounds = new List<int> ();
+ for (int n = 0; n < numLoBounds; n++)
+ loBounds.Add ((int)CorSigUncompressData (ref pData));
+ return MetadataType.MakeArray (t, sizes, loBounds);
+ }
+
+ case CorElementType.ELEMENT_TYPE_SZARRAY: {
+ Type t = ReadType (importer, ref pData);
+ return MetadataType.MakeArray (t, null, null);
+ }
+
+ case CorElementType.ELEMENT_TYPE_FNPTR: {
+ CorCallingConvention cconv;
+ Type retType;
+ List<Type> argTypes;
+ ReadMethodSignature (importer, ref pData, out cconv, out retType, out argTypes);
+ return MetadataType.MakeDelegate (retType, argTypes);
+ }
+
+ case CorElementType.ELEMENT_TYPE_CMOD_REQD:
+ case CorElementType.ELEMENT_TYPE_CMOD_OPT:
+ return ReadType (importer, ref pData);
+ }
+ throw new NotSupportedException ("Unknown sig element type: " + et);
+ }
+
// The below have been translated manually from the inline C++ helpers in cor.h
internal static uint CorSigUncompressBigData(
@@ -817,6 +966,97 @@ namespace Microsoft.Samples.Debugging.CorMetadata
}
return genargs;
}
- }
+ // [Xamarin] Expression evaluator.
+ static object[] emptyAttributes = new object[0];
+
+ static internal object[] GetDebugAttributes (IMetadataImport importer, int token)
+ {
+ ArrayList attributes = new ArrayList ();
+ object attr = MetadataHelperFunctions.GetCustomAttribute (importer, token, typeof (System.Diagnostics.DebuggerTypeProxyAttribute));
+ if (attr != null)
+ attributes.Add (attr);
+ attr = MetadataHelperFunctions.GetCustomAttribute (importer, token, typeof (System.Diagnostics.DebuggerDisplayAttribute));
+ if (attr != null)
+ attributes.Add (attr);
+ attr = MetadataHelperFunctions.GetCustomAttribute (importer, token, typeof (System.Diagnostics.DebuggerBrowsableAttribute));
+ if (attr != null)
+ attributes.Add (attr);
+ attr = MetadataHelperFunctions.GetCustomAttribute (importer, token, typeof (System.Runtime.CompilerServices.CompilerGeneratedAttribute));
+ if (attr != null)
+ attributes.Add (attr);
+
+ if (attributes.Count == 0)
+ return emptyAttributes;
+ else
+ return attributes.ToArray ();
+ }
+
+ // [Xamarin] Expression evaluator.
+ static internal object GetCustomAttribute (IMetadataImport importer, int token, Type type)
+ {
+ uint sigSize = 0;
+ IntPtr ppvSig = IntPtr.Zero;
+ int hr = importer.GetCustomAttributeByName (token, type.FullName, out ppvSig, out sigSize);
+ if (hr != 0)
+ return null;
+
+ byte[] data = new byte[sigSize];
+ Marshal.Copy (ppvSig, data, 0, (int)sigSize);
+ BinaryReader br = new BinaryReader (new MemoryStream (data));
+
+ // Prolog
+ if (br.ReadUInt16 () != 1)
+ throw new InvalidOperationException ("Incorrect attribute prolog");
+
+ ConstructorInfo ctor = type.GetConstructors ()[0];
+ ParameterInfo[] pars = ctor.GetParameters ();
+
+ object[] args = new object[pars.Length];
+
+ // Fixed args
+ for (int n=0; n<pars.Length; n++)
+ args [n] = ReadValue (br, pars[n].ParameterType);
+
+ object ob = Activator.CreateInstance (type, args);
+
+ // Named args
+ uint nargs = br.ReadUInt16 ();
+ for (; nargs > 0; nargs--) {
+ byte fieldOrProp = br.ReadByte ();
+ byte atype = br.ReadByte ();
+
+ // Boxed primitive
+ if (atype == 0x51)
+ atype = br.ReadByte ();
+ CorElementType et = (CorElementType) atype;
+ string pname = br.ReadString ();
+ object val = ReadValue (br, CorMetadataImport.CoreTypes[et]);
+
+ if (fieldOrProp == 0x53) {
+ FieldInfo fi = type.GetField (pname);
+ fi.SetValue (ob, val);
+ }
+ else {
+ PropertyInfo pi = type.GetProperty (pname);
+ pi.SetValue (ob, val, null);
+ }
+ }
+ return ob;
+ }
+
+ // [Xamarin] Expression evaluator.
+ static object ReadValue (BinaryReader br, Type type)
+ {
+ if (type.IsEnum) {
+ object ob = ReadValue (br, Enum.GetUnderlyingType (type));
+ return Enum.ToObject (type, Convert.ToInt64 (ob));
+ }
+ if (type == typeof (string) || type == typeof(Type))
+ return br.ReadString ();
+ if (type == typeof (int))
+ return br.ReadInt32 ();
+ throw new InvalidOperationException ("Can't parse value of type: " + type);
+ }
+ }
} // namspace Microsoft.Debugger.MetadataWrapper
diff --git a/extras/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataFieldInfo.cs b/extras/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataFieldInfo.cs
index b98ce101ae..262979bba2 100644
--- a/extras/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataFieldInfo.cs
+++ b/extras/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataFieldInfo.cs
@@ -65,7 +65,9 @@ namespace Microsoft.Samples.Debugging.CorMetadata
{
m_value = ParseDefaultValue(declaringType,ppvSigBlob,ppvRawValue);
}
- }
+ // [Xamarin] Expression evaluator.
+ MetadataHelperFunctions.GetCustomAttribute (importer, m_fieldToken, typeof (System.Diagnostics.DebuggerBrowsableAttribute));
+ }
private static object ParseDefaultValue(MetadataType declaringType, IntPtr ppvSigBlob, IntPtr ppvRawValue)
{
@@ -145,20 +147,30 @@ namespace Microsoft.Samples.Debugging.CorMetadata
throw new NotImplementedException();
}
- public override Object[] GetCustomAttributes(bool inherit)
- {
- throw new NotImplementedException();
- }
-
- public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
- {
- throw new NotImplementedException();
- }
-
- public override bool IsDefined (Type attributeType, bool inherit)
- {
- throw new NotImplementedException();
- }
+ // [Xamarin] Expression evaluator.
+ public override bool IsDefined (Type attributeType, bool inherit)
+ {
+ return GetCustomAttributes (attributeType, inherit).Length > 0;
+ }
+
+ // [Xamarin] Expression evaluator.
+ public override object[] GetCustomAttributes (Type attributeType, bool inherit)
+ {
+ ArrayList list = new ArrayList ();
+ foreach (object ob in GetCustomAttributes (inherit)) {
+ if (attributeType.IsInstanceOfType (ob))
+ list.Add (ob);
+ }
+ return list.ToArray ();
+ }
+
+ // [Xamarin] Expression evaluator.
+ public override object[] GetCustomAttributes (bool inherit)
+ {
+ if (m_customAttributes == null)
+ m_customAttributes = MetadataHelperFunctions.GetDebugAttributes (m_importer, m_fieldToken);
+ return m_customAttributes;
+ }
public override Type FieldType
@@ -232,5 +244,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata
private string m_name;
private FieldAttributes m_fieldAttributes;
private Object m_value;
- }
+ // [Xamarin] Expression evaluator.
+ private object[] m_customAttributes;
+ }
}
diff --git a/extras/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataParameterInfo.cs b/extras/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataParameterInfo.cs
index 4eda1940af..0793fab1fc 100644
--- a/extras/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataParameterInfo.cs
+++ b/extras/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataParameterInfo.cs
@@ -19,8 +19,9 @@ namespace Microsoft.Samples.Debugging.CorMetadata
{
public sealed class MetadataParameterInfo : ParameterInfo
{
+ // [Xamarin] Expression evaluator.
internal MetadataParameterInfo(IMetadataImport importer,int paramToken,
- MemberInfo memberImpl,Type typeImpl)
+ MemberInfo memberImpl,Type typeImpl, Type argType)
{
int parentToken;
uint pulSequence,pdwAttr,pdwCPlusTypeFlag,pcchValue,size;
@@ -50,7 +51,8 @@ namespace Microsoft.Samples.Debugging.CorMetadata
out pcchValue
);
NameImpl = szName.ToString();
- ClassImpl = typeImpl;
+ // [Xamarin] Expression evaluator.
+ ClassImpl = argType;
PositionImpl = (int)pulSequence;
AttrsImpl = (ParameterAttributes)pdwAttr;
diff --git a/extras/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataType.cs b/extras/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataType.cs
index e5a5184580..7ab4f88877 100644
--- a/extras/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataType.cs
+++ b/extras/MonoDevelop.Debugger.Win32/CorApi2/Metadata/MetadataType.cs
@@ -20,6 +20,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata
{
public sealed class MetadataType : Type
{
+ // [Xamarin] Expression evaluator.
internal MetadataType(IMetadataImport importer,int classToken)
{
Debug.Assert(importer!=null);
@@ -60,24 +61,31 @@ namespace Microsoft.Samples.Debugging.CorMetadata
string baseTypeName = GetTypeName(importer, ptkExtends);
IntPtr ppvSig;
- if (baseTypeName == "System.Enum")
- {
- m_isEnum = true;
- m_enumUnderlyingType = GetEnumUnderlyingType(importer,classToken);
-
- // Check for flags enum by looking for FlagsAttribute
- uint sigSize = 0;
- ppvSig = IntPtr.Zero;
- int hr = importer.GetCustomAttributeByName(classToken,"System.FlagsAttribute",out ppvSig,out sigSize);
- if (hr < 0)
- {
- throw new COMException("Exception looking for flags attribute",hr);
- }
- m_isFlagsEnum = (hr == 0); // S_OK means the attribute is present.
- }
+ if (baseTypeName == "System.Enum") {
+ m_isEnum = true;
+ m_enumUnderlyingType = GetEnumUnderlyingType (importer, classToken);
+
+ // Check for flags enum by looking for FlagsAttribute
+ uint sigSize = 0;
+ ppvSig = IntPtr.Zero;
+ int hr = importer.GetCustomAttributeByName (classToken, "System.FlagsAttribute", out ppvSig, out sigSize);
+ if (hr < 0) {
+ throw new COMException ("Exception looking for flags attribute", hr);
+ }
+ m_isFlagsEnum = (hr == 0); // S_OK means the attribute is present.
+ }
}
}
+ // [Xamarin] Expression evaluator.
+ public override Type DeclaringType
+ {
+ get
+ {
+ return m_declaringType;
+ }
+ }
+
private static string GetTypeName(IMetadataImport importer, int tk)
{
// Get the base type name
@@ -183,11 +191,18 @@ namespace Microsoft.Samples.Debugging.CorMetadata
}
}
+ // [Xamarin] Expression evaluator.
public override string Name
{
get
{
- return FullName;
+ int i = m_name.LastIndexOf ('+');
+ if (i == -1)
+ i = m_name.LastIndexOf ('.');
+ if (i != -1)
+ return m_name.Substring (i + 1);
+ else
+ return m_name;
}
}
@@ -220,19 +235,43 @@ namespace Microsoft.Samples.Debugging.CorMetadata
}
}
+ // [Xamarin] Expression evaluator.
public override String Namespace
{
get
{
- throw new NotImplementedException();
- }
+ int i = m_name.LastIndexOf ('.');
+ if (i != -1)
+ return m_name.Substring (0, i);
+ else
+ return "";
+ }
}
+ // [Xamarin] Expression evaluator.
public override String FullName
{
get
{
- return m_name;
+ StringBuilder sb = new StringBuilder (m_name);
+ if (m_typeArgs != null) {
+ sb.Append ("[");
+ for (int n = 0; n < m_typeArgs.Count; n++) {
+ if (n > 0)
+ sb.Append (",");
+ sb.Append (m_typeArgs[n].FullName);
+ }
+ sb.Append ("]");
+ }
+ if (IsPointer)
+ sb.Append ("*");
+ if (IsArray) {
+ sb.Append ("[");
+ for (int n = 1; n < m_arraySizes.Count; n++)
+ sb.Append (",");
+ sb.Append ("]");
+ }
+ return sb.ToString ();
}
}
@@ -269,22 +308,37 @@ namespace Microsoft.Samples.Debugging.CorMetadata
}
}
+ // [Xamarin] Expression evaluator.
+ public override Type[] GetGenericArguments ()
+ {
+ return m_typeArgs.ToArray ();
+ }
// methods
+ // [Xamarin] Expression evaluator.
public override bool IsDefined (Type attributeType, bool inherit)
{
- throw new NotImplementedException();
+ return GetCustomAttributes (attributeType, inherit).Length > 0;
}
+ // [Xamarin] Expression evaluator.
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
{
- throw new NotImplementedException();
+ ArrayList list = new ArrayList ();
+ foreach (object ob in GetCustomAttributes (inherit)) {
+ if (attributeType.IsInstanceOfType (ob))
+ list.Add (ob);
+ }
+ return list.ToArray ();
}
+ // [Xamarin] Expression evaluator.
public override object[] GetCustomAttributes(bool inherit)
{
- throw new NotImplementedException();
+ if (m_customAttributes == null)
+ m_customAttributes = MetadataHelperFunctions.GetDebugAttributes (m_importer, m_typeToken);
+ return m_customAttributes;
}
protected override bool HasElementTypeImpl()
@@ -307,19 +361,22 @@ namespace Microsoft.Samples.Debugging.CorMetadata
throw new NotImplementedException();
}
+ // [Xamarin] Expression evaluator.
protected override bool IsPointerImpl()
{
- throw new NotImplementedException();
+ return m_isPtr;
}
+ // [Xamarin] Expression evaluator.
protected override bool IsByRefImpl()
{
- throw new NotImplementedException();
+ return m_isByRef;
}
+ // [Xamarin] Expression evaluator.
protected override bool IsArrayImpl()
{
- throw new NotImplementedException();
+ return m_arraySizes != null;
}
protected override TypeAttributes GetAttributeFlagsImpl()
@@ -327,6 +384,15 @@ namespace Microsoft.Samples.Debugging.CorMetadata
throw new NotImplementedException();
}
+ // [Xamarin] Expression evaluator.
+ public override int GetArrayRank ()
+ {
+ if (m_arraySizes != null)
+ return m_arraySizes.Count;
+ else
+ return 0;
+ }
+
public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
{
throw new NotImplementedException();
@@ -342,10 +408,38 @@ namespace Microsoft.Samples.Debugging.CorMetadata
throw new NotImplementedException();
}
+ // [Xamarin] Expression evaluator.
public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
{
- throw new NotImplementedException();
- }
+ ArrayList al = new ArrayList ();
+ IntPtr hEnum = new IntPtr ();
+
+ int methodToken;
+ try {
+ while (true) {
+ uint size;
+ ((IMetadataImport2)m_importer).EnumProperties (ref hEnum, (int) m_typeToken, out methodToken, 1, out size);
+ if (size == 0)
+ break;
+ MetadataPropertyInfo prop = new MetadataPropertyInfo (m_importer, methodToken, this);
+ try {
+ MethodInfo mi = prop.GetGetMethod ();
+ if (mi == null)
+ mi = prop.GetSetMethod ();
+ if (FlagsMatch (mi.IsPublic, mi.IsStatic, bindingAttr))
+ al.Add (prop);
+ }
+ catch {
+ // Ignore
+ }
+ }
+ }
+ finally {
+ m_importer.CloseEnum (hEnum);
+ }
+
+ return (PropertyInfo[]) al.ToArray (typeof (PropertyInfo));
+ }
protected override PropertyInfo GetPropertyImpl(String name, BindingFlags bindingAttr,Binder binder,
Type returnType, Type[] types, ParameterModifier[] modifiers)
@@ -378,6 +472,21 @@ namespace Microsoft.Samples.Debugging.CorMetadata
throw new NotImplementedException();
}
+ // [Xamarin] Expression evaluator.
+ bool FlagsMatch (bool ispublic, bool isstatic, BindingFlags flags)
+ {
+ if (ispublic && (flags & BindingFlags.Public) == 0)
+ return false;
+ if (!ispublic && (flags & BindingFlags.NonPublic) == 0)
+ return false;
+ if (isstatic && (flags & BindingFlags.Static) == 0)
+ return false;
+ if (!isstatic && (flags & BindingFlags.Instance) == 0)
+ return false;
+ return true;
+ }
+
+ // [Xamarin] Expression evaluator.
public override FieldInfo[] GetFields(BindingFlags bindingAttr)
{
ArrayList al = new ArrayList();
@@ -389,10 +498,13 @@ namespace Microsoft.Samples.Debugging.CorMetadata
while(true)
{
uint size;
- m_importer.EnumFields(ref hEnum,(int)m_typeToken,out fieldToken,1,out size);
+ // TODO: Check this. Was just m_importer.EnumFields.
+ ((IMetadataImport2) m_importer).EnumFields(ref hEnum,(int)m_typeToken,out fieldToken,1,out size);
if(size==0)
break;
- al.Add(new MetadataFieldInfo(m_importer,fieldToken,this));
+ MetadataFieldInfo field = new MetadataFieldInfo (m_importer, fieldToken, this);
+ if (FlagsMatch (field.IsPublic, field.IsStatic, bindingAttr))
+ al.Add (field);
}
}
finally
@@ -402,6 +514,7 @@ namespace Microsoft.Samples.Debugging.CorMetadata
return (FieldInfo[]) al.ToArray(typeof(FieldInfo));
}
+ // [Xamarin] Expression evaluator.
public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
{
ArrayList al = new ArrayList();
@@ -416,7 +529,9 @@ namespace Microsoft.Samples.Debugging.CorMetadata
m_importer.EnumMethods(ref hEnum,(int)m_typeToken,out methodToken,1,out size);
if(size==0)
break;
- al.Add(new MetadataMethodInfo(m_importer,methodToken));
+ MetadataMethodInfo met = new MetadataMethodInfo (m_importer, methodToken);
+ if (FlagsMatch (met.IsPublic, met.IsStatic, bindingAttr))
+ al.Add (met);
}
}
finally
@@ -517,30 +632,95 @@ namespace Microsoft.Samples.Debugging.CorMetadata
}
}
+ // [Xamarin] Expression evaluator.
// returns "" for normal classes, returns prefix for nested classes
- private static string GetNestedClassPrefix(IMetadataImport importer, int classToken, TypeAttributes attribs)
+ private string GetNestedClassPrefix(IMetadataImport importer, int classToken, TypeAttributes attribs)
{
if( (attribs & TypeAttributes.VisibilityMask) > TypeAttributes.Public )
{
// it is a nested class
int enclosingClass;
importer.GetNestedClassProps(classToken, out enclosingClass);
- MetadataType mt = new MetadataType(importer,enclosingClass);
- return mt.Name+".";
+ m_declaringType = new MetadataType (importer, enclosingClass);
+ return m_declaringType.FullName + "+";
}
else
return String.Empty;
}
- // member variables
- private string m_name;
- private IMetadataImport m_importer;
- private int m_typeToken;
- private bool m_isEnum;
- private bool m_isFlagsEnum;
- private CorElementType m_enumUnderlyingType;
- private List<KeyValuePair<string,ulong>> m_enumValues;
- }
+ // [Xamarin] Expression evaluator.
+ internal static Type MakeDelegate (Type retType, List<Type> argTypes)
+ {
+
+ throw new NotImplementedException ();
+ }
+
+ // [Xamarin] Expression evaluator.
+ public static Type MakeArray (Type t, List<int> sizes, List<int> loBounds)
+ {
+ MetadataType mt = t as MetadataType;
+ if (mt != null) {
+ if (sizes == null) {
+ sizes = new List<int> ();
+ sizes.Add (1);
+ }
+ mt.m_arraySizes = sizes;
+ mt.m_arrayLoBounds = loBounds;
+ return mt;
+ }
+ if (sizes == null || sizes.Count == 1)
+ return t.MakeArrayType ();
+ else
+ return t.MakeArrayType (sizes.Count);
+ }
+
+ // [Xamarin] Expression evaluator.
+ public static Type MakeByRef (Type t)
+ {
+ MetadataType mt = t as MetadataType;
+ if (mt != null) {
+ mt.m_isByRef = true;
+ return mt;
+ }
+ return t.MakeByRefType ();
+ }
+
+ // [Xamarin] Expression evaluator.
+ public static Type MakePointer (Type t)
+ {
+ MetadataType mt = t as MetadataType;
+ if (mt != null) {
+ mt.m_isPtr = true;
+ return mt;
+ }
+ return t.MakeByRefType ();
+ }
+
+ // [Xamarin] Expression evaluator.
+ public static Type MakeGeneric (Type t, List<Type> typeArgs)
+ {
+ MetadataType mt = (MetadataType)t;
+ mt.m_typeArgs = typeArgs;
+ return mt;
+ }
+
+ // member variables
+ private string m_name;
+ private IMetadataImport m_importer;
+ private int m_typeToken;
+ private bool m_isEnum;
+ private bool m_isFlagsEnum;
+ private CorElementType m_enumUnderlyingType;
+ // [Xamarin] Expression evaluator.
+ private List<KeyValuePair<string, ulong>> m_enumValues;
+ private object[] m_customAttributes;
+ private Type m_declaringType;
+ private List<int> m_arraySizes;
+ private List<int> m_arrayLoBounds;
+ private bool m_isByRef, m_isPtr;
+ private List<Type> m_typeArgs;
+
+ }
// Sorts KeyValuePair<string,ulong>'s in increasing order by the value
class AscendingValueComparer<K, V> : IComparer<KeyValuePair<K,V>> where V:IComparable
diff --git a/extras/MonoDevelop.Debugger.Win32/CorApi2/debug/CorAPIAssemblyAttributes.cs b/extras/MonoDevelop.Debugger.Win32/CorApi2/debug/CorAPIAssemblyAttributes.cs
index 881760c68b..3da9b7c4ec 100644
--- a/extras/MonoDevelop.Debugger.Win32/CorApi2/debug/CorAPIAssemblyAttributes.cs
+++ b/extras/MonoDevelop.Debugger.Win32/CorApi2/debug/CorAPIAssemblyAttributes.cs
@@ -9,5 +9,5 @@ using System.Security.Permissions;
// Expose non-CLS-compliant types, so we can't be CLS-compliant
[assembly:CLSCompliant(true)]
-[assembly:System.Runtime.InteropServices.ComVisible(false)]
-[assembly:SecurityPermission(SecurityAction.RequestMinimum, Unrestricted=true)] \ No newline at end of file
+// [Xamarin] Bump version to .NET 4.0.
+[assembly:System.Runtime.InteropServices.ComVisible(false)] \ No newline at end of file
diff --git a/extras/MonoDevelop.Debugger.Win32/CorApi2/debug/Debugger.cs b/extras/MonoDevelop.Debugger.Win32/CorApi2/debug/Debugger.cs
index 8f717fbd8a..ddbc5f186d 100644
--- a/extras/MonoDevelop.Debugger.Win32/CorApi2/debug/Debugger.cs
+++ b/extras/MonoDevelop.Debugger.Win32/CorApi2/debug/Debugger.cs
@@ -5,8 +5,11 @@
//---------------------------------------------------------------------
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Diagnostics;
+#if !MDBG_FAKE_COM
using System.Runtime.InteropServices;
+#endif
using System.Runtime.InteropServices.ComTypes;
using System.Threading;
using System.Text;
@@ -15,6 +18,7 @@ using System.Globalization;
using Microsoft.Samples.Debugging.CorDebug.NativeApi;
+using Microsoft.Win32.SafeHandles;
namespace Microsoft.Samples.Debugging.CorDebug
@@ -27,6 +31,8 @@ namespace Microsoft.Samples.Debugging.CorDebug
public sealed class CorDebugger : MarshalByRefObject
{
private const int MaxVersionStringLength = 256; // == MAX_PATH
+ // [Xamarin] Output redirection.
+ public const int CREATE_REDIRECT_STD = 0x40000000;
public static string GetDebuggerVersionFromFile(string pathToExe)
{
@@ -147,6 +153,7 @@ namespace Microsoft.Samples.Debugging.CorDebug
return CreateProcess (applicationName, commandLine, ".");
}
+ // [Xamarin] ASP.NET Debugging.
/**
* Launch a process under the control of the debugger.
*
@@ -158,9 +165,26 @@ namespace Microsoft.Samples.Debugging.CorDebug
String currentDirectory
)
{
- return CreateProcess (applicationName, commandLine, currentDirectory, 0);
- }
-
+ return CreateProcess (applicationName, commandLine, currentDirectory, null, 0);
+ }
+
+ // [Xamarin] ASP.NET Debugging.
+ /**
+ * Launch a process under the control of the debugger.
+ *
+ * Parameters are the same as the Win32 CreateProcess call.
+ */
+ public CorProcess CreateProcess (
+ String applicationName,
+ String commandLine,
+ String currentDirectory,
+ IDictionary<string,string> environment
+ )
+ {
+ return CreateProcess (applicationName, commandLine, currentDirectory, environment, 0);
+ }
+
+ // [Xamarin] ASP.NET Debugging and output redirection.
/**
* Launch a process under the control of the debugger.
*
@@ -170,6 +194,7 @@ namespace Microsoft.Samples.Debugging.CorDebug
String applicationName,
String commandLine,
String currentDirectory,
+ IDictionary<string,string> environment,
int flags
)
{
@@ -179,9 +204,26 @@ namespace Microsoft.Samples.Debugging.CorDebug
si.cb = Marshal.SizeOf(si);
// initialize safe handles
- si.hStdInput = new Microsoft.Win32.SafeHandles.SafeFileHandle(new IntPtr(0),false);
- si.hStdOutput = new Microsoft.Win32.SafeHandles.SafeFileHandle(new IntPtr(0),false);
- si.hStdError = new Microsoft.Win32.SafeHandles.SafeFileHandle(new IntPtr(0),false);
+ SafeFileHandle outReadPipe = null, errorReadPipe = null;
+ if ((flags & CREATE_REDIRECT_STD) != 0) {
+ CreateHandles (si, out outReadPipe, out errorReadPipe);
+ flags &= ~CREATE_REDIRECT_STD;
+ }
+ else {
+ si.hStdInput = new SafeFileHandle (IntPtr.Zero, false);
+ si.hStdOutput = new SafeFileHandle (IntPtr.Zero, false);
+ si.hStdError = new SafeFileHandle (IntPtr.Zero, false);
+ }
+
+ IntPtr env = IntPtr.Zero;
+ if (environment != null) {
+ string senv = null;
+ foreach (KeyValuePair<string, string> var in environment) {
+ senv += var.Key + "=" + var.Value + "\0";
+ }
+ senv += "\0";
+ env = Marshal.StringToHGlobalAnsi (senv);
+ }
CorProcess ret;
@@ -199,7 +241,7 @@ namespace Microsoft.Samples.Debugging.CorDebug
null,
true, // inherit handles
flags, // creation flags
- new IntPtr(0), // environment
+ env, // environment
currentDirectory,
si, // startup info
ref pi, // process information
@@ -208,9 +250,64 @@ namespace Microsoft.Samples.Debugging.CorDebug
NativeMethods.CloseHandle (pi.hThread);
}
- return ret;
+ if (env != IntPtr.Zero)
+ Marshal.FreeHGlobal (env);
+
+ if (outReadPipe != null) {
+
+ // Close pipe handles (do not continue to modify the parent).
+ // You need to make sure that no handles to the write end of the
+ // output pipe are maintained in this process or else the pipe will
+ // not close when the child process exits and the ReadFile will hang.
+
+ si.hStdInput.Close ();
+ si.hStdOutput.Close ();
+ si.hStdError.Close ();
+
+ ret.TrackStdOutput (outReadPipe, errorReadPipe);
+ }
+
+ return ret;
}
+ // [Xamarin] Output redirection.
+ void CreateHandles (STARTUPINFO si, out SafeFileHandle outReadPipe, out SafeFileHandle errorReadPipe)
+ {
+ si.dwFlags |= 0x00000100; /*STARTF_USESTDHANDLES*/
+ SECURITY_ATTRIBUTES sa = new SECURITY_ATTRIBUTES ();
+ sa.bInheritHandle = true;
+ IntPtr curProc = NativeMethods.GetCurrentProcess ();
+
+ SafeFileHandle outWritePipe, outReadPipeTmp;
+ if (!NativeMethods.CreatePipe (out outReadPipeTmp, out outWritePipe, sa, 0))
+ throw new Exception ("Pipe creation failed");
+
+ // Create the child error pipe.
+ SafeFileHandle errorWritePipe, errorReadPipeTmp;
+ if (!NativeMethods.CreatePipe (out errorReadPipeTmp, out errorWritePipe, sa, 0))
+ throw new Exception ("Pipe creation failed");
+
+ // Create new output read and error read handles. Set
+ // the Properties to FALSE. Otherwise, the child inherits the
+ // properties and, as a result, non-closeable handles to the pipes
+ // are created.
+ if (!NativeMethods.DuplicateHandle (curProc, outReadPipeTmp, curProc, out outReadPipe, 0, false, NativeMethods.DUPLICATE_SAME_ACCESS))
+ throw new Exception ("Pipe creation failed");
+ if (!NativeMethods.DuplicateHandle (curProc, errorReadPipeTmp, curProc, out errorReadPipe, 0, false, NativeMethods.DUPLICATE_SAME_ACCESS))
+ throw new Exception ("Pipe creation failed");
+
+ NativeMethods.CloseHandle (curProc);
+
+ // Close inheritable copies of the handles you do not want to be
+ // inherited.
+ outReadPipeTmp.Close ();
+ errorReadPipeTmp.Close ();
+
+ si.hStdInput = NativeMethods.GetStdHandle (NativeMethods.STD_INPUT_HANDLE);
+ si.hStdOutput = outWritePipe;
+ si.hStdError = errorWritePipe;
+ }
+
/**
* Launch a process under the control of the debugger.
*
@@ -319,6 +416,7 @@ namespace Microsoft.Samples.Debugging.CorDebug
//
////////////////////////////////////////////////////////////////////////////////
+ // [Xamarin] .NET 4 API Version.
// called by constructors during initialization
private void InitFromVersion(string debuggerVersion)
{
@@ -329,7 +427,17 @@ namespace Microsoft.Samples.Debugging.CorDebug
}
ICorDebug rawDebuggingAPI;
- rawDebuggingAPI = NativeMethods.CreateDebuggingInterfaceFromVersion((int)CorDebuggerVersion.Whidbey,debuggerVersion);
+#if MDBG_FAKE_COM
+ // TODO: Ideally, there wouldn't be any difference in the corapi code for MDBG_FAKE_COM.
+ // This would require puting this initialization logic into the wrapper and interop assembly, which doesn't seem right.
+ // We should also release this pUnk, but doing that here would be difficult and we aren't done with it until
+ // we shutdown anyway.
+ IntPtr pUnk = NativeMethods.CreateDebuggingInterfaceFromVersion((int)CorDebuggerVersion.Whidbey, debuggerVersion);
+ rawDebuggingAPI = new NativeApi.CorDebugClass(pUnk);
+#else
+ int apiVersion = debuggerVersion.StartsWith ("v4") ? 4 : 3;
+ rawDebuggingAPI = NativeMethods.CreateDebuggingInterfaceFromVersion (apiVersion, debuggerVersion);
+#endif
InitFromICorDebug(rawDebuggingAPI);
}
@@ -502,7 +610,60 @@ namespace Microsoft.Samples.Debugging.CorDebug
ref Guid riid, // must be "ref NativeMethods.IIDICorDebug"
[MarshalAs(UnmanagedType.Interface)]out ICorDebug debuggingInterface
);
- }
+
+ // [Xamarin] Output redirection.
+ [
+ DllImport (Kernel32LibraryName, CharSet = CharSet.Auto, SetLastError = true)
+ ]
+ public static extern bool CreatePipe (out SafeFileHandle hReadPipe, out SafeFileHandle hWritePipe, SECURITY_ATTRIBUTES lpPipeAttributes, int nSize);
+
+ // [Xamarin] Output redirection.
+ [
+ DllImport (Kernel32LibraryName)
+ ]
+ public static extern bool DuplicateHandle (
+ IntPtr hSourceProcessHandle,
+ SafeFileHandle hSourceHandle,
+ IntPtr hTargetProcessHandle,
+ out SafeFileHandle lpTargetHandle,
+ uint dwDesiredAccess,
+ bool bInheritHandle,
+ uint dwOptions
+ );
+
+ // [Xamarin] Output redirection.
+ public static uint DUPLICATE_CLOSE_SOURCE = 0x00000001;
+ public static uint DUPLICATE_SAME_ACCESS = 0x00000002;
+
+ // [Xamarin] Output redirection.
+ [
+ DllImport (Kernel32LibraryName)
+ ]
+ public static extern SafeFileHandle GetStdHandle (uint nStdHandle);
+
+ // [Xamarin] Output redirection.
+ public const uint STD_INPUT_HANDLE = unchecked ((uint)-10);
+ public const uint STD_OUTPUT_HANDLE = unchecked ((uint)-11);
+ public const uint STD_ERROR_HANDLE = unchecked ((uint)-12);
+
+ // [Xamarin] Output redirection.
+ [
+ DllImport (Kernel32LibraryName)
+ ]
+ public static extern bool ReadFile (
+ SafeFileHandle hFile,
+ byte[] lpBuffer,
+ int nNumberOfBytesToRead,
+ out int lpNumberOfBytesRead,
+ IntPtr lpOverlapped
+ );
+
+ // [Xamarin] Output redirection.
+ [
+ DllImport (Kernel32LibraryName, CharSet = CharSet.Auto, SetLastError = true)
+ ]
+ public static extern IntPtr GetCurrentProcess ();
+ }
////////////////////////////////////////////////////////////////////////////////
//
@@ -1808,6 +1969,22 @@ namespace Microsoft.Samples.Debugging.CorDebug
Last = ManagedCallbackType.OnExceptionInCallback,
}
+ // [Xamarin] Output redirection.
+ public class CorTargetOutputEventArgs: EventArgs
+ {
+ public CorTargetOutputEventArgs (string text, bool isStdError)
+ {
+ Text = text;
+ }
+
+ public string Text { get; set; }
+
+ public bool IsStdError { get; set; }
+ }
+
+ // [Xamarin] Output redirection.
+ public delegate void CorTargetOutputEventHandler (Object sender, CorTargetOutputEventArgs e);
+
// Helper class to convert from COM-classic callback interface into managed args.
// Derived classes can overide the HandleEvent method to define the handling.
abstract public class ManagedCallbackBase : ICorDebugManagedCallback, ICorDebugManagedCallback2
diff --git a/extras/MonoDevelop.Debugger.Win32/CorApi2/debug/Process.cs b/extras/MonoDevelop.Debugger.Win32/CorApi2/debug/Process.cs
index 4076b9de20..53ecf17fc2 100644
--- a/extras/MonoDevelop.Debugger.Win32/CorApi2/debug/Process.cs
+++ b/extras/MonoDevelop.Debugger.Win32/CorApi2/debug/Process.cs
@@ -276,6 +276,45 @@ namespace Microsoft.Samples.Debugging.CorDebug
else
base.Continue(outOfBand);
}
+
+ // [Xamarin] Output redirection.
+ internal void TrackStdOutput (Microsoft.Win32.SafeHandles.SafeFileHandle outputPipe, Microsoft.Win32.SafeHandles.SafeFileHandle errorPipe)
+ {
+ Thread outputReader = new Thread (delegate ()
+ {
+ ReadOutput (outputPipe, false);
+ });
+ outputReader.Name = "Debugger output reader";
+ outputReader.IsBackground = true;
+ outputReader.Start ();
+
+ Thread errorReader = new Thread (delegate ()
+ {
+ ReadOutput (outputPipe, true);
+ });
+ errorReader.Name = "Debugger error reader";
+ errorReader.IsBackground = true;
+ errorReader.Start ();
+ }
+
+ // [Xamarin] Output redirection.
+ void ReadOutput (Microsoft.Win32.SafeHandles.SafeFileHandle pipe, bool isStdError)
+ {
+ byte[] buffer = new byte[256];
+ int nBytesRead;
+
+ try {
+ while (true) {
+ if (!NativeMethods.ReadFile (pipe, buffer, buffer.Length, out nBytesRead, IntPtr.Zero) || nBytesRead == 0)
+ break; // pipe done - normal exit path.
+ string s = System.Text.Encoding.Default.GetString (buffer, 0, nBytesRead);
+ if (OnStdOutput != null)
+ OnStdOutput (this, new CorTargetOutputEventArgs (s, isStdError));
+ }
+ }
+ catch {
+ }
+ }
// when process is first created wait till callbacks are enabled.
private ManualResetEvent m_callbackAttachedEvent = new ManualResetEvent(false);
@@ -750,5 +789,8 @@ namespace Microsoft.Samples.Debugging.CorDebug
}
}
+ // [Xamarin] Output redirection.
+ public event CorTargetOutputEventHandler OnStdOutput;
+
} /* class Process */
} /* namespace */
diff --git a/extras/MonoDevelop.Debugger.Win32/CorApi2/debug/Type.cs b/extras/MonoDevelop.Debugger.Win32/CorApi2/debug/Type.cs
index 593a66cf74..cf49fb0212 100644
--- a/extras/MonoDevelop.Debugger.Win32/CorApi2/debug/Type.cs
+++ b/extras/MonoDevelop.Debugger.Win32/CorApi2/debug/Type.cs
@@ -5,6 +5,7 @@
//---------------------------------------------------------------------
using System;
using System.Collections;
+using System.Collections.Generic;
using Microsoft.Samples.Debugging.CorDebug.NativeApi;
@@ -87,16 +88,20 @@ namespace Microsoft.Samples.Debugging.CorDebug
return dv==null?null:new CorValue (dv);
}
+ // [Xamarin] Expression evaluator.
// Expose IEnumerable, which can be used with for-each constructs.
// This will provide an collection of CorType parameters.
- public IEnumerable TypeParameters
+ public CorType[] TypeParameters
{
get
{
+ List<CorType> list = new List<CorType> ();
ICorDebugTypeEnum etp = null;
m_type.EnumerateTypeParameters (out etp);
if (etp==null) return null;
- return new CorTypeEnumerator (etp);
+ foreach (CorType t in new CorTypeEnumerator (etp))
+ list.Add (t);
+ return list.ToArray ();
}
}
} /* class Type */