Author: martin
Date: 2007-05-16 12:35:40 -0400 (Wed, 16 May 2007)
New Revision: 77487

Modified:
   trunk/debugger/ChangeLog
   trunk/debugger/backend/BreakpointHandle.cs
   trunk/debugger/classes/SourceLocation.cs
Log:
2007-05-16  Martin Baulig  <[EMAIL PROTECTED]>

        * classes/SourceLocation.cs
        (SourceLocation.FunctionBreakpointHandle): Moved into
        BreakpointHandle.cs and made internal.

        * backend/BreakpointHandle.cs
        (FunctionBreakpointHandle): New internal class.



Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog    2007-05-16 16:07:41 UTC (rev 77486)
+++ trunk/debugger/ChangeLog    2007-05-16 16:35:40 UTC (rev 77487)
@@ -1,5 +1,14 @@
 2007-05-16  Martin Baulig  <[EMAIL PROTECTED]>
 
+       * classes/SourceLocation.cs
+       (SourceLocation.FunctionBreakpointHandle): Moved into
+       BreakpointHandle.cs and made internal.
+
+       * backend/BreakpointHandle.cs
+       (FunctionBreakpointHandle): New internal class.
+
+2007-05-16  Martin Baulig  <[EMAIL PROTECTED]>
+
        * classes/Breakpoint.cs
        (Breakpoint.Resolve): New abstract internal method.
 

Modified: trunk/debugger/backend/BreakpointHandle.cs
===================================================================
--- trunk/debugger/backend/BreakpointHandle.cs  2007-05-16 16:07:41 UTC (rev 
77486)
+++ trunk/debugger/backend/BreakpointHandle.cs  2007-05-16 16:35:40 UTC (rev 
77487)
@@ -1,4 +1,5 @@
 using System;
+using Mono.Debugger.Languages;
 
 namespace Mono.Debugger.Backends
 {
@@ -62,4 +63,100 @@
                        index = -1;
                }
        }
+
+       internal class FunctionBreakpointHandle : BreakpointHandle
+       {
+               ILoadHandler load_handler;
+               TargetFunctionType function;
+               SourceMethod source;
+               int line = -1;
+               int index = -1;
+               int domain;
+
+               public FunctionBreakpointHandle (Breakpoint bpt, int domain, 
SourceMethod source)
+                       : base (bpt)
+               {
+                       this.domain = domain;
+                       this.source = source;
+               }
+
+               public FunctionBreakpointHandle (Breakpoint bpt, int domain,
+                                                SourceMethod source, int line)
+                       : this (bpt, domain, source)
+               {
+                       this.line = line;
+               }
+
+               public FunctionBreakpointHandle (Breakpoint bpt, int domain,
+                                                TargetFunctionType function)
+                       : this (bpt, domain, function.Source, -1)
+               {
+                       this.function = function;
+               }
+
+               public override void Insert (Thread target)
+               {
+                       if ((load_handler != null) || (index > 0))
+                               return;
+
+                       if ((function != null) && function.IsLoaded) {
+                               index = target.InsertBreakpoint (Breakpoint, 
function);
+                               return;
+                       }
+
+                       load_handler = 
source.SourceFile.Module.SymbolFile.RegisterLoadHandler (
+                               target, source, method_loaded, null);
+               }
+
+               public override void Remove (Thread target)
+               {
+                       if (index > 0)
+                               target.RemoveBreakpoint (index);
+
+                       if (load_handler != null)
+                               load_handler.Remove ();
+
+                       load_handler = null;
+                       index = -1;
+               }
+
+               protected TargetAddress GetAddress (int domain)
+               {
+                       Method method = source.GetMethod (domain);
+                       if (method == null)
+                               return TargetAddress.Null;
+
+                       if (line != -1) {
+                               if (method.HasSource)
+                                       return method.Source.Lookup (line);
+                               else
+                                       return TargetAddress.Null;
+                       } else if (method.HasMethodBounds)
+                               return method.MethodStartAddress;
+                       else
+                               return method.StartAddress;
+               }
+
+               // <summary>
+               //   The method has just been loaded, lookup the breakpoint
+               //   address and actually insert it.
+               // </summary>
+               public void method_loaded (TargetMemoryAccess target,
+                                          SourceMethod source, object data)
+               {
+                       load_handler = null;
+
+                       TargetAddress address = GetAddress (domain);
+                       if (address.IsNull)
+                               return;
+
+                       try {
+                               index = target.InsertBreakpoint (Breakpoint, 
address);
+                       } catch (TargetException ex) {
+                               Report.Error ("Can't insert breakpoint {0} at 
{1}: {2}",
+                                             Breakpoint.Index, address, 
ex.Message);
+                               index = -1;
+                       }
+               }
+       }
 }

