Add simple xml debug output. When both --xml and --debug is used there will be xml debug output.
This commit is contained in:
parent
40030ce27c
commit
954400a382
|
@ -2074,6 +2074,20 @@ void SymbolDatabase::printOut(const char *title) const
|
|||
}
|
||||
}
|
||||
|
||||
void SymbolDatabase::printXml() const
|
||||
{
|
||||
// Scopes..
|
||||
for (std::list<Scope>::const_iterator scope = scopeList.begin(); scope != scopeList.end(); ++scope) {
|
||||
std::cout << "<scope";
|
||||
std::cout << " id=\"" << &*scope << "\"";
|
||||
std::cout << " type=\"" << scope->type << "\"";
|
||||
if (!scope->className.empty())
|
||||
std::cout << " className=\"" << scope->className << "\"";
|
||||
std::cout << " nestedIn=\"" << scope->nestedIn << "\"";
|
||||
std::cout << "/>" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *scope)
|
||||
|
|
|
@ -836,6 +836,7 @@ public:
|
|||
|
||||
void printOut(const char * title = NULL) const;
|
||||
void printVariable(const Variable *var, const char *indent) const;
|
||||
void printXml() const;
|
||||
|
||||
bool isCPP() const;
|
||||
|
||||
|
|
|
@ -1083,17 +1083,42 @@ std::string Token::expressionString() const
|
|||
|
||||
}
|
||||
|
||||
void Token::printAst(bool verbose) const
|
||||
static std::string astStringXml(const Token *tok, std::size_t indent)
|
||||
{
|
||||
const std::string strindent(indent, ' ');
|
||||
|
||||
if (!tok->astOperand1() && !tok->astOperand2()) {
|
||||
std::ostringstream ret;
|
||||
ret << strindent << "<token text=\"" << tok->str() << "\"";
|
||||
if (tok->varId() > 0U)
|
||||
ret << " varId=\"" << MathLib::toString(tok->varId()) << "\"";
|
||||
ret << "/>";
|
||||
return ret.str();
|
||||
}
|
||||
|
||||
std::string ret = strindent + "<token text=\"" + tok->str() + "\">\n";
|
||||
if (tok->astOperand1())
|
||||
ret += astStringXml(tok->astOperand1(),indent+2U) + '\n';
|
||||
if (tok->astOperand2())
|
||||
ret += astStringXml(tok->astOperand2(),indent+2U) + '\n';
|
||||
return ret + strindent + "</token>";
|
||||
}
|
||||
|
||||
void Token::printAst(bool verbose, bool xml) const
|
||||
{
|
||||
bool title = false;
|
||||
|
||||
bool print = true;
|
||||
for (const Token *tok = this; tok; tok = tok->next()) {
|
||||
if (print && tok->_astOperand1) {
|
||||
if (!title)
|
||||
if (!title && !xml)
|
||||
std::cout << "\n\n##AST" << std::endl;
|
||||
title = true;
|
||||
if (verbose)
|
||||
if (xml) {
|
||||
std::cout << "<ast scope=\"" << tok->scope() << "\">" << std::endl;
|
||||
std::cout << astStringXml(tok->astTop(), 2U) << std::endl;
|
||||
std::cout << "</ast>" << std::endl;
|
||||
} else if (verbose)
|
||||
std::cout << tok->astTop()->astStringVerbose(0,0) << std::endl;
|
||||
else
|
||||
std::cout << tok->astTop()->astString(" ") << std::endl;
|
||||
|
|
|
@ -811,7 +811,7 @@ public:
|
|||
|
||||
std::string expressionString() const;
|
||||
|
||||
void printAst(bool verbose) const;
|
||||
void printAst(bool verbose, bool xml) const;
|
||||
|
||||
void printValueFlow() const;
|
||||
};
|
||||
|
|
|
@ -3738,10 +3738,20 @@ void Tokenizer::printDebugOutput() const
|
|||
if (_settings->debug) {
|
||||
list.front()->printOut(0, list.getFiles());
|
||||
|
||||
if (_settings->_verbose && _symbolDatabase)
|
||||
_symbolDatabase->printOut("Symbol database");
|
||||
if (_settings->_xml)
|
||||
std::cout << "<dump>" << std::endl;
|
||||
|
||||
list.front()->printAst(_settings->_verbose);
|
||||
if (_symbolDatabase) {
|
||||
if (_settings->_xml)
|
||||
_symbolDatabase->printXml();
|
||||
else if (_settings->_verbose)
|
||||
_symbolDatabase->printOut("Symbol database");
|
||||
}
|
||||
|
||||
list.front()->printAst(_settings->_verbose, _settings->_xml);
|
||||
|
||||
if (_settings->_xml)
|
||||
std::cout << "</dump>" << std::endl;
|
||||
|
||||
list.front()->printValueFlow();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue