75 #include <xercesc/sax/ErrorHandler.hpp> 77 #include <xercesc/util/XMLString.hpp> 78 using XERCES_CPP_NAMESPACE::XMLString;
210 m_structure(structure),
213 elemStructure(XMLString::transcode(
"HPCToolkitStructure")),
214 elemLM(XMLString::transcode(
"LM")),
215 elemVariable(XMLString::transcode(
"V")),
216 elemFile(XMLString::transcode(
"F")),
217 elemProc(XMLString::transcode(
"P")),
218 elemAlien(XMLString::transcode(
"A")),
219 elemLoop(XMLString::transcode(
"L")),
220 elemStmt(XMLString::transcode(
"S")),
221 elemGroup(XMLString::transcode(
"G")),
224 attrVer(XMLString::transcode(
"version")),
225 attrId(XMLString::transcode(
"i")),
226 attrName(XMLString::transcode(
"n")),
227 attrFile(XMLString::transcode(
"f")),
228 attrLnName(XMLString::transcode(
"ln")),
229 attrLine(XMLString::transcode(
"l")),
230 attrVMA(XMLString::transcode(
"v"))
247 XMLString::release((XMLCh**)&
elemLM);
249 XMLString::release((XMLCh**)&
elemFile);
250 XMLString::release((XMLCh**)&
elemProc);
252 XMLString::release((XMLCh**)&
elemLoop);
253 XMLString::release((XMLCh**)&
elemStmt);
257 XMLString::release((XMLCh**)&
attrVer);
258 XMLString::release((XMLCh**)&
attrId);
259 XMLString::release((XMLCh**)&
attrName);
260 XMLString::release((XMLCh**)&
attrFile);
262 XMLString::release((XMLCh**)&
attrLine);
263 XMLString::release((XMLCh**)&
attrVMA);
265 DIAG_AssertWarn(
scopeStack.
Depth() == 0,
"Invalid state reading HPCStructure.");
271 const XMLCh*
const name,
273 const XERCES_CPP_NAMESPACE::Attributes& attributes)
284 PGM_Throw(
"Found file format version " <<
m_version <<
": This format is outdated; please regenerate the file.");
294 else if (XMLString::equals(name,
elemLM)) {
309 else if (XMLString::equals(name,
elemFile)) {
333 variable->
m_origId = atoi(
id.c_str());
344 else if (XMLString::equals(name,
elemProc)) {
355 DIAG_Assert(
m_curLM &&
m_curFile && !
m_curProc,
"Parse error: Support for nested procedures is disabled (cf. buildLMSkeleton())!");
383 DIAG_Msg(0,
"Warning: Found procedure '" << nm <<
"' multiple times within file '" <<
m_curFile->
name() <<
"'; information for this procedure will be aggregated. If you do not want this, edit the STRUCTURE file and adjust the names by hand.");
394 else if (XMLString::equals(name,
elemAlien)) {
395 int numAttr = attributes.getLength();
411 alien->
m_origId = atoi(node_id.c_str());
413 DIAG_DevMsgIf(
DBG,
"PGMDocHandler: " << alien->
toStringMe());
419 else if (XMLString::equals(name,
elemLoop)) {
423 int numAttr = attributes.getLength();
437 loopNode->
m_origId = atoi(node_id.c_str());
439 DIAG_DevMsgIf(
DBG,
"PGMDocHandler: " << loopNode->
toStringMe());
445 else if (XMLString::equals(name,
elemStmt)) {
446 int numAttr = attributes.getLength();
455 DIAG_Assert(begLn == endLn,
"S line range [" << begLn <<
", " << endLn <<
"]");
468 stmtNode->
m_origId = atoi(node_id.c_str());
470 DIAG_DevMsgIf(
DBG,
"PGMDocHandler: " << stmtNode->
toStringMe());
476 else if (XMLString::equals(name,
elemGroup)) {
478 DIAG_Assert(!grpnm.empty(),
"");
483 DIAG_DevMsgIf(
DBG,
"PGMDocHandler: " << grpStrct->
toStringMe());
507 const XMLCh*
const name,
517 else if (XMLString::equals(name,
elemLM)) {
524 else if (XMLString::equals(name,
elemFile)) {
531 else if (XMLString::equals(name,
elemProc)) {
538 else if (XMLString::equals(name,
elemAlien)) {
545 else if (XMLString::equals(name,
elemLoop)) {
552 else if (XMLString::equals(name,
elemStmt)) {
557 else if (XMLString::equals(name,
elemGroup)) {
570 const XERCES_CPP_NAMESPACE::Attributes& attributes)
575 string begStr, endStr;
579 if (!lineStr.empty()) {
580 size_t dashpos = lineStr.find_first_of(
'-');
581 if (dashpos == std::string::npos) {
585 begStr = lineStr.substr(0, dashpos);
586 endStr = lineStr.substr(dashpos+1);
591 if (!begStr.empty()) {
594 if (!endStr.empty()) {
613 case Doc_NULL:
return "Document:NULL";
616 default:
DIAG_Die(
"Invalid Doc_t!");
690 DIAG_Assert(enclGrpDepth >= 2,
"");
691 unsigned int enclGrpIdx = enclGrpDepth - 1;
696 for (
unsigned int i = enclGrpIdx - 1; i >= 1; --i) {
701 shadowNode = curNode->
clone();
702 shadowNode->
link(parentNode);
705 parentNode = shadowNode;
711 topNode->
link(parentNode);
void getLineAttr(SrcFile::ln &begLn, SrcFile::ln &endLn, const XERCES_CPP_NAMESPACE::Attributes &attributes)
void fatalError(const SAXParseException &e)
static void report(std::ostream &estream, const char *prefix, const char *fileType, const XERCES_CPP_NAMESPACE::SAXParseException &e, const char *alternateFile=0, int numPrefixLines=0)
virtual std::string realpath(const std::string &oldpath) const
double toDbl(const char *str, unsigned *endidx)
Prof::Struct::Proc * m_curProc
const XMLCh *const elemAlien
static const char * ToString(Doc_t docty)
#define PGM_Throw(streamArgs)
long toLong(const char *str, unsigned *endidx)
const XMLCh *const elemFile
Prof::Struct::ANode * getScope(unsigned int idx)
void pushCurrentScope(Prof::Struct::ANode *scope)
void startElement(const XMLCh *const uri, const XMLCh *const name, const XMLCh *const qname, const XERCES_CPP_NAMESPACE::Attributes &attributes)
const XMLCh *const attrName
virtual const std::string & name() const
const XMLCh *const elemLoop
void endElement(const XMLCh *const uri, const XMLCh *const name, const XMLCh *const qname)
Prof::Struct::Root * m_curRoot
void fromString(const char *formattedstr)
Prof::Struct::ANode * GetShadow() const
Proc * findProc(const char *name, const char *linkname=NULL) const
PGMDocHandler(Doc_t ty, Prof::Struct::Tree *structure, DocHandlerArgs &args)
void SetShadow(Prof::Struct::ANode *x)
Prof::Struct::Tree * m_structure
const XMLCh *const attrVMA
string getAttr(const Attributes &attributes, int i)
void processGroupDocEndTag()
const XMLCh *const attrFile
const XMLCh *const elemVariable
const XMLCh *const elemProc
Prof::Struct::File * m_curFile
const VMAIntervalSet & vmaSet() const
void error(const SAXParseException &e)
const char * DIAG_UnexpectedInput
std::string toStringMe(uint oFlags=0, const char *pre="") const
#define DIAG_Msg(level,...)
const XMLCh *const elemStructure
StackEntry_t * getStackEntry(unsigned int idx)
static LM * demand(Root *pgm, const std::string &lm_fnm)
const XMLCh *const attrId
Prof::Struct::ANode * getScope() const
const XMLCh *const elemStmt
std::map< std::string, Prof::Struct::Proc * > idToProcMap
const XMLCh *const elemGroup
const XMLCh *const elemLM
static Group * demand(Root *pgm, const std::string &nm, ANode *parent)
void proc(Prof::Struct::Proc *proc)
unsigned int findEnclosingGroupScopeDepth()
const XMLCh *const attrVer
Prof::Struct::ANode * getCurrentScope()
void warning(const SAXParseException &e)
Prof::Struct::File * findCurrentFile()
Prof::Struct::LM * m_curLM
const XMLCh *const attrLnName
const XMLCh *const attrLine