Browse Source

fixed profiler start bugs

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3870 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Siegfried Pammer 17 years ago
parent
commit
255f6dfea7
  1. 3
      src/AddIns/Misc/Profiler/Frontend/AddIn/AddIn.csproj
  2. 4
      src/AddIns/Misc/Profiler/Frontend/AddIn/ICSharpCode.Profiler.AddIn.addin
  3. 21
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/ProfileProject.cs
  4. 30
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/ProfilerService.cs

3
src/AddIns/Misc/Profiler/Frontend/AddIn/AddIn.csproj

@ -15,8 +15,7 @@ @@ -15,8 +15,7 @@
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<OutputPath>..\..\..\..\..\..\AddIns\AddIns\Misc\Profiler\</OutputPath>
<StartAction>Program</StartAction>
<StartProgram>$(SharpDevelopBinPath)\SharpDevelop.exe</StartProgram>
<StartArguments>/addindir:$(MSBuildProjectDirectory)\$(OutputPath)</StartArguments>
<StartProgram>..\..\..\..\..\..\bin\SharpDevelop.exe</StartProgram>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>

4
src/AddIns/Misc/Profiler/Frontend/AddIn/ICSharpCode.Profiler.AddIn.addin

@ -8,8 +8,7 @@ @@ -8,8 +8,7 @@
<Import assembly="ICSharpCode.Profiler.AddIn.dll" />
</Runtime>
<Path name="/SharpDevelop/Workbench/MainMenu">
<MenuItem id="Profile" label="Profile" insertbefore="Debug" type="Menu">
<Path name="/SharpDevelop/Workbench/MainMenu/QualityTools/Profiler">
<ComplexCondition action="Disable">
<And>
<Condition name = "ProjectActive" activeproject="*" />
@ -25,7 +24,6 @@ @@ -25,7 +24,6 @@
class="ICSharpCode.Profiler.AddIn.Commands.ProfileExecutable"
label="Select executable to profile"
/>-->
</MenuItem>
</Path>
<Path name = "/SharpDevelop/Workbench/DisplayBindings">

21
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Commands/ProfileProject.cs

@ -32,21 +32,22 @@ namespace ICSharpCode.Profiler.AddIn.Commands @@ -32,21 +32,22 @@ namespace ICSharpCode.Profiler.AddIn.Commands
{
string outputPath;
Profiler profiler = ProfilerService.RunCurrentProject(out outputPath);
IProject selectedProject = ProjectService.CurrentProject;
if (profiler != null) {
profiler.SessionEnded += delegate {
string title = Path.GetFileName(outputPath);
profiler.DataWriter.Close();
ProfilingDataProvider provider = new ProfilingDataSQLiteProvider(outputPath);
WorkbenchSingleton.CallLater(20, () => WorkbenchSingleton.Workbench.ShowView(new WpfViewer(provider, title)));
FileProjectItem file = new FileProjectItem(ProjectService.CurrentProject, ItemType.Content, "ProfilingSessions\\" + title);
WorkbenchSingleton.MainForm.Invoke(
new MethodInvoker(
() => {
ProjectService.AddProjectItem(ProjectService.CurrentProject, file);
ProjectBrowserPad.Instance.ProjectBrowserControl.RefreshView();
ProjectService.CurrentProject.Save();
}
));
WorkbenchSingleton.CallLater(20,
() => {
WorkbenchSingleton.Workbench.ShowView(new WpfViewer(provider, title));
FileProjectItem file = new FileProjectItem(selectedProject, ItemType.Content, "ProfilingSessions\\" + title);
ProjectService.AddProjectItem(selectedProject, file);
ProjectBrowserPad.Instance.ProjectBrowserControl.RefreshView();
selectedProject.Save();
}
);
};
}
}

30
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/ProfilerService.cs

@ -1,8 +1,10 @@ @@ -1,8 +1,10 @@
using ICSharpCode.Profiler.AddIn.OptionsPanels;
using System;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.Profiler.AddIn.OptionsPanels;
using ICSharpCode.Profiler.Controller;
using ICSharpCode.Profiler.Controller.Data;
using ICSharpCode.SharpDevelop.Gui;
@ -17,33 +19,43 @@ namespace ICSharpCode.Profiler.AddIn @@ -17,33 +19,43 @@ namespace ICSharpCode.Profiler.AddIn
{
public static Profiler.Controller.Profiler RunCurrentProject(out string profilerSessionFilePath)
{
profilerSessionFilePath = Path.Combine(ProjectService.CurrentProject.Directory, @"ProfilingSessions\Session" + DateTime.Now.ToString("yyyyMMdd_HHmmss", CultureInfo.InvariantCulture) + ".sdps");
AbstractProject currentProj = ProjectService.CurrentProject as AbstractProject;
profilerSessionFilePath = Path.Combine(currentProj.Directory, @"ProfilingSessions\Session" + DateTime.Now.ToString("yyyyMMdd_HHmmss", CultureInfo.InvariantCulture) + ".sdps");
Directory.CreateDirectory(Path.GetDirectoryName(profilerSessionFilePath));
if (!ProjectService.CurrentProject.IsStartable) {
if (currentProj == null)
return null;
if (!currentProj.IsStartable) {
MessageService.ShowError("This project cannot be started, please select a startable project for Profiling!");
return null;
}
if (!File.Exists(ProjectService.CurrentProject.OutputAssemblyFullPath)) {
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;
}
Profiler.Controller.Profiler profiler = InitProfiler(ProjectService.CurrentProject.OutputAssemblyFullPath, profilerSessionFilePath);
Profiler.Controller.Profiler profiler = InitProfiler(currentProj.CreateStartInfo(), profilerSessionFilePath);
profiler.ProfilerOptions = ProfilerOptionsWrapper.CreateProfilerOptions();
profiler.Start();
return profiler;
}
static Profiler.Controller.Profiler InitProfiler(string path, string outputFilePath)
{
Profiler.Controller.Profiler profiler = new Profiler.Controller.Profiler(path, new ProfilingDataSQLiteWriter(outputFilePath));
return InitProfiler(new ProcessStartInfo(path), outputFilePath);
}
static Profiler.Controller.Profiler InitProfiler(ProcessStartInfo startInfo, string outputFilePath)
{
Profiler.Controller.Profiler profiler = new Profiler.Controller.Profiler(startInfo, new ProfilingDataSQLiteWriter(outputFilePath));
profiler.RegisterFailed += delegate { MessageService.ShowError("regsvr32 failed"); };
profiler.DeregisterFailed += delegate { MessageService.ShowError("regsvr32 /u failed"); };
profiler.RegisterFailed += delegate { MessageService.ShowError("Could not register the profiler into COM Registry. Cannot start profiling!"); };
profiler.DeregisterFailed += delegate { MessageService.ShowError("Could not unregister the profiler from COM Registry!"); };
profiler.OutputUpdated += delegate { SetOutputText(profiler.ProfilerOutput); };
return profiler;

Loading…
Cancel
Save