Files
UnrealEngineUWP/Engine/Source/Programs/CrashReporter/CrashReportProcess/CrashReportProcessService.cs
Robert Manuszewski 1ff335d148 Copying //UE4/Dev-Core to //UE4/Main
==========================
MAJOR FEATURES + CHANGES
==========================

Change 2877442 on 2016/02/23 by Graeme.Thornton@GThornton_DevCore

	Allow 'dumpnonframe' stat command to also take an optional group name which will filter the output

Change 2879289 on 2016/02/24 by Graeme.Thornton@GThornton_DevCore

	Removed "-" in switch string for load time tracker. Makes -NoLoadTrackClear cmd line param actually work

Change 2879323 on 2016/02/24 by Graeme.Thornton@GThornton_DevCore

	PC builds now log engine initialization time with the load time tracker

Change 2879418 on 2016/02/24 by Graeme.Thornton@GThornton_DevCore

	Optimization for FSignedArchiveReader
	 - Compute incoming data hash in parallel on another thread while we serialize and decrypt the signature on the chunk cache worker thread

Change 2879419 on 2016/02/24 by Graeme.Thornton@GThornton_DevCore

	Extra stats for PakFile group
	 - Time reading from pak handles
	 - Number of open pak handles

Change 2881199 on 2016/02/25 by Graeme.Thornton@GThornton_DevCore

	Use 32 bit CRCs to hash chunk contents rather than SHA1. Much faster to compute than SHA1, and the decrypting 4 bytes rather than 20 is also a lot faster

Change 2885687 on 2016/02/29 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1

	Close disregard for GC pool when disabling it to leave it in a good state.

Change 2887358 on 2016/03/01 by Steve.Robb@Dev-Core

	FlushCurrentThreadCache calls forwarded on from FMalloc wrappers.

Change 2887398 on 2016/03/01 by Steve.Robb@Dev-Core

	Stats for MallocBinned2.

Change 2887682 on 2016/03/01 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1

	Added code to catch game hangs. If game thread is stalled for more than 5 seconds we will catch that, report its callstack and crash.

Change 2889573 on 2016/03/02 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1

	Renamed the new StackWalkAndDump to ThreadStackWalkAndDump to avoid name collisions and build errors.

Change 2889687 on 2016/03/02 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1

	Send thread heartbeats during potentially slow tasks.

Change 2889963 on 2016/03/02 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1

	Added the ability to query the name of a thread given its TLS id.

Change 2890439 on 2016/03/02 by Steve.Robb@Dev-Core

	MallocBinned redirection header, to allow easy switching between MallocBinned and MallocBinned2.
	Switch back to MallocBinned by default.

Change 2891799 on 2016/03/03 by Steve.Robb@Dev-Core

	Shrunken GMallocBinned2MemSizeToIndex array.
	Improvement of some shared templated alignment-related functions.

Change 2891812 on 2016/03/03 by Graeme.Thornton@GThornton_DevCore

	Refactoring of pak signing to be more compatible with patching
	 - Store signatures in a block at the end of the pak file
	 - Optimize decryption of signatures by serializing them all when the pak is opened, and decrypting on the chunk cache worker thread between read requests.

Change 2891813 on 2016/03/03 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream2

	Don't compile UnrealPak with ICU

Change 2892386 on 2016/03/03 by Steve.Robb@Dev-Core

	GitHub #2070 - Fix incorrect FMallocDebug::Malloc alignment checking

Change 2894189 on 2016/03/04 by Steve.Robb@Dev-Core

	Memswap fixes for sizes of 3, 5, 6 and 7, and early out on 0.

Change 2894427 on 2016/03/04 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1

	Don't display message boxes in unattended mode when D3D device is removed.

Change 2896912 on 2016/03/07 by Graeme.Thornton@GThornton_DevCore

	Disable reading of anything outside the pak file when in shipping builds

Change 2897053 on 2016/03/07 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1

	A few improvements to thread heartbeat thread:
	- Don't check for heartbeat in debug builds
	- Don't spawn the thread heartbeat thread for programs
	- Ignore stalls when exiting

Change 2898752 on 2016/03/08 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1

	Fixing race conditions when using malloc verify

Change 2899075 on 2016/03/08 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1

	UnrealPak will now accept hex values for p and q. Added the command line param to trust p and q.

Change 2899091 on 2016/03/08 by Steve.Robb@Dev-Core

	Fix for TQueue::Peek const-correctness.

Change 2902775 on 2016/03/10 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1

	Adding code to test signature keys.

Change 2905040 on 2016/03/11 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1

	TBigInt Multiply is now 30x faster

