Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
2005-08-24 Martin Baulig <martin@ximian.com>
Browse files Browse the repository at this point in the history
	* backends/SingleSteppingEngine.cs
	(SingleSteppingEngine.Stop): Replaced with the former contents of
	the Interrupt() method.
	(SingleSteppingEngine.Interrupt): Renamed to Stop().

	* backends/Process.cs (ProcessExitedHandler): Removed.
	(Process.TargetExitedEvent): Removed.
	(Process.ProcessExitedEvent): Removed.

	* backends/ThreadManager.cs (ThreadManager.HandleChildEvent): Only
	raise a `TargetExitedEvent' if the main thread exited.


svn path=/trunk/debugger/; revision=48784
  • Loading branch information
Martin Baulig committed Aug 24, 2005
1 parent 699b375 commit ffca806
Show file tree
Hide file tree
Showing 16 changed files with 172 additions and 186 deletions.
14 changes: 14 additions & 0 deletions ChangeLog
@@ -1,3 +1,17 @@
2005-08-24 Martin Baulig <martin@ximian.com>

* backends/SingleSteppingEngine.cs
(SingleSteppingEngine.Stop): Replaced with the former contents of
the Interrupt() method.
(SingleSteppingEngine.Interrupt): Renamed to Stop().

* backends/Process.cs (ProcessExitedHandler): Removed.
(Process.TargetExitedEvent): Removed.
(Process.ProcessExitedEvent): Removed.

* backends/ThreadManager.cs (ThreadManager.HandleChildEvent): Only
raise a `TargetExitedEvent' if the main thread exited.

2005-08-23 Martin Baulig <martin@ximian.com>

* frontend/libedit/mono-debugger-readline.c
Expand Down
2 changes: 1 addition & 1 deletion arch/BfdContainer.cs
Expand Up @@ -11,7 +11,7 @@

