Skip to content

Commit a13927e

Browse files
committed
Remove UI compiler info providers
1 parent 2782655 commit a13927e

32 files changed

Lines changed: 211 additions & 137 deletions

src/ProfileExplorerCore/Compilers/ASM/ASMCompilerInfoProvider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public ASMCompilerInfoProvider(IRMode mode) {
3131
}
3232

3333
public virtual string CompilerIRName => "ASM";
34+
public virtual CompilerIRKind CompilerIRKind => CompilerIRKind.ASM;
3435
public virtual string CompilerDisplayName => "ASM " + ir_.Mode;
3536
public virtual string OpenFileFilter =>
3637
"ASM, Binary, Trace Files|*.asm;*.txt;*.log;*.exe;*.dll;*.sys;*.etl|All Files|*.*";

src/ProfileExplorerCore/Compilers/ASM/ASMFilterProvider.cs renamed to src/ProfileExplorerCore/Compilers/ASM/ASMDiffFilterProvider.cs

File renamed without changes.

src/ProfileExplorerUI/Compilers/Default/DefaultDiffOutputFilter.cs renamed to src/ProfileExplorerCore/Compilers/Defaults/DefaultDiffOutputFilter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using ProfileExplorer.Core.Document.Renderers.Highlighters;
88
using ProfileExplorer.Core.Settings;
99

10-
namespace ProfileExplorer.UI.Compilers.Default;
10+
namespace ProfileExplorer.Core.Compilers.Default;
1111