Change 2905218 on 2016/03/11 by Steve.Robb@Dev-Core

	New FCString::Strspn and FCString::Strcspn functions.

[CL 2921423 by Robert Manuszewski in Main branch]
2016-03-24 13:53:55 -04:00

190 lines
4.7 KiB
C#

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
using Tools.CrashReporter.CrashReportCommon;
using Tools.CrashReporter.CrashReportProcess.Properties;
namespace Tools.CrashReporter.CrashReportProcess
{
/// <summary>
/// A class to handle processing received crash reports for displaying on the website.
/// </summary>
partial class CrashReporterProcessServicer : ServiceBase
{
/// <summary>A class the handle detection of new reports.</summary>
public ReportWatcher Watcher = null;
/// <summary>A class to lazily process reports as they are detected.</summary>
public readonly List<ReportProcessor> Processors = new List<ReportProcessor>();
/// <summary>Current log file to write debug progress info to</summary>
public static LogWriter Log = null;
private static SlackWriter Slack = null;
public static StatusReporting StatusReporter = null;
/// <summary>Folder in which to store log files</summary>
static private string LogFolder = null;
/// <summary>
/// Write a status update to the event log.
/// </summary>
static public void WriteEvent( string Message )
{
if( Message != null && Message.Length > 2 )
{
Log.Print( "[STATUS] " + Message );
}
}
/// <summary>
/// Write a status update to the event log, from the MinidumpDiagnostics.
/// </summary>
static public void WriteMDD( string Message )
{
if( Message != null && Message.Length > 2 )
{
Log.Print( "[MDD ] " + Message );
}
}
/// <summary>
/// Write a status update to the event log, from the P4.
/// </summary>
static public void WriteP4( string Message )
{
if( Message != null && Message.Length > 2 )
{
Log.Print( "[P4 ] " + Message );
}
}
/// <summary>
/// Write a failure to the event log.
/// </summary>
static public void WriteFailure( string Message )
{
if( Message != null && Message.Length > 2 )
{
Log.Print( "[FAILED] " + Message );
}
}
/// <summary>
/// Write an exception message to the event log.
/// </summary>
static public void WriteException( string Message )
{
if( Message != null && Message.Length > 2 )
{
Log.Print( "[EXCEPT] " + Message );
StatusReporter.IncrementCount(StatusReportingConstants.ExceptionEvent);
}
}
/// <summary>
/// Write to Slack.
/// </summary>
static public void WriteSlack(string Message)
{
if (Message != null && Message.Length > 0)
{
Slack.Write(Message);
}
}
/// <summary>
/// Initialise all the components, and create an event log.
/// </summary>
public CrashReporterProcessServicer()
{
InitializeComponent();
var StartupPath = Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location );
LogFolder = Path.Combine( StartupPath, "Logs" );
}
/// <summary>
/// Start the service, and stop the service if there were any errors found.
/// </summary>
/// <param name="Arguments">Command line arguments (unused).</param>
protected override void OnStart( string[] Arguments )
{
// Create a log file for any start-up messages
Log = new LogWriter("CrashReportProcess", LogFolder);
Config.LoadConfig();
Slack = new SlackWriter
{
WebhookUrl = Config.Default.SlackWebhookUrl,
Channel = Config.Default.SlackChannel,
Username = Config.Default.SlackUsername,
IconEmoji = Config.Default.SlackEmoji
};
StatusReporter = new StatusReporting();
// Add directory watchers
Watcher = new ReportWatcher();
for (int ProcessorIndex = 0; ProcessorIndex < Config.Default.ProcessorThreadCount; ProcessorIndex++)
{
var Processor = new ReportProcessor(Watcher, ProcessorIndex);
Processors.Add(Processor);
}
StatusReporter.Start();
DateTime StartupTime = DateTime.UtcNow;
WriteEvent("Successfully started at " + StartupTime);
}
/// <summary>
/// Stop the service.
/// </summary>
protected override void OnStop()
{
// Clean up the directory watcher and crash processor threads
foreach (var Processor in Processors)
{
Processor.Dispose();
}
Processors.Clear();
Watcher.Dispose();
Watcher = null;
StatusReporter.Dispose();
StatusReporter = null;
Slack.Dispose();
Slack = null;
// Flush the log to disk
Log.Dispose();
Log = null;
}
/// <summary>
/// Run the service in debug mode. This spews all logging to the console rather than suppressing it.
/// </summary>
public void DebugRun()
{
OnStart( null );
Console.WriteLine( "Press enter to exit" );
Console.Read();
OnStop();
}
}
}