Add Freescale Nexus decoder implementation
[babeltrace.git] / converter / nexus / FullAddressVisitor.cpp
1 /*
2 * Copyright (C) 2013 Freescale Semiconductor, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 * IN THE SOFTWARE.
21 */
22
23 #include <inttypes.h>
24 #include <sstream>
25 #include <iomanip>
26
27 #include "FullAddressVisitor.h"
28 #include "NxMessage.h"
29
30 using std::ostringstream;
31 using std::endl;
32 using std::hex;
33 using std::dec;
34 using std::setfill;
35 using std::setw;
36
37 // implement the specific visit
38 void FullAddressVisitor::visit(NxProgramTraceSync *m)
39 {
40 last_key_ = m->sourceIdString();
41 mismatch_addr_ = source_addr_[last_key_];
42 data_mismatch_ = (m->address() != mismatch_addr_);
43 source_addr_[last_key_] = m->address();
44 useful_visit_ = true;
45 }
46
47 // implement the specific visit
48 void FullAddressVisitor::visit(NxProgramTraceIndirectBranch *m)
49 {
50 last_key_ = m->sourceIdString();
51 source_addr_[last_key_] ^= m->address();
52 useful_visit_ = true;
53 }
54
55 // implement the specific visit
56 void FullAddressVisitor::visit(NxProgramTraceIndirectBranchSync *m)
57 {
58 last_key_ = m->sourceIdString();
59 mismatch_addr_ = source_addr_[last_key_];
60 data_mismatch_ = (m->address() != mismatch_addr_);
61 source_addr_[last_key_] = m->address();
62 useful_visit_ = true;
63 }
64 // implement the specific visit
65 void FullAddressVisitor::visit(NxDAMInCircuitTraceMessage *m)
66 {
67 // source_addr_[m->sourceIdString()] = m->address();
68 // useful_visit_ = true;
69 }
70
71 // implement the specific visit
72 void FullAddressVisitor::visit(NxCDMInCircuitTraceMessage *m)
73 {
74 // source_addr_[m->sourceIdString()] = m->address();
75 // useful_visit_ = true;
76 }
77
78 // implement the specific visit
79 void FullAddressVisitor::visit(NxCAMInCircuitTraceMessage *m)
80 {
81 // source_addr_[m->sourceIdString()] = m->address();
82 // useful_visit_ = true;
83 }
84
85 // output message information as a string
86 string FullAddressVisitor::asString() const
87 {
88 ostringstream os;
89
90 if (useful_visit_) {
91 map<string, SizedAddress>::const_iterator i =
92 source_addr_.find(last_key_);
93 os << "-----------UNCOMPRESSED ADDRESS-----------" << endl;
94 if (i != source_addr_.end()) {
95 os << "SRC : " << last_key_ << endl;
96 os << "F-ADDR : " << i->second.asString() << endl;
97 if (data_mismatch_) {
98 os << "Warning: Sync Address differs from calculated Address" << endl;
99 os << "CALC ADDR : " << mismatch_addr_.asString() << endl;
100 data_mismatch_ = false;
101 }
102 } else {
103 os << "ERROR resolving address source" << endl;
104 }
105 os << endl;
106 }
107
108 return os.str();
109 }
This page took 0.033039 seconds and 4 git commands to generate.