654
|
1 |
/*
|
|
2 |
* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <new>
|
|
20 |
#include <iostream>
|
|
21 |
#include <fstream>
|
|
22 |
#include <string>
|
|
23 |
using namespace std;
|
|
24 |
|
|
25 |
#include "logging/loggingexception.hpp"
|
|
26 |
#include "logging/logparser.hpp"
|
|
27 |
#include "symbolgenerator.h"
|
|
28 |
|
|
29 |
|
|
30 |
LogParser* LogParser::Only = (LogParser*)0;
|
|
31 |
|
|
32 |
|
|
33 |
LogParser* LogParser::GetInstance(void) throw (LoggingException)
|
|
34 |
{
|
|
35 |
if(! LogParser::Only)
|
|
36 |
{
|
|
37 |
LogParser::Only = new (std::nothrow) LogParser();
|
|
38 |
if(! LogParser::Only)
|
|
39 |
throw LoggingException(LoggingException::RESOURCE_ALLOCATION_FAILURE);
|
|
40 |
}
|
|
41 |
|
|
42 |
return LogParser::Only;
|
|
43 |
}
|
|
44 |
|
|
45 |
|
|
46 |
void LogParser::ParseSymbol(const char* LogFilename) throw (LoggingException)
|
|
47 |
{
|
|
48 |
string linebuf;
|
|
49 |
SymbolGenerator* symgen = SymbolGenerator::GetInstance();
|
|
50 |
symgen->SetSymbolFileName(string(LogFilename));
|
|
51 |
|
|
52 |
ifstream logfd(LogFilename);
|
|
53 |
if(logfd.is_open())
|
|
54 |
{
|
|
55 |
while(! logfd.eof())
|
|
56 |
{
|
|
57 |
getline(logfd, linebuf);
|
|
58 |
if(linebuf.compare(0,4,"File") == 0)
|
|
59 |
{
|
|
60 |
if(linebuf.find("size:", 4) != string::npos)
|
|
61 |
{
|
|
62 |
size_t startpos = linebuf.find('\'') ;
|
|
63 |
size_t endpos = linebuf.rfind('\'');
|
|
64 |
if((startpos!=string::npos) && (endpos!=string::npos))
|
|
65 |
{
|
|
66 |
symgen->AddFile(linebuf.substr(startpos+1,endpos-startpos-1), false);
|
|
67 |
}
|
|
68 |
}
|
|
69 |
}
|
|
70 |
else if(linebuf.compare(0,26,"Compressed executable File") == 0)
|
|
71 |
{
|
|
72 |
if(linebuf.find("size:", 26) != string::npos)
|
|
73 |
{
|
|
74 |
size_t startpos = linebuf.find('\'') ;
|
|
75 |
size_t endpos = linebuf.rfind('\'');
|
|
76 |
if((startpos!=string::npos) && (endpos!=string::npos))
|
|
77 |
{
|
|
78 |
symgen->AddFile(linebuf.substr(startpos+1,endpos-startpos-1), true);
|
|
79 |
}
|
|
80 |
}
|
|
81 |
}
|
|
82 |
}
|
|
83 |
symgen->SetFinished();
|
|
84 |
symgen->Release();
|
|
85 |
}
|
|
86 |
else
|
|
87 |
{
|
|
88 |
throw LoggingException(LoggingException::INVALID_LOG_FILENAME);
|
|
89 |
}
|
|
90 |
|
|
91 |
return;
|
|
92 |
}
|
|
93 |
|
|
94 |
|
|
95 |
void LogParser::Cleanup(void)
|
|
96 |
{
|
|
97 |
return;
|
|
98 |
}
|
|
99 |
|
|
100 |
|
|
101 |
LogParser::LogParser(void)
|
|
102 |
{
|
|
103 |
return;
|
|
104 |
}
|