Skip to content

Commit

Permalink
Allow checking only runtime version when invoking VersionInfo.AtLeast (
Browse files Browse the repository at this point in the history
…#405)

Also, ensure we only check runtime version on EnC related checks

This should fix a bug where C# Hot Reload was not working correctly on net7
  • Loading branch information
mauroa authored Sep 21, 2023
1 parent 26f3e94 commit 84c5c67
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
21 changes: 13 additions & 8 deletions Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,24 @@ public void SetDebuggerLibsVersion(int major, int minor) {
/*
* Check that this version is at least major:minor
*/
public bool AtLeast (int major, int minor) {
if (debuggerLibsMajorVersion > 2 || (debuggerLibsMajorVersion == 2 && debuggerLibsMinorVersion >= 56))
public bool AtLeast (int major, int minor, bool checkOnlyRuntime = false) {
if (checkOnlyRuntime)
return AtLeastRuntime (major, minor);

if (AtLeastDebuggerLibs(2, 56))
{
if (((MajorVersion > major) || ((MajorVersion == major && MinorVersion >= minor))) &&
((debuggerLibsMajorVersion > major) || ((debuggerLibsMajorVersion == major && debuggerLibsMinorVersion >= minor))))
if (AtLeastRuntime (major, minor) && AtLeastDebuggerLibs(major, minor))
return true;

return false;
}
if ((MajorVersion > major) || ((MajorVersion == major && MinorVersion >= minor)))
return true;
else
return false;

return AtLeastRuntime (major, minor);
}

bool AtLeastRuntime (int major, int minor) => MajorVersion > major || (MajorVersion == major && MinorVersion >= minor);

bool AtLeastDebuggerLibs (int major, int minor) => debuggerLibsMajorVersion > major || (debuggerLibsMajorVersion == major && debuggerLibsMinorVersion >= minor);
}

struct SourceInfo {
Expand Down
2 changes: 1 addition & 1 deletion Mono.Debugger.Soft/Mono.Debugger.Soft/ModuleMirror.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public string SourceLink {
// 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.CheckProtocolVersion (2, 60, checkOnlyRuntime: true);
vm.conn.Module_ApplyChanges (id, dmeta.Id, dIL.Id, dPDB.Id);
}
}
Expand Down
6 changes: 3 additions & 3 deletions Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -791,14 +791,14 @@ internal ValueImpl[] EncodeFieldValues (IList<Value> values, FieldInfoMirror[] f
return res;
}

internal void CheckProtocolVersion (int major, int minor) {
if (!conn.Version.AtLeast (major, minor))
internal void CheckProtocolVersion (int major, int minor, bool checkOnlyRuntime = false) {
if (!conn.Version.AtLeast (major, minor, checkOnlyRuntime))
throw new NotSupportedException ("This request is not supported by the protocol version implemented by the debuggee.");
}

public string GetEnCCapabilities ()
{
if (conn.Version.AtLeast (2, 61))
if (conn.Version.AtLeast (2, 61, checkOnlyRuntime: true))
return conn.VM_EnCCapabilities ();
return "Baseline";
}
Expand Down

0 comments on commit 84c5c67

Please sign in to comment.