Author: toshok
Date: 2005-03-31 15:46:06 -0500 (Thu, 31 Mar 2005)
New Revision: 42445
Added:
trunk/debugger/classes/CatchpointHandle.cs
trunk/debugger/interfaces/IEventHandle.cs
Modified:
trunk/debugger/ChangeLog
trunk/debugger/backends/mono/MonoClassObject.cs
trunk/debugger/backends/mono/MonoLanguageBackend.cs
trunk/debugger/backends/mono/MonoSymbolFile.cs
trunk/debugger/classes/BreakpointHandle.cs
trunk/debugger/classes/SourceLocation.cs
trunk/debugger/frontend/Command.cs
trunk/debugger/frontend/Interpreter.cs
Log:
2005-03-31 Chris Toshok <[EMAIL PROTECTED]>
* backends/mono/MonoSymbolFile.cs (MonoMethod.get_variables): we
need to attach liveness ranges to MonoVariables if they're
defined
in nested blocks regardless of whether or not local names are
ambiguous. This is so MonoDevelop can update the variable
display
and not show variables that aren't in scope.
(MonoSymbolFile.GetMethod): remove spew.
* backends/mono/MonoClassObject.cs
* (MonoClassObject.PrintObject):
80% implementation. still needs some more type checking on the
method invoked.
* backends/mono/MonoLanguageBackend.cs
(MonoBuiltinTypeInfo..ctor): read in the Exception type from
mono_defaults.
(MonoLanguageBackend.get_ExceptionType): implement.
* frontend/Command.cs (BreakpointEnableCommand,
BreakpointDisableCommand, BreakpointDeleteCommand): switch from
BreakpointHandle to IEventHandle and track api change in
Interpreter, so we can deal with both catchpoints and breakpoints.
* frontend/Interpreter.cs (Interpreter.ShowBreakpoints): loop over
all IEventHandles now, and clean up the display a bit.
(Interpreter.GetEvent): rename GetBreakpoint to this, so it can
refer to both catchpoints and breakpoints.
(Interpreter.DeleteEvent): rename DeleteBreakpoint to this, so it
can refer to both catchpoints and breakpoints.
(Interpreter.InsertExceptionCatchPoint): EventHandle ->
CatchpointHandle.
* classes/SourceLocation.cs (SourceLocation.InsertBreakpoint):
track change to BreakpointHandle.
* classes/CatchpointHandle.cs: the majority of the old code from
EventHandle.cs, reorganized/renamed so as to implement
IEventHandle.
* classes/BreakpointHandle.cs: reorganize/rename things a bit so
we implement IEventHandle.
* interfaces/IEventHandle.cs: move classes/EventHandle.cs here,
and make it a general interface, implemented by both
classes/CatchpointHandle and classes/BreakpointHandle.
Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog 2005-03-31 20:06:10 UTC (rev 42444)
+++ trunk/debugger/ChangeLog 2005-03-31 20:46:06 UTC (rev 42445)
@@ -1,3 +1,49 @@
+2005-03-31 Chris Toshok <[EMAIL PROTECTED]>
+
+ * backends/mono/MonoSymbolFile.cs (MonoMethod.get_variables): we
+ need to attach liveness ranges to MonoVariables if they're defined
+ in nested blocks regardless of whether or not local names are
+ ambiguous. This is so MonoDevelop can update the variable display
+ and not show variables that aren't in scope.
+ (MonoSymbolFile.GetMethod): remove spew.
+
+ * backends/mono/MonoClassObject.cs (MonoClassObject.PrintObject):
+ 80% implementation. still needs some more type checking on the
+ method invoked.
+
+ * backends/mono/MonoLanguageBackend.cs
+ (MonoBuiltinTypeInfo..ctor): read in the Exception type from
+ mono_defaults.
+ (MonoLanguageBackend.get_ExceptionType): implement.
+
+ * frontend/Command.cs (BreakpointEnableCommand,
+ BreakpointDisableCommand, BreakpointDeleteCommand): switch from
+ BreakpointHandle to IEventHandle and track api change in
+ Interpreter, so we can deal with both catchpoints and breakpoints.
+
+ * frontend/Interpreter.cs (Interpreter.ShowBreakpoints): loop over
+ all IEventHandles now, and clean up the display a bit.
+ (Interpreter.GetEvent): rename GetBreakpoint to this, so it can
+ refer to both catchpoints and breakpoints.
+ (Interpreter.DeleteEvent): rename DeleteBreakpoint to this, so it
+ can refer to both catchpoints and breakpoints.
+ (Interpreter.InsertExceptionCatchPoint): EventHandle ->
+ CatchpointHandle.
+
+ * classes/SourceLocation.cs (SourceLocation.InsertBreakpoint):
+ track change to BreakpointHandle.
+
+ * classes/CatchpointHandle.cs: the majority of the old code from
+ EventHandle.cs, reorganized/renamed so as to implement
+ IEventHandle.
+
+ * classes/BreakpointHandle.cs: reorganize/rename things a bit so
+ we implement IEventHandle.
+
+ * interfaces/IEventHandle.cs: move classes/EventHandle.cs here,
+ and make it a general interface, implemented by both
+ classes/CatchpointHandle and classes/BreakpointHandle.
+
2005-03-24 Chris Toshok <[EMAIL PROTECTED]>
* configure.in (AC_OUTPUT): remove cslex/Makefile.
Modified: trunk/debugger/backends/mono/MonoClassObject.cs
===================================================================
--- trunk/debugger/backends/mono/MonoClassObject.cs 2005-03-31 20:06:10 UTC
(rev 42444)
+++ trunk/debugger/backends/mono/MonoClassObject.cs 2005-03-31 20:46:06 UTC
(rev 42445)
@@ -71,7 +71,37 @@
public string PrintObject ()
{
- throw new NotImplementedException ();
+ ITargetObject[] args = new ITargetObject[0];
+ ITargetFunctionObject func;
+ ITargetStructType stype = (ITargetStructType)type.Type;
+
+ again:
+ foreach (ITargetMethodInfo m in stype.Methods)
+ // XXX also check that the return type is
String, right?
+ if (m.Name == "ToString" &&
m.Type.ParameterTypes.Length == 0) {
+ func = GetMethod (m.Index);
+ break;
+ }
+
+ if (func == null) {
+ ITargetClassType ctype = stype as
ITargetClassType;
+ if (ctype != null && ctype.HasParent) {
+ stype = ctype.ParentType;
+ goto again;
+ }
+ else {
+ return null;
+ }
+ }
+
+ try {
+ ITargetObject retval = func.Invoke (args,
false);
+
+ return retval.Print();
+ }
+ catch (TargetInvocationException ex) {
+ return "Exception calling ToString()";
+ }
}
protected override long GetDynamicSize (ITargetMemoryReader
reader,
Modified: trunk/debugger/backends/mono/MonoLanguageBackend.cs
===================================================================
--- trunk/debugger/backends/mono/MonoLanguageBackend.cs 2005-03-31 20:06:10 UTC
(rev 42444)
+++ trunk/debugger/backends/mono/MonoLanguageBackend.cs 2005-03-31 20:46:06 UTC
(rev 42445)
@@ -72,6 +72,11 @@
}
}
+ // <summary>
+ // This class is the managed representation of the
+ // MonoDefaults struct (at least the types we're interested
+ // in) as defined in mono/metadata/class-internals.h.
+ // </summary>
internal class MonoBuiltinTypeInfo
{
public readonly MonoSymbolFile Corlib;
@@ -92,6 +97,7 @@
public readonly MonoFundamentalType DoubleType;
public readonly MonoFundamentalType CharType;
public readonly MonoStringType StringType;
+ public readonly MonoClassType ExceptionType;
public readonly int KlassFieldOffset;
public readonly int KlassMethodsOffset;
@@ -188,6 +194,15 @@
StringType = new MonoStringType (
corlib, typeof (string), object_size,
object_size + 4, klass);
corlib.AddCoreType (StringType);
+
+ // Skip a whole bunch of clases we don't care about
+ mono_defaults.Offset += 10 *
corlib.TargetInfo.TargetAddressSize;
+
+ // and get to the Exception class
+ klass = mono_defaults.ReadGlobalAddress ();
+ ExceptionType = new MonoClassType (corlib, typeof
(Exception));
+ //ExceptionType = new MonoFundamentalType (corlib,
typeof (Exception), object_size, klass);
+ corlib.AddCoreType (ExceptionType);
}
}
@@ -599,7 +614,7 @@
}
ITargetType ILanguage.ExceptionType {
- get { return null; }
+ get { return builtin_types.ExceptionType; }
}
#endregion
Modified: trunk/debugger/backends/mono/MonoSymbolFile.cs
===================================================================
--- trunk/debugger/backends/mono/MonoSymbolFile.cs 2005-03-31 20:06:10 UTC
(rev 42444)
+++ trunk/debugger/backends/mono/MonoSymbolFile.cs 2005-03-31 20:46:06 UTC
(rev 42445)
@@ -497,7 +497,6 @@
IMethod ISymbolFile.GetMethod (long handle)
{
MethodRangeEntry entry = (MethodRangeEntry) range_hash
[(int) handle];
- Console.WriteLine ("GET METHOD BY HANDLE: {0} {1}",
handle, entry);
if (entry == null)
return null;
@@ -640,7 +639,7 @@
local_types [i] =
file.MonoLanguage.LookupMonoType (type);
- if (method.LocalNamesAmbiguous &&
(local.BlockIndex > 0)) {
+ if (local.BlockIndex > 0) {
int index = local.BlockIndex -
1;
JitLexicalBlockEntry block =
address.LexicalBlocks [index];
locals [i] = new MonoVariable (
Modified: trunk/debugger/classes/BreakpointHandle.cs
===================================================================
--- trunk/debugger/classes/BreakpointHandle.cs 2005-03-31 20:06:10 UTC (rev
42444)
+++ trunk/debugger/classes/BreakpointHandle.cs 2005-03-31 20:46:06 UTC (rev
42445)
@@ -4,10 +4,13 @@
namespace Mono.Debugger
{
- public class BreakpointHandle
+ public class BreakpointHandle : IEventHandle
{
Breakpoint breakpoint;
SourceLocation location;
+ TargetAddress address = TargetAddress.Null;
+ int breakpoint_id = -1;
+ IDisposable load_handler;
private BreakpointHandle (Process process, Breakpoint
breakpoint,
SourceLocation location)
@@ -32,43 +35,40 @@
this.address = address;
}
+#region IEventHandle
public Breakpoint Breakpoint {
get { return breakpoint; }
}
- public SourceLocation SourceLocation {
- get { return location; }
+ public bool IsEnabled {
+ get { return (breakpoint_id > 0) || (load_handler !=
null); }
}
- IDisposable load_handler;
-
- // <summary>
- // The method has just been loaded, lookup the breakpoint
- // address and actually insert it.
- // </summary>
- void method_loaded (ITargetAccess target, SourceMethod method,
object data)
+ public void Enable (Process process)
{
- load_handler = null;
-
- address = location.GetAddress ();
- if (address.IsNull)
- return;
-
- breakpoint_id = target.InsertBreakpoint (breakpoint,
address);
+ lock (this) {
+ EnableBreakpoint (process);
+ }
}
- TargetAddress address = TargetAddress.Null;
- int breakpoint_id = -1;
-
- public bool IsEnabled {
- get { return (breakpoint_id > 0) || (load_handler !=
null); }
+ public void Disable (Process process)
+ {
+ lock (this) {
+ DisableBreakpoint (process);
+ }
}
- public TargetAddress Address {
- get { return address; }
+ public void Remove (Process process)
+ {
+ if (load_handler != null) {
+ load_handler.Dispose ();
+ load_handler = null;
+ }
+ Disable (process);
}
+#endregion
- protected void Enable (Process process)
+ void EnableBreakpoint (Process process)
{
lock (this) {
if ((load_handler != null) || (breakpoint_id >
0))
@@ -90,7 +90,7 @@
}
}
- protected void Disable (Process process)
+ void DisableBreakpoint (Process process)
{
lock (this) {
if (breakpoint_id > 0)
@@ -104,27 +104,27 @@
}
}
- public void EnableBreakpoint (Process process)
- {
- lock (this) {
- Enable (process);
- }
+ public SourceLocation SourceLocation {
+ get { return location; }
}
- public void DisableBreakpoint (Process process)
+ // <summary>
+ // The method has just been loaded, lookup the breakpoint
+ // address and actually insert it.
+ // </summary>
+ void method_loaded (ITargetAccess target, SourceMethod method,
object data)
{
- lock (this) {
- Disable (process);
- }
+ load_handler = null;
+
+ address = location.GetAddress ();
+ if (address.IsNull)
+ return;
+
+ breakpoint_id = target.InsertBreakpoint (breakpoint,
address);
}
- public void RemoveBreakpoint (Process process)
- {
- if (load_handler != null) {
- load_handler.Dispose ();
- load_handler = null;
- }
- DisableBreakpoint (process);
+ public TargetAddress Address {
+ get { return address; }
}
}
}
Added: trunk/debugger/classes/CatchpointHandle.cs
===================================================================
--- trunk/debugger/classes/CatchpointHandle.cs 2005-03-31 20:06:10 UTC (rev
42444)
+++ trunk/debugger/classes/CatchpointHandle.cs 2005-03-31 20:46:06 UTC (rev
42445)
@@ -0,0 +1,73 @@
+using System;
+
+using Mono.Debugger.Backends;
+
+namespace Mono.Debugger
+{
+ public class CatchpointHandle : IEventHandle
+ {
+ Breakpoint breakpoint;
+ int event_id;
+
+ private CatchpointHandle (Process process, Breakpoint
breakpoint)
+ {
+ this.breakpoint = breakpoint;
+
+ Enable (process);
+ }
+
+ public static CatchpointHandle Create (Process process,
Breakpoint breakpoint)
+ {
+ return new CatchpointHandle (process, breakpoint);
+ }
+
+#region IEventHandle
+ public Breakpoint Breakpoint {
+ get { return breakpoint; }
+ }
+
+ public bool IsEnabled {
+ get { return (event_id > 0); }
+ }
+
+ public void Enable (Process process)
+ {
+ lock (this) {
+ EnableCatchpoint (process);
+ }
+ }
+
+ public void Disable (Process process)
+ {
+ lock (this) {
+ DisableCatchpoint (process);
+ }
+ }
+
+ public void Remove (Process process)
+ {
+ Disable (process);
+ }
+#endregion
+
+ void EnableCatchpoint (Process process)
+ {
+ lock (this) {
+ if (event_id > 0)
+ return;
+
+ event_id = process.AddEventHandler
(EventType.CatchException, breakpoint);
+ }
+ }
+
+ void DisableCatchpoint (Process process)
+ {
+ lock (this) {
+ if (event_id > 0)
+ process.RemoveEventHandler (event_id);
+
+ event_id = -1;
+ }
+ }
+ }
+}
Modified: trunk/debugger/classes/SourceLocation.cs
===================================================================
--- trunk/debugger/classes/SourceLocation.cs 2005-03-31 20:06:10 UTC (rev
42444)
+++ trunk/debugger/classes/SourceLocation.cs 2005-03-31 20:46:06 UTC (rev
42445)
@@ -72,7 +72,7 @@
public BreakpointHandle InsertBreakpoint (Process process,
Breakpoint bpt)
{
BreakpointHandle handle = BreakpointHandle.Create
(process, bpt, this);
- handle.EnableBreakpoint (process);
+ handle.Enable (process);
return handle;
}
Modified: trunk/debugger/frontend/Command.cs
===================================================================
--- trunk/debugger/frontend/Command.cs 2005-03-31 20:06:10 UTC (rev 42444)
+++ trunk/debugger/frontend/Command.cs 2005-03-31 20:46:06 UTC (rev 42445)
@@ -1544,7 +1544,7 @@
public class BreakpointEnableCommand : DebuggerCommand,
IDocumentableCommand
{
- protected BreakpointHandle handle;
+ protected IEventHandle handle;
protected override bool DoResolve (ScriptingContext context)
{
@@ -1552,22 +1552,22 @@
try {
id = (int) UInt32.Parse (Argument);
} catch {
- context.Print ("Breakpoint number expected.");
+ context.Print ("event number expected.");
return false;
}
- handle = context.Interpreter.GetBreakpoint (id);
+ handle = context.Interpreter.GetEvent (id);
return handle != null;
}
protected override void DoExecute (ScriptingContext context)
{
- handle.EnableBreakpoint
(context.CurrentProcess.Process);
+ handle.Enable (context.CurrentProcess.Process);
}
// IDocumentableCommand
public virtual CommandFamily Family { get { return
CommandFamily.Breakpoints; } }
- public virtual string Description { get { return "Enable
breakpoint."; } }
+ public virtual string Description { get { return "Enable
breakpoint/catchpoint."; } }
public virtual string Documentation { get { return ""; } }
}
@@ -1575,12 +1575,12 @@
{
protected override void DoExecute (ScriptingContext context)
{
- handle.DisableBreakpoint
(context.CurrentProcess.Process);
+ handle.Disable (context.CurrentProcess.Process);
}
// IDocumentableCommand
public override CommandFamily Family { get { return
CommandFamily.Breakpoints; } }
- public override string Description { get { return "Disable
breakpoint."; } }
+ public override string Description { get { return "Disable
breakpoint/catchpoint."; } }
public override string Documentation { get { return ""; } }
}
@@ -1588,12 +1588,12 @@
{
protected override void DoExecute (ScriptingContext context)
{
- context.Interpreter.DeleteBreakpoint
(context.CurrentProcess, handle);
+ context.Interpreter.DeleteEvent
(context.CurrentProcess, handle);
}
// IDocumentableCommand
public override CommandFamily Family { get { return
CommandFamily.Breakpoints; } }
- public override string Description { get { return "Delete
breakpoint."; } }
+ public override string Description { get { return "Delete
breakpoint/catchpoint."; } }
public override string Documentation { get { return ""; } }
}
Modified: trunk/debugger/frontend/Interpreter.cs
===================================================================
--- trunk/debugger/frontend/Interpreter.cs 2005-03-31 20:06:10 UTC (rev
42444)
+++ trunk/debugger/frontend/Interpreter.cs 2005-03-31 20:46:06 UTC (rev
42445)
@@ -25,7 +25,6 @@
ProcessHandle current_process;
Hashtable procs;
- Hashtable breakpoints;
Hashtable events;
Hashtable styles;
@@ -64,7 +63,6 @@
this.options = options;
procs = new Hashtable ();
- breakpoints = new Hashtable ();
events = new Hashtable ();
styles = new Hashtable ();
@@ -465,26 +463,37 @@
public void ShowBreakpoints ()
{
Print ("Breakpoints:");
- foreach (BreakpointHandle handle in breakpoints.Values)
{
- Print ("{0} ({1}): [{3}] {2}",
handle.Breakpoint.Index,
- handle.Breakpoint.ThreadGroup.Name,
handle.Breakpoint,
- handle.IsEnabled ? "*" : " ");
+ Print ("{0,3} {1,6} {2,3} {3,12} {4}", "Id", "Type",
"En", "ThreadGroup", "What");
+ foreach (IEventHandle handle in events.Values) {
+ string type;
+
+ if (handle is CatchpointHandle)
+ type = "catch";
+ else
+ type = "break";
+
+ Print ("{0,3} {1,6} {2,3} {3,12} {4}",
+ handle.Breakpoint.Index,
+ type,
+ handle.IsEnabled ? "y" : "n",
+ handle.Breakpoint.ThreadGroup.Name,
handle.Breakpoint.Name);
}
}
- public BreakpointHandle GetBreakpoint (int index)
+ public IEventHandle GetEvent (int index)
{
- BreakpointHandle handle = (BreakpointHandle)
breakpoints [index];
+ IEventHandle handle = (IEventHandle) events [index];
+
if (handle == null)
- throw new ScriptingException ("No such
breakpoint.");
+ throw new ScriptingException ("No such
breakpoint/catchpoint.");
return handle;
}
- public void DeleteBreakpoint (ProcessHandle process,
BreakpointHandle handle)
+ public void DeleteEvent (ProcessHandle process, IEventHandle
handle)
{
- handle.RemoveBreakpoint (process.Process);
- breakpoints.Remove (handle.Breakpoint.Index);
+ handle.Remove (process.Process);
+ events.Remove (handle.Breakpoint.Index);
}
public Module[] GetModules (int[] indices)
@@ -637,7 +646,6 @@
current_process = null;
procs = new Hashtable ();
- breakpoints = new Hashtable ();
events = new Hashtable ();
context = new ScriptingContext (this, is_interactive,
true);
@@ -738,7 +746,7 @@
if (handle == null)
throw new ScriptingException ("Could not insert
breakpoint.");
- breakpoints.Add (breakpoint.Index, handle);
+ events.Add (breakpoint.Index, handle);
return breakpoint.Index;
}
@@ -748,8 +756,8 @@
{
Breakpoint breakpoint = new ExceptionCatchPoint
(language, exception, group);
- EventHandle handle = EventHandle.Create (
- thread.Process, EventType.CatchException,
breakpoint);
+ CatchpointHandle handle = CatchpointHandle.Create (
+ thread.Process, breakpoint);
if (handle == null)
throw new ScriptingException ("Could not add
catch point.");
Copied: trunk/debugger/interfaces/IEventHandle.cs (from rev 42188,
trunk/debugger/classes/EventHandle.cs)
===================================================================
--- trunk/debugger/classes/EventHandle.cs 2005-03-24 05:41:23 UTC (rev
42188)
+++ trunk/debugger/interfaces/IEventHandle.cs 2005-03-31 20:46:06 UTC (rev
42445)
@@ -0,0 +1,34 @@
+using System;
+
+using Mono.Debugger.Backends;
+
+namespace Mono.Debugger
+{
+ public enum EventType {
+
+ CatchException
+
+ }
+
+ // A general interface to events, like breakpoints, catchpoints..
+ // probably watchpoints at some time in the future
+
+ public interface IEventHandle {
+
+ // The breakpoint associated with this event
+ Breakpoint Breakpoint { get; }
+
+ // Whether or not the event is active
+ bool IsEnabled { get; }
+
+ // Enable the event in the given process
+ void Enable (Process process);
+
+ // Disable the event in the given process
+ void Disable (Process process);
+
+ // Remove the event from the given process (also
+ // disables it)
+ void Remove (Process process);
+ }
+}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches