2 * Copyright (C) 2013 Freescale Semiconductor, Inc.
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:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
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
27 #include "FManDebugLogVisitor.h"
28 #include "NxMessageVisitor.h"
29 #include "NxMessage.h"
30 #include "FManDebugLog.h"
32 using std::ostringstream
;
39 FManDebugLogVisitor::FManDebugLogVisitor()
41 for (int i
= 0; i
< MAX_FMAN_LOGS
; i
++) {
42 log_
[i
] = new FManDebugLog();
43 log_
[i
]->setFManID(i
);
44 already_reported_
[i
] = false;
48 FManDebugLogVisitor::~FManDebugLogVisitor()
50 for (int i
= 0; i
< MAX_FMAN_LOGS
; i
++) {
55 void FManDebugLogVisitor::visit(NxDPFMInCircuitTraceMessage
*m
)
57 // select the correct log
58 int fmsel
= m
->getFmsel();
59 if ( fmsel
< 0 || fmsel
>= MAX_FMAN_LOGS
) {
62 FManDebugLog
*log
= log_
[fmsel
];
64 // if this is the first beat then reset the log
65 int beatcnt
= m
->getBtcnt();
67 already_reported_
[fmsel
] = false;
71 // capture the context data - always 4 words
72 const uint32_t *context
= m
->getContext();
73 for (int i
= 0; i
< 4; i
++) {
74 log
->addContextData(context
[i
]);
77 // begin parsing the log on the last beat
78 bool lastbeat
= m
->getLbeat();
80 log
->setLastContextData();
81 log
->parseContextData();
86 // output message information as a string
87 string
FManDebugLogVisitor::asString() const
91 for (int i
= 0; i
< MAX_FMAN_LOGS
; i
++) {
92 if (log_
[i
]->logComplete() && !already_reported_
[i
]) {
93 os
<< log_
[i
]->asString();
94 already_reported_
[i
] = true;