From 09424e6b1c76c366d2a75ab5045a4442cfcd2fda Mon Sep 17 00:00:00 2001 From: Vance Morrison Date: Fri, 2 Mar 2018 15:37:34 -0800 Subject: [PATCH] Cleanup unused ifdefs Also added some docs Fixed a manifest generation bug that cause TraceParserGen to fail. --- README.md | 4 ++-- documentation/Downloading.md | 3 ++- src/Directory.Build.props | 4 ++-- src/HeapDump/GCHeapDump.cs | 13 +++++-------- src/HeapDump/GCHeapDumper.cs | 16 ---------------- src/HeapDump/HeapDump.csproj | 4 ---- src/PerfView/App.cs | 15 +++++++++------ src/PerfView/PerfView.csproj | 8 ++++++-- src/TraceEvent/RegisteredTraceEventParser.cs | 10 +++++++++- src/TraceEvent/Symbols/SymbolPath.cs | 4 ---- src/Utilities/EnvironmentUtilities.cs | 11 ----------- 11 files changed, 35 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index 0a1c3722a..1eceb0864 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ among other things a PerfView.exe. This one file is all you need to deploy. ### Information for build troubleshooting. - * One of the unusual things about PerfView is that it incorporates its support DLL into the EXE itself, and these get + * One of the unusual things about PerfView is that it incorporates its support DLLs into the EXE itself, and these get unpacked on first launch. This means that there are tricky dependencies in the build that are not typical. You will see errors that certain DLLs can't be found if there were build problems earlier in the build. Typically you can fix this simply by doing a normal (non-clean) build, since the missing file will be present from the last compilation. @@ -119,7 +119,7 @@ among other things a PerfView.exe. This one file is all you need to deploy. This includes exactly what you tried, and what the error messages were. * If you get an error "MSB8036: The Windows SDK version 8.1 was not found", go to your Control panel -> Programs and Features, - and right click on your VS2017 and select 'Modify'. Then look under the C++ Desktop Development and check that hte Windows SDK 8.1 option is selected. If not select it and have the setup install this. + and right click on your VS2017 and select 'Modify'. Then look under the C++ Desktop Development and check that the Windows SDK 8.1 option is selected. If not select it and have the setup install this. ### Running Tests diff --git a/documentation/Downloading.md b/documentation/Downloading.md index 8b6356b33..4c74f4c33 100644 --- a/documentation/Downloading.md +++ b/documentation/Downloading.md @@ -1,5 +1,6 @@ -# PerfView Overview +# Downloading PerfView +PerfView is a free profiling tool from Microsoft. This page tells you how to get a copy of it for yourself. See the [PerfView Overview](https://github.com/Microsoft/perfview#perfview-overview) for general information about PerfView. diff --git a/src/Directory.Build.props b/src/Directory.Build.props index a61bf2332..350688a7a 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -21,8 +21,8 @@ - 2.0.5 - 2.0.6 + 2.0.7 + 2.0.7 diff --git a/src/HeapDump/GCHeapDump.cs b/src/HeapDump/GCHeapDump.cs index 56ab06aed..3a75bdaf7 100644 --- a/src/HeapDump/GCHeapDump.cs +++ b/src/HeapDump/GCHeapDump.cs @@ -8,9 +8,8 @@ using System.Globalization; using System.Text.RegularExpressions; using Microsoft.Diagnostics.Utilities; -#if PERFVIEW using System.Xml; -#endif + /// /// Represents a .GCDump file. You can open it for reading with the construtor @@ -374,19 +373,19 @@ int IFastSerializableVersion.MinimumReaderVersion MemoryGraph m_graph; InteropInfo m_interop; - #endregion +#endregion } public class JSHeapInfo : IFastSerializable { - #region private +#region private void IFastSerializable.ToStream(Serializer serializer) { } void IFastSerializable.FromStream(Deserializer deserializer) { } - #endregion +#endregion } public class InteropInfo : IFastSerializable @@ -656,7 +655,6 @@ void IFastSerializable.FromStream(Deserializer deserializer) } } -#if PERFVIEW /// /// Reads the format as an XML file. It it is a very simple format Here is an example. /// @@ -984,9 +982,8 @@ private static float FetchFloat(XmlReader reader, string attributeName, float de return ret; } - #endregion +#endregion } -#endif diff --git a/src/HeapDump/GCHeapDumper.cs b/src/HeapDump/GCHeapDumper.cs index cd1a8a90e..99bb43538 100644 --- a/src/HeapDump/GCHeapDumper.cs +++ b/src/HeapDump/GCHeapDumper.cs @@ -1,6 +1,5 @@ #define DEPENDENT_HANDLE using ClrMemory; -#if STANDALONE_EXE using Microsoft.Diagnostics.Symbols; using Microsoft.Diagnostics.Tracing; using Microsoft.Diagnostics.Tracing.Parsers; @@ -9,7 +8,6 @@ using Microsoft.Diagnostics.Tracing.Parsers.JSDumpHeap; using Microsoft.Diagnostics.Tracing.Session; using System.Threading.Tasks; -#endif using FastSerialization; using Graphs; using Microsoft.Diagnostics.Runtime; @@ -115,10 +113,8 @@ private CollectionMetadata CaptureLiveHeapDump(int processID) // There are assumptions that JavaScript is first (CCW nodes, and aggregate stats) bool hasDotNet = false; bool hasJScript = false; -#if STANDALONE_EXE bool hasCoreClr = false; bool hasSilverlight = false; -#endif bool hasClrDll = false; bool hasMrt = false; @@ -140,11 +136,9 @@ private CollectionMetadata CaptureLiveHeapDump(int processID) } else if (fileName.EndsWith("\\coreclr.dll", StringComparison.OrdinalIgnoreCase)) { -#if STANDALONE_EXE if (0 <= fileName.IndexOf("Microsoft Silverlight", StringComparison.OrdinalIgnoreCase)) hasSilverlight = true; hasCoreClr = true; -#endif hasDotNet = true; } else if (fileName.EndsWith("\\mscorwks.dll", StringComparison.OrdinalIgnoreCase)) @@ -166,7 +160,6 @@ private CollectionMetadata CaptureLiveHeapDump(int processID) m_log.WriteLine("Process Has DotNet: {0} Has JScript: {1} Has ClrDll: {2} HasMrt {3}", hasDotNet, hasJScript, hasClrDll, hasMrt); -#if STANDALONE_EXE if (hasClrDll && hasJScript) { m_log.WriteLine("[Detected both a JScript and .NET heap, forcing a GC before doing a heap dump.]"); @@ -183,12 +176,10 @@ private CollectionMetadata CaptureLiveHeapDump(int processID) if (hasJScript) TryGetJavaScriptDump(processID); -#endif IList configurationDirectories = null; bool is64bitSource = false; -#if STANDALONE_EXE if (hasMrt || (hasCoreClr && !hasSilverlight) || (hasDotNet && UseETW)) { if (hasMrt) @@ -200,7 +191,6 @@ private CollectionMetadata CaptureLiveHeapDump(int processID) throw new ApplicationException("Could not get .NET Heap Dump."); } else -#endif if (hasDotNet) { if (!TryGetDotNetDump(processID)) @@ -315,7 +305,6 @@ private void InitializeClrRuntime(string processDumpFile, out DataTarget target, runtime = currRuntime.CreateRuntime(dacLocation); break; } -#if STANDALONE_EXE else { var dacInfo = currRuntime.DacInfo; @@ -352,7 +341,6 @@ private void InitializeClrRuntime(string processDumpFile, out DataTarget target, runtime = currRuntime.CreateRuntime(dacFilePath); break; } -#endif } catch (ClrDiagnosticsException clrDiagEx) { @@ -415,7 +403,6 @@ private void InitializeClrRuntime(string processDumpFile, out DataTarget target, /// public ulong PromotedBytesThreshold; -#if STANDALONE_EXE /// /// Force a .NET GC on a particular process. /// @@ -665,7 +652,6 @@ private void TriggerAllGCs(TraceEventSession session, Stopwatch sw, int processI }; } -#endif // output properties /// @@ -788,7 +774,6 @@ private void ResumeProcessIfNecessary(int processID) } } -#if STANDALONE_EXE /// /// Loads the ETWClrProfiler into the process 'processID'. /// @@ -935,7 +920,6 @@ private bool TryGetDotNetDumpETW(int processID) } return m_gotDotNetData; } -#endif private bool TryGetDotNetDump(int processID) { diff --git a/src/HeapDump/HeapDump.csproj b/src/HeapDump/HeapDump.csproj index ba28541c6..c7283c417 100644 --- a/src/HeapDump/HeapDump.csproj +++ b/src/HeapDump/HeapDump.csproj @@ -25,10 +25,6 @@ true - - $(DefineConstants);STANDALONE_EXE - - diff --git a/src/PerfView/App.cs b/src/PerfView/App.cs index 253208c6d..f89a1c22f 100755 --- a/src/PerfView/App.cs +++ b/src/PerfView/App.cs @@ -1,4 +1,4 @@ -// #define PUBLIC_ONLY +// #define PUBLIC_BUILD using System; using System.Diagnostics; using System.IO; @@ -586,7 +586,10 @@ public static string SymbolPath // Since the default goes off machine, if we are outside of Microsoft, we have to ask // the user for permission. if (AppLog.InternalUser) + { + symPath.Add("SRV*http://symweb.corp.microsoft.com"); symPath.Add(Microsoft.Diagnostics.Symbols.SymbolPath.MicrosoftSymbolServerPath); + } else if (symPath.Elements.Count == 0) { if (SupportFiles.ProcessArch == ProcessorArchitecture.Arm || App.CommandLineArgs.NoGui) @@ -1003,7 +1006,7 @@ public static bool CanSendFeedback { get { -#if PUBLIC_ONLY +#if PUBLIC_BUILD return false; #else if (!s_CanSendFeedback.HasValue) @@ -1045,7 +1048,7 @@ public static bool InternalUser { get { -#if PUBLIC_ONLY +#if PUBLIC_BUILD return false; #else if (!s_InternalUser.HasValue) @@ -1060,7 +1063,7 @@ public static bool InternalUser /// public static void LogUsage(string eventName, string arg1 = "", string arg2 = "") { -#if !PUBLIC_ONLY +#if !PUBLIC_BUILD if (!CanSendFeedback) return; try @@ -1094,7 +1097,7 @@ public static void LogUsage(string eventName, string arg1 = "", string arg2 = "" /// public static bool SendFeedback(string message, bool crash) { -#if PUBLIC_ONLY +#if PUBLIC_BUILD return false; #else if (!CanSendFeedback) @@ -1165,7 +1168,7 @@ private static string FeedbackDirectory private static DateTime s_startTime; // used as a unique ID for the launch of the program (for SQM style logging) internal static bool s_IsUnderTest; // set from tests: indicates we're in a test -#if !PUBLIC_ONLY +#if !PUBLIC_BUILD private static DateTime s_ProbedForFeedbackAt; private static bool? s_CanSendFeedback; private static bool? s_InternalUser; diff --git a/src/PerfView/PerfView.csproj b/src/PerfView/PerfView.csproj index b3d260702..1e8abe6c7 100644 --- a/src/PerfView/PerfView.csproj +++ b/src/PerfView/PerfView.csproj @@ -1,4 +1,4 @@ - + @@ -21,10 +21,14 @@ - $(DefineConstants);PERFVIEW;STANDALONE_EXE + $(DefineConstants);PERFVIEW $(NoWarn),0436,0618 + + $(DefineConstants);PUBLIC_BUILD + + performance.ico diff --git a/src/TraceEvent/RegisteredTraceEventParser.cs b/src/TraceEvent/RegisteredTraceEventParser.cs index 0918d57c1..11848db18 100644 --- a/src/TraceEvent/RegisteredTraceEventParser.cs +++ b/src/TraceEvent/RegisteredTraceEventParser.cs @@ -229,7 +229,15 @@ public static string GetManifestForRegisteredProvider(Guid providerGuid) { string opcodeId; if (eventInfo->EventDescriptor.Opcode < 10) // It is a reserved opcode. - opcodeId = "win:" + opcodeName; + { + // For some reason opcodeName does not have the underscore, which we need. + if (eventInfo->EventDescriptor.Opcode == (byte)TraceEventOpcode.DataCollectionStart) + opcodeId = "win:DC_Start"; + else if (eventInfo->EventDescriptor.Opcode == (byte)TraceEventOpcode.DataCollectionStop) + opcodeId = "win:DC_Stop"; + else + opcodeId = "win:" + opcodeName; + } else { opcodeId = opcodeName; diff --git a/src/TraceEvent/Symbols/SymbolPath.cs b/src/TraceEvent/Symbols/SymbolPath.cs index 7fe313c6f..9c3ca0f31 100644 --- a/src/TraceEvent/Symbols/SymbolPath.cs +++ b/src/TraceEvent/Symbols/SymbolPath.cs @@ -70,10 +70,6 @@ public static string MicrosoftSymbolServerPath { if (s_MicrosoftSymbolServerPath == null) { -#if !PUBLIC_ONLY - if (ComputerNameExists("symweb.corp.microsoft.com")) - s_MicrosoftSymbolServerPath = "SRV*http://symweb.corp.microsoft.com"; // Internal Microsoft location. -#endif s_MicrosoftSymbolServerPath = s_MicrosoftSymbolServerPath + ";" + @"SRV*http://msdl.microsoft.com/download/symbols" + // Operatig system Symbols ";" + @"SRV*https://nuget.smbsrc.net" + // Nuget symbols diff --git a/src/Utilities/EnvironmentUtilities.cs b/src/Utilities/EnvironmentUtilities.cs index 9bf698c61..f0df11d27 100644 --- a/src/Utilities/EnvironmentUtilities.cs +++ b/src/Utilities/EnvironmentUtilities.cs @@ -19,18 +19,7 @@ public static bool Is64BitOperatingSystem { get { -#if STANDALONE_EXE return Environment.Is64BitOperatingSystem; -#else - // 64-bit programs run only on 64-bit - if (EnvironmentUtilities.Is64BitProcess) - return true; - - bool isWow64; // WinXP SP2+ and Win2k3 SP1+ - return Win32Native.DoesWin32MethodExist(Win32Native.KERNEL32, "IsWow64Process") - && Win32Native.IsWow64Process(Win32Native.GetCurrentProcess(), out isWow64) - && isWow64; -#endif } } }