diff options
author | Thays Grazia <thaystg@gmail.com> | 2019-07-11 00:29:13 +0300 |
---|---|---|
committer | Alexander Köplinger <alex.koeplinger@outlook.com> | 2019-07-11 00:29:13 +0300 |
commit | 4917c086b6f638254cefc6de4fccc700d87db97b (patch) | |
tree | 375548468eeea100ae5f8d430309b8c4b745ebdc /mcs/class/Mono.Debugger.Soft | |
parent | 2f2a9bcc373d1ef7566f56bfae91038311313742 (diff) |
[debugger] Add intrinsic for creating a byte array (#15591)
Fixes #15268
Diffstat (limited to 'mcs/class/Mono.Debugger.Soft')
3 files changed, 41 insertions, 1 deletions
diff --git a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/AppDomainMirror.cs b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/AppDomainMirror.cs index 00ec6e2b3f2..3071df610b9 100644 --- a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/AppDomainMirror.cs +++ b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/AppDomainMirror.cs @@ -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"); diff --git a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs index f07725ddcf9..bbe59a9c899 100644 --- a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs +++ b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs @@ -533,7 +533,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 { @@ -1025,6 +1026,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); @@ -1903,6 +1914,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 (); } diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs index cef1452f26e..aa5fd2fe58e 100644 --- a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs +++ b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs @@ -1354,6 +1354,21 @@ public class DebuggerTests val = frame.GetArgument (0); AssertValue ("BLA", val); } + [Test] + public void CreateByteArrays () { + byte[] bt = new byte[5]; + bt[0] = 1; + bt[1] = 0; + bt[2] = 255; + bt[3] = 10; + bt[4] = 50; + var val = vm.RootDomain.CreateByteArray (bt); + AssertValue (1, val [0]); + AssertValue (0, val [1]); + AssertValue (255, val [2]); + AssertValue (10, val [3]); + AssertValue (50, val [4]); + } [Test] public void Arrays () { |