//** from the company.\r
//**\r
//****************************************************************************\r
-\r
+#include "ProcessorBind.h"\r
+#include <iostream>\r
#include <stdexcept>\r
#include <list>\r
#include <map>\r
-#include <iostream>\r
+#include <vector>\r
#include <iomanip>\r
#include <fstream>\r
#include <sstream>\r
#include <functional>\r
using namespace std;\r
\r
-typedef unsigned __int64 ulonglong_t;\r
+typedef UINT64 ulonglong_t;\r
+\r
+#ifdef __GNUC__\r
+#if __STDC_VERSION__ < 199901L\r
+#define __FUNCTION__ __FILE__\r
+#endif\r
+#endif\r
\r
template <class T>\r
class CMemoryLeakChecker : public list<T*>\r
<< setw(4) << (unsigned short)(idRight.m_ullId[0] >> 16) << '-'\r
<< setw(4) << (unsigned short)idRight.m_ullId[0] << '-'\r
<< setw(4) << (unsigned short)(idRight.m_ullId[1] >> 48) << '-'\r
- << setw(12) << (idRight.m_ullId[1] & 0xffffffffffff);\r
+ << setw(12) << (idRight.m_ullId[1] & 0xffffffffffffULL);\r
}\r
\r
class CInputFile : public CObjRoot\r
if (i->second.second == "*")\r
continue;\r
\r
- pair<iterator, bool> r = insert(value_type(i->first,\r
- new CMapFile(i->second.second.substr(0, i->second.second.rfind('.')) + ".map")));\r
- r.first->second->SetLoadAddress(i->second.first);\r
+ try\r
+ {\r
+ pair<iterator, bool> r = insert(value_type(i->first,\r
+ new CMapFile(i->second.second.substr(0, i->second.second.rfind('.')) + ".map")));\r
+ r.first->second->SetLoadAddress(i->second.first);\r
+ }\r
+ catch (const runtime_error& e)\r
+ {\r
+ }\r
}\r
}\r
\r
+CFvMapFile::~CFvMapFile(void)\r
+{\r
+ Cleanup();\r
+}\r
+\r
void CFvMapFile::Cleanup(void)\r
{\r
for (iterator i = begin(); i != end(); i++)\r
delete i->second;\r
}\r
\r
+static bool map_less(const CFvMapFile::const_iterator& l, const CFvMapFile::const_iterator& r)\r
+{\r
+ return l->second->m_ullLoadAddr < r->second->m_ullLoadAddr;\r
+}\r
+\r
ostream& operator << (ostream& os, const CFvMapFile& fvMap)\r
{\r
- for (CFvMapFile::const_iterator i = fvMap.begin(); !!os && i != fvMap.end(); i++)\r
+ vector<CFvMapFile::const_iterator> rgIter;\r
+ rgIter.reserve(fvMap.size());\r
+ for (CFvMapFile::const_iterator i = fvMap.begin(); i != fvMap.end(); i++)\r
+ rgIter.push_back(i);\r
+ sort(rgIter.begin(), rgIter.end(), map_less);\r
+\r
+ for (vector<CFvMapFile::const_iterator>::const_iterator i = rgIter.begin(); i != rgIter.end(); i++)\r
{\r
- CMapFile::const_iterator j = i->second->begin();\r
- while (j != i->second->end() && j->m_strAddress != i->second->m_strEntryPoint) j++;\r
- if (j == i->second->end())\r
+ CMapFile::const_iterator j = (*i)->second->begin();\r
+ while (j != (*i)->second->end() && j->m_strAddress != (*i)->second->m_strEntryPoint) j++;\r
+ if (j == (*i)->second->end())\r
throw runtime_error(\r
__FUNCTION__ ":Entry point not found for module " +\r
- i->second->m_strModuleName);\r
+ (*i)->second->m_strModuleName);\r
\r
os << hex\r
- << i->second->m_strModuleName\r
- << " (EP=" << j->m_ullRva\r
- << ", BA=" << i->second->m_ullLoadAddr\r
- << ", GUID=" << i->first\r
+ << (*i)->second->m_strModuleName\r
+ << " (EntryPoint=" << j->m_ullRva\r
+ << ", BaseAddress=" << (*i)->second->m_ullLoadAddr\r
+ << ", GUID=" << (*i)->first\r
<< ")" << endl << endl;\r
\r
- for (j = i->second->begin(); j != i->second->end(); j++)\r
+ for (j = (*i)->second->begin(); j != (*i)->second->end(); j++)\r
os << " " << *j << endl;\r
\r
os << endl << endl;\r
return os;\r
}\r
\r
-CFvMapFile::~CFvMapFile(void)\r
-{\r
- Cleanup();\r
-}\r
-\r
class CGenFvMapUsage : public invalid_argument\r
{\r
public:\r