1 /* 2 * \file snapshot_reader.h 3 * \brief OpenCSD : Snapshot Parser Library 4 * 5 * \copyright Copyright (c) 2015, ARM Limited. All Rights Reserved. 6 */ 7 8 9 /* 10 * Redistribution and use in source and binary forms, with or without modification, 11 * are permitted provided that the following conditions are met: 12 * 13 * 1. Redistributions of source code must retain the above copyright notice, 14 * this list of conditions and the following disclaimer. 15 * 16 * 2. Redistributions in binary form must reproduce the above copyright notice, 17 * this list of conditions and the following disclaimer in the documentation 18 * and/or other materials provided with the distribution. 19 * 20 * 3. Neither the name of the copyright holder nor the names of its contributors 21 * may be used to endorse or promote products derived from this software without 22 * specific prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND 25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 27 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 */ 35 36 #ifndef ARM_SNAPSHOT_READER_H_INCLUDED 37 #define ARM_SNAPSHOT_READER_H_INCLUDED 38 39 #include <string> 40 #include <vector> 41 42 #include "snapshot_parser.h" 43 44 class ITraceErrorLog; 45 46 class SnapShotReader 47 { 48 public: 49 SnapShotReader(); 50 ~SnapShotReader(); 51 52 void setSnapshotDir(const std::string &dir); getSnapShotDir()53 const std::string &getSnapShotDir() const { return m_snapshotPath; }; 54 55 const bool readSnapShot(); // read the snapshot dir 56 57 // true if the snapshot ini file can be found on the path. snapshotFound()58 const bool snapshotFound() const { return m_snapshot_found; }; 59 snapshotReadOK()60 const bool snapshotReadOK() const { return m_read_ok; }; 61 62 void setErrorLogger(ITraceErrorLog *err_log); setVerboseOutput(const bool bVerbose)63 void setVerboseOutput(const bool bVerbose) { m_verbose = bVerbose; }; 64 65 bool getSourceBufferNameList(std::vector<std::string> &nameList); 66 bool getTraceBufferSourceTree(const std::string &traceBufferName, Parser::TraceBufferSourceTree &sourceTree); 67 68 bool getDeviceData(const std::string &deviceName, Parser::Parsed **devData); 69 70 private: 71 void checkPath(); // see if the ini file can be opened on the current path 72 void LogInfo(const std::string &msg); 73 void LogError(const std::string &msg); 74 75 76 std::string m_snapshotPath; // snapshot directory - default to cwd. 77 bool m_snapshot_found; // true if the path supplied can be opened. 78 ITraceErrorLog *m_i_err_log; 79 ocsd_hndl_err_log_t m_errlog_handle; 80 bool m_verbose; // true for verbose output. 81 bool m_read_ok; 82 83 // list of parsed device ini files, mapped by device name . 84 // <device_name (ETM_0 | cpu_0)> : { <parsed_device_data> } 85 std::map<std::string, Parser::Parsed> m_parsed_device_list; 86 87 Parser::ParsedTrace m_parsed_trace; // the parsed trace meta data 88 89 // trace metadata rearranged as source trees, mapped by source name 90 // <source_buffer_name> : { buffer_info, {<ETM_0:cpu_0>,....} } 91 std::map<std::string, Parser::TraceBufferSourceTree> m_source_trees; 92 }; 93 94 // the top level snapshot file name. 95 const char* const SnapshotINIFilename("snapshot.ini"); 96 97 #endif // ARM_SNAPSHOT_READER_H_INCLUDED 98 99 /* End of File snapshot_reader.h */ 100