Skip to content

Commit

Permalink
Cleanup unused ifdefs
Browse files Browse the repository at this point in the history
Also added some docs
Fixed a manifest generation bug that cause TraceParserGen to fail.
  • Loading branch information
vancem committed Mar 2, 2018
1 parent e2e8b44 commit 09424e6
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 57 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand Down
3 changes: 2 additions & 1 deletion documentation/Downloading.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
4 changes: 2 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
</PropertyGroup>

<PropertyGroup>
<PerfViewVersion>2.0.5</PerfViewVersion>
<TraceEventVersion>2.0.6</TraceEventVersion>
<PerfViewVersion>2.0.7</PerfViewVersion>
<TraceEventVersion>2.0.7</TraceEventVersion>
</PropertyGroup>

<!-- versions of dependencies that more than one project use -->
Expand Down
13 changes: 5 additions & 8 deletions src/HeapDump/GCHeapDump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
using System.Globalization;
using System.Text.RegularExpressions;
using Microsoft.Diagnostics.Utilities;
#if PERFVIEW
using System.Xml;
#endif


/// <summary>
/// Represents a .GCDump file. You can open it for reading with the construtor
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -656,7 +655,6 @@ void IFastSerializable.FromStream(Deserializer deserializer)
}
}

#if PERFVIEW
/// <summary>
/// Reads the format as an XML file. It it is a very simple format Here is an example.
/// <graph>
Expand Down Expand Up @@ -984,9 +982,8 @@ private static float FetchFloat(XmlReader reader, string attributeName, float de
return ret;
}

#endregion
#endregion


}
#endif

16 changes: 0 additions & 16 deletions src/HeapDump/GCHeapDumper.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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))
Expand All @@ -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.]");
Expand All @@ -183,12 +176,10 @@ private CollectionMetadata CaptureLiveHeapDump(int processID)

if (hasJScript)
TryGetJavaScriptDump(processID);
#endif

IList<string> configurationDirectories = null;
bool is64bitSource = false;

#if STANDALONE_EXE
if (hasMrt || (hasCoreClr && !hasSilverlight) || (hasDotNet && UseETW))
{
if (hasMrt)
Expand All @@ -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))
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -352,7 +341,6 @@ private void InitializeClrRuntime(string processDumpFile, out DataTarget target,
runtime = currRuntime.CreateRuntime(dacFilePath);
break;
}
#endif
}
catch (ClrDiagnosticsException clrDiagEx)
{
Expand Down Expand Up @@ -415,7 +403,6 @@ private void InitializeClrRuntime(string processDumpFile, out DataTarget target,
/// </summary>
public ulong PromotedBytesThreshold;

#if STANDALONE_EXE
/// <summary>
/// Force a .NET GC on a particular process.
/// </summary>
Expand Down Expand Up @@ -665,7 +652,6 @@ private void TriggerAllGCs(TraceEventSession session, Stopwatch sw, int processI
};

}
#endif

// output properties
/// <summary>
Expand Down Expand Up @@ -788,7 +774,6 @@ private void ResumeProcessIfNecessary(int processID)
}
}

#if STANDALONE_EXE
/// <summary>
/// Loads the ETWClrProfiler into the process 'processID'.
/// </summary>
Expand Down Expand Up @@ -935,7 +920,6 @@ private bool TryGetDotNetDumpETW(int processID)
}
return m_gotDotNetData;
}
#endif

private bool TryGetDotNetDump(int processID)
{
Expand Down
4 changes: 0 additions & 4 deletions src/HeapDump/HeapDump.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>

<PropertyGroup>
<DefineConstants>$(DefineConstants);STANDALONE_EXE</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MicroBuild.Core" Version="0.2.0" />
<PackageReference Include="Microsoft.Diagnostics.Runtime" Version="$(MicrosoftDiagnosticsRuntimeVersion)" />
Expand Down
15 changes: 9 additions & 6 deletions src/PerfView/App.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// #define PUBLIC_ONLY
// #define PUBLIC_BUILD
using System;
using System.Diagnostics;
using System.IO;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1003,7 +1006,7 @@ public static bool CanSendFeedback
{
get
{
#if PUBLIC_ONLY
#if PUBLIC_BUILD
return false;
#else
if (!s_CanSendFeedback.HasValue)
Expand Down Expand Up @@ -1045,7 +1048,7 @@ public static bool InternalUser
{
get
{
#if PUBLIC_ONLY
#if PUBLIC_BUILD
return false;
#else
if (!s_InternalUser.HasValue)
Expand All @@ -1060,7 +1063,7 @@ public static bool InternalUser
/// </summary>
public static void LogUsage(string eventName, string arg1 = "", string arg2 = "")
{
#if !PUBLIC_ONLY
#if !PUBLIC_BUILD
if (!CanSendFeedback)
return;
try
Expand Down Expand Up @@ -1094,7 +1097,7 @@ public static void LogUsage(string eventName, string arg1 = "", string arg2 = ""
/// </summary>
public static bool SendFeedback(string message, bool crash)
{
#if PUBLIC_ONLY
#if PUBLIC_BUILD
return false;
#else
if (!CanSendFeedback)
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 6 additions & 2 deletions src/PerfView/PerfView.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
Expand All @@ -21,10 +21,14 @@
</ItemGroup>

<PropertyGroup>
<DefineConstants>$(DefineConstants);PERFVIEW;STANDALONE_EXE</DefineConstants>
<DefineConstants>$(DefineConstants);PERFVIEW</DefineConstants>
<NoWarn>$(NoWarn),0436,0618</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(PUBLIC_BUILD)' == 'true'">
<DefineConstants>$(DefineConstants);PUBLIC_BUILD</DefineConstants>
</PropertyGroup>

<PropertyGroup>
<ApplicationIcon>performance.ico</ApplicationIcon>
</PropertyGroup>
Expand Down
10 changes: 9 additions & 1 deletion src/TraceEvent/RegisteredTraceEventParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions src/TraceEvent/Symbols/SymbolPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions src/Utilities/EnvironmentUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down

0 comments on commit 09424e6

Please sign in to comment.