Author: janderwald Date: Sat Oct 21 04:13:52 2006 New Revision: 24588
URL: http://svn.reactos.org/svn/reactos?rev=24588&view=rev Log: - implement a basic boot detection algorithm - sysreg can now recognize some user mode detection and blue screen of deaths - a few timing issues have to be sorted out in order make deployment ready
Modified: trunk/reactos/tools/sysreg/rosboot_test.cpp trunk/reactos/tools/sysreg/rosboot_test.h trunk/reactos/tools/sysreg/sym_file.cpp 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.c... ============================================================================== --- trunk/reactos/tools/sysreg/rosboot_test.cpp (original) +++ trunk/reactos/tools/sysreg/rosboot_test.cpp Sat Oct 21 04:13:52 2006 @@ -11,10 +11,17 @@
#include "rosboot_test.h" #include "pipe_reader.h" +#include "sym_file.h"
#include <iostream> +#include <vector> #include <time.h> #include <float.h> +#include <stdio.h> +#include <stdlib.h> +#include <assert.h> + +
namespace Sysreg_ { @@ -32,8 +39,9 @@
#endif
- + using std::vector; using System_::PipeReader; + using System_::SymbolFile;
string RosBootTest::VARIABLE_NAME = _T("ROSBOOT_CMD"); string RosBootTest::CLASS_NAME = _T("rosboot"); @@ -108,7 +116,7 @@ return ret; } //--------------------------------------------------------------------------------------- - bool RosBootTest::checkDebugData(string debug_data) + bool RosBootTest::checkDebugData(vector<string> & debug_data) { /// /// FIXME @@ -118,9 +126,71 @@ /// TBD the information needs to be written into an provided log object /// which writes the info into HTML/log / sends etc ....
-// cerr << debug_data << endl; + bool clear = true; + + for(size_t i = 0; i < debug_data.size();i++) + { + string line = debug_data[i]; + + if (line.find (_T("*** Fatal System Error")) != string::npos) + { + cerr << "BSOD detected" <<endl; + return false; + } + else if (line.find (_T("Unhandled exception")) != string::npos) + { + if (i + 3 >= debug_data.size ()) + { + /// + /// missing information is cut off -> try reconstruct at next call + /// + clear = false; + break; + } + + cerr << "UM detected" <<endl; + + /// + /// extract address from next line + /// + + string address = debug_data[i+2]; + string::size_type pos = address.find_last_of (_T(" ")); + address = address.substr (pos, address.length () - 1 - pos); + + /// + /// extract module name + /// + string modulename = debug_data[i+3]; + pos = modulename.find_last_of (_T("\")); + modulename = modulename.substr (pos + 1, modulename.length () - pos); + pos = modulename.find_last_of (_T(".")); + modulename = modulename.substr (0, pos); + + /// + /// resolve address + /// + string result; + result.reserve (200); + + SymbolFile::resolveAddress (modulename, address, result); + cerr << result << endl; + + /// + /// TODO + /// + /// resolve frame addresses + + return false; + } + + } + + if (clear) + { + debug_data.clear (); + } return true; - } //--------------------------------------------------------------------------------------- bool RosBootTest::isTimeout(double max_timeout) @@ -150,7 +220,6 @@ //--------------------------------------------------------------------------------------- bool RosBootTest::fetchDebugByPipe(string boot_cmd) { - struct timeval ts; PipeReader pipe_reader;
if (!pipe_reader.openPipe(boot_cmd, string(_T("rt")))) @@ -159,9 +228,10 @@ return false; } string Buffer; - Buffer.reserve (10000); + Buffer.reserve (500);
bool ret = true; + vector<string> vect;
while(!pipe_reader.isEof ()) { @@ -170,11 +240,11 @@ break; }
- string::size_type size = pipe_reader.readPipe (Buffer); - cerr << "XXXsize_type " << size <<endl; - - - if (!checkDebugData(Buffer)) + pipe_reader.readPipe (Buffer); + vect.push_back (Buffer); + + + if (!checkDebugData(vect)) { ret = false; break; @@ -194,6 +264,12 @@ cerr << "Error: failed to open pipe with cmd: " << boot_cmd << endl; return false; } + + // FIXXME + // give the emulator some time to load freeloadr + _sleep( (clock_t)4 * CLOCKS_PER_SEC ); + + FILE * file = _tfopen(debug_log.c_str (), _T("rt")); if (!file) { @@ -202,15 +278,18 @@ return false; }
- TCHAR szBuffer[500]; + TCHAR szBuffer[150]; bool ret = true; + vector<string> vect;
while(!pipe_reader.isEof ()) { if (_fgetts(szBuffer, sizeof(szBuffer) / sizeof(TCHAR), file)) { - string buffer = szBuffer; - if (!checkDebugData(buffer)) + string line = szBuffer; + vect.push_back (line); + + if (!checkDebugData(vect)) { ret = false; break;
Modified: trunk/reactos/tools/sysreg/rosboot_test.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/rosboot_test.h... ============================================================================== --- trunk/reactos/tools/sysreg/rosboot_test.h (original) +++ trunk/reactos/tools/sysreg/rosboot_test.h Sat Oct 21 04:13:52 2006 @@ -12,10 +12,12 @@
#include "reg_test.h" -#include <winsock2.h> +#include <vector>
namespace Sysreg_ { + using std::vector; + //--------------------------------------------------------------------------------------- /// /// class RosBootTest @@ -100,7 +102,7 @@ /// Note: the received debug information should be written to an internal log object /// to facilate post-processing of the results
- bool checkDebugData(string debug_data); + bool checkDebugData(vector<string> & debug_data);
//--------------------------------------------------------------------------------------- ///
Modified: trunk/reactos/tools/sysreg/sym_file.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/sym_file.cpp?r... ============================================================================== --- trunk/reactos/tools/sysreg/sym_file.cpp (original) +++ trunk/reactos/tools/sysreg/sym_file.cpp Sat Oct 21 04:13:52 2006 @@ -170,14 +170,11 @@ return false; }
- string pipe_cmd = m_SymResolver; - pipe_cmd += _T("--exe="); - pipe_cmd += it->second; - - pipe_cmd += _T(" "); - pipe_cmd += module_address; - - + TCHAR szCmd[300]; + + _stprintf(szCmd, _T("%s --exe=%s %s"), m_SymResolver.c_str (), it->second.c_str (), module_address.c_str()); + string pipe_cmd(szCmd); + PipeReader pipe_reader;
if (!pipe_reader.openPipe (pipe_cmd))
Modified: trunk/reactos/tools/sysreg/sysreg.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/sysreg.cpp?rev... ============================================================================== --- trunk/reactos/tools/sysreg/sysreg.cpp (original) +++ trunk/reactos/tools/sysreg/sysreg.cpp Sat Oct 21 04:13:52 2006 @@ -91,7 +91,7 @@ } else { - cout << "The regression test " << regtest->getName () << "failed" << endl; + cout << "The regression test " << regtest->getName () << " failed" << endl; }
return 0;