Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Module.ApplyChanges #342

Merged
merged 2 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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