0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
#include "rundump.h"
|
|
17 |
#include <e32base.h>
|
|
18 |
#include <e32std.h>
|
|
19 |
#include <e32cons.h> // Console
|
|
20 |
|
|
21 |
#include <coredumpserverapi.h>
|
|
22 |
#include <e32property.h>
|
|
23 |
#include <crashdatasave.h>
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
// Constants
|
|
28 |
|
|
29 |
_LIT(KTextConsoleTitle, "Console");
|
|
30 |
_LIT(KTextFailed, " failed, leave code = %d");
|
|
31 |
_LIT(KTextPressAnyKey, " [press any key]\n");
|
|
32 |
_LIT(KCrashAppFileName,"Z:\\sys\\bin\\crashapp.exe");
|
|
33 |
|
|
34 |
// Global Variables
|
|
35 |
|
|
36 |
LOCAL_D CConsoleBase* console; // write all messages to this
|
|
37 |
|
|
38 |
|
|
39 |
// Local Functions
|
|
40 |
|
|
41 |
LOCAL_C void MainL()
|
|
42 |
{
|
|
43 |
TUid SELF_UID_V2 = { 0x102836bb };
|
|
44 |
TUid WRITER_UID = { 0x102831E4 };
|
|
45 |
TUid CDS_UID = { 0x10282FE5 };
|
|
46 |
TUid UTRACE_UID = { 0x102836BA };
|
|
47 |
TUid DEXC_UID = { 0x102832C5 };
|
|
48 |
|
|
49 |
RCoreDumpSession cdsSess;
|
|
50 |
CleanupClosePushL(cdsSess);
|
|
51 |
cdsSess.Connect();
|
|
52 |
|
|
53 |
//
|
|
54 |
// add your program code here, example code below
|
|
55 |
//
|
|
56 |
console->Write(_L("Starting megadump\n"));
|
|
57 |
console->Write(_L("SELF or UTRACE or DEXC? (s/u/d)"));
|
|
58 |
TChar inp = console->Getch();
|
|
59 |
|
|
60 |
//Load plugins
|
|
61 |
TPluginRequest req;
|
|
62 |
req.iPluginType = TPluginRequest::EFormatter;
|
|
63 |
req.iLoad = ETrue;
|
|
64 |
|
|
65 |
switch(inp)
|
|
66 |
{
|
|
67 |
case('s'):
|
|
68 |
{
|
|
69 |
req.iUid = SELF_UID_V2;
|
|
70 |
console->Write(_L("\nLoading SELF formatter V2\n"));
|
|
71 |
break;
|
|
72 |
}
|
|
73 |
case('u'):
|
|
74 |
{
|
|
75 |
req.iUid = UTRACE_UID;
|
|
76 |
console->Write(_L("\nLoading UTRACE formatter\n"));
|
|
77 |
break;
|
|
78 |
}
|
|
79 |
case('d'):
|
|
80 |
{
|
|
81 |
req.iUid = DEXC_UID;
|
|
82 |
console->Write(_L("\nLoading DEXC Formatter"));
|
|
83 |
return;
|
|
84 |
}
|
|
85 |
default:
|
|
86 |
{
|
|
87 |
console->Write(_L("\nNot an option"));
|
|
88 |
return;
|
|
89 |
}
|
|
90 |
|
|
91 |
}
|
|
92 |
|
|
93 |
TBuf<10> crashAppParam;
|
|
94 |
console->Write(_L("Should crashapp write trace data? (y/n)\n"));
|
|
95 |
inp = console->Getch();
|
|
96 |
switch(inp)
|
|
97 |
{
|
|
98 |
case('y'):
|
|
99 |
{
|
|
100 |
console->Write(_L("Crashapp will write trace data\n"));
|
|
101 |
crashAppParam.Append(_L("-d1 -t"));
|
|
102 |
break;
|
|
103 |
}
|
|
104 |
default:
|
|
105 |
{
|
|
106 |
console->Write(_L("Crashapp will not write any trace data\n"));
|
|
107 |
crashAppParam.Append(_L("-d1"));
|
|
108 |
break;
|
|
109 |
}
|
|
110 |
}
|
|
111 |
|
|
112 |
//Start the process that we intend to crash....
|
|
113 |
RProcess crashProcess;
|
|
114 |
CleanupClosePushL(crashProcess);
|
|
115 |
crashProcess.Create( KCrashAppFileName, crashAppParam);
|
|
116 |
|
|
117 |
cdsSess.PluginRequestL( req );
|
|
118 |
|
|
119 |
TPluginRequest req2;
|
|
120 |
req2.iUid = WRITER_UID;
|
|
121 |
req2.iPluginType = TPluginRequest::EWriter;
|
|
122 |
req2.iLoad = ETrue;
|
|
123 |
|
|
124 |
console->Write(_L("Loading File writer\n"));
|
|
125 |
cdsSess.PluginRequestL( req2 );
|
|
126 |
|
|
127 |
_LIT( KPostCrashEventActionPrompt, "Action After Crash:\n 0-None,\n 1-Resume Thread,\n 2-Resume Process,\n 4-Kill Process" );
|
|
128 |
_LIT( KFilePathPrompt, "not_important" );
|
|
129 |
_LIT( KCrashFileName, "e:\\file");
|
|
130 |
|
|
131 |
console->Write(_L("Configuring CDS\n"));
|
|
132 |
DoConfigureL(2, CDS_UID.iUid, COptionConfig::ECoreDumpServer, COptionConfig::ETUInt, KPostCrashEventActionPrompt,
|
|
133 |
1, KNullDesC, 4, KNullDesC, 0, cdsSess);
|
|
134 |
|
|
135 |
console->Write(_L("Configuring Writer\n"));
|
|
136 |
DoConfigureL((TInt)(CCrashDataSave::ECoreFilePath), WRITER_UID.iUid, COptionConfig::EWriterPlugin, COptionConfig::ETFileName,
|
|
137 |
KFilePathPrompt, 1, KNullDesC, 0, KCrashFileName, 0, cdsSess);
|
|
138 |
|
|
139 |
/* if(trace)
|
|
140 |
{
|
|
141 |
console->Write(_L("Configuring Trace\n"));
|
|
142 |
DoConfigureL(0, UTRACE_UID.iUid, COptionConfig::EFormatterPlugin, COptionConfig::ETInt,
|
|
143 |
KFilePathPrompt, 1, KNullDesC, 1, KCrashFileName, 0, cdsSess);
|
|
144 |
}*/
|
|
145 |
|
|
146 |
console->Write(_L("Observing\n"));
|
|
147 |
cdsSess.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, ETrue) ;
|
|
148 |
|
|
149 |
console->Write(_L("Starting process\n"));
|
|
150 |
crashProcess.Resume();
|
|
151 |
CleanupStack::PopAndDestroy(&crashProcess);
|
|
152 |
CleanupStack::PopAndDestroy(&cdsSess);
|
|
153 |
|
|
154 |
console->Write(_L("Any key to exit...."));
|
|
155 |
console->Getch();
|
|
156 |
|
|
157 |
}
|
|
158 |
|
|
159 |
void DoConfigureL(const TUint32& aIndex,
|
|
160 |
const TUint32& aUID,
|
|
161 |
const COptionConfig::TParameterSource& aSource,
|
|
162 |
const COptionConfig::TOptionType& aType,
|
|
163 |
const TDesC& aPrompt,
|
|
164 |
const TUint32& aNumOptions,
|
|
165 |
const TDesC& aOptions,
|
|
166 |
const TInt32& aVal,
|
|
167 |
const TDesC& aStrValue,
|
|
168 |
const TUint aInstance,
|
|
169 |
const RCoreDumpSession &aSess)
|
|
170 |
/**
|
|
171 |
* @return void
|
|
172 |
* @param aIndex Internal index to the component that owns the object
|
|
173 |
* @param aUID UID of the component that owns the object
|
|
174 |
* @param aSource Type of component that owns the object
|
|
175 |
* @param aType Type of parameter
|
|
176 |
* @param aPrompt Prompt to present to user
|
|
177 |
* @param aNumOptions Number of options that the parameter can be set to. Only applies if type is ETMultiEntryEnum.
|
|
178 |
* @param aOptions Comma separated list of options. Applies to ETMultiEntryEnum and ETBool
|
|
179 |
* @param aVal Integer value. Applies to ETInt, ETUInt, ETBool
|
|
180 |
* @param aStrValue String value. Applies to ETString, ETFileName, ETMultiEntry, ETBool
|
|
181 |
*/
|
|
182 |
{
|
|
183 |
COptionConfig * config;
|
|
184 |
|
|
185 |
config = COptionConfig::NewL( aIndex,
|
|
186 |
aUID,
|
|
187 |
aSource,
|
|
188 |
aType,
|
|
189 |
aPrompt,
|
|
190 |
aNumOptions,
|
|
191 |
aOptions,
|
|
192 |
aVal,
|
|
193 |
aStrValue);
|
|
194 |
|
|
195 |
CleanupStack::PushL(config);
|
|
196 |
|
|
197 |
config->Instance(aInstance);
|
|
198 |
|
|
199 |
//Configure now...
|
|
200 |
aSess.SetConfigParameterL(*config);
|
|
201 |
|
|
202 |
CleanupStack::PopAndDestroy(config);
|
|
203 |
}
|
|
204 |
|
|
205 |
|
|
206 |
LOCAL_C void DoStartL()
|
|
207 |
{
|
|
208 |
// Create active scheduler (to run active objects)
|
|
209 |
CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
|
|
210 |
CleanupStack::PushL(scheduler);
|
|
211 |
CActiveScheduler::Install(scheduler);
|
|
212 |
|
|
213 |
TRAPD(err, MainL());
|
|
214 |
|
|
215 |
if(err != KErrNone)
|
|
216 |
{
|
|
217 |
console->Printf(_L("All is not well in the land of megadump. Error = %d\n"), err);
|
|
218 |
}
|
|
219 |
|
|
220 |
// Delete active scheduler
|
|
221 |
CleanupStack::PopAndDestroy(scheduler);
|
|
222 |
}
|
|
223 |
|
|
224 |
|
|
225 |
// Global Functions
|
|
226 |
|
|
227 |
GLDEF_C TInt E32Main()
|
|
228 |
{
|
|
229 |
// Create cleanup stack
|
|
230 |
__UHEAP_MARK;
|
|
231 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
|
232 |
|
|
233 |
// Create output console
|
|
234 |
TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));
|
|
235 |
if (createError)
|
|
236 |
return createError;
|
|
237 |
|
|
238 |
// Run application code inside TRAP harness, wait keypress when terminated
|
|
239 |
TRAPD(mainError, DoStartL());
|
|
240 |
if (mainError)
|
|
241 |
console->Printf(KTextFailed, mainError);
|
|
242 |
console->Printf(KTextPressAnyKey);
|
|
243 |
console->Getch();
|
|
244 |
|
|
245 |
delete console;
|
|
246 |
delete cleanup;
|
|
247 |
__UHEAP_MARKEND;
|
|
248 |
return KErrNone;
|
|
249 |
}
|
|
250 |
|
|
251 |
|
|
252 |
|