• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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);
56     void destroyDecodeTree();
getDecodeTree()57     DecodeTree *getDecodeTree() const { return m_pDecodeTree; };
getBufferFileName()58     const char *getBufferFileName() const { return m_BufferFileName.c_str(); };
59 
60     // TBD: add in filters for ID list, first ID found.
61 
62 private:
63     // create a decoder related to a core source (ETM, PTM)
64     bool createPEDecoder(const std::string &coreName, Parser::Parsed *devSrc);
65     // protocol specific core source decoders
66     bool createETMv4Decoder(const std::string &coreName, Parser::Parsed *devSrc, const bool bDataChannel = false);
67     bool createETMv3Decoder(const std::string &coreName, Parser::Parsed *devSrc);
68     bool createPTMDecoder(const std::string &coreName, Parser::Parsed *devSrc);
69     // TBD add etmv4d
70 
71     // create a decoder related to a software trace source (ITM, STM)
72     bool createSTDecoder(Parser::Parsed *devSrc);
73     // protocol specific decoders
74     bool createSTMDecoder(Parser::Parsed *devSrc);
75 
76     typedef struct _regs_to_access {
77         const char *pszName;
78         bool failIfMissing;
79         uint32_t *value;
80         uint32_t val_default;
81     } regs_to_access_t;
82 
83     bool getRegisters(std::map<std::string, std::string, Util::CaseInsensitiveLess> &regDefs, int numRegs, regs_to_access_t *reg_access_array);
84     bool getRegByPrefix(std::map<std::string, std::string, Util::CaseInsensitiveLess> &regDefs,
85                         regs_to_access_t &reg_accessor);
86     bool getCoreProfile(const std::string &coreName, ocsd_arch_version_t &arch_ver, ocsd_core_profile_t &core_prof);
87 
88     void LogError(const std::string &msg);
89     void LogError(const ocsdError &err);
90 
91     void processDumpfiles(std::vector<Parser::DumpDef> &dumps);
92 
93 
94 
95 
96     bool m_bInit;
97     DecodeTree *m_pDecodeTree;
98     SnapShotReader *m_pReader;
99     ITraceErrorLog *m_pErrLogInterface;
100     ocsd_hndl_err_log_t m_errlog_handle;
101 
102     bool m_bPacketProcOnly;
103     std::string m_BufferFileName;
104 
105     CoreArchProfileMap m_arch_profiles;
106 };
107 
108 
109 #endif // ARM_SS_TO_DCDTREE_H_INCLUDED
110 
111 /* End of File ss_to_dcdtree.h */
112