Modified: trunk/debugger/classes/SourceLocation.cs
===================================================================
--- trunk/debugger/classes/SourceLocation.cs    2007-05-16 16:07:41 UTC (rev 
77486)
+++ trunk/debugger/classes/SourceLocation.cs    2007-05-16 16:35:40 UTC (rev 
77487)
@@ -276,11 +276,11 @@
                        if (function != null) {
                                if (line > 0)
                                        source = function.Source;
-                               else if (function.IsLoaded) {
-                                       return new FunctionBreakpointHandle 
(breakpoint, domain, this);
-                               } else {
+                               else if (function.IsLoaded)
+                                       return new FunctionBreakpointHandle 
(breakpoint, domain, function);
+                               else {
                                        source = function.Source;
-                                       return new FunctionBreakpointHandle 
(breakpoint, domain, this);
+                                       return new FunctionBreakpointHandle 
(breakpoint, domain, source);
                                }
                        }
 
@@ -295,7 +295,7 @@
                                // callback when it's loaded.  We register this
                                // callback here and do the actual insertion 
when
                                // the method is loaded.
-                               return new FunctionBreakpointHandle 
(breakpoint, domain, this);
+                               return new FunctionBreakpointHandle 
(breakpoint, domain, source, line);
                        }
 
                        return null;
@@ -346,69 +346,5 @@
                                module.ModuleLoadedEvent -= module_loaded;
                        }
                }
-
-               class FunctionBreakpointHandle : BreakpointHandle
-               {
-                       DynamicSourceLocation location;
-                       ILoadHandler load_handler;
-                       int index = -1;
-                       int domain;
-
-                       public FunctionBreakpointHandle (Breakpoint bpt, int 
domain,
-                                                        DynamicSourceLocation 
location)
-
-                               : base (bpt)
-                       {
-                               this.location = location;
-                               this.domain = domain;
-                       }
-
-                       public override void Insert (Thread target)
-                       {
-                               if ((load_handler != null) || (index > 0))
-                                       return;
-
-                               if ((location.function != null) && 
location.function.IsLoaded)
-                                       index = target.InsertBreakpoint 
(Breakpoint, location.function);
-                               else
-                                       load_handler = 
location.module.SymbolFile.RegisterLoadHandler (
-                                               target, location.source, 
method_loaded, location);
-                       }
-
-                       public override void Remove (Thread target)
-                       {
-                               if (index > 0)
-                                       target.RemoveBreakpoint (index);
-
-                               if (load_handler != null)
-                                       load_handler.Remove ();
-
-                               load_handler = null;
-                               index = -1;
-                       }
-
-                       // <summary>
-                       //   The method has just been loaded, lookup the 
breakpoint
-                       //   address and actually insert it.
-                       // </summary>
-                       public void method_loaded (TargetMemoryAccess target,
-                                                  SourceMethod source, object 
data)
-                       {
-                               load_handler = null;
-
-                               DynamicSourceLocation location = 
(DynamicSourceLocation) data;
-                               TargetAddress address = location.GetAddress 
(domain);
-                               if (address.IsNull)
-                                       return;
-
-                               try {
-                                       index = target.InsertBreakpoint 
(Breakpoint, address);
-                               } catch (TargetException ex) {
-                                       Report.Error ("Can't insert breakpoint 
{0} at {1}: {2}",
-                                                     Breakpoint.Index, 
address, ex.Message);
-                                       index = -1;
-                               }
-                       }
-               }
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to