1212
public sealed class DefaultDiffOutputFilter : IDiffOutputFilter {
1313
private DiffSettings settings_;

src/ProfileExplorerUI/Compilers/Default/DefaultNameProvider.cs renamed to src/ProfileExplorerCore/Compilers/Defaults/DefaultNameProvider.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
using ProfileExplorer.Core;
77
using ProfileExplorer.Core.Binary;
88
using ProfileExplorer.Core.Providers;
9+
using ProfileExplorer.Core.Utilities;
910

10-
namespace ProfileExplorer.UI.Compilers.Default;
11+
namespace ProfileExplorer.Core.Compilers.Default;
1112

1213
public enum FilteredSectionNameKind {
1314
TrimPrefix,
@@ -46,8 +47,8 @@ static DefaultNameProvider() {
4647
}
4748

4849
public bool IsDemanglingSupported => true;
49-
public bool IsDemanglingEnabled => IsDemanglingSupported && App.Settings.SectionSettings.ShowDemangledNames;
50-
public FunctionNameDemanglingOptions GlobalDemanglingOptions => App.Settings.SectionSettings.DemanglingOptions;
50+
public bool IsDemanglingEnabled => IsDemanglingSupported && CoreSettingsProvider.SectionSettings.ShowDemangledNames;
51+
public FunctionNameDemanglingOptions GlobalDemanglingOptions => CoreSettingsProvider.SectionSettings.DemanglingOptions;
5152

5253
public string GetSectionName(IRTextSection section, bool includeNumber) {
5354
string sectionName = section.Name;

src/ProfileExplorerUI/Compilers/LLVM/LLVMCompilerInfoProvider.cs renamed to src/ProfileExplorerCore/Compilers/LLVM/LLVMCompilerInfoProvider.cs

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,29 @@
99
using ProfileExplorer.Core.Providers;
1010
using ProfileExplorer.Core.Binary;
1111
using ProfileExplorer.Core.Diff;
12-
using ProfileExplorer.UI.Compilers.Default;
13-
using ProfileExplorer.Core.Settings;
14-
using ProfileExplorer.UI;
15-
using ProfileExplorer.UI.Query;
16-
using ProfileExplorerUI.Session;
12+
using ProfileExplorer.Core.Compilers.Default;
1713

18-
namespace ProfileExplorer.UI.Compilers.LLVM;
14+
namespace ProfileExplorer.Core.Compilers.LLVM;
1915

20-
public class LLVMCompilerInfoProvider : IUICompilerInfoProvider {
16+
public class LLVMCompilerInfoProvider : ICompilerInfoProvider {
2117
private LLVMCompilerIRInfo ir_;
2218
private DefaultNameProvider names_;
23-
private DefaultRemarkProvider remarks_;
24-
private DefaultSectionStyleProvider styles_;
2519
private readonly IBinaryFileFinder binaryFileFinder_;
2620
private readonly IDebugFileFinder debugFileFinder_;
2721
private readonly IDebugInfoProviderFactory debugInfoProviderFactory_;
2822
private readonly IDiffFilterProvider diffFilterProvider_;
2923

3024
public LLVMCompilerInfoProvider() {
3125
ir_ = new LLVMCompilerIRInfo();
32-
styles_ = new DefaultSectionStyleProvider(this);
3326
names_ = new DefaultNameProvider();
34-
remarks_ = new DefaultRemarkProvider(this);
3527
binaryFileFinder_ = new LLVMBinaryFileFinder();
3628
debugFileFinder_ = new LLVMDebugFileFinder();
3729
debugInfoProviderFactory_ = new LLVMDebugInfoProviderFactory();
38-
diffFilterProvider_ = new LLVMDiffFilterProvider();
30+
diffFilterProvider_ = new LLVMDiffFilterProvider();
3931
}
4032

4133
public string CompilerIRName => "LLVM";
34+
public CompilerIRKind CompilerIRKind => CompilerIRKind.LLVM;
4235
public string CompilerDisplayName => "LLVM";
4336
public string DefaultSyntaxHighlightingFile => "LLVM";
4437
public string OpenFileFilter =>
@@ -50,31 +43,11 @@ public LLVMCompilerInfoProvider() {
5043
public IDebugFileFinder DebugFileFinder => debugFileFinder_;
5144
public IDebugInfoProviderFactory DebugInfoProviderFactory => debugInfoProviderFactory_;
5245
public IDiffFilterProvider DiffFilterProvider => diffFilterProvider_;
53-
public ISectionStyleProvider SectionStyleProvider => styles_;
54-
public IRRemarkProvider RemarkProvider => remarks_;
55-
public List<QueryDefinition> BuiltinQueries => new();
56-
public List<FunctionTaskDefinition> BuiltinFunctionTasks => new();
57-
public List<FunctionTaskDefinition> ScriptFunctionTasks => new();
58-
59-
public IBlockFoldingStrategy CreateFoldingStrategy(FunctionIR function) {
60-
return new BasicBlockFoldingStrategy(function);
61-
}
62-
63-
private sealed class LLVMDiffFilterProvider : IDiffFilterProvider {
64-
public IDiffInputFilter CreateDiffInputFilter() => null;
65-
public IDiffOutputFilter CreateDiffOutputFilter() => new DefaultDiffOutputFilter();
66-
}
6746

6847
public async Task<bool> AnalyzeLoadedFunction(FunctionIR function, IRTextSection section,
6948
ILoadedDocument loadedDoc, FunctionDebugInfo funcDebugInfo) {
7049
//? TODO: var loopGraph = new LoopGraph(function);
7150
//loopGraph.FindLoops();
7251
return true;
7352
}
74-
75-
public Task HandleLoadedSection(IRDocument document, FunctionIR function, IRTextSection section) {
76-
return Task.CompletedTask;
77-
}
78-
79-
// ReloadSettings removed
8053
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Text;
6+
using ProfileExplorer.Core.Compilers.Default;
7+
using ProfileExplorer.Core.Diff;
8+
using ProfileExplorer.Core.Settings;
9+
using ProfileExplorer.Core.Utilities;
10+
11+
namespace ProfileExplorer.Core.Compilers.LLVM;
12+
13+
public class LLVMDiffFilterProvider : IDiffFilterProvider {
14+
public IDiffInputFilter CreateDiffInputFilter() => null;
15+
public IDiffOutputFilter CreateDiffOutputFilter() => new DefaultDiffOutputFilter();
16+
}

src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace ProfileExplorer.Core.Profile.ETW;
2323

2424
// Event delegates for session callbacks
2525
public delegate Task SetupNewSessionHandler(ILoadedDocument mainDocument, List<ILoadedDocument> otherDocuments, ProfileData profileData);
26-
public delegate Task StartNewSessionHandler(string sessionName, SessionKind sessionKind, IRMode irMode);
26+
public delegate Task StartNewSessionHandler(string sessionName, SessionKind sessionKind, ICompilerInfoProvider compilerInfo);
2727

2828
public sealed class ETWProfileDataProvider : IProfileDataProvider, IDisposable {
2929
private const int IMAGE_LOCK_COUNT = 64;
@@ -56,9 +56,8 @@ public sealed class ETWProfileDataProvider : IProfileDataProvider, IDisposable {
5656
public event SetupNewSessionHandler SetupNewSessionRequested;
5757
public event StartNewSessionHandler StartNewSessionRequested;
5858

59-
public ETWProfileDataProvider(ICompilerInfoProvider compilerInfoProvider) {
59+
public ETWProfileDataProvider() {
6060
profileData_ = new ProfileData();
61-
compilerInfoProvider_ = compilerInfoProvider;
6261

6362
// Data structs used for module loading.
6463
lockObject_ = new object();
@@ -904,7 +903,8 @@ private async Task LoadBinaryAndDebugFiles(RawProfileData rawProfile, ProfilePro
904903
Trace.WriteLine($"Binary download time: {binSw.Elapsed}");
905904
#endif
906905

907-
await (StartNewSessionRequested?.Invoke(mainImageName, SessionKind.FileSession, irMode) ?? Task.CompletedTask);
906+
compilerInfoProvider_ = new ASMCompilerInfoProvider(irMode);
907+
await (StartNewSessionRequested?.Invoke(mainImageName, SessionKind.FileSession, compilerInfoProvider_) ?? Task.CompletedTask);
908908

909909
// Locate the needed debug files, in parallel. This will download them
910910
// from the symbol server if not yet on local machine and enabled.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
namespace ProfileExplorer.Core.Providers;
5+
6+
/// <summary>
7+
/// Defines the different compiler IR types supported by Profile Explorer.
8+
/// </summary>
9+
public enum CompilerIRKind {
10+
/// <summary>
11+
/// Assembly/machine code IR
12+
/// </summary>
13+
ASM,
14+
15+
/// <summary>
16+
/// LLVM Intermediate Representation
17+
/// </summary>
18+
LLVM
19+
}

src/ProfileExplorerCore/Providers/ICompilerInfoProvider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace ProfileExplorer.Core.Providers;
1414

1515
public interface ICompilerInfoProvider {
1616
string CompilerIRName { get; }
17+
CompilerIRKind CompilerIRKind { get; }
1718
string CompilerDisplayName { get; }
1819
string DefaultSyntaxHighlightingFile { get; }
1920
string OpenFileFilter { get; }

src/ProfileExplorerCore/Session/BaseSession.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,12 @@ public class BaseSession : ISession
3535

3636
public BaseSession()
3737
{
38-
compilerInfo_ = new ASMCompilerInfoProvider(IRMode.Default);
3938
profileData_ = null;
4039
documents_ = new List<ILoadedDocument>();
4140
}
4241

4342
public async Task<bool> LoadProfileData(string profileFilePath, List<int> processIds, ProfileDataProviderOptions options, SymbolFileSourceSettings symbolSettings, ProfileDataReport report, ProfileLoadProgressHandler progressCallback, CancelableTask cancelableTask) {
44-
using var provider = new ETWProfileDataProvider(compilerInfo_);
43+
using var provider = new ETWProfileDataProvider();
4544

4645
var result = await provider.LoadTraceAsync(profileFilePath, processIds,
4746
options, symbolSettings,

0 commit comments

Comments
 (0)