diff --git a/reactos/tools/sysreg/rosboot_test.cpp b/reactos/tools/sysreg/rosboot_test.cpp index ac713a3f7e8..5362c86e3df 100644 --- a/reactos/tools/sysreg/rosboot_test.cpp +++ b/reactos/tools/sysreg/rosboot_test.cpp @@ -117,7 +117,7 @@ namespace Sysreg_ { break; } - if (hasTimeout(&ts, 60000) + //if (hasTimeout(&ts, 60000) } pipe_reader.closePipe (); diff --git a/reactos/tools/sysreg/sym_file.cpp b/reactos/tools/sysreg/sym_file.cpp index dc202b3c5b2..41bb8e2e829 100644 --- a/reactos/tools/sysreg/sym_file.cpp +++ b/reactos/tools/sysreg/sym_file.cpp @@ -12,10 +12,13 @@ #include "sym_file.h" #include "env_var.h" #include "pipe_reader.h" +#include "conf_parser.h" #include +#include #include #include +#define _FINDDATA_T_DEFINED #include #include @@ -25,8 +28,14 @@ namespace System_ using std::cout; using std::endl; using std::cerr; + using std::vector; string SymbolFile::VAR_ROS_OUTPUT = _T("ROS_OUTPUT"); + string SymbolFile::ROS_ADDR2LINE = _T("ROS_ADDR2LINE"); + string SymbolFile::m_SymbolPath= _T(""); + string SymbolFile::m_SymResolver= _T(""); + SymbolFile::SymbolMap SymbolFile::m_Map; + //--------------------------------------------------------------------------------------- SymbolFile::SymbolFile() { @@ -40,19 +49,35 @@ namespace System_ } //--------------------------------------------------------------------------------------- - bool SymbolFile::initialize(const System_::string &Path) + bool SymbolFile::initialize(ConfigParser & conf_parser, const System_::string &Path) { - char szBuffer[260]; -// vector vect; + vector vect; EnvironmentVariable envvar; + string current_dir; - string val = _T("output-i386"); + if (Path == _T("")) + { + current_dir = _T("output-i386"); + envvar.getValue(SymbolFile::VAR_ROS_OUTPUT, current_dir); + } + else + { + current_dir = Path; + } - envvar.getValue(SymbolFile::VAR_ROS_OUTPUT, val); + m_SymbolPath = current_dir; - struct _finddata_t c_file; - strcpy(szBuffer, "D:\\reactos\\output-i386\\*"); - intptr_t hFile = _findfirst(szBuffer, &c_file); + if (!conf_parser.getStringValue (ROS_ADDR2LINE, m_SymResolver)) + { + cerr << "Warning: ROS_ADDR2LINE is not set in configuration file -> symbol lookup will fail" <(modulename, path)); + + } + if (c_file.attrib & _A_SUBDIR) + { + if (c_file.name[0] != _T('.')) + { + string path = current_dir; + path.insert (path.length ()-1, _T("\\")); + path.insert (path.length ()-1, c_file.name); + vect.push_back (path); + } + } + + }while(_tfindnext(hFile, &c_file) == 0); + + _findclose(hFile); + hFile = -1L; + + while(!vect.empty ()) + { + current_dir = vect.front (); + vect.erase (vect.begin()); + val = current_dir; + val.insert (val.length() -1, _T("\\*")); + hFile = _tfindfirst64i32(val.c_str(), &c_file); + if (hFile != -1L) + { + break; + } } - }while(_findnext(hFile, &c_file) == 0); + if (hFile == -1L) + { + break; + } + + }while(1); - - - return false; + return !m_Map.empty(); } //--------------------------------------------------------------------------------------- bool SymbolFile::resolveAddress(const string &module_name, const string &module_address, string &Buffer) { SymbolMap::const_iterator it = m_Map.find (module_name); -/* - if (it == m_Map.end ()) + + if (it == m_Map.end () || m_SymResolver == _T("")) { -#ifdef NDEBUG - cerr << "SymbolFile::resolveAddress> no symbol file found for module " << module_name << endl; -#endif + cerr << "SymbolFile::resolveAddress> no symbol file or ROS_ADDR2LINE not set" << endl; return false; } -*/ - /// - /// fetch environment path - /// - EnvironmentVariable envvar; -#if 1 - string pipe_cmd = _T("");//D:\\reactos\\output-i386"); -#else - string path = _T("output-i386"); - envvar.getValue(SymbolFile::VAR_ROS_OUTPUT, path); -#endif - pipe_cmd += _T("addr2line.exe "); //FIXXME file extension + + string pipe_cmd = m_SymResolver; pipe_cmd += _T("--exe="); -#if 1 - pipe_cmd += _T("D:\\reactos\\output-i386\\dll\\win32\\kernel32\\kernel32.nostrip.dll"); -#else - path += it->second; -#endif + pipe_cmd += it->second; pipe_cmd += _T(" "); pipe_cmd += module_address; @@ -114,9 +168,7 @@ namespace System_ if (!pipe_reader.openPipe (pipe_cmd)) { -#ifdef NDEBUG _tprintf(_T("SymbolFile::resolveAddress> failed to open pipe %s"), pipe_cmd); -#endif return false; } @@ -125,20 +177,24 @@ namespace System_ Buffer.reserve (500); } - return pipe_reader.readPipe (Buffer); + bool ret = pipe_reader.readPipe (Buffer); + pipe_reader.closePipe (); + return ret; } //--------------------------------------------------------------------------------------- bool SymbolFile::getSymbolFilePath(const System_::string &ModuleName, System_::string &FilePath) { - cerr << "SymbolFile::getSymbolFilePath is not yet implemented" < no symbol file found for module %s"), ModuleName.c_str()); + return false; + } + + FilePath = it->second; + return true; } - - - - - } // end of namespace System_ \ No newline at end of file diff --git a/reactos/tools/sysreg/sym_file.h b/reactos/tools/sysreg/sym_file.h index bf03bbcc6bc..365c6bed218 100644 --- a/reactos/tools/sysreg/sym_file.h +++ b/reactos/tools/sysreg/sym_file.h @@ -11,6 +11,8 @@ * PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at) */ +#include "conf_parser.h" + #include #include #include @@ -19,6 +21,7 @@ namespace System_ { typedef std::basic_string string; + using Sysreg_::ConfigParser; //--------------------------------------------------------------------------------------- /// @@ -33,17 +36,10 @@ namespace System_ class SymbolFile { - typedef std::map SymbolMap; public: static string VAR_ROS_OUTPUT; -//--------------------------------------------------------------------------------------- -/// -/// SymbolFile -/// -/// Description: constructor of class SymbolFile - - SymbolFile(); - + static string ROS_ADDR2LINE; + typedef std::map SymbolMap; //--------------------------------------------------------------------------------------- /// /// ~SymbolFile @@ -70,7 +66,7 @@ namespace System_ /// @param Path path to ROS_OUTPUT containing symbol files /// @return bool - bool initialize(const string & Path = _T("output-i386")); + static bool initialize(ConfigParser & conf_parser, const string & Path); //--------------------------------------------------------------------------------------- /// @@ -85,7 +81,7 @@ namespace System_ /// @param buffer receives information about the resolved location /// @return bool - bool resolveAddress(const string & module_name, const string & module_address, string & Buffer); + static bool resolveAddress(const string & module_name, const string & module_address, string & Buffer); //--------------------------------------------------------------------------------------- /// @@ -97,11 +93,21 @@ namespace System_ /// @param ModuleName name of the module to lookup /// @param FilePath buffer receiving the address of symbol file - bool getSymbolFilePath(const string & ModuleName, string & FilePath); + static bool getSymbolFilePath(const string & ModuleName, string & FilePath); protected: - SymbolMap m_Map; +//--------------------------------------------------------------------------------------- +/// +/// SymbolFile +/// +/// Description: constructor of class SymbolFile + + SymbolFile(); + + static SymbolMap m_Map; + static string m_SymbolPath; + static string m_SymResolver; }; } // end of namespace System_ diff --git a/reactos/tools/sysreg/sysreg.cpp b/reactos/tools/sysreg/sysreg.cpp index 051d650f3e9..75f90885ef3 100644 --- a/reactos/tools/sysreg/sysreg.cpp +++ b/reactos/tools/sysreg/sysreg.cpp @@ -28,8 +28,6 @@ using Sysreg_::ConfigParser; using Sysreg_::RegressionTest; using Sysreg_::RosBootTest; - -//test include using System_::SymbolFile; typedef ComponentFactoryTemplate ComponentFactory; @@ -69,6 +67,12 @@ int _tmain(int argc, TCHAR * argv[]) return -1; } + string envvar; + string ros = _T("ROS_OUTPUT"); + config.getStringValue (ros, envvar); + + SymbolFile::initialize (config, envvar); + if (regtest->execute (config)) { _tprintf(_T("The regression test %s completed successfully\n"), regtest->getName ().c_str ());