1 /* 2 * \file ss_to_dcdtree.h 3 * \brief OpenCSD : Create a decode tree given a snapshot database. 4 * 5 * \copyright Copyright (c) 2015, ARM Limited. All Rights Reserved. 6 */ 7 8 /* 9 * Redistribution and use in source and binary forms, with or without modification, 10 * are permitted provided that the following conditions are met: 11 * 12 * 1. Redistributions of source code must retain the above copyright notice, 13 * this list of conditions and the following disclaimer. 14 * 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. 18 * 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. 22 * 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. 33 */ 34 35 #ifndef ARM_SS_TO_DCDTREE_H_INCLUDED 36 #define ARM_SS_TO_DCDTREE_H_INCLUDED 37 38 #include <string> 39 40 #include "opencsd.h" 41 #include "snapshot_parser.h" 42 #include "snapshot_reader.h" 43 44 class DecodeTree; 45 class ITraceErrorLog; 46 47 class CreateDcdTreeFromSnapShot 48 { 49 public: 50 CreateDcdTreeFromSnapShot(); 51 ~CreateDcdTreeFromSnapShot(); 52 53 void initialise(SnapShotReader *m_pReader, ITraceErrorLog *m_pErrLogInterface); 54 55 bool createDecodeTree(const std::string &SourceBufferName, bool bPacketProcOnly, uint32_t add_create_flags = 0); 56 void destroyDecodeTree(); getDecodeTree()57 DecodeTree *getDecodeTree() const { return m_pDecodeTree; }; getBufferFileName()58 const char *getBufferFileName() const { return m_BufferFileName.c_str(); }; 59 std::string getBufferFileNameFromBuffName(const std::string& buff_name); 60 61 // TBD: add in filters for ID list, first ID found. 62 63 private: 64 // create a decoder related to a core source (ETM, PTM) 65 bool createPEDecoder(const std::string &coreName, Parser::Parsed *devSrc); 66 // protocol specific core source decoders 67 bool createETMv4Decoder(const std::string &coreName, Parser::Parsed *devSrc, const bool bDataChannel = false); 68 bool createETMv3Decoder(const std::string &coreName, Parser::Parsed *devSrc); 69 bool createPTMDecoder(const std::string &coreName, Parser::Parsed *devSrc); 70 bool createETEDecoder(const std::string &coreName, Parser::Parsed *devSrc); 71 // TBD add etmv4d 72 73 // create a decoder related to a software trace source (ITM, STM) 74 bool createSTDecoder(Parser::Parsed *devSrc); 75 // protocol specific decoders 76 bool createSTMDecoder(Parser::Parsed *devSrc); 77 78 typedef struct _regs_to_access { 79 const char *pszName; 80 bool failIfMissing; 81 uint32_t *value; 82 uint32_t val_default; 83 } regs_to_access_t; 84 85 bool getRegisters(std::map<std::string, std::string, Util::CaseInsensitiveLess> ®Defs, int numRegs, regs_to_access_t *reg_access_array); 86 bool getRegByPrefix(std::map<std::string, std::string, Util::CaseInsensitiveLess> ®Defs, 87 regs_to_access_t ®_accessor); 88 bool getCoreProfile(const std::string &coreName, ocsd_arch_version_t &arch_ver, ocsd_core_profile_t &core_prof); 89 90 void LogError(const std::string &msg); 91 void LogError(const ocsdError &err); 92 93 ocsd_mem_space_acc_t getMemSpaceFromString(const std::string& memspace); 94 ocsd_err_t processDumpfiles(std::vector<Parser::DumpDef> &dumps); 95 96 97 uint32_t m_add_create_flags; 98 99 bool m_bInit; 100 DecodeTree *m_pDecodeTree; 101 SnapShotReader *m_pReader; 102 ITraceErrorLog *m_pErrLogInterface; 103 ocsd_hndl_err_log_t m_errlog_handle; 104 105 bool m_bPacketProcOnly; 106 std::string m_BufferFileName; 107 108 CoreArchProfileMap m_arch_profiles; 109 }; 110 111 112 #endif // ARM_SS_TO_DCDTREE_H_INCLUDED 113 114 /* End of File ss_to_dcdtree.h */ 115