Imported Upstream version 6.6.0.89

Former-commit-id: b39a328747c2f3414dc52e009fb6f0aa80ca2492
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-09-24 08:53:40 +00:00
parent cf815e07e0
commit 95fdb59ea6
2556 changed files with 138145 additions and 47453 deletions

View File

@@ -72,6 +72,14 @@ namespace Mono.Debugger.Soft
return vm.GetObject<StringMirror> (vm.conn.Domain_CreateString (id, s));
}
public ArrayMirror CreateByteArray (byte [] bytes) {
vm.CheckProtocolVersion (2, 52);
if (bytes == null)
throw new ArgumentNullException ("bytes");
return vm.GetObject<ArrayMirror> (vm.conn.Domain_CreateByteArray (id, bytes));
}
public ObjectMirror CreateBoxedValue (Value value) {
if (value == null)
throw new ArgumentNullException ("value");

View File

@@ -151,7 +151,8 @@ namespace Mono.Debugger.Soft
enum ValueTypeId {
VALUE_TYPE_ID_NULL = 0xf0,
VALUE_TYPE_ID_TYPE = 0xf1,
VALUE_TYPE_ID_PARENT_VTYPE = 0xf2
VALUE_TYPE_ID_PARENT_VTYPE = 0xf2,
VALUE_TYPE_ID_FIXED_ARRAY = 0xf3
}
[Flags]
@@ -215,6 +216,7 @@ namespace Mono.Debugger.Soft
public bool IsEnum; // For ElementType.ValueType
public long Id; /* For VALUE_TYPE_ID_TYPE */
public int Index; /* For VALUE_TYPE_PARENT_VTYPE */
public int FixedSize;
}
class ModuleInfo {
@@ -427,7 +429,7 @@ namespace Mono.Debugger.Soft
* with newer runtimes, and vice versa.
*/
internal const int MAJOR_VERSION = 2;
internal const int MINOR_VERSION = 51;
internal const int MINOR_VERSION = 53;
enum WPSuspendPolicy {
NONE = 0,
@@ -533,7 +535,8 @@ namespace Mono.Debugger.Soft
GET_ENTRY_ASSEMBLY = 4,
CREATE_STRING = 5,
GET_CORLIB = 6,
CREATE_BOXED_VALUE = 7
CREATE_BOXED_VALUE = 7,
CREATE_BYTE_ARRAY = 8,
}
enum CmdAssembly {
@@ -854,7 +857,6 @@ namespace Mono.Debugger.Soft
public ValueImpl ReadValue () {
ElementType etype = (ElementType)ReadByte ();
switch (etype) {
case ElementType.Void:
return new ValueImpl { Type = etype };
@@ -915,11 +917,94 @@ namespace Mono.Debugger.Soft
return new ValueImpl () { Type = etype, Id = ReadId () };
case (ElementType)ValueTypeId.VALUE_TYPE_ID_PARENT_VTYPE:
return new ValueImpl () { Type = etype, Index = ReadInt () };
case (ElementType)ValueTypeId.VALUE_TYPE_ID_FIXED_ARRAY:
return ReadValueFixedSize ();
default:
throw new NotImplementedException ("Unable to handle type " + etype);
}
}
ValueImpl ReadValueFixedSize () {
var lenFixedSize = 1;
ElementType etype = (ElementType)ReadByte ();
lenFixedSize = ReadInt ();
switch (etype) {
case ElementType.I1: {
var val = new sbyte[lenFixedSize];
for (int i = 0; i < lenFixedSize; i++)
val[i] = (sbyte)ReadInt ();
return new ValueImpl { Type = etype, Value = val };
}
case ElementType.U1: {
var val = new byte[lenFixedSize];
for (int i = 0; i < lenFixedSize; i++)
val[i] = (byte)ReadInt ();
return new ValueImpl { Type = etype, Value = val };
}
case ElementType.Boolean: {
var val = new bool[lenFixedSize];
for (int i = 0; i < lenFixedSize; i++)
val[i] = (ReadInt () != 0);
return new ValueImpl { Type = etype, Value = val };
}
case ElementType.I2: {
var val = new short[lenFixedSize];
for (int i = 0; i < lenFixedSize; i++)
val[i] = (short)ReadInt ();
return new ValueImpl { Type = etype, Value = val };
}
case ElementType.U2: {
var val = new ushort[lenFixedSize];
for (int i = 0; i < lenFixedSize; i++)
val[i] = (ushort)ReadInt ();
return new ValueImpl { Type = etype, Value = val };
}
case ElementType.Char: {
var val = new char[lenFixedSize];
for (int i = 0; i < lenFixedSize; i++)
val[i] = (char)ReadInt ();
return new ValueImpl { Type = etype, Value = val };
}
case ElementType.I4: {
var val = new int[lenFixedSize];
for (int i = 0; i < lenFixedSize; i++)
val[i] = ReadInt ();
return new ValueImpl { Type = etype, Value = val };
}
case ElementType.U4: {
var val = new uint[lenFixedSize];
for (int i = 0; i < lenFixedSize; i++)
val[i] = (uint)ReadInt ();
return new ValueImpl { Type = etype, Value = val };
}
case ElementType.I8: {
var val = new long[lenFixedSize];
for (int i = 0; i < lenFixedSize; i++)
val[i] = ReadLong ();
return new ValueImpl { Type = etype, Value = val };
}
case ElementType.U8: {
var val = new ulong[lenFixedSize];
for (int i = 0; i < lenFixedSize; i++)
val[i] = (ulong) ReadLong ();
return new ValueImpl { Type = etype, Value = val };
}
case ElementType.R4: {
var val = new float[lenFixedSize];
for (int i = 0; i < lenFixedSize; i++)
val[i] = ReadFloat ();
return new ValueImpl { Type = etype, Value = val };
}
case ElementType.R8: {
var val = new double[lenFixedSize];
for (int i = 0; i < lenFixedSize; i++)
val[i] = ReadDouble ();
return new ValueImpl { Type = etype, Value = val };
}
}
throw new NotImplementedException ("Unable to handle type " + etype);
}
public long[] ReadIds (int n) {
long[] res = new long [n];
for (int i = 0; i < n; ++i)
@@ -1025,6 +1110,16 @@ namespace Mono.Debugger.Soft
offset += b.Length;
return this;
}
public PacketWriter WriteBytes (byte[] b) {
if (b == null)
return WriteInt (-1);
MakeRoom (4);
encode_int (data, b.Length, ref offset);
MakeRoom (b.Length);
Buffer.BlockCopy (b, 0, data, offset, b.Length);
offset += b.Length;
return this;
}
public PacketWriter WriteBool (bool val) {
WriteByte (val ? (byte)1 : (byte)0);
@@ -1035,9 +1130,13 @@ namespace Mono.Debugger.Soft
ElementType t;
if (v.Value != null)
t = TypeCodeToElementType (Type.GetTypeCode (v.Value.GetType ()));
t = TypeCodeToElementType (Type.GetTypeCode (v.Value.GetType ()), v.Value.GetType ());
else
t = v.Type;
if (v.FixedSize > 1 && t != ElementType.ValueType) {
WriteFixedSizeValue (v);
return this;
}
WriteByte ((byte)t);
switch (t) {
case ElementType.Boolean:
@@ -1102,6 +1201,61 @@ namespace Mono.Debugger.Soft
return this;
}
PacketWriter WriteFixedSizeValue (ValueImpl v) {
ElementType t;
if (v.Value != null)
t = TypeCodeToElementType (Type.GetTypeCode (v.Value.GetType ()), v.Value.GetType ());
else
t = v.Type;
WriteByte ((byte) ValueTypeId.VALUE_TYPE_ID_FIXED_ARRAY);
WriteByte ((byte)t);
WriteInt (v.FixedSize);
for (int j = 0 ; j < v.FixedSize; j++) {
switch (t) {
case ElementType.Boolean:
WriteInt (((bool[])v.Value)[j]? 1 : 0);
break;
case ElementType.Char:
WriteInt ((int)((char[])v.Value)[j]);
break;
case ElementType.I1:
WriteInt ((int)((sbyte[])v.Value)[j]);
break;
case ElementType.U1:
WriteInt ((int)((byte[])v.Value)[j]);
break;
case ElementType.I2:
WriteInt ((int)((short[])v.Value)[j]);
break;
case ElementType.U2:
WriteInt ((int)((ushort[])v.Value)[j]);
break;
case ElementType.I4:
WriteInt ((int)((int[])v.Value)[j]);
break;
case ElementType.U4:
WriteInt ((int)((uint[])v.Value)[j]);
break;
case ElementType.I8:
WriteLong ((long)((long[])v.Value)[j]);
break;
case ElementType.U8:
WriteLong ((long)((ulong[])v.Value)[j]);
break;
case ElementType.R4:
WriteFloat (((float[])v.Value)[j]);
break;
case ElementType.R8:
WriteDouble (((double[])v.Value)[j]);
break;
default:
throw new NotImplementedException ();
}
}
return this;
}
public PacketWriter WriteValues (ValueImpl[] values) {
for (int i = 0; i < values.Length; ++i)
WriteValue (values [i]);
@@ -1684,7 +1838,7 @@ namespace Mono.Debugger.Soft
return res;
}
static ElementType TypeCodeToElementType (TypeCode c) {
static ElementType TypeCodeToElementType (TypeCode c, Type t) {
switch (c) {
case TypeCode.Boolean:
return ElementType.Boolean;
@@ -1710,6 +1864,8 @@ namespace Mono.Debugger.Soft
return ElementType.R4;
case TypeCode.Double:
return ElementType.R8;
case TypeCode.Object:
return TypeCodeToElementType(Type.GetTypeCode (t.GetElementType()), t.GetElementType());
default:
throw new NotImplementedException ();
}
@@ -1903,6 +2059,12 @@ namespace Mono.Debugger.Soft
return SendReceive (CommandSet.APPDOMAIN, (int)CmdAppDomain.CREATE_STRING, new PacketWriter ().WriteId (id).WriteString (s)).ReadId ();
}
internal long Domain_CreateByteArray (long id, byte [] bytes) {
var w = new PacketWriter ().WriteId (id);
w.WriteBytes (bytes);
return SendReceive (CommandSet.APPDOMAIN, (int)CmdAppDomain.CREATE_BYTE_ARRAY, w).ReadId ();
}
internal long Domain_CreateBoxedValue (long id, long type_id, ValueImpl v) {
return SendReceive (CommandSet.APPDOMAIN, (int)CmdAppDomain.CREATE_BOXED_VALUE, new PacketWriter ().WriteId (id).WriteId (type_id).WriteValue (v)).ReadId ();
}

View File

@@ -17,6 +17,7 @@ namespace Mono.Debugger.Soft
FieldAttributes attrs;
CustomAttributeDataMirror[] cattrs;
bool inited;
int len_fixed_size_array;
#if ENABLE_CECIL
C.FieldDefinition meta;
@@ -27,6 +28,7 @@ namespace Mono.Debugger.Soft
this.name = name;
this.type = type;
this.attrs = attrs;
this.len_fixed_size_array = -1;
inited = true;
}
@@ -162,6 +164,28 @@ namespace Mono.Debugger.Soft
}
}
public int FixedSize
{
get
{
if (len_fixed_size_array == -1) {
if (!vm.Version.AtLeast (2, 53) || !type.IsValueType) {
len_fixed_size_array = 0;
}
else {
var fbas = this.GetCustomAttributes (true);
for (int j = 0 ; j < fbas.Length; ++j) {
if (fbas [j].Constructor.DeclaringType.FullName.Equals("System.Runtime.CompilerServices.FixedBufferAttribute")){
len_fixed_size_array = (int) fbas [j].ConstructorArguments[1].Value;
break;
}
}
}
}
return len_fixed_size_array;
}
}
public CustomAttributeDataMirror[] GetCustomAttributes (bool inherit) {
return GetCAttrs (null, inherit);
}

View File

@@ -168,6 +168,10 @@ namespace Mono.Debugger.Soft
throw new ArgumentNullException ("loc");
try {
vm.conn.Thread_SetIP (id, loc.Method.Id, loc.ILOffset);
if (vm.conn.Version.AtLeast(2, 52)) {
InvalidateFrames();
FetchFrames(true);
}
} catch (CommandException ex) {
if (ex.ErrorCode == ErrorCode.INVALID_ARGUMENT)
throw new ArgumentException ("loc doesn't refer to a location in the current method of this thread.", "loc");

View File

@@ -357,20 +357,18 @@ namespace Mono.Debugger.Soft
public string CSharpName {
get {
if (IsArray) {
if (GetArrayRank () == 1)
var ranks = GetArrayRank ();
if (ranks == 1)
return GetElementType ().CSharpName + "[]";
else {
string ranks = "";
for (int i = 0; i < GetArrayRank (); ++i)
ranks += ',';
return GetElementType ().CSharpName + "[" + ranks + "]";
}
return GetElementType ().CSharpName + "[" + new string(',', ranks - 1) + "]";
}
if (IsPrimitive) {
switch (Name) {
case "Byte":
return "byte";
case "Sbyte":
case "SByte":
return "sbyte";
case "Char":
return "char";

View File

@@ -724,7 +724,32 @@ namespace Mono.Debugger.Soft
return new ValueImpl { Type = (ElementType)ValueTypeId.VALUE_TYPE_ID_NULL, Objid = 0 };
duplicates.Add (v);
return new ValueImpl { Type = ElementType.ValueType, Klass = (v as StructMirror).Type.Id, Fields = EncodeValues ((v as StructMirror).Fields, duplicates) };
return new ValueImpl { Type = ElementType.ValueType, Klass = (v as StructMirror).Type.Id, Fields = EncodeFieldValues ((v as StructMirror).Fields, (v as StructMirror).Type.GetFields (), duplicates, 1) };
} else if (v is PointerValue) {
PointerValue val = (PointerValue)v;
return new ValueImpl { Type = ElementType.Ptr, Klass = val.Type.Id, Value = val.Address };
} else {
throw new NotSupportedException ("Value of type " + v.GetType());
}
}
internal ValueImpl EncodeValueFixedSize (Value v, List<Value> duplicates, int len_fixed_size) {
if (v is PrimitiveValue) {
object val = (v as PrimitiveValue).Value;
if (val == null)
return new ValueImpl { Type = (ElementType)ValueTypeId.VALUE_TYPE_ID_NULL, Objid = 0 };
else
return new ValueImpl { Value = val , FixedSize = len_fixed_size};
} else if (v is ObjectMirror) {
return new ValueImpl { Type = ElementType.Object, Objid = (v as ObjectMirror).Id };
} else if (v is StructMirror) {
if (duplicates == null)
duplicates = new List<Value> ();
if (duplicates.Contains (v))
return new ValueImpl { Type = (ElementType)ValueTypeId.VALUE_TYPE_ID_NULL, Objid = 0 };
duplicates.Add (v);
return new ValueImpl { Type = ElementType.ValueType, Klass = (v as StructMirror).Type.Id, Fields = EncodeFieldValues ((v as StructMirror).Fields, (v as StructMirror).Type.GetFields (), duplicates, len_fixed_size) };
} else if (v is PointerValue) {
PointerValue val = (PointerValue)v;
return new ValueImpl { Type = ElementType.Ptr, Klass = val.Type.Id, Value = val.Address };
@@ -740,6 +765,17 @@ namespace Mono.Debugger.Soft
return res;
}
internal ValueImpl[] EncodeFieldValues (IList<Value> values, FieldInfoMirror[] field_info, List<Value> duplicates, int fixedSize) {
ValueImpl[] res = new ValueImpl [values.Count];
for (int i = 0; i < values.Count; ++i) {
if (fixedSize > 1 || field_info [i].FixedSize > 1)
res [i] = EncodeValueFixedSize (values [i], duplicates, fixedSize > 1 ? fixedSize : field_info [i].FixedSize);
else
res [i] = EncodeValue (values [i], duplicates);
}
return res;
}
internal void CheckProtocolVersion (int major, int minor) {
if (!conn.Version.AtLeast (major, minor))
throw new NotSupportedException ("This request is not supported by the protocol version implemented by the debuggee.");

View File

@@ -174,6 +174,95 @@ public struct AStruct : ITest2 {
}
}
public struct int4
{
public int w, x, y, z;
public int4(int w, int x, int y, int z)
{
this.w = w;
this.x = x;
this.y = y;
this.z = z;
}
}
public struct char4
{
public int w, x, y, z;
public char4(char w, char x, char y, char z)
{
this.w = w;
this.x = x;
this.y = y;
this.z = z;
}
}
public unsafe struct NodeTestFixedArray
{
private fixed short buffer[4];
private fixed char buffer2[4];
public int4 Buffer
{
set
{
fixed (NodeTestFixedArray* p = &this) {
p->buffer[0] = (short)value.w;
p->buffer[1] = (short)value.x;
p->buffer[2] = (short)value.y;
p->buffer[3] = (short)value.z;
}
}
}
public char4 Buffer2
{
set
{
fixed (NodeTestFixedArray* p = &this) {
p->buffer2[0] = (char)value.w;
p->buffer2[1] = (char)value.x;
p->buffer2[2] = (char)value.y;
p->buffer2[3] = (char)value.z;
}
}
}
public String getBuffer0() {
fixed (NodeTestFixedArray* p = &this)
return Convert.ToString(p->buffer[0]);
}
public String getBuffer1() {
fixed (NodeTestFixedArray* p = &this)
return Convert.ToString(p->buffer[1]);
}
public String getBuffer2() {
fixed (NodeTestFixedArray* p = &this)
return Convert.ToString(p->buffer[2]);
}
public String getBuffer3() {
fixed (NodeTestFixedArray* p = &this)
return Convert.ToString(p->buffer[3]);
}
public String getBuffer2_0() {
fixed (NodeTestFixedArray* p = &this)
return Char.ToString(p->buffer2[0]);
}
public String getBuffer2_1() {
fixed (NodeTestFixedArray* p = &this)
return Char.ToString(p->buffer2[1]);
}
public String getBuffer2_2() {
fixed (NodeTestFixedArray* p = &this)
return Char.ToString(p->buffer2[2]);
}
public String getBuffer2_3() {
fixed (NodeTestFixedArray* p = &this)
return Char.ToString(p->buffer2[3]);
}
}
public struct BlittableStruct {
public int i;
@@ -494,6 +583,7 @@ public class Tests : TestsBase, ITest2
field_with_unsafe_cast_value();
inspect_enumerator_in_generic_struct();
if_property_stepping();
fixed_size_array();
return 3;
}
@@ -730,6 +820,13 @@ public class Tests : TestsBase, ITest2
Thread.Sleep(300);
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void fixed_size_array () {
var n = new NodeTestFixedArray();
n.Buffer = new int4(1, 2, 3, 4);
n.Buffer2 = new char4('a', 'b', 'c', 'd');
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void inspect_enumerator_in_generic_struct() {
TestEnumeratorInsideGenericStruct<String, String> generic_struct = new TestEnumeratorInsideGenericStruct<String, String>(new KeyValuePair<string, string>("0", "f1"));

View File

@@ -1 +1 @@
1f394d53c53a481ed108fe1e55be458a7fb03923
75967555e6b2fb9903c055d496b749f56798e897