diff options
author | Massimiliano Mantione <massi@mono-cvs.ximian.com> | 2009-01-18 00:16:30 +0300 |
---|---|---|
committer | Massimiliano Mantione <massi@mono-cvs.ximian.com> | 2009-01-18 00:16:30 +0300 |
commit | ad82c00237e3623c950a5a552e2e5700a87c371c (patch) | |
tree | a5fbe5483994b52e30fa6956138b6f9beb77f79d /Mono.Profiler | |
parent | 3e15e2f702b71f76172a1cdd94e67786ca290ea0 (diff) |
Fixed a bug in the stat profiler that prevented file names to be shown for unmanaged functions.
svn path=/trunk/mono-tools/; revision=123710
Diffstat (limited to 'Mono.Profiler')
5 files changed, 33 insertions, 25 deletions
diff --git a/Mono.Profiler/profiler-decoder-library/BaseTypes.cs b/Mono.Profiler/profiler-decoder-library/BaseTypes.cs index 3de31bbd..1fb0b476 100644 --- a/Mono.Profiler/profiler-decoder-library/BaseTypes.cs +++ b/Mono.Profiler/profiler-decoder-library/BaseTypes.cs @@ -40,10 +40,11 @@ namespace Mono.Profiler { public interface ILoadedMethod<LC> : ILoadedElement where LC : ILoadedClass { LC Class {get;} } - public interface IUnmanagedFunctionFromID<MR,UFR> : ILoadedElement where UFR : IUnmanagedFunctionFromRegion where MR : IExecutableMemoryRegion<UFR> { + public interface IUnmanagedFunctionFromID<MR,UFR> : ILoadedElement where UFR : IUnmanagedFunctionFromRegion<UFR> where MR : IExecutableMemoryRegion<UFR> { MR Region {get;} } - public interface IUnmanagedFunctionFromRegion { + public interface IUnmanagedFunctionFromRegion<UFR> where UFR : IUnmanagedFunctionFromRegion<UFR> { + IExecutableMemoryRegion<UFR> Region {get; set;} string Name {get; set;} uint StartOffset {get; set;} uint EndOffset {get; set;} @@ -68,7 +69,7 @@ namespace Mono.Profiler { } } } - public interface IExecutableMemoryRegion<UFR> : ILoadedElement where UFR : IUnmanagedFunctionFromRegion { + public interface IExecutableMemoryRegion<UFR> : ILoadedElement where UFR : IUnmanagedFunctionFromRegion<UFR> { ulong StartAddress {get;} ulong EndAddress {get;} uint FileOffset {get;} @@ -100,7 +101,7 @@ namespace Mono.Profiler { bool RecordSnapshot {get;} } - public interface ILoadedElementFactory<LC,LM,UFR,UFI,MR,HO,HS> where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { + public interface ILoadedElementFactory<LC,LM,UFR,UFI,MR,HO,HS> where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion<UFR> where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { LC NewClass (uint id, string name, uint size); LM NewMethod (uint id, LC c, string name); MR NewExecutableMemoryRegion (uint id, string fileName, uint fileOffset, ulong startAddress, ulong endAddress); @@ -109,7 +110,7 @@ namespace Mono.Profiler { bool RecordHeapSnapshots {get; set;} } - public interface ILoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> : ILoadedElementFactory<LC,LM,UFR,UFI,MR,HO,HS> where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { + public interface ILoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> : ILoadedElementFactory<LC,LM,UFR,UFI,MR,HO,HS> where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion<UFR> where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { LC[] Classes {get;} LC GetClass (uint id); LM[] Methods {get;} @@ -123,7 +124,7 @@ namespace Mono.Profiler { UFI GetUnmanagedFunctionByID (uint id); HS[] HeapSnapshots {get;} } - public interface IProfilerEventHandler<LC,LM,UFR,UFI,MR,EH,HO,HS> where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where EH : ILoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { + public interface IProfilerEventHandler<LC,LM,UFR,UFI,MR,EH,HO,HS> where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion<UFR> where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where EH : ILoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { DirectivesHandler Directives {get;} EH LoadedElements {get;} @@ -241,9 +242,9 @@ namespace Mono.Profiler { this.c = c; } } - public class BaseUnmanagedFunctionFromRegion : IUnmanagedFunctionFromRegion { - IExecutableMemoryRegion<IUnmanagedFunctionFromRegion> region; - public IExecutableMemoryRegion<IUnmanagedFunctionFromRegion> Region { + public class BaseUnmanagedFunctionFromRegion<UFR> : IUnmanagedFunctionFromRegion<UFR> where UFR : IUnmanagedFunctionFromRegion<UFR> { + IExecutableMemoryRegion<UFR> region; + public IExecutableMemoryRegion<UFR> Region { get { return region; } @@ -284,14 +285,14 @@ namespace Mono.Profiler { this.startOffset = 0; this.endOffset = 0; } - public BaseUnmanagedFunctionFromRegion (IExecutableMemoryRegion<IUnmanagedFunctionFromRegion> region, string name, uint startOffset, uint endOffset) { + public BaseUnmanagedFunctionFromRegion (IExecutableMemoryRegion<UFR> region, string name, uint startOffset, uint endOffset) { this.region = region; this.name = name; this.startOffset = startOffset; this.endOffset = endOffset; } } - public class BaseUnmanagedFunctionFromID<MR,UFR>: BaseLoadedElement, IUnmanagedFunctionFromID<MR,UFR> where UFR : IUnmanagedFunctionFromRegion where MR : IExecutableMemoryRegion<UFR> { + public class BaseUnmanagedFunctionFromID<MR,UFR>: BaseLoadedElement, IUnmanagedFunctionFromID<MR,UFR> where UFR : IUnmanagedFunctionFromRegion<UFR> where MR : IExecutableMemoryRegion<UFR> { MR region; public MR Region { get { @@ -707,7 +708,7 @@ namespace Mono.Profiler { } } - public class BaseProfilerEventHandler<LC,LM,UFR,UFI,MR,EH,HO,HS> : IProfilerEventHandler<LC,LM,UFR,UFI,MR,EH,HO,HS> where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where EH : ILoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { + public class BaseProfilerEventHandler<LC,LM,UFR,UFI,MR,EH,HO,HS> : IProfilerEventHandler<LC,LM,UFR,UFI,MR,EH,HO,HS> where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion<UFR> where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where EH : ILoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { DirectivesHandler directives; public DirectivesHandler Directives { get { @@ -806,7 +807,7 @@ namespace Mono.Profiler { public virtual void DataProcessed (uint offset) {} } - public class DebugProfilerEventHandler<LC,LM,UFR,UFI,MR,EH,HO,HS> : BaseProfilerEventHandler<LC,LM,UFR,UFI,MR,EH,HO,HS> where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where EH : ILoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { + public class DebugProfilerEventHandler<LC,LM,UFR,UFI,MR,EH,HO,HS> : BaseProfilerEventHandler<LC,LM,UFR,UFI,MR,EH,HO,HS> where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion<UFR> where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where EH : ILoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { uint currentOffset; public uint CurrentOffset { get { @@ -996,7 +997,7 @@ namespace Mono.Profiler { } } - public class BaseExecutableMemoryRegion<UFR> : BaseLoadedElement, IExecutableMemoryRegion<UFR> where UFR : IUnmanagedFunctionFromRegion, new() { + public class BaseExecutableMemoryRegion<UFR> : BaseLoadedElement, IExecutableMemoryRegion<UFR> where UFR : IUnmanagedFunctionFromRegion<UFR>, new() { uint fileOffset; public uint FileOffset { get { @@ -1025,6 +1026,7 @@ namespace Mono.Profiler { result.Name = name; result.StartOffset = offset; result.EndOffset = offset; + result.Region = this; functions.Add (result); return result; } @@ -1097,7 +1099,7 @@ namespace Mono.Profiler { } } - public class LoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> : ILoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { + public class LoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> : ILoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion<UFR> where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { ILoadedElementFactory<LC,LM,UFR,UFI,MR,HO,HS> factory; int loadedClassesCount; diff --git a/Mono.Profiler/profiler-decoder-library/ChangeLog b/Mono.Profiler/profiler-decoder-library/ChangeLog index 4c0315ee..42cf566f 100644 --- a/Mono.Profiler/profiler-decoder-library/ChangeLog +++ b/Mono.Profiler/profiler-decoder-library/ChangeLog @@ -1,3 +1,9 @@ +2009-01-17 Massimiliano Mantione <massi@ximian.com> + * BaseTypes.cs: Added "Region" property to IExecutableMemoryRegion, so + that it is possible to set the region when we load the elf file, and + use it in "BaseExecutableMemoryRegion.NewFunction". + * Decoder.cs, ObjectModel.cs, NativeLibraryReader.cs: Likewise. + 2008-12-29 Massimiliano Mantione <massi@ximian.com> * ObjectModel.cs: fixed call stack array resize condition. diff --git a/Mono.Profiler/profiler-decoder-library/Decoder.cs b/Mono.Profiler/profiler-decoder-library/Decoder.cs index 5880f4d5..aeca0de1 100644 --- a/Mono.Profiler/profiler-decoder-library/Decoder.cs +++ b/Mono.Profiler/profiler-decoder-library/Decoder.cs @@ -294,7 +294,7 @@ namespace Mono.Profiler { generation = eventValue & 0xff; } - public void Decode<LC,LM,UFR,UFI,MR,EH,HO,HS> (IProfilerEventHandler<LC,LM,UFR,UFI,MR,EH,HO,HS> handler, IDataBlockRecycler blockRecycler) where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where EH : ILoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { + public void Decode<LC,LM,UFR,UFI,MR,EH,HO,HS> (IProfilerEventHandler<LC,LM,UFR,UFI,MR,EH,HO,HS> handler, IDataBlockRecycler blockRecycler) where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion<UFR> where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where EH : ILoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { try { Decode<LC,LM,UFR,UFI,MR,EH,HO,HS> (handler); } finally { @@ -303,7 +303,7 @@ namespace Mono.Profiler { } } - public void Decode<LC,LM,UFR,UFI,MR,EH,HO,HS> (IProfilerEventHandler<LC,LM,UFR,UFI,MR,EH,HO,HS> handler) where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where EH : ILoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { + public void Decode<LC,LM,UFR,UFI,MR,EH,HO,HS> (IProfilerEventHandler<LC,LM,UFR,UFI,MR,EH,HO,HS> handler) where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion<UFR> where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where EH : ILoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { uint offsetInBlock = 0; StackSectionElement<LC,LM>[] stackSection = new StackSectionElement<LC,LM> [32]; @@ -1015,7 +1015,7 @@ namespace Mono.Profiler { bool handleExceptions = true; - void DumpDebugInformation<LC,LM,UFR,UFI,MR,EH,HO,HS> (uint offsetInBlock, IProfilerEventHandler<LC,LM,UFR,UFI,MR,EH,HO,HS> handler) where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where EH : ILoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { + void DumpDebugInformation<LC,LM,UFR,UFI,MR,EH,HO,HS> (uint offsetInBlock, IProfilerEventHandler<LC,LM,UFR,UFI,MR,EH,HO,HS> handler) where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion<UFR> where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where EH : ILoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { if (debugLog != null) { debugLog.WriteLine ("Attempting to decode data printing block contents..."); handleExceptions = false; @@ -1033,7 +1033,7 @@ namespace Mono.Profiler { } } } - void HandleDecodingException<LC,LM,UFR,UFI,MR,EH,HO,HS> (DecodingException e, uint offsetInBlock, IProfilerEventHandler<LC,LM,UFR,UFI,MR,EH,HO,HS> handler) where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where EH : ILoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { + void HandleDecodingException<LC,LM,UFR,UFI,MR,EH,HO,HS> (DecodingException e, uint offsetInBlock, IProfilerEventHandler<LC,LM,UFR,UFI,MR,EH,HO,HS> handler) where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion<UFR> where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where EH : ILoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { if (debugLog != null) { debugLog.WriteLine ("ERROR: DecodingException in block of code {0}, length {1}, file offset {2}, block offset {3}: {4}", e.FailingData.Code, e.FailingData.Length, e.FailingData.FileOffset, e.OffsetInBlock, e.Message); debugLog.WriteLine (e.StackTrace); @@ -1046,7 +1046,7 @@ namespace Mono.Profiler { throw e; } - void HandleRegularException<LC,LM,UFR,UFI,MR,EH,HO,HS> (Exception e, uint offsetInBlock, IProfilerEventHandler<LC,LM,UFR,UFI,MR,EH,HO,HS> handler) where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where EH : ILoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { + void HandleRegularException<LC,LM,UFR,UFI,MR,EH,HO,HS> (Exception e, uint offsetInBlock, IProfilerEventHandler<LC,LM,UFR,UFI,MR,EH,HO,HS> handler) where LC : ILoadedClass where LM : ILoadedMethod<LC> where UFR : IUnmanagedFunctionFromRegion<UFR> where UFI : IUnmanagedFunctionFromID<MR,UFR> where MR : IExecutableMemoryRegion<UFR> where EH : ILoadedElementHandler<LC,LM,UFR,UFI,MR,HO,HS> where HO: IHeapObject<HO,LC> where HS: IHeapSnapshot<HO,LC> { if (debugLog != null) { debugLog.WriteLine ("ERROR: Exception in block of code {0}, length {1}, file offset {2}, block offset {3}: {4}", Code, Length, FileOffset, offsetInBlock, e.Message); debugLog.WriteLine (e.StackTrace); diff --git a/Mono.Profiler/profiler-decoder-library/NativeLibraryReader.cs b/Mono.Profiler/profiler-decoder-library/NativeLibraryReader.cs index 120dc909..7427bb88 100644 --- a/Mono.Profiler/profiler-decoder-library/NativeLibraryReader.cs +++ b/Mono.Profiler/profiler-decoder-library/NativeLibraryReader.cs @@ -60,11 +60,11 @@ namespace Mono.Profiler { static Regex nmNoSymbols = new Regex ("(.*)nm:(.*)No symbols$"); static Regex nmUnknownProblem = new Regex ("(.*)nm:(.*)$"); - public static void FillFunctions<MR,UFR> (MR region) where UFR : IUnmanagedFunctionFromRegion where MR : IExecutableMemoryRegion <UFR> { + public static void FillFunctions<MR,UFR> (MR region) where UFR : IUnmanagedFunctionFromRegion<UFR> where MR : IExecutableMemoryRegion <UFR> { FillFunctionsUsingNm<MR,UFR> (region); } - static void FillFunctionsUsingNm<MR,UFR> (MR region) where UFR : IUnmanagedFunctionFromRegion where MR : IExecutableMemoryRegion <UFR> { + static void FillFunctionsUsingNm<MR,UFR> (MR region) where UFR : IUnmanagedFunctionFromRegion<UFR> where MR : IExecutableMemoryRegion <UFR> { try { string[] outputLines = RunExternalProcess ("/usr/bin/nm", "-n " + region.Name); if (outputLines.Length == 1) { @@ -91,7 +91,7 @@ namespace Mono.Profiler { outputLines = RunExternalProcess ("/usr/bin/nm", "-n -D " + region.Name); } - IUnmanagedFunctionFromRegion lastFunction = null; + IUnmanagedFunctionFromRegion<UFR> lastFunction = null; foreach (string outputLine in outputLines) { Match m = nmSymbolLine.Match (outputLine); if (m.Success) { diff --git a/Mono.Profiler/profiler-decoder-library/ObjectModel.cs b/Mono.Profiler/profiler-decoder-library/ObjectModel.cs index 77fd585f..bef8a1fa 100644 --- a/Mono.Profiler/profiler-decoder-library/ObjectModel.cs +++ b/Mono.Profiler/profiler-decoder-library/ObjectModel.cs @@ -881,7 +881,7 @@ namespace Mono.Profiler { } } - public class UnmanagedFunctionFromRegion : BaseUnmanagedFunctionFromRegion, IStatisticalHitItem { + public class UnmanagedFunctionFromRegion : BaseUnmanagedFunctionFromRegion<UnmanagedFunctionFromRegion>, IStatisticalHitItem { uint statisticalHits; public uint StatisticalHits { get { @@ -913,7 +913,7 @@ namespace Mono.Profiler { string IStatisticalHitItem.Name { get { - IExecutableMemoryRegion<IUnmanagedFunctionFromRegion> r = Region; + IExecutableMemoryRegion<UnmanagedFunctionFromRegion> r = Region; return String.Format ("[{0}({1}-{2})]{3}", r != null ? r.Name : "NULL", this.StartOffset, this.EndOffset, this.Name); } } |