diff options
author | Thays Grazia <thaystg@gmail.com> | 2021-07-15 23:09:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-15 23:09:33 +0300 |
commit | 03850bfd42eb17d6425f03ee03114f9dc471db6c (patch) | |
tree | 94c7770b5dbb27d84a1641e921a6122a5c0e1af2 | |
parent | 08268b730a73cca0e3b3ac9c703f0b773a3be25b (diff) |
Support debug on android after hot reload. (#344)
7 files changed, 90 insertions, 3 deletions
diff --git a/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs b/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs index 5003825..6f2c541 100644 --- a/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs +++ b/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs @@ -483,7 +483,9 @@ namespace Mono.Debugger.Soft KEEPALIVE = 14, USER_BREAK = 15, USER_LOG = 16, - CRASH = 17 + CRASH = 17, + ENC_UPDATE = 18,
+ METHOD_UPDATE = 19, } enum ModifierKind { @@ -1620,6 +1622,9 @@ namespace Mono.Debugger.Soft //EventHandler.Exception (req_id, thread_id, id, loc); } else if (kind == EventKind.KEEPALIVE) { events [i] = new EventInfo (etype, req_id) { }; + } else if (kind == EventKind.METHOD_UPDATE) {
+ long id = r.ReadId ();
+ events[i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id };
} else { throw new NotImplementedException ("Unknown event kind: " + kind); } diff --git a/Mono.Debugger.Soft/Mono.Debugger.Soft/EncEvents.cs b/Mono.Debugger.Soft/Mono.Debugger.Soft/EncEvents.cs new file mode 100644 index 0000000..3228175 --- /dev/null +++ b/Mono.Debugger.Soft/Mono.Debugger.Soft/EncEvents.cs @@ -0,0 +1,20 @@ + +namespace Mono.Debugger.Soft +{ + public class MethodUpdateEvent : Event
+ { + long id; + MethodMirror method; + internal MethodUpdateEvent (VirtualMachine vm, int req_id, long thread_id, long id) : base (EventType.MethodUpdate, vm, req_id, thread_id)
+ { + this.id = id; + method = vm.GetMethod (id); + method.ClearCachedLocalsDebugInfo (); + } + + public MethodMirror GetMethod()
+ {
+ return method;
+ } + } +} diff --git a/Mono.Debugger.Soft/Mono.Debugger.Soft/EventRequest.cs b/Mono.Debugger.Soft/Mono.Debugger.Soft/EventRequest.cs index 69f35f4..5962f57 100644 --- a/Mono.Debugger.Soft/Mono.Debugger.Soft/EventRequest.cs +++ b/Mono.Debugger.Soft/Mono.Debugger.Soft/EventRequest.cs @@ -138,5 +138,18 @@ namespace Mono.Debugger.Soft if (vm != m.VirtualMachine) throw new VMMismatchException (); } + + //Used by EnC
+ public void UpdateReqId (int id) + { + this.id = id; + enabled = true; + } + + public int GetId () + {
+ return id; + } + } }
\ No newline at end of file diff --git a/Mono.Debugger.Soft/Mono.Debugger.Soft/EventType.cs b/Mono.Debugger.Soft/Mono.Debugger.Soft/EventType.cs index 9fd82bd..6b17a29 100644 --- a/Mono.Debugger.Soft/Mono.Debugger.Soft/EventType.cs +++ b/Mono.Debugger.Soft/Mono.Debugger.Soft/EventType.cs @@ -27,8 +27,10 @@ namespace Mono.Debugger.Soft // UserLog = 16, // Fatal error handling - Crash = 17, - // Not part of the wire protocol + Crash = 17,
+ EnCUpdate = 18,
+ MethodUpdate = 19,
+ // Not part of the wire protocol
VMDisconnect = 99 } } diff --git a/Mono.Debugger.Soft/Mono.Debugger.Soft/MethodMirror.cs b/Mono.Debugger.Soft/Mono.Debugger.Soft/MethodMirror.cs index 3c48682..1500aa4 100644 --- a/Mono.Debugger.Soft/Mono.Debugger.Soft/MethodMirror.cs +++ b/Mono.Debugger.Soft/Mono.Debugger.Soft/MethodMirror.cs @@ -33,6 +33,10 @@ namespace Mono.Debugger.Soft internal MethodMirror (VirtualMachine vm, long id) : base (vm, id) { } + public long GetId() {
+ return id;
+ } + public string Name { get { if (name == null) @@ -248,6 +252,13 @@ namespace Mono.Debugger.Soft } } + public void ClearCachedLocalsDebugInfo ()
+ {
+ locals = null;
+ debug_info = null;
+ locations = null;
+ } + public LocalScope [] GetScopes () { vm.CheckProtocolVersion (2, 43); GetLocals (); diff --git a/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs b/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs index 9cf3a11..3d51655 100644 --- a/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs +++ b/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs @@ -874,6 +874,9 @@ namespace Mono.Debugger.Soft case EventType.Crash: l.Add (new CrashEvent (vm, req_id, thread_id, ei.Dump, ei.Hash)); break; + case EventType.MethodUpdate: + l.Add (new MethodUpdateEvent (vm, req_id, thread_id, id)); + break; } } diff --git a/Mono.Debugging.Soft/SoftDebuggerSession.cs b/Mono.Debugging.Soft/SoftDebuggerSession.cs index 3d4bb73..c68ba56 100644 --- a/Mono.Debugging.Soft/SoftDebuggerSession.cs +++ b/Mono.Debugging.Soft/SoftDebuggerSession.cs @@ -602,6 +602,9 @@ namespace Mono.Debugging.Soft machine.EnableEvents (EventType.TypeLoad); } +
+ machine.EnableEvents (EventType.MethodUpdate); + started = true; /* Wait for the VMStart event */ @@ -1347,6 +1350,17 @@ namespace Mono.Debugging.Soft InsertBreakpoint (bp, bi, bi.Location.Method, bi.Location.ILOffset); } + void UpdateBreakpoint (Breakpoint bp, BreakInfo bi)
+ {
+ foreach (var req in bi.Requests)
+ {
+ req.Key.Disable ();
+ var request = vm.SetBreakpoint (bi.Location.Method, bi.Location.ILOffset);
+ req.Key.UpdateReqId (request.GetId());
+ req.Key.Enabled = bp.Enabled;
+ }
+ } + void InsertBreakpoint (Breakpoint bp, BreakInfo bi, MethodMirror method, int ilOffset) { EventRequest request; @@ -1858,6 +1872,9 @@ namespace Mono.Debugging.Soft case EventType.UserLog: HandleUserLogEvents (Array.ConvertAll (es.Events, item => (UserLogEvent)item)); break; + case EventType.MethodUpdate: + HandleMethodUpdateEvents (Array.ConvertAll (es.Events, item => (MethodUpdateEvent)item)); + break; default: DebuggerLoggingService.LogMessage ("Ignoring unknown debugger event type {0}", type); break; @@ -2391,6 +2408,22 @@ namespace Mono.Debugging.Soft OnTargetDebug (ul.Level, ul.Category, ul.Message); } + void HandleMethodUpdateEvents(MethodUpdateEvent[] methods)
+ {
+ foreach (var method in methods)
+ {
+ 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);
+ }
+ }
+ }
+ } + public ObjectMirror GetExceptionObject (ThreadMirror thread) { ObjectMirror obj; |