97 {
return (strcmp(m1->
GetName().c_str(), m2->
GetName().c_str()) < 0); }
134 std::istream* is =
NULL;
135 bool usingStdin = (!profFile || profFile[0] ==
'\0');
143 std::ifstream* pFile =
new std::ifstream(profFile);
145 if ( !pFile->is_open() || pFile->fail()) {
146 cerr <<
"Error opening file `" << profFile <<
"'" << endl;
147 goto ReadProfileFile_CleanupAfterError;
162 profData =
dynamic_cast<PCProfile*
>(ReadProfileFile_DCPICat(*is));
166 cerr <<
"Error reading file `" << profFile <<
"'" << endl;
168 cerr <<
"Error reading from stdin" << endl;
175 ReadProfileFile_CleanupAfterError:
193 const int bufSz = 128;
198 std::stringstream hdr;
200 string profiledFilePath;
208 hdr << std::showbase;
218 if (is.peek() ==
'l') {
225 while ( (!is.eof() && !is.fail()) && is.peek() ==
'p' ) {
227 if (profiledFilePath.empty()) {
241 is >> hex >> txtStart >> dec >> std::ws;
242 hdr << hex << txtStart << dec <<
"\n";
247 is >> hex >> txtSz >> dec >> std::ws;
248 hdr << hex << txtSz << dec <<
"\n";
250 if (is.eof() || is.fail()) {
return NULL; }
274 bool invalidMetric =
false;
275 unsigned int metricCount = 0;
277 while ( (!is.eof() && !is.fail()) && is.peek() ==
'e' ) {
283 if ( !isdigit(is.peek()) ) {
287 X +=
":" + pmcounter;
300 invalidMetric =
true;
303 mlist.push_back(curMetric);
311 if (!profiledFilePath.empty()) {
319 while (!mlist.empty()) {
325 if (invalidMetric || is.eof() || is.fail()) {
326 goto DCPICat_CleanupAfterError;
347 unsigned long pcCount = 0;
351 while ( (!is.eof() && !is.fail()) ) {
353 is >> hex >> PC >> dec;
355 profData->
AddPC(PC, 0);
356 for (
unsigned long i = 0; i < metricCount; i++) {
367 if (is.fail()) {
goto DCPICat_CleanupAfterError; }
374 DCPICat_CleanupAfterError:
385 if (mset.
GetSz() > 1) {
390 for (
unsigned int i = 0; setIt.IsValid(); ++setIt, ++i) {
391 mvec[i] = setIt.Current();
402 if (cur1->GetName() == cur2->GetName()) {
404 cerr <<
"Warning: Duplicate metric names exist: '" 405 << cur1->GetName() <<
"'." << endl;
407 }
while (it+1 != mvec.end());
410 for (it = mvec.begin(); it != mvec.end(); ++it) { *it =
NULL; }
420 if (strncmp(
"m0", pmcounter, 2) == 0) {
422 }
else if (strncmp(
"m1", pmcounter, 2) == 0) {
424 }
else if (strncmp(
"m2", pmcounter, 2) == 0) {
426 }
else if (strncmp(
"m3", pmcounter, 2) == 0) {
441 if (!str) {
return NULL; }
443 const char* ptr = str;
446 while (*ptr !=
'\0' && isspace(*ptr)) { ptr++; }
449 while (*ptr !=
'\0' && !isspace(*ptr)) { ptr++; }
452 while (*ptr !=
'\0' && isspace(*ptr)) { ptr++; }
std::list< PCProfileMetric * > PCProfileMetricList
static DCPIProfile * ReadProfileFile_DCPICat(std::istream &pFile)
static PCProfile * ReadProfileFile(const char *profFile)
unsigned int GetSz() const
PCProfileMetricVec::iterator PCProfileMetricVecIt
void SetHdrInfo(const char *s)
bool operator()(const PCProfileMetric *m1, const PCProfileMetric *m2) const
void SetTotalCount(PCProfileDatum d)
bool Skip(std::istream &is, const char *s)
void SetName(const char *s)
void AddMetric(const PCProfileMetric *m)
std::vector< PCProfileMetric * > PCProfileMetricVec
std::string GetLine(std::istream &is, char end)
std::string Get(std::istream &is, char end)
static bool MetricNamesAreUnique(PCProfileMetricSet &mset)
const DCPIMetricDesc & GetDCPIDesc() const
static const char * GetSecondSubstring(const char *str)
static DCPIProfile::PMMode DeterminePMMode(const char *pmcounter)
const PCProfileMetric * GetMetric(unsigned int i) const
void AddPC(VMA pc, ushort opIndex)
const std::string & GetName() const
void SetProfiledFile(const char *s)