Skip to content
Closed
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
30 changes: 29 additions & 1 deletion Mono.Debugging.Soft/SoftDebuggerSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public class SoftDebuggerSession : DebuggerSession
bool autoStepInto;
bool disposed;
bool started;
bool domainUnloaded = false;

internal int StackVersion;

Expand Down Expand Up @@ -417,7 +418,7 @@ void ConnectionStarted (VirtualMachine machine)

HideConnectionDialog ();

machine.EnableEvents (EventType.AssemblyLoad, EventType.ThreadStart, EventType.ThreadDeath,
machine.EnableEvents (EventType.AppDomainUnload, EventType.AssemblyLoad, EventType.ThreadStart, EventType.ThreadDeath,
EventType.AssemblyUnload, EventType.UserBreak, EventType.UserLog);
try {
unhandledExceptionRequest = machine.CreateExceptionRequest (null, false, true);
Expand Down Expand Up @@ -524,6 +525,24 @@ public TypeMirror GetType (string fullName)
if (!types.TryGetValue (fullName, out tm))
aliases.TryGetValue (fullName, out tm);

if (!domainUnloaded || tm == null)
return tm;

// Check if this type has been unloaded due to bug https://github.com/mono/debugger-libs/issues/57
try
{
tm.GetTypeObject();
}
catch(CommandException e)
{
if (e.ErrorCode == ErrorCode.ERR_UNLOADED)
{
types.Remove(fullName);
aliases.Remove(fullName);
return null;
}
}

return tm;
}

Expand Down Expand Up @@ -1475,6 +1494,10 @@ void HandleEventSet (EventSet es)
}

switch (type) {

case EventType.AppDomainUnload:
HandleAppDomainUnloadEvents (Array.ConvertAll(es.Events, item => (AppDomainUnloadEvent)item));
break;
case EventType.AssemblyLoad:
HandleAssemblyLoadEvents (Array.ConvertAll (es.Events, item => (AssemblyLoadEvent)item));
break;
Expand Down Expand Up @@ -1825,6 +1848,11 @@ void HandleBreakEventSet (Event[] es, bool dequeuing)
}
}

void HandleAppDomainUnloadEvents (AppDomainUnloadEvent[] events)
{
domainUnloaded = true;
}

void HandleAssemblyLoadEvents (AssemblyLoadEvent[] events)
{
var asm = events [0].Assembly;
Expand Down