Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/debugger-libs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThays Grazia <thaystg@gmail.com>2022-06-24 20:04:17 +0300
committerGitHub <noreply@github.com>2022-06-24 20:04:17 +0300
commit74da8b11c514d57edd21379c860d289ddc228c30 (patch)
treefc15050184ab8e1bbe939cd3b55e3fce44f927ab /Mono.Debugging.Soft
parent7cc29ac19969ffdda3844efd8f9984c90df7430e (diff)
Support new hotreload features and support line changes (#365)
* About HotReload now we can do in an android app and the debug will continue working: 1) add lines before the breakpoint and the breakpoint will continue working 2) remove lines before the breakpoint and the breakpoint will continue working 3) add new static methods 4) add new static fields 5) add new classes Also we check what is supported by runtime to make it possible from debugger. * Addressing @lewing comments. * Fix wrong implementation. * Changing enum as it was changed on runtime * Addressing @nosami comments.
Diffstat (limited to 'Mono.Debugging.Soft')
-rw-r--r--Mono.Debugging.Soft/SoftDebuggerSession.cs64
1 files changed, 54 insertions, 10 deletions
diff --git a/Mono.Debugging.Soft/SoftDebuggerSession.cs b/Mono.Debugging.Soft/SoftDebuggerSession.cs
index a173d25..ecd28ca 100644
--- a/Mono.Debugging.Soft/SoftDebuggerSession.cs
+++ b/Mono.Debugging.Soft/SoftDebuggerSession.cs
@@ -48,6 +48,7 @@ using Mono.Debugging.Client;
using Mono.Debugging.Evaluation;
using StackFrame = Mono.Debugger.Soft.StackFrame;
+using System.Collections.Immutable;
namespace Mono.Debugging.Soft
{
@@ -76,6 +77,7 @@ namespace Mono.Debugging.Soft
bool loggedSymlinkedRuntimesBug;
SoftDebuggerStartArgs startArgs;
List<string> userAssemblyNames;
+ List<SourceUpdate> sourceUpdates;
ThreadInfo[] current_threads;
string remoteProcessName;
long currentAddress = -1;
@@ -99,6 +101,7 @@ namespace Mono.Debugging.Soft
Adaptor = CreateSoftDebuggerAdaptor ();
Adaptor.BusyStateChanged += (sender, e) => SetBusyState (e);
Adaptor.DebuggerSession = this;
+ sourceUpdates = new List<SourceUpdate> ();
}
protected virtual SoftDebuggerAdaptor CreateSoftDebuggerAdaptor ()
@@ -1193,12 +1196,12 @@ namespace Mono.Debugging.Soft
found = true;
breakInfo.SetStatus (BreakEventStatus.Bound, null);
}
-
lock (pending_bes) {
pending_bes.Add (breakInfo);
}
if (!found) {
+ breakInfo.Breakpoint = breakpoint;
if (insideLoadedRange)
breakInfo.SetStatus (BreakEventStatus.Invalid, null);
else
@@ -2415,15 +2418,33 @@ namespace Mono.Debugging.Soft
void HandleMethodUpdateEvents(MethodUpdateEvent[] methods)
{
- foreach (var method in methods)
+ foreach (var method in methods) //add new methods to type
{
- foreach (var bp in breakpoints) {
- if (bp.Value.Location.Method.GetId() == method.GetMethod().GetId())
- {
- bool dummy = false;
- var l = FindLocationByMethod (bp.Value.Location.Method, bp.Value.Location.SourceFile, bp.Value.Location.LineNumber, bp.Value.Location.ColumnNumber, ref dummy);
- bp.Value.Location = l;
- UpdateBreakpoint ((Breakpoint)bp.Value.BreakEvent, bp.Value);
+ method.GetMethod ().ClearCachedLocalsDebugInfo ();
+ method.GetMethod ().DeclaringType.AddMethodIfNotExist (method.GetMethod ());
+ }
+ foreach (var breakpoint in breakpoints) {
+ Breakpoint bp = ((Breakpoint)breakpoint.Value.BreakEvent);
+ if (bp.UpdatedByEnC) {
+ bool dummy = false;
+ var l = FindLocationByMethod (breakpoint.Value.Location.Method, bp.FileName, bp.Line, bp.Column, ref dummy);
+ if (l != null) {
+ breakpoint.Value.Location = l;
+ UpdateBreakpoint (bp, breakpoint.Value);
+ bp.UpdatedByEnC = false;
+ }
+ }
+ }
+ foreach (var bp in pending_bes) {
+ if (bp.Status != BreakEventStatus.Bound) {
+ foreach (var location in FindLocationsByFile (bp.Breakpoint.FileName, bp.Breakpoint.Line, bp.Breakpoint.Column, out _, out bool insideLoadedRange)) {
+ OnDebuggerOutput (false, string.Format ("Resolved pending breakpoint at '{0}:{1},{2}' to {3} [0x{4:x5}].\n",
+ bp.Breakpoint.FileName, bp.Breakpoint.Line, bp.Breakpoint.Column,
+ GetPrettyMethodName (location.Method), location.ILOffset));
+
+ bp.Location = location;
+ InsertBreakpoint (bp.Breakpoint, bp);
+ bp.SetStatus (BreakEventStatus.Bound, null);
}
}
}
@@ -3342,6 +3363,14 @@ namespace Mono.Debugging.Soft
return lines.ToArray ();
}
+ public void AddSourceUpdate (string fileName)
+ {
+ sourceUpdates.Add (new SourceUpdate(fileName));
+ }
+ public void AddLineUpdate (int oldLine, int newLine)
+ {
+ sourceUpdates.Last().LineUpdates.Add (new Tuple<int, int>(oldLine, newLine));
+ }
public void ApplyChanges (ModuleMirror module, byte[] metadataDelta, byte[] ilDelta, byte[] pdbDelta = null)
{
var rootDomain = VirtualMachine.RootDomain;
@@ -3353,7 +3382,22 @@ namespace Mono.Debugging.Soft
else
pdbArray = rootDomain.CreateByteArray (pdbDelta);
- module.ApplyChanges (metadataArray, ilArray, pdbArray);
+ module.Assembly.ApplyChanges_DebugInformation (metadataDelta, pdbDelta);
+ module.ApplyChanges (metadataArray, ilArray, pdbArray);
+ foreach (var sourceUpdate in sourceUpdates)
+ {
+ var types = VirtualMachine.GetTypesForSourceFile (sourceUpdate.FileName, false);
+ foreach (var type in types)
+ {
+ type.ApplySourceChanges (sourceUpdate);
+ }
+ }
+ sourceUpdates.Clear ();
+ }
+
+ public string GetEnCCapabilities()
+ {
+ return vm.GetEnCCapabilities ();
}
static string EscapeString (string text)
{