-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathPerfMarkerAtpFile.h
134 lines (114 loc) · 5.4 KB
/
PerfMarkerAtpFile.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//==============================================================================
// Copyright (c) 2015 Advanced Micro Devices, Inc. All rights reserved.
/// \author AMD Developer Tools Team
/// \file
/// \brief PerfMarker Atp File writer and parser
//==============================================================================
#ifndef _PERF_MARKER_ATP_FILE_H_
#define _PERF_MARKER_ATP_FILE_H_
// common
#include <AMDTOSWrappers/Include/osOSDefinitions.h>
// profiler common
#include <ProfilerOutputFileDefs.h>
#include "AtpFile.h"
//------------------------------------------------------------------------------------
/// PerfMarker Entry
//------------------------------------------------------------------------------------
class PerfMarkerEntry
{
public:
/// Perf Marker entry type
enum PerfMarkerType
{
PerfMarkerType_Begin = 0, ///< Begin Perf Marker
PerfMarkerType_End = 1, ///< End Perf Marker
PerfMarkerType_EndEx = 2 ///< End Ex Perf Marker
};
/// Constructor
/// \param markerType the type of perf marker entry
/// \param timestamp the timestamp for the perf marker entry
/// \param tid the thread id for the perf marker entry
PerfMarkerEntry(PerfMarkerType markerType, ULONGLONG timestamp, osThreadId tid) : m_markerType(markerType), m_timestamp(timestamp), m_tid(tid) {}
/// Destructor
virtual ~PerfMarkerEntry() {}
PerfMarkerType m_markerType; ///< Type of perf marker
ULONGLONG m_timestamp; ///< Timestamp
osThreadId m_tid; ///< Thread ID
};
//------------------------------------------------------------------------------------
/// PerfMarker Begin Entry
//------------------------------------------------------------------------------------
class PerfMarkerBeginEntry : public PerfMarkerEntry
{
public:
/// Constructor
/// \param markerType the type of perf marker entry
/// \param timestamp the timestamp for the perf marker entry
/// \param tid the thread id for the perf marker entry
/// \param strName Marker name
/// \param strGroup Group name
PerfMarkerBeginEntry(PerfMarkerType markerType, ULONGLONG timestamp, osThreadId tid, const std::string& strName, const std::string& strGroup) :
PerfMarkerEntry(markerType, timestamp, tid), m_strName(strName), m_strGroup(strGroup) {}
std::string m_strName; ///< Marker name
std::string m_strGroup; ///< Group name
};
//------------------------------------------------------------------------------------
/// PerfMarker End Ex Entry
//------------------------------------------------------------------------------------
class PerfMarkerEndExEntry : public PerfMarkerEntry
{
public:
/// Constructor
/// \param markerType the type of perf marker entry
/// \param timestamp the timestamp for the perf marker entry
/// \param tid the thread id for the perf marker entry
/// \param strName Marker name
/// \param strGroup Group name
PerfMarkerEndExEntry(PerfMarkerType markerType, ULONGLONG timestamp, osThreadId tid, const std::string& strName, const std::string& strGroup) :
PerfMarkerEntry(markerType, timestamp, tid), m_strName(strName), m_strGroup(strGroup) {}
std::string m_strName; ///< Marker name
std::string m_strGroup; ///< Group name
};
//------------------------------------------------------------------------------------
/// cl perfmarker trace result
//------------------------------------------------------------------------------------
class PerfMarkerAtpFilePart : public IAtpFilePart, public IAtpFilePartParser, public BaseParser<PerfMarkerEntry>
{
public:
/// Constructor
/// \param config Config object
PerfMarkerAtpFilePart(const Config& config, bool shouldReleaseMemory = true) : IAtpFilePart(config, shouldReleaseMemory)
{
m_strPartName = PERFMARKER_PART_NAME;
m_sections.push_back(ATP_PERFMARKER_SECTION_NAME);
m_sections.push_back(ATP_PERFMARKER_SECTION_NAME_PREV); // add this section for backward compatibility -- this allows us to parse a file created with older versions of the ActivityLogger
m_sections.push_back(CODEXL_STR ATP_PERFMARKER_SECTION_NAME); // add for before CodeXL 2.3
}
/// Write header section
/// If a AptFilePart wants to output to header section, implement this method
/// \param sout Output stream
void WriteHeaderSection(SP_fileStream& sout)
{
SP_UNREFERENCED_PARAMETER(sout);
}
/// Write content section
/// \param sout Output stream
/// \param strTmpFilePath Output fragment files path
/// \param strPID child process ID
/// \return true if any contents were written, false otherwise
bool WriteContentSection(SP_fileStream& sout, const std::string& strTmpFilePath, const std::string& strPID);
/// Save atp file part into a separate file (Called only in compatibility mode)
/// \param strTmpFilePath Output fragment files path
/// \param strPID child process ID
void SaveToFile(const std::string& strTmpFilePath, const std::string& strPID);
/// Parse input stream
/// \param in Input stream
/// \return True if succeeded
bool Parse(std::istream& in, std::string& outErrorMsg) override;
/// Parse header
/// \param strKey Key name
/// \param strVal Value
/// \return True if succeeded
bool ParseHeader(const std::string& strKey, const std::string& strVal);
};
#endif // _PERF_MARKER_ATP_FILE_H_