Browse Source
- fixed bug in CopyStacktrace git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@4083 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
14 changed files with 327 additions and 56 deletions
@ -0,0 +1,94 @@
@@ -0,0 +1,94 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Diagnostics; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.Profiler.Controller.Data; |
||||
using ICSharpCode.SharpDevelop.Profiling; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using System.IO; |
||||
|
||||
namespace ICSharpCode.Profiler.AddIn |
||||
{ |
||||
/// <summary>
|
||||
/// Description of WindowsProfiler.
|
||||
/// </summary>
|
||||
public class WindowsProfiler : IProfiler |
||||
{ |
||||
ProfilerRunner runner; |
||||
bool isRunning = false; |
||||
|
||||
public WindowsProfiler() |
||||
{ |
||||
} |
||||
|
||||
public bool CanProfile(IProject project) |
||||
{ |
||||
return project != null && project.IsStartable; |
||||
} |
||||
|
||||
public void Start(ProcessStartInfo info, string outputPath, Action afterFinishAction) |
||||
{ |
||||
this.runner = new ProfilerRunner(info, true, new ProfilingDataSQLiteWriter(outputPath)); |
||||
|
||||
if (runner != null) { |
||||
runner.RunFinished += delegate { |
||||
try { |
||||
afterFinishAction(); |
||||
} finally { |
||||
this.isRunning = false; |
||||
} |
||||
}; |
||||
this.isRunning = true; |
||||
runner.Run(); |
||||
} |
||||
} |
||||
|
||||
public static ProfilerRunner CreateRunner(IProfilingDataWriter writer) |
||||
{ |
||||
AbstractProject currentProj = ProjectService.CurrentProject as AbstractProject; |
||||
|
||||
if (currentProj == null) |
||||
return null; |
||||
|
||||
if (!currentProj.IsStartable) { |
||||
if (MessageService.AskQuestion("This project cannot be started. Do you want to profile the solution's StartUp project instead?")) { |
||||
currentProj = ProjectService.OpenSolution.StartupProject as AbstractProject; |
||||
if (currentProj == null) { |
||||
MessageService.ShowError("No startable project was found. Aborting ..."); |
||||
return null; |
||||
} |
||||
} else |
||||
return null; |
||||
} |
||||
if (!File.Exists(currentProj.OutputAssemblyFullPath)) { |
||||
MessageService.ShowError("This project cannot be started because the executable file was not found, " + |
||||
"please ensure that the project and all its depencies are built correctly!"); |
||||
return null; |
||||
} |
||||
|
||||
ProfilerRunner runner = new ProfilerRunner(currentProj.CreateStartInfo(), true, writer); |
||||
return runner; |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
} |
||||
|
||||
public bool IsRunning { |
||||
get { |
||||
return this.isRunning; |
||||
} |
||||
} |
||||
|
||||
public void Stop() |
||||
{ |
||||
this.runner.Stop(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Profiling |
||||
{ |
||||
public class DefaultProfiler : IProfiler |
||||
{ |
||||
public bool CanProfile(ICSharpCode.SharpDevelop.Project.IProject project) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
public void Start(System.Diagnostics.ProcessStartInfo info, string outputPath, Action afterFinishedAction) |
||||
{ |
||||
throw new NotSupportedException(); |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
} |
||||
|
||||
public bool IsRunning { |
||||
get { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public void Stop() |
||||
{ |
||||
throw new NotSupportedException(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using System; |
||||
using System.Diagnostics; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Profiling |
||||
{ |
||||
public interface IProfiler : IDisposable |
||||
{ |
||||
bool CanProfile(IProject project); |
||||
void Start(ProcessStartInfo info, string outputPath, Action afterFinishedAction); |
||||
void Stop(); |
||||
bool IsRunning { get; } |
||||
} |
||||
} |
||||
@ -0,0 +1,74 @@
@@ -0,0 +1,74 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Globalization; |
||||
using System.IO; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Profiling |
||||
{ |
||||
public static class ProfilerService |
||||
{ |
||||
static IProfiler currentProfiler; |
||||
static IProfiler[] profilers; |
||||
|
||||
static ProfilerService() |
||||
{ |
||||
profilers = AddInTree.BuildItems<IProfiler>("/SharpDevelop/Services/ProfilerService/Profiler", null, false).ToArray(); |
||||
} |
||||
|
||||
public static bool IsProfilerLoaded |
||||
{ |
||||
get { |
||||
return currentProfiler != null; |
||||
} |
||||
} |
||||
|
||||
static IProfiler GetCompatibleProfiler() |
||||
{ |
||||
IProject project = null; |
||||
if (ProjectService.OpenSolution != null) |
||||
project = ProjectService.OpenSolution.StartupProject; |
||||
foreach (var p in profilers) { |
||||
if (p != null && p.CanProfile(project)) |
||||
return p; |
||||
} |
||||
return new DefaultProfiler(); |
||||
} |
||||
|
||||
public static IProfiler CurrentProfiler { |
||||
get { |
||||
if (currentProfiler == null) { |
||||
currentProfiler = GetCompatibleProfiler(); |
||||
} |
||||
|
||||
return currentProfiler; |
||||
} |
||||
} |
||||
|
||||
public static string GetSessionFileName(IProject project) |
||||
{ |
||||
AbstractProject currentProj = ProjectService.CurrentProject as AbstractProject; |
||||
|
||||
if (currentProj == null) |
||||
throw new InvalidOperationException("Can not profile project"); |
||||
|
||||
string filePart = @"ProfilingSessions\Session" + |
||||
DateTime.Now.ToString("yyyyMMdd_HHmmss", CultureInfo.InvariantCulture) + |
||||
".sdps"; |
||||
|
||||
string path = Path.Combine(currentProj.Directory, filePart); |
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path)); |
||||
|
||||
return path; |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue