Browse Source

fixed bug when using other file sizes than 64 mb for temporary storage file.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@4052 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Siegfried Pammer 17 years ago
parent
commit
4eff6e60b7
  1. 17
      src/AddIns/Misc/Profiler/Controller/Profiler.cs
  2. 3
      src/AddIns/Misc/Profiler/Frontend/AddIn/AddIn.csproj
  3. 19
      src/AddIns/Misc/Profiler/Frontend/AddIn/Src/ProfilerRunner.cs
  4. 2
      src/AddIns/Misc/Profiler/Frontend/BenchmarkRunner/BenchmarkRunner.cs
  5. 2
      src/AddIns/Misc/Profiler/Frontend/Gui/Window1.xaml.cs
  6. 5
      src/AddIns/Misc/Profiler/Hook/SharedMemory.cpp

17
src/AddIns/Misc/Profiler/Controller/Profiler.cs

@ -119,15 +119,10 @@ namespace ICSharpCode.Profiler.Controller
ProfilerOptions profilerOptions = new ProfilerOptions(); ProfilerOptions profilerOptions = new ProfilerOptions();
/// <summary> /// <summary>
/// Gets and sets all settings used by this profiler instance. /// Gets all settings used by this profiler instance.
/// </summary> /// </summary>
public ProfilerOptions ProfilerOptions { public ProfilerOptions ProfilerOptions {
get { return profilerOptions; } get { return profilerOptions; }
set {
if (isRunning)
throw new InvalidOperationException("Can not change settings while the profiler is executing!");
profilerOptions = value;
}
} }
SharedMemoryHeader32* memHeader32; SharedMemoryHeader32* memHeader32;
@ -206,8 +201,8 @@ namespace ICSharpCode.Profiler.Controller
/// <summary> /// <summary>
/// Creates a new profiler using the path to an executable to profile and a data writer. /// Creates a new profiler using the path to an executable to profile and a data writer.
/// </summary> /// </summary>
public Profiler(string pathToExecutable, IProfilingDataWriter dataWriter) public Profiler(string pathToExecutable, IProfilingDataWriter dataWriter, ProfilerOptions options)
: this(new ProcessStartInfo(pathToExecutable), dataWriter) : this(new ProcessStartInfo(pathToExecutable), dataWriter, options)
{ {
if (!File.Exists(pathToExecutable)) if (!File.Exists(pathToExecutable))
throw new FileNotFoundException("File not found!", pathToExecutable); throw new FileNotFoundException("File not found!", pathToExecutable);
@ -218,7 +213,7 @@ namespace ICSharpCode.Profiler.Controller
/// <summary> /// <summary>
/// Creates a new profiler using a process start info of an executable and a data writer. /// Creates a new profiler using a process start info of an executable and a data writer.
/// </summary> /// </summary>
public Profiler(ProcessStartInfo info, IProfilingDataWriter dataWriter) public Profiler(ProcessStartInfo info, IProfilingDataWriter dataWriter, ProfilerOptions options)
{ {
if (dataWriter == null) if (dataWriter == null)
throw new ArgumentNullException("dataWriter"); throw new ArgumentNullException("dataWriter");
@ -228,6 +223,8 @@ namespace ICSharpCode.Profiler.Controller
if (!DetectBinaryType.IsDotNetExecutable(info.FileName)) if (!DetectBinaryType.IsDotNetExecutable(info.FileName))
throw new ProfilerException("File is not a valid .NET executable file!"); throw new ProfilerException("File is not a valid .NET executable file!");
this.profilerOptions = options;
this.is64Bit = DetectBinaryType.RunsAs64Bit(info.FileName); this.is64Bit = DetectBinaryType.RunsAs64Bit(info.FileName);
@ -245,7 +242,7 @@ namespace ICSharpCode.Profiler.Controller
this.psi.EnvironmentVariables["AccessEventName"] = AccessEventId; // name for access event of controller this.psi.EnvironmentVariables["AccessEventName"] = AccessEventId; // name for access event of controller
this.psi.EnvironmentVariables["COR_ENABLE_PROFILING"] = "1"; // enable profiling; 0 = disable this.psi.EnvironmentVariables["COR_ENABLE_PROFILING"] = "1"; // enable profiling; 0 = disable
this.psi.EnvironmentVariables["COR_PROFILER"] = ProfilerGuid; // GUID for the profiler this.psi.EnvironmentVariables["COR_PROFILER"] = ProfilerGuid; // GUID for the profiler
file = MemoryMappedFile.CreateSharedMemory(SharedMemoryId, profilerOptions.SharedMemorySize); file = MemoryMappedFile.CreateSharedMemory(SharedMemoryId, profilerOptions.SharedMemorySize);
fullView = file.MapView(0, profilerOptions.SharedMemorySize); fullView = file.MapView(0, profilerOptions.SharedMemorySize);

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

@ -94,7 +94,8 @@
<Compile Include="Src\Commands\GoToDefinition.cs" /> <Compile Include="Src\Commands\GoToDefinition.cs" />
<Compile Include="Src\Commands\ProfileExecutable.cs" /> <Compile Include="Src\Commands\ProfileExecutable.cs" />
<Compile Include="Src\Commands\ProfileProject.cs" /> <Compile Include="Src\Commands\ProfileProject.cs" />
<Compile Include="Src\Commands\ProfilerMenuCommand.cs" /> <Compile Include="Src\Commands\SetAsRoot.cs" /> <Compile Include="Src\Commands\ProfilerMenuCommand.cs" />
<Compile Include="Src\Commands\SetAsRoot.cs" />
<Compile Include="Src\Commands\ShowFunctions.cs" /> <Compile Include="Src\Commands\ShowFunctions.cs" />
<Compile Include="Src\Dialogs\ProfileExecutableForm.xaml.cs"> <Compile Include="Src\Dialogs\ProfileExecutableForm.xaml.cs">
<DependentUpon>ProfileExecutableForm.xaml</DependentUpon> <DependentUpon>ProfileExecutableForm.xaml</DependentUpon>

19
src/AddIns/Misc/Profiler/Frontend/AddIn/Src/ProfilerRunner.cs

@ -49,14 +49,14 @@ namespace ICSharpCode.Profiler.AddIn
if (useTempFileDatabase) { if (useTempFileDatabase) {
this.database = new TempFileDatabase(); this.database = new TempFileDatabase();
this.writer = writer; this.writer = writer;
this.profiler = new Controller.Profiler(startInfo, this.database.GetWriter()); this.profiler = new Controller.Profiler(startInfo, this.database.GetWriter(), General.CreateProfilerOptions());
} else { } else {
this.database = null; this.database = null;
this.writer = writer; this.writer = writer;
this.profiler = new Controller.Profiler(startInfo, writer); this.profiler = new Controller.Profiler(startInfo, writer, General.CreateProfilerOptions());
} }
this.profiler.ProfilerOptions = General.CreateProfilerOptions(); PrintProfilerOptions();
this.profiler.RegisterFailed += delegate { MessageService.ShowError("Could not register the profiler into COM Registry. Cannot start profiling!"); }; this.profiler.RegisterFailed += delegate { MessageService.ShowError("Could not register the profiler into COM Registry. Cannot start profiling!"); };
this.profiler.DeregisterFailed += delegate { MessageService.ShowError("Could not unregister the profiler from COM Registry!"); }; this.profiler.DeregisterFailed += delegate { MessageService.ShowError("Could not unregister the profiler from COM Registry!"); };
@ -64,8 +64,18 @@ namespace ICSharpCode.Profiler.AddIn
this.profiler.SessionEnded += delegate { FinishSession(); }; this.profiler.SessionEnded += delegate { FinishSession(); };
} }
void FinishSession() void PrintProfilerOptions()
{ {
var options = General.CreateProfilerOptions();
LoggingService.Info("Profiler settings:");
LoggingService.Info("Shared memory size: " + options.SharedMemorySize + " (" + (options.SharedMemorySize / 1024 / 1024) + " MB)");
LoggingService.Info("Combine recursive calls: " + options.CombineRecursiveFunction);
LoggingService.Info("Enable DC: " + options.EnableDC);
LoggingService.Info("Profile .NET internals: " + (!options.DoNotProfileDotNetInternals));
}
void FinishSession()
{
using (AsynchronousWaitDialog dlg = AsynchronousWaitDialog.ShowWaitDialog("Preparing for analysis", true)) { using (AsynchronousWaitDialog dlg = AsynchronousWaitDialog.ShowWaitDialog("Preparing for analysis", true)) {
if (database != null) { if (database != null) {
database.WriteTo(writer, progress => !dlg.IsCancelled); database.WriteTo(writer, progress => !dlg.IsCancelled);
@ -82,6 +92,7 @@ namespace ICSharpCode.Profiler.AddIn
public void Run() public void Run()
{ {
WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)).BringPadToFront();
profiler.Start(); profiler.Start();
} }

2
src/AddIns/Misc/Profiler/Frontend/BenchmarkRunner/BenchmarkRunner.cs

@ -85,7 +85,7 @@ namespace BenchmarkRunner
File.Delete(fileName); File.Delete(fileName);
using (var profiler = new Profiler( using (var profiler = new Profiler(
startInfo, new ProfilingDataSQLiteWriter(fileName) startInfo, new ProfilingDataSQLiteWriter(fileName), new ProfilerOptions()
)) { )) {
using (ManualResetEvent mre = new ManualResetEvent(false)) { using (ManualResetEvent mre = new ManualResetEvent(false)) {
profiler.SessionEnded += delegate { profiler.SessionEnded += delegate {

2
src/AddIns/Misc/Profiler/Frontend/Gui/Window1.xaml.cs

@ -57,7 +57,7 @@ namespace ICSharpCode.Profiler.Frontend
this.database = new TempFileDatabase(); this.database = new TempFileDatabase();
this.profiler = new Profiler.Controller.Profiler(path, database.GetWriter()); this.profiler = new Profiler.Controller.Profiler(path, database.GetWriter(), new ProfilerOptions());
profiler.RegisterFailed += delegate { MessageBox.Show("register failed"); }; profiler.RegisterFailed += delegate { MessageBox.Show("register failed"); };
profiler.DeregisterFailed += delegate { MessageBox.Show("deregister failed"); }; profiler.DeregisterFailed += delegate { MessageBox.Show("deregister failed"); };

5
src/AddIns/Misc/Profiler/Hook/SharedMemory.cpp

@ -37,10 +37,13 @@ CSharedMemory::CSharedMemory(char *name)
#endif #endif
this->length = header->TotalLength; this->length = header->TotalLength;
UnmapViewOfFile(this->startPtr); UnmapViewOfFile(this->startPtr);
DebugWriteLine(L"Length: %d", this->length);
this->startPtr = MapViewOfFile(this->fileHandle, FILE_MAP_ALL_ACCESS, 0, 0, this->length); this->startPtr = MapViewOfFile(this->fileHandle, FILE_MAP_ALL_ACCESS, 0, 0, this->length);
if (startPtr == nullptr) { if (startPtr == nullptr) {
char buffer[512];
sprintf_s(buffer, 512, "Error while creating temporary storage file (shared memory)!\n\nError: %d", GetLastError());
DebugWriteLine(L"second MapViewOfFile returned nullptr"); DebugWriteLine(L"second MapViewOfFile returned nullptr");
MessageBox(nullptr, TEXT(""), TEXT("Profiler Error"), MB_OK); MessageBox(nullptr, buffer, TEXT("Profiler Error"), MB_OK);
} }
this->header = (SharedMemoryHeader*)this->startPtr; this->header = (SharedMemoryHeader*)this->startPtr;
} }

Loading…
Cancel
Save