2 * \file snapshot_parser.h
3 * \brief OpenCSD : Snapshot Parser Library
5 * \copyright Copyright (c) 2015, ARM Limited. All Rights Reserved.
9 * Redistribution and use in source and binary forms, with or without modification,
10 * are permitted provided that the following conditions are met:
12 * 1. Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
19 * 3. Neither the name of the copyright holder nor the names of its contributors
20 * may be used to endorse or promote products derived from this software without
21 * specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #ifndef ARM_SNAPSHOT_PARSER_H_INCLUDED
36 #define ARM_SNAPSHOT_PARSER_H_INCLUDED
46 #include "snapshot_parser_util.h"
47 #include "snapshot_info.h"
49 class ITraceErrorLog; // forward declare the OCSD error log interface.
53 //! \brief Stores a parsed [dump] section
65 //! \brief Stores the entire parsed device ini file
68 Parsed() : foundGlobal() {}
72 std::vector<DumpDef> dumpDefs;
74 std::string, // register value is stored as a string initially to cope with > 64 bit registers
75 Util::CaseInsensitiveLess> regDefs;
76 std::map<uint32_t, uint32_t> extendRegDefs;
77 std::string deviceName;
78 std::string deviceClass;
79 std::string deviceTypeName; // Cortex-Ax or ETMvN
83 /*! \brief Parse the device ini file and call back on the builder as appropriate.
84 * \param input the ini file
85 * \return parsed definitions
87 Parsed ParseSingleDevice(std::istream& input);
89 //! \brief Stores the entire device list
92 std::map<std::string, std::string> deviceList;
93 SnapshotInfo snapshotInfo;
94 std::string traceMetaDataName;
97 /*! \brief Parse the snapshot.ini file that contains the device list and call back on the builder as appropriate.
98 * \param input the ini file
99 * \return parsed definitions
101 ParsedDevices ParseDeviceList(std::istream& input);
103 // basic info about the buffer
104 struct TraceBufferInfo
106 std::string bufferName;
107 std::string dataFileName;
108 std::string dataFormat;
111 // list of buffers and associations as presented in the ini file.
114 std::vector<std::string> buffer_section_names;
115 std::vector<TraceBufferInfo> trace_buffers;
116 std::map<std::string, std::string> source_buffer_assoc; // trace source name -> trace buffer name assoc
117 std::map<std::string, std::string> cpu_source_assoc; // trace source name -> cpu_name assoc
120 // single buffer information containing just the assoc for the buffer
121 // -> created by processing the ini data for a single named buffer.
122 // this can then be used to create a decode tree in the decode library.
123 struct TraceBufferSourceTree
125 TraceBufferInfo buffer_info;
126 std::map<std::string, std::string> source_core_assoc; // list of source names attached to core device names (e.g. ETM_0:cpu_0)
129 // parse the trace metadata ini file.
130 ParsedTrace ParseTraceMetaData(std::istream& input);
132 // build a source tree for a single buffer
133 bool ExtractSourceTree(const std::string &buffer_name, ParsedTrace &metadata, TraceBufferSourceTree &buffer_data);
135 std::vector<std::string> GetBufferNameList(ParsedTrace &metadata);
138 static ITraceErrorLog *s_pErrorLogger = 0;
139 static ocsd_hndl_err_log_t s_errlog_handle = 0;
140 static bool s_verbose_logging = true;
142 void SetIErrorLogger(ITraceErrorLog *i_err_log);
143 void SetVerboseLogging(bool verbose);
144 ITraceErrorLog *GetIErrorLogger();
145 void LogInfoStr(const std::string &logMsg);
150 #endif // ARM_SNAPSHOT_PARSER_H_INCLUDED
152 /* End of File snapshot_parser.h */