namespace Mono.Debugger.Architecture
{
internal class BfdContainer : IDisposable
internal class BfdContainer : MarshalByRefObject, IDisposable
{
Hashtable bfd_hash;
DebuggerBackend backend;
Expand Down
29 changes: 7 additions & 22 deletions backends/Process.cs
Expand Up @@ -21,7 +21,6 @@ namespace Mono.Debugger
int index, object user_data);
public delegate void BreakpointHitHandler (StackFrame frame, int index,
object user_data);
public delegate void ProcessExitedHandler (Process process);

public class Process : MarshalByRefObject, ITargetAccess
{
Expand Down Expand Up @@ -55,18 +54,6 @@ protected virtual void OnTargetEvent (TargetEventArgs args)
TargetEvent (this, args);
}

protected virtual void OnTargetExitedEvent ()
{
if (TargetExitedEvent != null)
TargetExitedEvent ();
}

protected virtual void OnProcessExitedEvent ()
{
if (ProcessExitedEvent != null)
ProcessExitedEvent (this);
}

public event TargetOutputHandler TargetOutput;
public event DebuggerOutputHandler DebuggerOutput;
public event DebuggerErrorHandler DebuggerError;
Expand All @@ -77,8 +64,6 @@ protected virtual void OnProcessExitedEvent ()
// emitted after the whole operation completed.
// </summary>
public event TargetEventHandler TargetEvent;
public event TargetExitedHandler TargetExitedEvent;
public event ProcessExitedHandler ProcessExitedEvent;

internal void OnInferiorOutput (bool is_stderr, string line)
{
Expand All @@ -99,6 +84,11 @@ internal void OnDebuggerOutput (string line)
DebuggerError (this, message, e);
}

public override string ToString ()
{
return Name;
}

// <summary>
// The single-stepping engine's target state. This will be
// TargetState.RUNNING while the engine is stepping.
Expand Down Expand Up @@ -168,10 +158,6 @@ void check_engine ()

internal void SendTargetEvent (TargetEventArgs args)
{
if ((args.Type == TargetEventType.TargetSignaled) ||
(args.Type == TargetEventType.TargetExited))
OnTargetExitedEvent ();

OnTargetEvent (args);
}

Expand Down Expand Up @@ -381,14 +367,13 @@ public bool Continue (TargetAddress until, bool in_background)
public void Kill ()
{
operation_completed_event.Set ();
OnProcessExitedEvent ();
Dispose ();
}

public bool Stop ()
public void Stop ()
{
check_engine ();
return engine.Stop ();
engine.Stop ();
}

public void Wait ()
Expand Down
172 changes: 81 additions & 91 deletions backends/SingleSteppingEngine.cs
Expand Up @@ -153,16 +153,27 @@ void setup_engine ()
public void ProcessEvent (int status)
{
Inferior.ChildEvent cevent = inferior.ProcessEvent (status);
if (has_thread_lock) {
Report.Debug (DebugFlags.EventLoop,
"{0} received event {1} while being thread-locked ({2})",
this, cevent, stop_event);
if (stop_event != null)
throw new InternalError ();
stop_event = cevent;
stopped = true;
return;
}
if (cevent.Type == Inferior.ChildEventType.CHILD_NOTIFICATION)
Report.Debug (DebugFlags.Notification,
"{0} received event {1} ({2:x})",
this, cevent, status);
"{0} received event {1} {2} ({3:x})",
this, cevent, (NotificationType) cevent.Argument,
status);
else
Report.Debug (DebugFlags.EventLoop,
"{0} received event {1} ({2:x})",
this, cevent, status);

if (manager.HandleChildEvent (inferior, ref cevent))
if (manager.HandleChildEvent (this, inferior, ref cevent))
return;
ProcessChildEvent (cevent);
}
Expand Down Expand Up @@ -490,8 +501,8 @@ internal void Start (TargetAddress func, bool is_main)
do_continue ();
} else {
send_target_event (new TargetEventArgs (TargetEventType.TargetRunning, null));
current_operation = new OperationRun (func, true);
do_continue (func);
current_operation = new OperationRun (TargetAddress.Null, true);
do_continue ();
}
}

Expand Down Expand Up @@ -743,9 +754,6 @@ public bool SendAsyncCommand (Command command)
return false;
}

if (!manager.AcquireCommandMutex ())
return false;

engine_stopped = false;
engine_stopped_event.Reset ();
}
Expand All @@ -755,73 +763,19 @@ public bool SendAsyncCommand (Command command)
return true;
}

public bool Stop ()
{
return do_wait (true);
}

public bool Wait ()
{
return do_wait (false);
}

public void Kill ()
{
operation_completed (new TargetEventArgs (TargetEventType.TargetExited, 0));

if (inferior != null)
inferior.Kill ();
}

bool do_wait (bool stop)
{
#if FIXME
lock (this) {
// First try to get the `command_mutex'.
// If we succeed, then no synchronous command is currently
// running.
if (!manager.AcquireCommandMutex (this)) {
Report.Debug (DebugFlags.Wait,
"{0} cannot get command mutex", this);
return false;
}
// Check whether we're curring performing an async
// stepping operation.
if (engine_stopped) {
Report.Debug (DebugFlags.Wait,
"{0} already stopped", this);
manager.ReleaseCommandMutex ();
return true;
}

if (stop) {
stop_requested = true;
if (!inferior.Stop ()) {
// We're already stopped, so just consider the
// current operation as finished.
step_operation_finished ();
engine_stopped = true;
stop_requested = false;
operation_completed_event.Set ();
manager.ReleaseCommandMutex ();
return true;
}
}
if (!engine_stopped)
operation_completed (
new TargetEventArgs (TargetEventType.TargetExited, 0));
}

// Ok, we got the `command_mutex'.
// Now we can wait for the operation to finish.
Report.Debug (DebugFlags.Wait, "{0} waiting", this);
operation_completed_event.WaitOne ();
Report.Debug (DebugFlags.Wait, "{0} stopped", this);
manager.ReleaseCommandMutex ();
return true;
#else
return true;
#endif
if (inferior != null)
inferior.Kill ();
}

