[ros-diffs] [janderwald] 24585: - fix compilation - implement scanning of symbol directories

janderwald at svn.reactos.org janderwald at svn.reactos.org
Fri Oct 20 21:40:34 CEST 2006


Author: janderwald
Date: Fri Oct 20 23:40:33 2006
New Revision: 24585

URL: http://svn.reactos.org/svn/reactos?rev=24585&view=rev
Log:
- fix compilation
- implement scanning of symbol directories

Modified:
    trunk/reactos/tools/sysreg/rosboot_test.cpp
    trunk/reactos/tools/sysreg/sym_file.cpp
    trunk/reactos/tools/sysreg/sym_file.h
    trunk/reactos/tools/sysreg/sysreg.cpp

Modified: trunk/reactos/tools/sysreg/rosboot_test.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/rosboot_test.cpp?rev=24585&r1=24584&r2=24585&view=diff
==============================================================================
--- trunk/reactos/tools/sysreg/rosboot_test.cpp (original)
+++ trunk/reactos/tools/sysreg/rosboot_test.cpp Fri Oct 20 23:40:33 2006
@@ -117,7 +117,7 @@
 			{
 				break;
 			}
-			if (hasTimeout(&ts, 60000)
+			//if (hasTimeout(&ts, 60000)
 
 		}
 		pipe_reader.closePipe ();

Modified: trunk/reactos/tools/sysreg/sym_file.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/sym_file.cpp?rev=24585&r1=24584&r2=24585&view=diff
==============================================================================
--- trunk/reactos/tools/sysreg/sym_file.cpp (original)
+++ trunk/reactos/tools/sysreg/sym_file.cpp Fri Oct 20 23:40:33 2006
@@ -12,10 +12,13 @@
 #include "sym_file.h"
 #include "env_var.h"
 #include "pipe_reader.h"
+#include "conf_parser.h"
 
 #include <iostream>
+#include <vector>
 #include <stdio.h>
 #include <stdlib.h>
+#define _FINDDATA_T_DEFINED
 #include <io.h>
 #include <time.h>
 
@@ -25,8 +28,14 @@
 	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 @@
 	}
 
 //---------------------------------------------------------------------------------------
-	bool SymbolFile::initialize(const System_::string &Path) 
-	{
-		char szBuffer[260];
-//		vector<string> vect;
+	bool SymbolFile::initialize(ConfigParser & conf_parser, const System_::string &Path) 
+	{
+		vector<string> vect;
 		EnvironmentVariable envvar;
-
-		string val = _T("output-i386");
-
-		envvar.getValue(SymbolFile::VAR_ROS_OUTPUT, val);
-
-		struct _finddata_t c_file;
-		strcpy(szBuffer, "D:\\reactos\\output-i386\\*");
-		intptr_t hFile = _findfirst(szBuffer, &c_file);
+		string current_dir;
+
+		if (Path == _T(""))
+		{
+			current_dir = _T("output-i386");
+			envvar.getValue(SymbolFile::VAR_ROS_OUTPUT, current_dir);
+		}
+		else
+		{
+			current_dir = Path;
+		}
+
+		m_SymbolPath = current_dir;
+
+		if (!conf_parser.getStringValue (ROS_ADDR2LINE, m_SymResolver))
+		{
+			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)
 		{
@@ -62,49 +87,78 @@
 
 		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(_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);
-
-
-
-
-		return false;
+			if (hFile == -1L)
+			{
+				break;
+			}
+
+		}while(1);
+
+
+		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 ())
-		{
-#ifdef NDEBUG
-			cerr << "SymbolFile::resolveAddress> no symbol file found for module " << module_name << endl;
-#endif
-			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
+
+		if (it == m_Map.end () || m_SymResolver == _T(""))
+		{
+			cerr << "SymbolFile::resolveAddress> no symbol file or ROS_ADDR2LINE not set" << endl;
+			return false;
+		}
+
+		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 @@
 
 		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 @@
 			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" <<endl;
-		return false;
-
-	}
-
-
-
-
-
+		SymbolMap::const_iterator it = m_Map.find (ModuleName);
+
+		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_

Modified: trunk/reactos/tools/sysreg/sym_file.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/sym_file.h?rev=24585&r1=24584&r2=24585&view=diff
==============================================================================
--- trunk/reactos/tools/sysreg/sym_file.h (original)
+++ trunk/reactos/tools/sysreg/sym_file.h Fri Oct 20 23:40:33 2006
@@ -11,6 +11,8 @@
  * PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
  */
 
+#include "conf_parser.h"
+
 #include <string>
 #include <tchar.h>
 #include <map>
@@ -19,6 +21,7 @@
 {
 
 	typedef std::basic_string<TCHAR> string;
+	using Sysreg_::ConfigParser;
 
 //---------------------------------------------------------------------------------------
 ///
@@ -33,17 +36,10 @@
 
 	class SymbolFile
 	{
-		typedef std::map<string, string> SymbolMap;
 	public:
 		static string VAR_ROS_OUTPUT;
-//---------------------------------------------------------------------------------------
-///
-/// SymbolFile
-///
-/// Description: constructor of class SymbolFile
-
-		SymbolFile();
-
+		static string ROS_ADDR2LINE;
+		typedef std::map<string, string> SymbolMap;
 //---------------------------------------------------------------------------------------
 ///
 /// ~SymbolFile 
@@ -70,7 +66,7 @@
 /// @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 @@
 /// @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 @@
 /// @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_
 

Modified: trunk/reactos/tools/sysreg/sysreg.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/sysreg.cpp?rev=24585&r1=24584&r2=24585&view=diff
==============================================================================
--- trunk/reactos/tools/sysreg/sysreg.cpp (original)
+++ trunk/reactos/tools/sysreg/sysreg.cpp Fri Oct 20 23:40:33 2006
@@ -28,8 +28,6 @@
 using Sysreg_::RegressionTest;
 using Sysreg_::RosBootTest;
 
-
-//test include
 using System_::SymbolFile;
 
 typedef ComponentFactoryTemplate<RegressionTest, string> ComponentFactory;
@@ -69,6 +67,12 @@
 		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 ());




More information about the Ros-diffs mailing list