Skip to content

Commit

Permalink
Add Module.ApplyChanges (#342)
Browse files Browse the repository at this point in the history
[Mono.Debugger.Soft] add ModuleMirror.ApplyChanges
[Mono.Debugging.Soft] add SoftDebuggerSession.ApplyChanges
Related mono/mono Mono.Debugger.Soft PR: mono/mono#20889
Related dotnet/runtime PR: dotnet/runtime#49043

Contributes to dotnet/runtime#44806
  • Loading branch information
lambdageek authored Mar 3, 2021
1 parent 1b5a55a commit 08268b7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ enum CmdAssembly {

enum CmdModule {
GET_INFO = 1,
APPLY_CHANGES = 2,
}

enum CmdMethod {
Expand Down Expand Up @@ -2357,6 +2358,11 @@ internal ModuleInfo Module_GetInfo (long id) {
return info;
}


internal void Module_ApplyChanges (long id, long dmeta_id, long dil_id, long dpdb_id) {
SendReceive (CommandSet.MODULE, (int)CmdModule.APPLY_CHANGES, new PacketWriter().WriteId (id).WriteId (dmeta_id).WriteId (dil_id).WriteId (dpdb_id));
}

/*
* ASSEMBLY
*/
Expand Down
8 changes: 8 additions & 0 deletions Mono.Debugger.Soft/Mono.Debugger.Soft/ModuleMirror.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,13 @@ public string SourceLink {
return info.SourceLink;
}
}

// Apply a hot reload delta to the current module
// Since protocol version 2.60
public void ApplyChanges (ArrayMirror dmeta, ArrayMirror dIL, Value dPDB) {
/* dPDB is Value because it can be ArrayMirror or PrimitiveValue (vm, null) */
vm.CheckProtocolVersion (2, 60);
vm.conn.Module_ApplyChanges (id, dmeta.Id, dIL.Id, dPDB.Id);
}
}
}
13 changes: 13 additions & 0 deletions Mono.Debugging.Soft/SoftDebuggerSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3304,6 +3304,19 @@ public AssemblyLine[] Disassemble (StackFrame frame, int firstLine, int count)
return lines.ToArray ();
}

public void ApplyChanges (ModuleMirror module, byte[] metadataDelta, byte[] ilDelta, byte[] pdbDelta = null)
{
var rootDomain = VirtualMachine.RootDomain;
var metadataArray = rootDomain.CreateByteArray (metadataDelta);
var ilArray = rootDomain.CreateByteArray (ilDelta);
Value pdbArray;
if (pdbDelta == null)
pdbArray = VirtualMachine.CreateValue (null);
else
pdbArray = rootDomain.CreateByteArray (pdbDelta);

module.ApplyChanges (metadataArray, ilArray, pdbArray);
}
static string EscapeString (string text)
{
var escaped = new StringBuilder ();
Expand Down

0 comments on commit 08268b7

Please sign in to comment.