Skip to content

Commit

Permalink
Merge dev and bombomby master
Browse files Browse the repository at this point in the history
  • Loading branch information
s.makeev_local committed Oct 17, 2016
1 parent 199c08c commit 466ca93
Show file tree
Hide file tree
Showing 25 changed files with 3,818 additions and 3,695 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ Brofiler/obj/
Build/
*.suo
*.user
Publish/
Publish/
*.rej
*.orig
3 changes: 2 additions & 1 deletion BrofilerCore/Brofiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@

#if defined(BRO_WINDOWS)
#define USE_BROFILER_SAMPLING (USE_BROFILER && !BRO_UWP)
#define USE_BROFILER_ETW (USE_BROFILER /*&& !BRO_UWP*/)
#endif



#if USE_BROFILER
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// EXPORTS
Expand Down
45 changes: 36 additions & 9 deletions BrofilerCore/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ void Core::CleanupThreads()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Core::Core() : progressReportedLastTimestampMS(0), isActive(false)
{
schedulerTracer = ISchedulerTracer::Get();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Core::Update()
Expand Down Expand Up @@ -222,6 +223,38 @@ void Core::UpdateEvents()

Server::Get().Update();
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Core::ReportSwitchContext(const SwitchContextDesc& desc)
{
BRO_UNUSED(desc.reason);

for (size_t i = 0; i < threads.size(); ++i)
{
ThreadEntry* entry = threads[i];

if (entry->description.threadID.AsUInt64() == desc.oldThreadId)
{
if (SyncData* time = entry->storage.synchronizationBuffer.Back())
{
time->finish = desc.timestamp;
}
}

if (entry->description.threadID.AsUInt64() == desc.newThreadId)
{
SyncData& time = entry->storage.synchronizationBuffer.Add();
time.start = desc.timestamp;
time.finish = time.start;
time.core = desc.cpuId;
}
}


}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Core::StartSampling()
{
Expand Down Expand Up @@ -250,18 +283,12 @@ void Core::Activate( bool active )

if (active)
{
#if USE_BROFILER_ETW
EtwStatus status = etw.Start();
#else
EtwStatus status = ETW_OK;
#endif
SchedulerTraceStatus::Type status = schedulerTracer->Start();
SendHandshakeResponse(status);
}
else
{
#if USE_BROFILER_ETW
etw.Stop();
#endif
schedulerTracer->Stop();
}
}

Expand All @@ -287,7 +314,7 @@ bool Core::IsTimeToReportProgress() const
return MT::GetTimeMilliSeconds() > progressReportedLastTimestampMS + 200;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Core::SendHandshakeResponse(EtwStatus status)
void Core::SendHandshakeResponse(SchedulerTraceStatus::Type status)
{
OutputDataStream stream;
stream << (uint32)status;
Expand Down
23 changes: 17 additions & 6 deletions BrofilerCore/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "Serialization.h"
#include "MemoryPool.h"
#include "Sampler.h"
#include "Tracer.h"
#include "SchedulerTrace/ISchedulerTrace.h"
//#include "Graphics.h"
#include <map>

Expand Down Expand Up @@ -109,6 +109,16 @@ struct ThreadEntry
void Activate(bool isActive);
};

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct SwitchContextDesc
{
int64_t timestamp;
uint64 oldThreadId;
uint64 newThreadId;
uint8 cpuId;
uint8 reason;
};


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef std::vector<ThreadEntry*> ThreadList;
Expand Down Expand Up @@ -136,7 +146,7 @@ class Core
static Core notThreadSafeInstance;

void DumpCapturingProgress();
void SendHandshakeResponse(EtwStatus status);
void SendHandshakeResponse(SchedulerTraceStatus::Type status);

void DumpThread(const ThreadEntry& entry, const EventTime& timeSlice, ScopeData& scope);

Expand All @@ -156,14 +166,15 @@ class Core
// Controls GPU activity
// Graphics graphics;

#if USE_BROFILER_ETW
// Event Trace for Windows interface
ETW etw;
#endif
// System scheduler trace
ISchedulerTracer* schedulerTracer;

// Returns thread collection
const std::vector<ThreadEntry*>& GetThreads() const;

// Report switch context event
void ReportSwitchContext(const SwitchContextDesc& desc);

// Starts sampling process
void StartSampling();

Expand Down
10 changes: 0 additions & 10 deletions BrofilerCore/EtwStatus.h

This file was deleted.

28 changes: 28 additions & 0 deletions BrofilerCore/SchedulerTrace/ISchedulerTrace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

namespace Brofiler
{

namespace SchedulerTraceStatus
{
enum Type
{
OK = 0,
ERR_ALREADY_EXISTS = 1,
ERR_ACCESS_DENIED = 2,
FAILED = 3,
};
}


struct ISchedulerTracer
{
virtual ~ISchedulerTracer() {};

virtual SchedulerTraceStatus::Type Start() = 0;
virtual bool Stop() = 0;

static ISchedulerTracer* Get();
};

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#ifdef _WIN32

#if USE_BROFILER_ETW

#define INITGUID // Causes definition of SystemTraceControlGuid in evntrace.h.
#include <strsafe.h>
Expand Down Expand Up @@ -94,5 +94,6 @@ typedef struct _EVENT_RECORD {
#endif
///////////////////////////////////////////////////////////////////////////////

#endif


#endif
Loading

0 comments on commit 466ca93

Please sign in to comment.