summaryrefslogtreecommitdiffstats
path: root/decoder/tests/snapshot_parser_lib/include/ss_to_dcdtree.h
blob: 3c85f9d152dac5121e3f78cdf8cc75c7303bdd6c (plain)
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
/*
 * \file       ss_to_dcdtree.h
 * \brief      OpenCSD : Create a decode tree given a snapshot database.
 * 
 * \copyright  Copyright (c) 2015, ARM Limited. All Rights Reserved.
 */

/* 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice, 
 * this list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form must reproduce the above copyright notice, 
 * this list of conditions and the following disclaimer in the documentation 
 * and/or other materials provided with the distribution. 
 * 
 * 3. Neither the name of the copyright holder nor the names of its contributors 
 * may be used to endorse or promote products derived from this software without 
 * specific prior written permission. 
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND 
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */ 

#ifndef ARM_SS_TO_DCDTREE_H_INCLUDED
#define ARM_SS_TO_DCDTREE_H_INCLUDED

#include <string>

#include "opencsd.h"
#include "snapshot_parser.h"
#include "snapshot_reader.h"

class DecodeTree;
class ITraceErrorLog;

class CreateDcdTreeFromSnapShot
{
public:
    CreateDcdTreeFromSnapShot();
    ~CreateDcdTreeFromSnapShot();
    
    void initialise(SnapShotReader *m_pReader, ITraceErrorLog *m_pErrLogInterface);

    bool createDecodeTree(const std::string &SourceBufferName, bool bPacketProcOnly, uint32_t add_create_flags = 0);
    void destroyDecodeTree();
    DecodeTree *getDecodeTree() const { return m_pDecodeTree; };
    const char *getBufferFileName() const { return m_BufferFileName.c_str(); };

    // TBD: add in filters for ID list, first ID found.

private:
    // create a decoder related to a core source (ETM, PTM)
    bool createPEDecoder(const std::string &coreName, Parser::Parsed *devSrc);
    // protocol specific core source decoders
    bool createETMv4Decoder(const std::string &coreName, Parser::Parsed *devSrc, const bool bDataChannel = false);
    bool createETMv3Decoder(const std::string &coreName, Parser::Parsed *devSrc);
    bool createPTMDecoder(const std::string &coreName, Parser::Parsed *devSrc);
    bool createETEDecoder(const std::string &coreName, Parser::Parsed *devSrc);
    // TBD add etmv4d

    // create a decoder related to a software trace source (ITM, STM)
    bool createSTDecoder(Parser::Parsed *devSrc);
    // protocol specific decoders
    bool createSTMDecoder(Parser::Parsed *devSrc);

    typedef struct _regs_to_access {
        const char *pszName;
        bool failIfMissing;
        uint32_t *value;
        uint32_t val_default;
    } regs_to_access_t;

    bool getRegisters(std::map<std::string, std::string, Util::CaseInsensitiveLess> &regDefs, int numRegs, regs_to_access_t *reg_access_array);
    bool getRegByPrefix(std::map<std::string, std::string, Util::CaseInsensitiveLess> &regDefs, 
                        regs_to_access_t &reg_accessor);
    bool getCoreProfile(const std::string &coreName, ocsd_arch_version_t &arch_ver, ocsd_core_profile_t &core_prof);

    void LogError(const std::string &msg);
    void LogError(const ocsdError &err);

    void processDumpfiles(std::vector<Parser::DumpDef> &dumps);


    uint32_t m_add_create_flags;

    bool m_bInit;
    DecodeTree *m_pDecodeTree;
    SnapShotReader *m_pReader;
    ITraceErrorLog *m_pErrLogInterface;
    ocsd_hndl_err_log_t m_errlog_handle;

    bool m_bPacketProcOnly;
    std::string m_BufferFileName;

    CoreArchProfileMap m_arch_profiles;
};


#endif // ARM_SS_TO_DCDTREE_H_INCLUDED

/* End of File ss_to_dcdtree.h */