Skip to content

Commit 1848d78

Browse files
radekdouliklewing
authored andcommitted
[aotprof-tool] Initial import of AOT profiler tool (#15384)
* [aotprof-tool] Initial import Imported https://github.com/radekdoulik/aotprofile-tool and updated it to use Mono.Profiler.Log * [aotprof-tool] Added man page * [aotprof-tool] Use the shortened name in README.md
1 parent da0086e commit 1848d78

File tree

9 files changed

+544
-0
lines changed

9 files changed

+544
-0
lines changed

bcl.sln

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ilasm", "mcs/ilasm/ilasm.cs
574574
EndProject
575575
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "al", "mcs/tools/al/al.csproj", "{0A20671F-CCA9-457D-886C-0828C7D64128}"
576576
EndProject
577+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "aprofutil", "mcs/tools/aprofutil/aprofutil.csproj", "{658B566B-CED1-4C42-9926-C1AA930BA368}"
578+
EndProject
577579
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "monolinker", "mcs/tools/linker/monolinker.csproj", "{D60432F1-3C12-4235-A1CC-4CA5575403BD}"
578580
EndProject
579581
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "culevel", "mcs/tools/culevel/culevel.csproj", "{E8E246BD-CD0C-4734-A3C2-7F44796EC47B}"
@@ -10100,6 +10102,28 @@ Global
1010010102
{0A20671F-CCA9-457D-886C-0828C7D64128}.Release|winaot.ActiveCfg = Release|net_4_x
1010110103
{0A20671F-CCA9-457D-886C-0828C7D64128}.Debug|xammac.ActiveCfg = Debug|net_4_x
1010210104
{0A20671F-CCA9-457D-886C-0828C7D64128}.Release|xammac.ActiveCfg = Release|net_4_x
10105+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|net_4_x.ActiveCfg = Debug|net_4_x
10106+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|net_4_x.Build.0 = Debug|net_4_x
10107+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|net_4_x.ActiveCfg = Release|net_4_x
10108+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|net_4_x.Build.0 = Release|net_4_x
10109+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|monodroid.ActiveCfg = Debug|net_4_x
10110+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|monodroid.ActiveCfg = Release|net_4_x
10111+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|monotouch.ActiveCfg = Debug|net_4_x
10112+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|monotouch.ActiveCfg = Release|net_4_x
10113+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|monotouch_tv.ActiveCfg = Debug|net_4_x
10114+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|monotouch_tv.ActiveCfg = Release|net_4_x
10115+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|monotouch_watch.ActiveCfg = Debug|net_4_x
10116+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|monotouch_watch.ActiveCfg = Release|net_4_x
10117+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|orbis.ActiveCfg = Debug|net_4_x
10118+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|orbis.ActiveCfg = Release|net_4_x
10119+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|unreal.ActiveCfg = Debug|net_4_x
10120+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|unreal.ActiveCfg = Release|net_4_x
10121+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|wasm.ActiveCfg = Debug|net_4_x
10122+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|wasm.ActiveCfg = Release|net_4_x
10123+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|winaot.ActiveCfg = Debug|net_4_x
10124+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|winaot.ActiveCfg = Release|net_4_x
10125+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|xammac.ActiveCfg = Debug|net_4_x
10126+
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|xammac.ActiveCfg = Release|net_4_x
1010310127
{D60432F1-3C12-4235-A1CC-4CA5575403BD}.Debug|net_4_x.ActiveCfg = Debug|net_4_x
1010410128
{D60432F1-3C12-4235-A1CC-4CA5575403BD}.Debug|net_4_x.Build.0 = Debug|net_4_x
1010510129
{D60432F1-3C12-4235-A1CC-4CA5575403BD}.Release|net_4_x.ActiveCfg = Release|net_4_x

man/aprofutil.1

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
.TH aprofutil 1
2+
.SH NAME
3+
aprofutil \- Mono's AOT profile tool
4+
.SH SYNOPSIS
5+
.B aprofutil
6+
\fR[\fIoptions\fR] <\fIyour-aot-profile.aotprofile\fR>
7+
.SH DESCRIPTION
8+
AOT profile tool is a tool to inspect AOT profiler files.
9+
.PP
10+
It can be used to show, filter and write the profiler file content in readable text form.
11+
.SH OPTIONS
12+
.nf
13+
.RS
14+
-h, --help, -? Show this message and exit
15+
-a, --all Show modules, types and methods in the profile
16+
-d, --modules Show modules in the profile
17+
--filter-method=VALUE Filter by method with regex VALUE
18+
--filter-module=VALUE Filter by module with regex VALUE
19+
--filter-type=VALUE Filter by type with regex VALUE
20+
-m, --methods Show methods in the profile
21+
-o, --output=VALUE Write profile to OUTPUT file
22+
-s, --summary Show summary of the profile
23+
-t, --types Show types in the profile
24+
-v, --verbose Output information about progress during the run
25+
of the tool
26+
.RE
27+
.fi
28+
.SH EXAMPLES
29+
Display modules and summary of XA startup profile
30+
.PP
31+
.nf
32+
.RS
33+
mono aprofutil.exe -sd startup.aotprofile
34+
.fi
35+
.RE
36+
.PP
37+
Output:
38+
.PP
39+
.nf
40+
.RS
41+
Modules:
42+
41C38B0A-2032-45CE-8638-0299CED65330 mscorlib
43+
0326DF03-2158-4F7A-9A2B-B7A9419F021D Mono.Android
44+
8FB63BB4-1195-4173-A9ED-0EC341B07C32 System
45+
74C06E06-C1C7-4A4C-B64E-EAC7DBB08BBC Java.Interop
46+
11E2319F-6A26-461C-9C46-C972248BEE4B System.Core
47+
7999CC4B-D566-4ECA-8A72-469344172CA3 Xamarin.Forms.Platform.Android
48+
C5089213-328B-451D-BA87-D6585C120780 Xamarin.Forms.Performance.Integration.Droid
49+
D754F8AE-503C-41C8-B16F-647FC662507A Xamarin.Android.Support.v7.AppCompat
50+
929ECB6D-1171-4C66-8470-DD32AC608969 Xamarin.Android.Support.Fragment
51+
F841E23B-59A8-4AE2-9A84-D2FC1D891B4A Xamarin.Forms.Core
52+
945CCBF8-C2DB-468B-B3BD-D7ACA37B69AD Xamarin.Forms.Performance.Integration
53+
AF20FA19-F07E-4BD4-B5ED-104706EA660E Xamarin.Forms.Xaml
54+
629C84F8-0988-42EF-8BC5-872173A0A71F FormsViewGroup
55+
60398815-8E62-487E-A553-781F56A0849D Xamarin.Android.Support.Design
56+
F0C550D7-665A-40B5-A307-8E9B49976D87 Xamarin.Android.Support.Core.UI
57+
23A34485-DE75-440E-BA9D-E235F664E990 Xamarin.Android.Support.Compat
58+
Summary:
59+
Modules: 16
60+
Types: 907
61+
Methods: 4,230
62+
.fi
63+
.RE
64+
.PP
65+
Filter Java.Interop.Runtime type in XA startup profile
66+
.PP
67+
.nf
68+
.RS
69+
mono aprofutil.exe --filter-type Java.Interop.Runtime -sa startup.aotprofile
70+
.fi
71+
.RE
72+
.PP
73+
Output:
74+
.PP
75+
.nf
76+
.RS
77+
Modules:
78+
0326DF03-2158-4F7A-9A2B-B7A9419F021D Mono.Android
79+
Types:
80+
Java.Interop.Runtime
81+
Methods:
82+
bool Java.Interop.Runtime:IsGCUserPeer (Android.Runtime.IJavaObject)
83+
bool Java.Interop.Runtime:IsGCUserPeer (intptr)
84+
Summary:
85+
Modules: 1 (of 16)
86+
Types: 1 (of 907)
87+
Methods: 2 (of 4230)
88+
.fi
89+
.RE
90+
.SH SEE ALSO
91+
\fBmono-profilers\fR(1)

mcs/class/Mono.Profiler.Log/Mono.Profiler.Aot/Records.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System.Text;
2+
13
namespace Mono.Profiler.Aot
24
{
35
//
@@ -31,6 +33,11 @@ public string Name {
3133
public string Mvid {
3234
get; set;
3335
}
36+
37+
public override string ToString ()
38+
{
39+
return Name;
40+
}
3441
}
3542

3643
public class GenericInstRecord : ProfileRecord
@@ -43,6 +50,27 @@ public GenericInstRecord (int id, TypeRecord[] types) : base (id)
4350
public TypeRecord[] Types {
4451
get; set;
4552
}
53+
54+
public override string ToString ()
55+
{
56+
if (Types == null || Types.Length <= 0)
57+
return "";
58+
59+
var sb = new StringBuilder ("<");
60+
var first = true;
61+
foreach (var type in Types) {
62+
if (!first)
63+
sb.Append (", ");
64+
else
65+
first = false;
66+
67+
sb.Append (type.ToString ());
68+
}
69+
70+
sb.Append (">");
71+
72+
return sb.ToString ();
73+
}
4674
}
4775

4876
public class TypeRecord : ProfileRecord
@@ -62,9 +90,27 @@ public string Name {
6290
get; set;
6391
}
6492

93+
public string FullName {
94+
get {
95+
string prefix;
96+
97+
if (Name.Length > 0 && Name [0] == '.')
98+
prefix = Module.ToString ();
99+
else
100+
prefix = "";
101+
102+
return $"{prefix}{Name}{GenericInst}";
103+
}
104+
}
105+
65106
public GenericInstRecord GenericInst {
66107
get; set;
67108
}
109+
110+
public override string ToString ()
111+
{
112+
return FullName;
113+
}
68114
}
69115

70116
public class MethodRecord : ProfileRecord
@@ -97,5 +143,10 @@ public string Signature {
97143
public int ParamCount {
98144
get; set;
99145
}
146+
147+
public override string ToString ()
148+
{
149+
return $"{Signature.Replace ("(", $" {Type}:{Name} (")}";
150+
}
100151
}
101152
}

mcs/tools/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ thisdir = tools
22

33
net_4_5_dirs := \
44
al \
5+
aprofutil \
56
linker \
67
culevel \
78
genxs \

mcs/tools/aprofutil/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
thisdir = tools/aprofutil
2+
include ../../build/rules.make
3+
4+
PROGRAM = aprofutil.exe
5+
6+
LIB_REFS = System System.Core Mono.Options Mono.Profiler.Log
7+
8+
include ../../build/executable.make

0 commit comments

Comments
 (0)