You've already forked linux-packaging-mono
Imported Upstream version 6.4.0.137
Former-commit-id: 943baa9f16a098c33e129777827f3a9d20da00d6
This commit is contained in:
parent
e9207cf623
commit
ef583813eb
@@ -7,7 +7,9 @@ LIBRARY_WARN_AS_ERROR = yes
|
||||
KEYFILE = $(LIBRARY_SNK)
|
||||
|
||||
LIB_REFS = System System.Core
|
||||
LIB_MCS_FLAGS = /unsafe /publicsign /nowarn:0618
|
||||
LIB_MCS_FLAGS = /unsafe /publicsign /nowarn:0618 -D:MONO_DATACONVERTER_STATIC_METHOD
|
||||
|
||||
ifeq (net_4_x,$(PROFILE))
|
||||
|
||||
XTEST_LIB_REFS = System System.Core Facades/System.Threading.Tasks
|
||||
|
||||
@@ -17,12 +19,18 @@ $(topdir)/class/lib/$(PROFILE_DIRECTORY)/tests/log-profiler-test.exe: Test/log-p
|
||||
mkdir -p $(dir $@)
|
||||
$(CSCOMPILE) $(PLATFORM_DEBUG_FLAGS) /unsafe $(if $(MCS_MODE),,/warnaserror) /r:$(build_libdir)/mscorlib.dll /r:$(build_lib) /out:$@ $<
|
||||
|
||||
EXTRA_DISTFILES = \
|
||||
Test/log-profiler-test.cs
|
||||
|
||||
CLEAN_FILES = \
|
||||
$(topdir)/class/lib/$(PROFILE_DIRECTORY)/tests/log-profiler-test.exe \
|
||||
$(topdir)/class/lib/$(PROFILE_DIRECTORY)/tests/log-profiler-test.exe.mdb \
|
||||
$(topdir)/class/lib/$(PROFILE_DIRECTORY)/tests/log-profiler-test.pdb
|
||||
|
||||
else
|
||||
|
||||
NO_TEST = yes
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DISTFILES = \
|
||||
Test/log-profiler-test.cs
|
||||
|
||||
include ../../build/library.make
|
||||
|
||||
16
mcs/class/Mono.Profiler.Log/Mono.Profiler.Aot/ProfileData.cs
Normal file
16
mcs/class/Mono.Profiler.Log/Mono.Profiler.Aot/ProfileData.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace Mono.Profiler.Aot
|
||||
{
|
||||
public sealed class ProfileData
|
||||
{
|
||||
public ProfileData (ModuleRecord[] modules, TypeRecord[] types, MethodRecord[] methods)
|
||||
{
|
||||
this.Modules = modules;
|
||||
this.Types = types;
|
||||
this.Methods = methods;
|
||||
}
|
||||
|
||||
public ModuleRecord[] Modules { get; private set; }
|
||||
public TypeRecord[] Types { get; private set; }
|
||||
public MethodRecord[] Methods { get; private set; }
|
||||
}
|
||||
}
|
||||
166
mcs/class/Mono.Profiler.Log/Mono.Profiler.Aot/ProfileReader.cs
Normal file
166
mcs/class/Mono.Profiler.Log/Mono.Profiler.Aot/ProfileReader.cs
Normal file
@@ -0,0 +1,166 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Profiler.Aot
|
||||
{
|
||||
//
|
||||
// Read the contents of a .aotprofile created by the AOT profiler
|
||||
// See mono-profiler-aot.h for a description of the file format
|
||||
//
|
||||
public sealed class ProfileReader
|
||||
{
|
||||
enum RecordType
|
||||
{
|
||||
NONE = 0,
|
||||
IMAGE = 1,
|
||||
TYPE = 2,
|
||||
GINST = 3,
|
||||
METHOD = 4
|
||||
}
|
||||
|
||||
enum MonoTypeEnum
|
||||
{
|
||||
MONO_TYPE_CLASS = 0x12,
|
||||
}
|
||||
|
||||
const string MAGIC = "AOTPROFILE";
|
||||
const int MAJOR_VERSION = 1;
|
||||
const int MINOR_VERSION = 0;
|
||||
|
||||
DataConverter conv;
|
||||
byte[] data;
|
||||
int pos;
|
||||
|
||||
public ProfileReader ()
|
||||
{
|
||||
conv = DataConverter.LittleEndian;
|
||||
}
|
||||
|
||||
int ReadByte ()
|
||||
{
|
||||
int res = data [pos];
|
||||
pos ++;
|
||||
return res;
|
||||
}
|
||||
|
||||
int ReadInt ()
|
||||
{
|
||||
int res = conv.GetInt32 (data, pos);
|
||||
pos += 4;
|
||||
return res;
|
||||
}
|
||||
|
||||
string ReadString ()
|
||||
{
|
||||
int len = ReadInt ();
|
||||
var res = new string (Encoding.UTF8.GetChars (data, pos, len));
|
||||
pos += len;
|
||||
return res;
|
||||
}
|
||||
|
||||
public ProfileData ReadAllData (Stream stream)
|
||||
{
|
||||
byte[] buf = new byte [16];
|
||||
int len = stream.Read (buf, 0, MAGIC.Length);
|
||||
if (len != MAGIC.Length)
|
||||
throw new IOException ("Input file is too small.");
|
||||
var magic = new String (Encoding.UTF8.GetChars (buf, 0, MAGIC.Length));
|
||||
if (magic != MAGIC)
|
||||
throw new IOException ("Input file is not a AOT profiler output file.");
|
||||
|
||||
// Profile files are not expected to be large, so reading them is ok
|
||||
len = (int)stream.Length - MAGIC.Length;
|
||||
data = new byte [len];
|
||||
pos = 0;
|
||||
int count = stream.Read (data, 0, len);
|
||||
if (count != len)
|
||||
throw new IOException ("Can't read profile file.");
|
||||
|
||||
int version = ReadInt ();
|
||||
int expected_version = (MAJOR_VERSION << 16) | MINOR_VERSION;
|
||||
if (version != expected_version)
|
||||
throw new IOException (String.Format ("Expected file version 0x{0:x}, got 0x{1:x}.", expected_version, version));
|
||||
|
||||
var modules = new List<ModuleRecord> ();
|
||||
var types = new List<TypeRecord> ();
|
||||
var methods = new List<MethodRecord> ();
|
||||
|
||||
Dictionary<int, ProfileRecord> records = new Dictionary<int, ProfileRecord> ();
|
||||
|
||||
while (true) {
|
||||
RecordType rtype = (RecordType)data [pos];
|
||||
pos ++;
|
||||
if (rtype == RecordType.NONE)
|
||||
break;
|
||||
int id = ReadInt ();
|
||||
switch (rtype) {
|
||||
case RecordType.IMAGE: {
|
||||
string name = ReadString ();
|
||||
string mvid = ReadString ();
|
||||
var module = new ModuleRecord (id, name, mvid);
|
||||
records [id] = module;
|
||||
modules.Add (module);
|
||||
break;
|
||||
}
|
||||
case RecordType.GINST: {
|
||||
int argc = ReadInt ();
|
||||
|
||||
TypeRecord[] tr = new TypeRecord [argc];
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
int type_id = ReadInt ();
|
||||
tr [i] = (TypeRecord)records [type_id];
|
||||
}
|
||||
var ginst = new GenericInstRecord (id, tr);
|
||||
records [id] = ginst;
|
||||
break;
|
||||
}
|
||||
case RecordType.TYPE: {
|
||||
MonoTypeEnum ttype = (MonoTypeEnum)ReadByte ();
|
||||
|
||||
switch (ttype) {
|
||||
case MonoTypeEnum.MONO_TYPE_CLASS: {
|
||||
int image_id = ReadInt ();
|
||||
int ginst_id = ReadInt ();
|
||||
string name = ReadString ();
|
||||
|
||||
GenericInstRecord inst = null;
|
||||
if (ginst_id != -1)
|
||||
inst = (GenericInstRecord)records [ginst_id];
|
||||
|
||||
var module = (ModuleRecord)records [image_id];
|
||||
var type = new TypeRecord (id, module, name, inst);
|
||||
types.Add (type);
|
||||
records [id] = type;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RecordType.METHOD: {
|
||||
int class_id = ReadInt ();
|
||||
int ginst_id = ReadInt ();
|
||||
int param_count = ReadInt ();
|
||||
string name = ReadString ();
|
||||
string sig = ReadString ();
|
||||
|
||||
var type = (TypeRecord)records [class_id];
|
||||
GenericInstRecord ginst = ginst_id != -1 ? (GenericInstRecord)records [ginst_id] : null;
|
||||
var method = new MethodRecord (id, type, ginst, name, sig, param_count);
|
||||
methods.Add (method);
|
||||
records [id] = method;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new NotImplementedException (rtype.ToString ());
|
||||
}
|
||||
}
|
||||
|
||||
return new ProfileData (modules.ToArray (), types.ToArray (), methods.ToArray ());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
101
mcs/class/Mono.Profiler.Log/Mono.Profiler.Aot/Records.cs
Normal file
101
mcs/class/Mono.Profiler.Log/Mono.Profiler.Aot/Records.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
namespace Mono.Profiler.Aot
|
||||
{
|
||||
//
|
||||
// Represents the contents of an .aotprofile file created by the
|
||||
// AOT profiler
|
||||
//
|
||||
public class ProfileRecord
|
||||
{
|
||||
public ProfileRecord (int id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public int Id {
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
public class ModuleRecord : ProfileRecord
|
||||
{
|
||||
public ModuleRecord (int id, string name, string mvid) : base (id)
|
||||
{
|
||||
Name = name;
|
||||
Mvid = mvid;
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string Mvid {
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
public class GenericInstRecord : ProfileRecord
|
||||
{
|
||||
public GenericInstRecord (int id, TypeRecord[] types) : base (id)
|
||||
{
|
||||
Types = types;
|
||||
}
|
||||
|
||||
public TypeRecord[] Types {
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
public class TypeRecord : ProfileRecord
|
||||
{
|
||||
public TypeRecord (int id, ModuleRecord module, string name, GenericInstRecord ginst) : base (id)
|
||||
{
|
||||
Module = module;
|
||||
Name = name;
|
||||
GenericInst = ginst;
|
||||
}
|
||||
|
||||
public ModuleRecord Module {
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get; set;
|
||||
}
|
||||
|
||||
public GenericInstRecord GenericInst {
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
public class MethodRecord : ProfileRecord
|
||||
{
|
||||
public MethodRecord (int id, TypeRecord type, GenericInstRecord ginst, string name, string sig, int param_count) : base (id)
|
||||
{
|
||||
Type = type;
|
||||
GenericInst = ginst;
|
||||
Name = name;
|
||||
Signature = sig;
|
||||
ParamCount = param_count;
|
||||
}
|
||||
|
||||
public TypeRecord Type {
|
||||
get; set;
|
||||
}
|
||||
|
||||
public GenericInstRecord GenericInst {
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string Signature {
|
||||
get; set;
|
||||
}
|
||||
|
||||
public int ParamCount {
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
Assembly/AssemblyInfo.cs
|
||||
../../build/common/Consts.cs
|
||||
../../build/common/Locale.cs
|
||||
../corlib/Mono/DataConverter.cs
|
||||
|
||||
Mono.Profiler.Log/LogBufferHeader.cs
|
||||
Mono.Profiler.Log/LogEnums.cs
|
||||
Mono.Profiler.Log/LogEvent.cs
|
||||
@@ -12,3 +13,6 @@ Mono.Profiler.Log/LogProfiler.cs
|
||||
Mono.Profiler.Log/LogReader.cs
|
||||
Mono.Profiler.Log/LogStream.cs
|
||||
Mono.Profiler.Log/LogStreamHeader.cs
|
||||
Mono.Profiler.Aot/ProfileData.cs
|
||||
Mono.Profiler.Aot/ProfileReader.cs
|
||||
Mono.Profiler.Aot/Records.cs
|
||||
|
||||
Reference in New Issue
Block a user