Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@novell.com>2009-03-04 21:44:45 +0300
committerLluis Sanchez <lluis@novell.com>2009-03-04 21:44:45 +0300
commit49cc846960cd02b6c41918d5bcdc73ceca792da6 (patch)
tree25d17632b1a684e3402030a1b7e716089a59d822
parentaff5ed5ff06abf4380e1a82a47b8d82464275fc6 (diff)
Merged from trunk. Revisions 128565:128574
svn path=/branches/monodevelop/extras/MonoDevelop.Debugger.Gdb/2.0/; revision=128586
-rw-r--r--extras/MonoDevelop.Debugger.Gdb/ChangeLog14
-rw-r--r--extras/MonoDevelop.Debugger.Gdb/GdbSessionFactory.cs69
2 files changed, 78 insertions, 5 deletions
diff --git a/extras/MonoDevelop.Debugger.Gdb/ChangeLog b/extras/MonoDevelop.Debugger.Gdb/ChangeLog
index 294a22d5bf..5d13dd69e7 100644
--- a/extras/MonoDevelop.Debugger.Gdb/ChangeLog
+++ b/extras/MonoDevelop.Debugger.Gdb/ChangeLog
@@ -1,3 +1,17 @@
+2009-03-04 Lluis Sanchez Gual <lluis@novell.com>
+
+ * GdbSessionFactory.cs: Removed unused CanDebugPlatform and
+ rename CanDebugFile to CanDebugCommand.
+
+2009-03-04 Lluis Sanchez Gual <lluis@novell.com>
+
+ * GdbSessionFactory.cs: Changed the way execution handlers
+ work. We are not using platform ids anymore. Instead, we use
+ command strings when looking for execution handlers.
+ IExecutionHandlerFactory has been removed and now everything
+ is handled by IExecutionHandler, which has a new CanExecute
+ method. This model is more simple and more generic.
+
2009-02-26 Lluis Sanchez Gual <lluis@novell.com>
* MonoDevelop.Debugger.Gdb.sln: Flush.
diff --git a/extras/MonoDevelop.Debugger.Gdb/GdbSessionFactory.cs b/extras/MonoDevelop.Debugger.Gdb/GdbSessionFactory.cs
index dd7ef883db..95ab72b738 100644
--- a/extras/MonoDevelop.Debugger.Gdb/GdbSessionFactory.cs
+++ b/extras/MonoDevelop.Debugger.Gdb/GdbSessionFactory.cs
@@ -35,19 +35,65 @@ namespace MonoDevelop.Debugger.Gdb
{
public class GdbSessionFactory: IDebuggerEngine
{
+ struct FileData {
+ public DateTime LastCheck;
+ public bool IsExe;
+ }
+
+ Dictionary<string,FileData> fileCheckCache = new Dictionary<string, FileData> ();
+
public string Name {
get { return "GNU Debugger (GDB)"; }
}
- public bool CanDebugPlatform (string platformId)
+ public bool CanDebugCommand (string file)
{
- return platformId == "Native";
+ string ext = System.IO.Path.GetExtension (file).ToLower ();
+ if (ext == ".exe" || ext == ".dll")
+ return false;
+ file = FindFile (file);
+ if (!File.Exists (file)) {
+ // The provided file is not guaranteed to exist. If it doesn't
+ // we assume we can execute it because otherwise the run command
+ // in the IDE will be disabled, and that's not good because that
+ // command will build the project if the exec doesn't yet exist.
+ return true;
+ }
+
+ file = Path.GetFullPath (file);
+ DateTime currentTime = File.GetLastWriteTime (file);
+
+ FileData data;
+ if (fileCheckCache.TryGetValue (file, out data)) {
+ if (data.LastCheck == currentTime)
+ return data.IsExe;
+ }
+ data.LastCheck = currentTime;
+ try {
+ data.IsExe = IsExecutable (file);
+ } catch {
+ data.IsExe = false;
+ }
+ fileCheckCache [file] = data;
+ return data.IsExe;
}
- public bool CanDebugFile (string file)
+ public bool IsExecutable (string file)
{
- string ext = System.IO.Path.GetExtension (file).ToLower ();
- return ext != ".exe" && ext != ".dll";
+ // HACK: this is a quick but not very reliable way of checking if a file
+ // is a native executable. Actually, we are interested in checking that
+ // the file is not a script.
+ using (StreamReader sr = new StreamReader (file)) {
+ char[] chars = new char[3];
+ int n = 0, nr = 0;
+ while (n < chars.Length && (nr = sr.ReadBlock (chars, n, chars.Length - n)) != 0)
+ n += nr;
+ if (nr != chars.Length)
+ return true;
+ if (chars [0] == '#' && chars [1] == '!')
+ return false;
+ }
+ return true;
}
public DebuggerFeatures SupportedFeatures {
@@ -82,5 +128,18 @@ namespace MonoDevelop.Debugger.Gdb
return procs.ToArray ();
}
+ string FindFile (string cmd)
+ {
+ if (Path.IsPathRooted (cmd))
+ return cmd;
+ string pathVar = Environment.GetEnvironmentVariable ("PATH");
+ string[] paths = pathVar.Split (Path.PathSeparator);
+ foreach (string path in paths) {
+ string file = Path.Combine (path, cmd);
+ if (File.Exists (file))
+ return file;
+ }
+ return cmd;
+ }
}
}