Author: martin
Date: 2007-02-28 08:16:53 -0500 (Wed, 28 Feb 2007)
New Revision: 73542
Modified:
trunk/debugger/ChangeLog
trunk/debugger/classes/Module.cs
trunk/debugger/classes/Process.cs
trunk/debugger/classes/SourceInfo.cs
trunk/debugger/classes/SourceLocation.cs
Log:
2007-02-28 Martin Baulig <[EMAIL PROTECTED]>
* classes/SourceInfo.cs
(SourceFile.FindMethod): New public method.
* classes/Process.cs
(Process.FindFile): New public method.
* classes/Module.cs
(Module.FindFile): New public method.
* classes/SourceLocation.cs
(SourceLocation): Allow file-line locations.
Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog 2007-02-28 13:10:32 UTC (rev 73541)
+++ trunk/debugger/ChangeLog 2007-02-28 13:16:53 UTC (rev 73542)
@@ -1,3 +1,17 @@
+2007-02-28 Martin Baulig <[EMAIL PROTECTED]>
+
+ * classes/SourceInfo.cs
+ (SourceFile.FindMethod): New public method.
+
+ * classes/Process.cs
+ (Process.FindFile): New public method.
+
+ * classes/Module.cs
+ (Module.FindFile): New public method.
+
+ * classes/SourceLocation.cs
+ (SourceLocation): Allow file-line locations.
+
2007-02-27 Martin Baulig <[EMAIL PROTECTED]>
* frontend/Command.cs
Modified: trunk/debugger/classes/Module.cs
===================================================================
--- trunk/debugger/classes/Module.cs 2007-02-28 13:10:32 UTC (rev 73541)
+++ trunk/debugger/classes/Module.cs 2007-02-28 13:16:53 UTC (rev 73542)
@@ -448,24 +448,42 @@
}
// <summary>
- // Find the method containing line @line in @source_file,
which must be
- // the file's full pathname.
+ // Find source file @filename. If @filename is a full
pathname, an exact
+ // match is required. Otherwise, a match from any directory
is ok.
// </summary>
- public SourceLocation FindLocation (string source_file, int
line)
+ public SourceFile FindFile (string filename)
{
if (!SymbolsLoaded)
return null;
- foreach (SourceFile source in Sources) {
- if (source.FileName != source_file)
- continue;
-
- return source.FindLine (line);
+ if (filename.IndexOf ('/') >= 0) {
+ foreach (SourceFile source in Sources) {
+ if (source.FileName == filename)
+ return source;
+ }
+ } else {
+ foreach (SourceFile source in Sources) {
+ if (source.FileName.EndsWith (filename))
+ return source;
+ }
}
return null;
}
+ // <summary>
+ // Find the method containing line @line in @source_file,
which must be
+ // the file's full pathname.
+ // </summary>
+ public SourceLocation FindLocation (string source_file, int
line)
+ {
+ SourceFile file = FindFile (source_file);
+ if (file == null)
+ return null;
+
+ return file.FindLine (line);
+ }
+
public Symbol SimpleLookup (TargetAddress address, bool
exact_match)
{
return SymbolFile.SimpleLookup (address, exact_match);
Modified: trunk/debugger/classes/Process.cs
===================================================================
--- trunk/debugger/classes/Process.cs 2007-02-28 13:10:32 UTC (rev 73541)
+++ trunk/debugger/classes/Process.cs 2007-02-28 13:16:53 UTC (rev 73542)
@@ -129,6 +129,19 @@
return null;
}
+ public SourceFile FindFile (string file_name)
+ {
+ foreach (Module module in Modules) {
+ SourceFile file = module.FindFile (file_name);
+
+ if (file != null)
+ return file;
+ }
+
+ return null;
+ }
+
+
public SourceLocation FindMethod (string name)
{
foreach (Module module in Modules) {
Modified: trunk/debugger/classes/SourceInfo.cs
===================================================================
--- trunk/debugger/classes/SourceInfo.cs 2007-02-28 13:10:32 UTC (rev
73541)
+++ trunk/debugger/classes/SourceInfo.cs 2007-02-28 13:16:53 UTC (rev
73542)
@@ -53,6 +53,17 @@
}
}
+ public SourceMethod FindMethod (int line)
+ {
+ SourceMethod[] methods = module.GetMethods (this);
+ foreach (SourceMethod method in methods) {
+ if ((method.StartRow <= line) && (method.EndRow
>= line))
+ return method;
+ }
+
+ return null;
+ }
+
public SourceLocation FindLine (int line)
{
SourceMethod[] methods = module.GetMethods (this);
Modified: trunk/debugger/classes/SourceLocation.cs
===================================================================
--- trunk/debugger/classes/SourceLocation.cs 2007-02-28 13:10:32 UTC (rev
73541)
+++ trunk/debugger/classes/SourceLocation.cs 2007-02-28 13:16:53 UTC (rev
73542)
@@ -71,6 +71,12 @@
Line = line;
}
+ public SourceLocation (string file, int line)
+ {
+ this.Line = line;
+ this.FileName = Name = file + ":" + line;
+ }
+
public void DumpLineNumbers ()
{
if (dynamic == null)
@@ -79,14 +85,12 @@
dynamic.DumpLineNumbers ();
}
- internal BreakpointHandle InsertBreakpoint (DebuggerSession
session,
- Thread target,
Breakpoint breakpoint,
- int domain)
+ protected bool Resolve (DebuggerSession session, Thread target)
{
- if (dynamic == null) {
- if (Method == null)
- throw new TargetException
(TargetError.LocationInvalid);
+ if (dynamic != null)
+ return true;
+ if (Method != null) {
Module module = session.GetModule (Module);
int pos = Method.IndexOf (':');
@@ -100,8 +104,35 @@
dynamic = new DynamicSourceLocation (
module.FindMethod (Method),
Line);
}
+
+ return true;
}
+ if (FileName != null) {
+ int pos = FileName.IndexOf (':');
+ if (pos < 0)
+ return false;
+
+ string filename = FileName.Substring (0, pos);
+
+ SourceFile file = target.Process.FindFile
(filename);
+ if (file == null)
+ return false;
+
+ dynamic = new DynamicSourceLocation (file,
Line);
+ return true;
+ }
+
+ return false;
+ }
+
+ internal BreakpointHandle InsertBreakpoint (DebuggerSession
session,
+ Thread target,
Breakpoint breakpoint,
+ int domain)
+ {
+ if (!Resolve (session, target))
+ throw new TargetException
(TargetError.LocationInvalid);
+
return dynamic.InsertBreakpoint (target, breakpoint,
domain);
}
@@ -227,17 +258,20 @@
return new ModuleBreakpointHandle (breakpoint,
this);
if ((function == null) && (source == null)) {
- if (method == null)
- throw new TargetException
(TargetError.LocationInvalid);
+ if (method != null) {
+ int pos = method.IndexOf (':');
+ if (pos > 0) {
+ string class_name =
method.Substring (0, pos);
+ string method_name =
method.Substring (pos + 1);
- int pos = method.IndexOf (':');
- if (pos > 0) {
- string class_name = method.Substring
(0, pos);
- string method_name = method.Substring
(pos + 1);
-
- function = module.LookupMethod
(class_name, method_name);
+ function = module.LookupMethod
(class_name, method_name);
+ } else {
+ source = module.FindMethod
(method);
+ }
+ } else if (file != null) {
+ source = file.FindMethod (line);
} else {
- source = module.FindMethod (method);
+ throw new TargetException
(TargetError.LocationInvalid);
}
}
@@ -359,7 +393,13 @@
if (address.IsNull)
return;
- index = target.InsertBreakpoint (Breakpoint,
address);
+ 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