public void Interrupt ()
public void Stop ()
{
lock (this) {
Report.Debug (DebugFlags.EventLoop, "{0} interrupt: {1}",
Expand Down Expand Up @@ -1175,6 +1129,9 @@ void insert_temporary_breakpoint (TargetAddress address)
{
check_inferior ();
int dr_index;
Report.Debug (DebugFlags.SSE, "{0} inserting temp breakpoint at {1}",
this, address);

temp_breakpoint_id = inferior.InsertHardwareBreakpoint (
address, true, out dr_index);
}
Expand Down Expand Up @@ -1405,6 +1362,7 @@ public bool AcquireThreadLock ()
Report.Debug (DebugFlags.Threads,
"{0} acquiring thread lock", this);

has_thread_lock = true;
stopped = inferior.Stop (out stop_event);
Inferior.StackFrame frame = inferior.GetCurrentFrame ();

Expand All @@ -1425,6 +1383,8 @@ public void ReleaseThreadLock ()
"{0} releasing thread lock: {1} {2}",
this, stopped, stop_event);

has_thread_lock = false;

// If the target was already stopped, there's nothing to do for us.
if (!stopped)
return;
Expand All @@ -1440,11 +1400,9 @@ public void ReleaseThreadLock ()
return;
}

if (manager.HandleChildEvent (inferior, ref cevent))
if (manager.HandleChildEvent (this, inferior, ref cevent))
return;
ProcessChildEvent (cevent);
} else {
do_continue ();
}
}

Expand Down Expand Up @@ -1622,6 +1580,7 @@ public void Dispose ()
bool engine_stopped;
ManualResetEvent engine_stopped_event;
bool stop_requested;
bool has_thread_lock;
bool is_main, reached_main;
public readonly int ID;
public readonly int PID;
Expand Down Expand Up @@ -2671,45 +2630,76 @@ public override string ToString ()
}
}

[Serializable]
internal enum CallMethodType
{
LongLong,
LongString
}

internal sealed class CallMethodData
internal sealed class CallMethodData : MarshalByRefObject
{
public readonly CallMethodType Type;
public readonly TargetAddress Method;
public readonly long Argument1;
public readonly long Argument2;
public readonly string StringArgument;
public readonly object Data;
public object Result;
CallMethodType type;
TargetAddress method;
long argument1;
long argument2;
string sargument;
object data;
object result;

public CallMethodType Type {
get { return type; }
}

public TargetAddress Method {
get { return method; }
}

public long Argument1 {
get { return argument1; }
}

public long Argument2 {
get { return argument2; }
}

public string StringArgument {
get { return sargument; }
}

public object Data {
get { return data; }
}

public object Result {
get { return result; }
set { result = value; }
}

public CallMethodData (TargetAddress method, long arg, string sarg,
object data)
{
this.Type = CallMethodType.LongString;
this.Method = method;
this.Argument1 = arg;
this.Argument2 = 0;
this.StringArgument = sarg;
this.Data = data;
this.type = CallMethodType.LongString;
this.method = method;
this.argument1 = arg;
this.argument2 = 0;
this.sargument = sarg;
this.data = data;
}

public CallMethodData (TargetAddress method, long arg1, long arg2,
object data)
{
this.Type = CallMethodType.LongLong;
this.Method = method;
this.Argument1 = arg1;
this.Argument2 = arg2;
this.StringArgument = null;
this.Data = data;
this.type = CallMethodType.LongLong;
this.method = method;
this.argument1 = arg1;
this.argument2 = arg2;
this.sargument = null;
this.data = data;
}
}

[Serializable]
internal sealed class RuntimeInvokeData
{
public readonly StackFrame Frame;
Expand Down

0 comments on commit ffca806

Please sign in to comment.