Author: martin
Date: 2006-04-25 16:49:18 -0400 (Tue, 25 Apr 2006)
New Revision: 59872
Modified:
trunk/debugger/ChangeLog
trunk/debugger/backends/DebuggerServant.cs
trunk/debugger/backends/ProcessServant.cs
trunk/debugger/backends/ThreadServant.cs
trunk/debugger/classes/Breakpoint.cs
trunk/debugger/classes/Debugger.cs
trunk/debugger/classes/Event.cs
trunk/debugger/classes/ExceptionCatchPoint.cs
trunk/debugger/classes/Module.cs
trunk/debugger/classes/Process.cs
trunk/debugger/classes/SourceLocation.cs
trunk/debugger/classes/Thread.cs
trunk/debugger/classes/ThreadGroup.cs
trunk/debugger/frontend/Interpreter.cs
trunk/debugger/languages/TargetFunctionType.cs
trunk/debugger/languages/mono/MonoClassInfo.cs
trunk/debugger/languages/mono/MonoFunctionType.cs
trunk/debugger/languages/native/NativeFunctionType.cs
Log:
2006-04-25 Martin Baulig <[EMAIL PROTECTED]>
* classes/Process.cs
(Process.SaveSession, Process.LoadSession): Moved the session
handling into the `ProcessServant'.
* classes/Debugger.cs
(Debugger.ctor): Create the `DebuggerServant' in another appdomain.
Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog 2006-04-25 20:20:47 UTC (rev 59871)
+++ trunk/debugger/ChangeLog 2006-04-25 20:49:18 UTC (rev 59872)
@@ -1,5 +1,14 @@
2006-04-25 Martin Baulig <[EMAIL PROTECTED]>
+ * classes/Process.cs
+ (Process.SaveSession, Process.LoadSession): Moved the session
+ handling into the `ProcessServant'.
+
+ * classes/Debugger.cs
+ (Debugger.ctor): Create the `DebuggerServant' in another appdomain.
+
+2006-04-25 Martin Baulig <[EMAIL PROTECTED]>
+
* backends/SingleSteppingEngine.cs
(SingleSteppingEngine.StartThread): Added `do_attach' argument.
(SingleSteppingEngine.GetThreadID): Removed.
Modified: trunk/debugger/backends/DebuggerServant.cs
===================================================================
--- trunk/debugger/backends/DebuggerServant.cs 2006-04-25 20:20:47 UTC (rev
59871)
+++ trunk/debugger/backends/DebuggerServant.cs 2006-04-25 20:49:18 UTC (rev
59872)
@@ -104,7 +104,6 @@
}
OnTargetExitedEvent ();
- Dispose ();
}
public void Detach ()
Modified: trunk/debugger/backends/ProcessServant.cs
===================================================================
--- trunk/debugger/backends/ProcessServant.cs 2006-04-25 20:20:47 UTC (rev
59871)
+++ trunk/debugger/backends/ProcessServant.cs 2006-04-25 20:49:18 UTC (rev
59872)
@@ -44,7 +44,7 @@
private ProcessServant (ThreadManager manager)
{
this.manager = manager;
- this.client = new Process (manager.Debugger.Client,
this);
+ this.client = manager.Debugger.Client.CreateProcess
(this);
thread_lock_mutex = new DebuggerMutex
("thread_lock_mutex");
@@ -555,6 +555,68 @@
}
//
+ // Session management.
+ //
+
+ public void SaveSession (Stream stream, StreamingContextStates
states )
+ {
+ StreamingContext context = new StreamingContext (
+ states, this);
+
+ ISurrogateSelector ss =
DebuggerSession.CreateSurrogateSelector (context);
+ BinaryFormatter formatter = new BinaryFormatter (ss,
context);
+
+ SessionInfo info = new SessionInfo (this);
+ formatter.Serialize (stream, info);
+ }
+
+ public void LoadSession (Stream stream, StreamingContextStates
states)
+ {
+ StreamingContext context = new StreamingContext (
+ StreamingContextStates.Persistence, this);
+
+ ISurrogateSelector ss =
DebuggerSession.CreateSurrogateSelector (context);
+ BinaryFormatter formatter = new BinaryFormatter (ss,
context);
+
+ SessionInfo info = (SessionInfo) formatter.Deserialize
(stream);
+
+ foreach (Event handle in info.Events) {
+ AddEvent (handle);
+ handle.Enable (MainThread.Client);
+ }
+ }
+
+ [Serializable]
+ private class SessionInfo : ISerializable,
IDeserializationCallback
+ {
+ public readonly Module[] Modules;
+ public readonly Event[] Events;
+
+ public SessionInfo (ProcessServant process)
+ {
+ this.Modules = process.Modules;
+ this.Events = process.Events;
+ }
+
+ public void GetObjectData (SerializationInfo info,
StreamingContext context)
+ {
+ info.AddValue ("modules", Modules);
+ info.AddValue ("events", Events);
+ }
+
+ void IDeserializationCallback.OnDeserialization (object
obj)
+ { }
+
+ private SessionInfo (SerializationInfo info,
StreamingContext context)
+ {
+ Modules = (Module []) info.GetValue (
+ "modules", typeof (Module []));
+ Events = (Event []) info.GetValue (
+ "events", typeof (Event []));
+ }
+ }
+
+ //
// Thread Groups
//
Modified: trunk/debugger/backends/ThreadServant.cs
===================================================================
--- trunk/debugger/backends/ThreadServant.cs 2006-04-25 20:20:47 UTC (rev
59871)
+++ trunk/debugger/backends/ThreadServant.cs 2006-04-25 20:49:18 UTC (rev
59872)
@@ -27,7 +27,7 @@
tgroup = process.CreateThreadGroup ("@" + ID);
tgroup.AddThread (ID);
- thread = new Thread (this, ID);
+ thread = process.Debugger.Client.CreateThread (this,
ID);
}
protected readonly int id;
Modified: trunk/debugger/classes/Breakpoint.cs
===================================================================
--- trunk/debugger/classes/Breakpoint.cs 2006-04-25 20:20:47 UTC (rev
59871)
+++ trunk/debugger/classes/Breakpoint.cs 2006-04-25 20:49:18 UTC (rev
59872)
@@ -104,13 +104,13 @@
this.address = address;
}
- protected override void GetSessionData (SerializationInfo info)
+ internal override void GetSessionData (SerializationInfo info)
{
base.GetSessionData (info);
info.AddValue ("location", location);
}
- protected override void SetSessionData (SerializationInfo info,
Process process)
+ internal override void SetSessionData (SerializationInfo info,
ProcessServant process)
{
base.SetSessionData (info, process);
location = (SourceLocation) info.GetValue ("location",
typeof (SourceLocation));
Modified: trunk/debugger/classes/Debugger.cs
===================================================================
--- trunk/debugger/classes/Debugger.cs 2006-04-25 20:20:47 UTC (rev 59871)
+++ trunk/debugger/classes/Debugger.cs 2006-04-25 20:49:18 UTC (rev 59872)
@@ -22,11 +22,21 @@
public class Debugger : MarshalByRefObject
{
+ AppDomain domain;
DebuggerServant servant;
public Debugger ()
{
- this.servant = new DebuggerServant (this);
+ domain = AppDomain.CreateDomain ("mdb");
+
+ ObjectHandle oh = domain.CreateInstance (
+ Assembly.GetExecutingAssembly ().FullName,
+ typeof (DebuggerServant).FullName, false,
+ BindingFlags.Instance | BindingFlags.NonPublic,
+ null, new object [] { this },
+ null, null, null);
+
+ servant = (DebuggerServant) oh.Unwrap ();
}
public event TargetOutputHandler TargetOutputEvent;
@@ -39,6 +49,16 @@
public event TargetEventHandler TargetEvent;
public event SymbolTableChangedHandler SymbolTableChanged;
+ internal Process CreateProcess (ProcessServant servant)
+ {
+ return new Process (this, servant);
+ }
+
+ internal Thread CreateThread (ThreadServant servant, int id)
+ {
+ return new Thread (servant, id);
+ }
+
internal void OnProcessCreatedEvent (Process process)
{
if (ProcessCreatedEvent != null)
@@ -89,6 +109,7 @@
public void Kill ()
{
+ check_disposed ();
servant.Kill ();
}
@@ -146,6 +167,11 @@
servant.Dispose ();
servant = null;
}
+
+ if (domain != null) {
+ AppDomain.Unload (domain);
+ domain = null;
+ }
}
}
Modified: trunk/debugger/classes/Event.cs
===================================================================
--- trunk/debugger/classes/Event.cs 2006-04-25 20:20:47 UTC (rev 59871)
+++ trunk/debugger/classes/Event.cs 2006-04-25 20:49:18 UTC (rev 59872)
@@ -9,7 +9,7 @@
CatchException
}
- public abstract class Event
+ public abstract class Event : MarshalByRefObject
{
// <summary>
// An automatically generated unique index for this event.
@@ -62,14 +62,14 @@
// Session handling.
//
- protected virtual void GetSessionData (SerializationInfo info)
+ internal virtual void GetSessionData (SerializationInfo info)
{
info.AddValue ("index", index);
info.AddValue ("group", group);
info.AddValue ("name", name);
}
- protected virtual void SetSessionData (SerializationInfo info,
Process process)
+ internal virtual void SetSessionData (SerializationInfo info,
ProcessServant process)
{
index = info.GetInt32 ("index");
group = (ThreadGroup) info.GetValue ("group", typeof
(ThreadGroup));
@@ -90,7 +90,7 @@
ISurrogateSelector
selector)
{
Event handle = (Event) obj;
- handle.SetSessionData (info, (Process)
context.Context);
+ handle.SetSessionData (info, (ProcessServant)
context.Context);
if ((context.State &
StreamingContextStates.File) != 0)
handle.index = Event.GetNextEventIndex
();
return handle;
Modified: trunk/debugger/classes/ExceptionCatchPoint.cs
===================================================================
--- trunk/debugger/classes/ExceptionCatchPoint.cs 2006-04-25 20:20:47 UTC
(rev 59871)
+++ trunk/debugger/classes/ExceptionCatchPoint.cs 2006-04-25 20:49:18 UTC
(rev 59872)
@@ -87,17 +87,17 @@
TargetType exception;
- protected override void GetSessionData (SerializationInfo info)
+ internal override void GetSessionData (SerializationInfo info)
{
base.GetSessionData (info);
info.AddValue ("exception", exception.Name);
}
- protected override void SetSessionData (SerializationInfo info,
Process process)
+ internal override void SetSessionData (SerializationInfo info,
ProcessServant process)
{
base.SetSessionData (info, process);
- Language language = process.Servant.MonoLanguage;
+ Language language = process.MonoLanguage;
exception = language.LookupType (info.GetString
("exception"));
}
}
Modified: trunk/debugger/classes/Module.cs
===================================================================
--- trunk/debugger/classes/Module.cs 2006-04-25 20:20:47 UTC (rev 59871)
+++ trunk/debugger/classes/Module.cs 2006-04-25 20:49:18 UTC (rev 59872)
@@ -374,10 +374,10 @@
StreamingContext context,
ISurrogateSelector
selector)
{
- Process process = (Process) context.Context;
+ ProcessServant process = (ProcessServant)
context.Context;
string name = info.GetString ("name");
- Module module =
process.Servant.ModuleManager.CreateModule (name);
+ Module module =
process.ModuleManager.CreateModule (name);
module.name = info.GetString ("name");
module.load_symbols = info.GetBoolean
("load-symbols");
Modified: trunk/debugger/classes/Process.cs
===================================================================
--- trunk/debugger/classes/Process.cs 2006-04-25 20:20:47 UTC (rev 59871)
+++ trunk/debugger/classes/Process.cs 2006-04-25 20:49:18 UTC (rev 59872)
@@ -185,64 +185,16 @@
// Session management.
//
- public void SaveSession (Stream stream, StreamingContextStates
states )
+ public void SaveSession (Stream stream, StreamingContextStates
states)
{
- StreamingContext context = new StreamingContext (
- states, this);
-
- ISurrogateSelector ss =
DebuggerSession.CreateSurrogateSelector (context);
- BinaryFormatter formatter = new BinaryFormatter (ss,
context);
-
- SessionInfo info = new SessionInfo (this);
- formatter.Serialize (stream, info);
+ servant.SaveSession (stream, states);
}
public void LoadSession (Stream stream, StreamingContextStates
states)
{
- StreamingContext context = new StreamingContext (
- StreamingContextStates.Persistence, this);
-
- ISurrogateSelector ss =
DebuggerSession.CreateSurrogateSelector (context);
- BinaryFormatter formatter = new BinaryFormatter (ss,
context);
-
- SessionInfo info = (SessionInfo) formatter.Deserialize
(stream);
-
- foreach (Event handle in info.Events) {
- servant.AddEvent (handle);
- handle.Enable (servant.MainThread.Client);
- }
+ servant.LoadSession (stream, states);
}
- [Serializable]
- private class SessionInfo : ISerializable,
IDeserializationCallback
- {
- public readonly Module[] Modules;
- public readonly Event[] Events;
-
- public SessionInfo (Process process)
- {
- this.Modules = process.Modules;
- this.Events = process.Events;
- }
-
- public void GetObjectData (SerializationInfo info,
StreamingContext context)
- {
- info.AddValue ("modules", Modules);
- info.AddValue ("events", Events);
- }
-
- void IDeserializationCallback.OnDeserialization (object
obj)
- { }
-
- private SessionInfo (SerializationInfo info,
StreamingContext context)
- {
- Modules = (Module []) info.GetValue (
- "modules", typeof (Module []));
- Events = (Event []) info.GetValue (
- "events", typeof (Event []));
- }
- }
-
//
// IDisposable
//
Modified: trunk/debugger/classes/SourceLocation.cs
===================================================================
--- trunk/debugger/classes/SourceLocation.cs 2006-04-25 20:20:47 UTC (rev
59871)
+++ trunk/debugger/classes/SourceLocation.cs 2006-04-25 20:49:18 UTC (rev
59872)
@@ -11,7 +11,7 @@
// Instances of this class are normally created as the result of a
user action
// such as a method lookup.
// </summary>
- public class SourceLocation : IDeserializationCallback
+ public class SourceLocation : MarshalByRefObject,
IDeserializationCallback
{
Module module;
SourceMethod source;
@@ -168,7 +168,7 @@
info.AddValue ("type", "unknown");
}
- protected virtual void SetSessionData (SerializationInfo info,
Process process)
+ protected virtual void SetSessionData (SerializationInfo info)
{
string type = info.GetString ("type");
if (type == "source") {
@@ -197,7 +197,7 @@
ISurrogateSelector
selector)
{
SourceLocation location = (SourceLocation) obj;
- location.SetSessionData (info, (Process)
context.Context);
+ location.SetSessionData (info);
return location;
}
}
Modified: trunk/debugger/classes/Thread.cs
===================================================================
--- trunk/debugger/classes/Thread.cs 2006-04-25 20:20:47 UTC (rev 59871)
+++ trunk/debugger/classes/Thread.cs 2006-04-25 20:49:18 UTC (rev 59872)
@@ -115,6 +115,13 @@
}
}
+ internal ThreadServant ThreadServant {
+ get {
+ check_servant ();
+ return servant;
+ }
+ }
+
public bool IsDaemon {
get {
check_servant ();
@@ -547,12 +554,6 @@
return (TargetAddress) result.Result;
}
- internal object Invoke (TargetAccessDelegate func, object data)
- {
- check_servant ();
- return servant.Invoke (func, data);
- }
-
public void Return (bool run_finally)
{
CommandResult result;
Modified: trunk/debugger/classes/ThreadGroup.cs
===================================================================
--- trunk/debugger/classes/ThreadGroup.cs 2006-04-25 20:20:47 UTC (rev
59871)
+++ trunk/debugger/classes/ThreadGroup.cs 2006-04-25 20:49:18 UTC (rev
59872)
@@ -3,6 +3,8 @@
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
+using Mono.Debugger.Backends;
+
namespace Mono.Debugger
{
// <summary>
@@ -96,7 +98,7 @@
StreamingContext context,
ISurrogateSelector
selector)
{
- Process process = (Process) context.Context;
+ ProcessServant process = (ProcessServant)
context.Context;
string name = info.GetString ("name");
return process.ThreadGroupByName (name);
Modified: trunk/debugger/frontend/Interpreter.cs
===================================================================
--- trunk/debugger/frontend/Interpreter.cs 2006-04-25 20:20:47 UTC (rev
59871)
+++ trunk/debugger/frontend/Interpreter.cs 2006-04-25 20:49:18 UTC (rev
59872)
@@ -695,11 +695,11 @@
protected void TargetExited ()
{
- if (debugger != null) {
- debugger.Dispose ();
- debugger = null;
- }
+ ThreadPool.QueueUserWorkItem (delegate (object state) {
+ ((Debugger) state).Dispose ();
+ }, debugger);
+ debugger = null;
main_process = current_process = null;
current_thread = null;
Modified: trunk/debugger/languages/TargetFunctionType.cs
===================================================================
--- trunk/debugger/languages/TargetFunctionType.cs 2006-04-25 20:20:47 UTC
(rev 59871)
+++ trunk/debugger/languages/TargetFunctionType.cs 2006-04-25 20:49:18 UTC
(rev 59872)
@@ -52,7 +52,7 @@
protected abstract void GetSessionData (SerializationInfo info);
- protected abstract object SetSessionData (SerializationInfo
info, Process process);
+ protected abstract object SetSessionData (SerializationInfo
info);
protected internal class SessionSurrogate :
ISerializationSurrogate
{
@@ -68,7 +68,7 @@
ISurrogateSelector
selector)
{
TargetFunctionType type = (TargetFunctionType)
obj;
- return type.SetSessionData (info, (Process)
context.Context);
+ return type.SetSessionData (info);
}
}
}
Modified: trunk/debugger/languages/mono/MonoClassInfo.cs
===================================================================
--- trunk/debugger/languages/mono/MonoClassInfo.cs 2006-04-25 20:20:47 UTC
(rev 59871)
+++ trunk/debugger/languages/mono/MonoClassInfo.cs 2006-04-25 20:49:18 UTC
(rev 59872)
@@ -58,7 +58,7 @@
if (initialized)
return;
- target.Invoke (do_initialize, null);
+ target.ThreadServant.Invoke (do_initialize, null);
}
object do_initialize (Thread target, object data)
Modified: trunk/debugger/languages/mono/MonoFunctionType.cs
===================================================================
--- trunk/debugger/languages/mono/MonoFunctionType.cs 2006-04-25 20:20:47 UTC
(rev 59871)
+++ trunk/debugger/languages/mono/MonoFunctionType.cs 2006-04-25 20:49:18 UTC
(rev 59872)
@@ -121,7 +121,7 @@
info.AddValue ("token", token);
}
- protected override object SetSessionData (SerializationInfo
info, Process process)
+ protected override object SetSessionData (SerializationInfo
info)
{
Module module = (Module) info.GetValue ("module",
typeof (Module));
string klass = info.GetString ("klass");
Modified: trunk/debugger/languages/native/NativeFunctionType.cs
===================================================================
--- trunk/debugger/languages/native/NativeFunctionType.cs 2006-04-25
20:20:47 UTC (rev 59871)
+++ trunk/debugger/languages/native/NativeFunctionType.cs 2006-04-25
20:49:18 UTC (rev 59872)
@@ -95,7 +95,7 @@
throw new NotSupportedException ();
}
- protected override object SetSessionData (SerializationInfo
info, Process process)
+ protected override object SetSessionData (SerializationInfo
info)
{
throw new NotSupportedException ();
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches