- fix compilation

- implement scanning of symbol directories

svn path=/trunk/; revision=24585
This commit is contained in:
Johannes Anderwald 2006-10-20 19:40:33 +00:00
parent 4ba2129226
commit 98aa4d7f47
4 changed files with 128 additions and 62 deletions

View file

@ -117,7 +117,7 @@ namespace Sysreg_
{ {
break; break;
} }
if (hasTimeout(&ts, 60000) //if (hasTimeout(&ts, 60000)
} }
pipe_reader.closePipe (); pipe_reader.closePipe ();

View file

@ -12,10 +12,13 @@
#include "sym_file.h" #include "sym_file.h"
#include "env_var.h" #include "env_var.h"
#include "pipe_reader.h" #include "pipe_reader.h"
#include "conf_parser.h"
#include <iostream> #include <iostream>
#include <vector>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define _FINDDATA_T_DEFINED
#include <io.h> #include <io.h>
#include <time.h> #include <time.h>
@ -25,8 +28,14 @@ namespace System_
using std::cout; using std::cout;
using std::endl; using std::endl;
using std::cerr; using std::cerr;
using std::vector;
string SymbolFile::VAR_ROS_OUTPUT = _T("ROS_OUTPUT"); 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() 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<string> vect;
// vector<string> vect;
EnvironmentVariable envvar; 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; if (!conf_parser.getStringValue (ROS_ADDR2LINE, m_SymResolver))
strcpy(szBuffer, "D:\\reactos\\output-i386\\*"); {
intptr_t hFile = _findfirst(szBuffer, &c_file); cerr << "Warning: ROS_ADDR2LINE is not set in configuration file -> symbol lookup will fail" <<endl;
return false;
}
string val = current_dir;
val.insert (val.length()-1, _T("\\*"));
struct _tfinddata64i32_t c_file;
intptr_t hFile = _tfindfirst64i32(val.c_str(), &c_file);
if (hFile == -1L) if (hFile == -1L)
{ {
@ -62,49 +87,78 @@ namespace System_
do do
{ {
if (strstr(c_file.name, ".nostrip."))
do
{ {
cerr << c_file.name << endl; TCHAR * pos;
if ((pos = _tcsstr(c_file.name, _T(".nostrip."))))
{
size_t len = _tcslen(pos);
string modulename = c_file.name;
string filename = modulename;
modulename.erase(modulename.length() - len, len);
string path = current_dir;
path.insert (path.length () -1, _T("\\"));
path.insert (path.length () -1, filename);
m_Map.insert(std::make_pair<string, string>(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(_findnext(hFile, &c_file) == 0); }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;
}
}
if (hFile == -1L)
{
break;
}
}while(1);
return !m_Map.empty();
return false;
} }
//--------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------
bool SymbolFile::resolveAddress(const string &module_name, const string &module_address, string &Buffer) bool SymbolFile::resolveAddress(const string &module_name, const string &module_address, string &Buffer)
{ {
SymbolMap::const_iterator it = m_Map.find (module_name); 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 or ROS_ADDR2LINE not set" << endl;
cerr << "SymbolFile::resolveAddress> no symbol file found for module " << module_name << endl;
#endif
return false; return false;
} }
*/
/// string pipe_cmd = m_SymResolver;
/// 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
pipe_cmd += _T("--exe="); pipe_cmd += _T("--exe=");
#if 1 pipe_cmd += it->second;
pipe_cmd += _T("D:\\reactos\\output-i386\\dll\\win32\\kernel32\\kernel32.nostrip.dll");
#else
path += it->second;
#endif
pipe_cmd += _T(" "); pipe_cmd += _T(" ");
pipe_cmd += module_address; pipe_cmd += module_address;
@ -114,9 +168,7 @@ namespace System_
if (!pipe_reader.openPipe (pipe_cmd)) if (!pipe_reader.openPipe (pipe_cmd))
{ {
#ifdef NDEBUG
_tprintf(_T("SymbolFile::resolveAddress> failed to open pipe %s"), pipe_cmd); _tprintf(_T("SymbolFile::resolveAddress> failed to open pipe %s"), pipe_cmd);
#endif
return false; return false;
} }
@ -125,20 +177,24 @@ namespace System_
Buffer.reserve (500); 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) bool SymbolFile::getSymbolFilePath(const System_::string &ModuleName, System_::string &FilePath)
{ {
cerr << "SymbolFile::getSymbolFilePath is not yet implemented" <<endl; SymbolMap::const_iterator it = m_Map.find (ModuleName);
return false;
if (it == m_Map.end ())
{
_tprintf(_T("SymbolFile::resolveAddress> no symbol file found for module %s"), ModuleName.c_str());
return false;
} }
FilePath = it->second;
return true;
}
} // end of namespace System_ } // end of namespace System_

View file

@ -11,6 +11,8 @@
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at) * PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
*/ */
#include "conf_parser.h"
#include <string> #include <string>
#include <tchar.h> #include <tchar.h>
#include <map> #include <map>
@ -19,6 +21,7 @@ namespace System_
{ {
typedef std::basic_string<TCHAR> string; typedef std::basic_string<TCHAR> string;
using Sysreg_::ConfigParser;
//--------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------
/// ///
@ -33,17 +36,10 @@ namespace System_
class SymbolFile class SymbolFile
{ {
typedef std::map<string, string> SymbolMap;
public: public:
static string VAR_ROS_OUTPUT; static string VAR_ROS_OUTPUT;
//--------------------------------------------------------------------------------------- static string ROS_ADDR2LINE;
/// typedef std::map<string, string> SymbolMap;
/// SymbolFile
///
/// Description: constructor of class SymbolFile
SymbolFile();
//--------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------
/// ///
/// ~SymbolFile /// ~SymbolFile
@ -70,7 +66,7 @@ namespace System_
/// @param Path path to ROS_OUTPUT containing symbol files /// @param Path path to ROS_OUTPUT containing symbol files
/// @return bool /// @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 /// @param buffer receives information about the resolved location
/// @return bool /// @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 ModuleName name of the module to lookup
/// @param FilePath buffer receiving the address of symbol file /// @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: 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_ } // end of namespace System_

View file

@ -28,8 +28,6 @@ using Sysreg_::ConfigParser;
using Sysreg_::RegressionTest; using Sysreg_::RegressionTest;
using Sysreg_::RosBootTest; using Sysreg_::RosBootTest;
//test include
using System_::SymbolFile; using System_::SymbolFile;
typedef ComponentFactoryTemplate<RegressionTest, string> ComponentFactory; typedef ComponentFactoryTemplate<RegressionTest, string> ComponentFactory;
@ -69,6 +67,12 @@ int _tmain(int argc, TCHAR * argv[])
return -1; return -1;
} }
string envvar;
string ros = _T("ROS_OUTPUT");
config.getStringValue (ros, envvar);
SymbolFile::initialize (config, envvar);
if (regtest->execute (config)) if (regtest->execute (config))
{ {
_tprintf(_T("The regression test %s completed successfully\n"), regtest->getName ().c_str ()); _tprintf(_T("The regression test %s completed successfully\n"), regtest->getName ().c_str ());