@@ -138,13 +138,33 @@ void ValgrindTreeDecoder::readRoot(
138
138
noteEvt.verbosityLevel = /* note */ 1 ;
139
139
}
140
140
141
+ // / read valgrind's message
142
+ std::string readMsg (const pt::ptree &defNode)
143
+ {
144
+ const pt::ptree *whatNode;
145
+ if (findChildOf (&whatNode, defNode, " what" ))
146
+ // message found in <what>...</what>
147
+ return whatNode->get_value <std::string>();
148
+
149
+ if (findChildOf (&whatNode, defNode, " xwhat" )
150
+ && findChildOf (&whatNode, *whatNode, " text" ))
151
+ // message found in <xwhat><text>...</text></xwhat>
152
+ return whatNode->get_value <std::string>();
153
+
154
+ // message not found
155
+ return " <unknown>" ;
156
+ }
157
+
141
158
bool ValgrindTreeDecoder::readNode (Defect *pDef, pt::ptree::const_iterator defIter)
142
159
{
143
160
static const std::string errorKey = " error" ;
144
161
if (errorKey != defIter->first )
145
162
// not a node we are interested in
146
163
return false ;
147
164
165
+ // the current "error" node representing a single valgrind's report
166
+ const pt::ptree &defNode = defIter->second ;
167
+
148
168
// initialize the defect structure
149
169
Defect &def = *pDef;
150
170
def = this ->defPrototype ;
@@ -153,9 +173,10 @@ bool ValgrindTreeDecoder::readNode(Defect *pDef, pt::ptree::const_iterator defIt
153
173
def.keyEventIdx = def.events .size ();
154
174
def.events .push_back (DefEvent (" warning" ));
155
175
DefEvent &keyEvent = def.events .back ();
176
+ keyEvent.fileName = " <unknown>" ;
177
+ keyEvent.msg = readMsg (defNode);
156
178
157
179
// read "kind" of the report
158
- const pt::ptree &defNode = defIter->second ;
159
180
pt::ptree::const_assoc_iterator itKind = defNode.find (" kind" );
160
181
if (defNode.not_found () != itKind)
161
182
keyEvent.event += " [" + itKind->second .get_value <std::string>() + " ]" ;
0 commit comments