|
1 // Copyright (c) 2006-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 // symbianelfoptions.cpp |
|
15 // Implementation of the symbian elf options class. |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalTechnology |
|
21 @released |
|
22 */ |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <e32debug.h> |
|
26 |
|
27 #include "symbianelfoptionsv2.h" |
|
28 #include <debuglogging.h> |
|
29 |
|
30 /** |
|
31 1st stage construction |
|
32 @return pointer to the newly created object, caller takes ownership of the object. |
|
33 */ |
|
34 CElfOptionsV2* CElfOptionsV2::NewL( TUint32 aUID ) |
|
35 { |
|
36 //LOG_MSG( "CElfOptionsV2::NewL()\n" ); |
|
37 CElfOptionsV2* self = CElfOptionsV2::NewLC( aUID ); |
|
38 CleanupStack::Pop(); |
|
39 return self; |
|
40 } |
|
41 |
|
42 /** |
|
43 1st stage construction |
|
44 @return pointer to the newly created object, caller takes ownership of the object. |
|
45 */ |
|
46 CElfOptionsV2* CElfOptionsV2::NewLC( TUint32 aUID ) |
|
47 { |
|
48 //LOG_MSG( "CElfOptionsV2::NewLC()\n" ); |
|
49 |
|
50 CElfOptionsV2* self = new(ELeave) CElfOptionsV2(); |
|
51 |
|
52 CleanupStack::PushL(self); |
|
53 |
|
54 self->ConstructL( aUID ); |
|
55 return self; |
|
56 } |
|
57 |
|
58 /** |
|
59 2nd stage construction |
|
60 Reserves config parameter list, creates config parameter objects and sets them to default values. |
|
61 @leave err one of the system wide error codes |
|
62 */ |
|
63 void CElfOptionsV2::ConstructL( TUint32 aUID ) |
|
64 { |
|
65 //LOG_MSG("->CElfOptionsV2::ConstructL()\n"); |
|
66 TInt err; |
|
67 |
|
68 iConfigList.ReserveL( (TInt)EElfOptionsLast ); |
|
69 |
|
70 COptionConfig * config; |
|
71 TInt index = 0; // Index of config params that we create |
|
72 |
|
73 _LIT( KTrueFalseOpt, "True,False" ); |
|
74 _LIT( KTrueOpt, "True" ); |
|
75 |
|
76 _LIT( KCreateSystemInfo, "System-Wide Crash Data Option:\n 0-System-Wide Data,\n 1-Crashed Process Only,\n 2-Both" ); |
|
77 config = COptionConfig::NewL( (TInt)ECreateSystemCrashInfo, |
|
78 aUID, |
|
79 COptionConfig::EFormatterPlugin, |
|
80 COptionConfig::ETUInt, |
|
81 KCreateSystemInfo, |
|
82 1, |
|
83 KNullDesC, |
|
84 ESystemWideAndCrashedProc, |
|
85 KNullDesC ); |
|
86 err = iConfigList.Append( config ); |
|
87 if(err != KErrNone) |
|
88 { |
|
89 delete config; |
|
90 User::Leave(err); |
|
91 } |
|
92 |
|
93 index ++; |
|
94 |
|
95 _LIT( KCreateProcessDataPrompt, |
|
96 "Create Data for all Threads in Crashed Process?" ); |
|
97 // 0 1 2 3 4 5 |
|
98 // 12345678901234567890123456789012345678901234657890 |
|
99 |
|
100 config = COptionConfig::NewL( (TInt)ECreateProcessData, |
|
101 aUID, // UID |
|
102 COptionConfig::EFormatterPlugin, |
|
103 COptionConfig::ETBool, |
|
104 KCreateProcessDataPrompt, |
|
105 1, |
|
106 KTrueFalseOpt, |
|
107 1, // Default Value = 1 == True |
|
108 KTrueOpt ); // Default Option String = True |
|
109 err = iConfigList.Append( config ); |
|
110 if(err != KErrNone) |
|
111 { |
|
112 delete config; |
|
113 User::Leave(err); |
|
114 } |
|
115 |
|
116 index ++; |
|
117 |
|
118 _LIT( KDataSegmentPrompt, "Create Data Segments?" ); |
|
119 config = COptionConfig::NewL( (TInt)ECreateDataSegments, |
|
120 aUID, // UID |
|
121 COptionConfig::EFormatterPlugin, |
|
122 COptionConfig::ETBool, |
|
123 KDataSegmentPrompt, |
|
124 1, // Number of options |
|
125 KTrueFalseOpt, // Option string |
|
126 1, // Default Value = 1 == True |
|
127 KTrueOpt ); // Default Option String = True |
|
128 err = iConfigList.Append( config ); |
|
129 if(err != KErrNone) |
|
130 { |
|
131 delete config; |
|
132 User::Leave(err); |
|
133 } |
|
134 |
|
135 index ++; |
|
136 |
|
137 _LIT( KCodeSegmentPrompt, "Create Code Segments?" ); |
|
138 config = COptionConfig::NewL( (TInt)ECreateCodeSegments, |
|
139 aUID, // UID |
|
140 COptionConfig::EFormatterPlugin, |
|
141 COptionConfig::ETBool, |
|
142 KCodeSegmentPrompt, |
|
143 1, |
|
144 KTrueFalseOpt, |
|
145 1, // Default Value = 1 == True |
|
146 KTrueOpt ); // Default Option String = True |
|
147 err = iConfigList.Append( config ); |
|
148 if(err != KErrNone) |
|
149 { |
|
150 delete config; |
|
151 User::Leave(err); |
|
152 } |
|
153 |
|
154 index ++; |
|
155 |
|
156 _LIT( KThreadSegmentPrompt, "Create Thread Segments?" ); |
|
157 config = COptionConfig::NewL( (TInt)ECreateThreadSegments, |
|
158 aUID, // UID |
|
159 COptionConfig::EFormatterPlugin, |
|
160 COptionConfig::ETBool, |
|
161 KThreadSegmentPrompt, |
|
162 1, |
|
163 KTrueFalseOpt, |
|
164 1, // Default Value = 1 == True |
|
165 KTrueOpt ); // Default Option String = True |
|
166 err = iConfigList.Append( config ); |
|
167 if(err != KErrNone) |
|
168 { |
|
169 delete config; |
|
170 User::Leave(err); |
|
171 } |
|
172 |
|
173 index ++; |
|
174 |
|
175 _LIT( KRegisterSegmentPrompt, "Create Register Segments?" ); |
|
176 config = COptionConfig::NewL( (TInt)ECreateRegisterSegments, |
|
177 aUID, // UID |
|
178 COptionConfig::EFormatterPlugin, |
|
179 COptionConfig::ETBool, |
|
180 KRegisterSegmentPrompt, |
|
181 1, |
|
182 KTrueFalseOpt, |
|
183 1, // Default Value = 1 == True |
|
184 KTrueOpt ); // Default Option String = True |
|
185 err = iConfigList.Append( config ); |
|
186 if(err != KErrNone) |
|
187 { |
|
188 delete config; |
|
189 User::Leave(err); |
|
190 } |
|
191 |
|
192 index ++; |
|
193 |
|
194 _LIT( KCreateExecInfoPrompt, "Create Exec Info?" ); |
|
195 config = COptionConfig::NewL( (TInt)ECreateExecSegments, |
|
196 aUID, // UID |
|
197 COptionConfig::EFormatterPlugin, |
|
198 COptionConfig::ETBool, |
|
199 KCreateExecInfoPrompt, |
|
200 1, |
|
201 KTrueFalseOpt, |
|
202 1, // Default Value = 1 == True |
|
203 KTrueOpt ); // Default Option String = True |
|
204 err = iConfigList.Append( config ); |
|
205 if(err != KErrNone) |
|
206 { |
|
207 delete config; |
|
208 User::Leave(err); |
|
209 } |
|
210 |
|
211 index ++; |
|
212 |
|
213 _LIT( KCreateProcessSegmentInfo, "Create Process Info?" ); |
|
214 config = COptionConfig::NewL( (TInt)ECreateProcessSegments, |
|
215 aUID, // UID |
|
216 COptionConfig::EFormatterPlugin, |
|
217 COptionConfig::ETBool, |
|
218 KCreateProcessSegmentInfo, |
|
219 1, |
|
220 KTrueFalseOpt, |
|
221 1, // Default Value = 1 == True |
|
222 KTrueOpt ); // Default Option String = True |
|
223 err = iConfigList.Append( config ); |
|
224 if(err != KErrNone) |
|
225 { |
|
226 delete config; |
|
227 User::Leave(err); |
|
228 } |
|
229 |
|
230 index++; |
|
231 |
|
232 _LIT( KCreateTraceData, "How much Trace data to capture (Kb)" ); |
|
233 config = COptionConfig::NewL( (TInt)ECreateTraceData, |
|
234 aUID, |
|
235 COptionConfig::EFormatterPlugin, |
|
236 COptionConfig::ETInt, |
|
237 KCreateTraceData, |
|
238 1, |
|
239 KNullDesC, |
|
240 100, |
|
241 KNullDesC ); |
|
242 err = iConfigList.Append( config ); |
|
243 if(err != KErrNone) |
|
244 { |
|
245 delete config; |
|
246 User::Leave(err); |
|
247 } |
|
248 |
|
249 index ++; |
|
250 |
|
251 _LIT( KCreateLockData, "Capture System Lock Data ?" ); |
|
252 config = COptionConfig::NewL( (TInt)ECreateLockSegments, |
|
253 aUID, |
|
254 COptionConfig::EFormatterPlugin, |
|
255 COptionConfig::ETBool, |
|
256 KCreateLockData, |
|
257 1, |
|
258 KTrueFalseOpt, |
|
259 1, |
|
260 KTrueOpt ); |
|
261 err = iConfigList.Append( config ); |
|
262 if(err != KErrNone) |
|
263 { |
|
264 delete config; |
|
265 User::Leave(err); |
|
266 } |
|
267 |
|
268 index ++; |
|
269 |
|
270 _LIT( KCreateRomBuildInfo, "Capture ROM build data ?" ); |
|
271 config = COptionConfig::NewL( (TInt)ECreateRomInfo, |
|
272 aUID, |
|
273 COptionConfig::EFormatterPlugin, |
|
274 COptionConfig::ETInt, |
|
275 KCreateRomBuildInfo, |
|
276 1, |
|
277 KNullDesC, |
|
278 100, |
|
279 KNullDesC ); |
|
280 err = iConfigList.Append( config ); |
|
281 if(err != KErrNone) |
|
282 { |
|
283 delete config; |
|
284 User::Leave(err); |
|
285 } |
|
286 |
|
287 index ++; |
|
288 |
|
289 _LIT( KCreateHeapData, "Capture Heap Data ?" ); |
|
290 config = COptionConfig::NewL( (TInt)ECreateHeapInfo, |
|
291 aUID, |
|
292 COptionConfig::EFormatterPlugin, |
|
293 COptionConfig::ETBool, |
|
294 KCreateHeapData, |
|
295 1, |
|
296 KTrueFalseOpt, |
|
297 1, |
|
298 KTrueOpt ); |
|
299 err = iConfigList.Append( config ); |
|
300 if(err != KErrNone) |
|
301 { |
|
302 delete config; |
|
303 User::Leave(err); |
|
304 } |
|
305 |
|
306 index ++; |
|
307 |
|
308 _LIT( KCreateVariantData, "Create Variant Specific Data ?" ); |
|
309 config = COptionConfig::NewL( (TInt)ECreateVariantInfo, |
|
310 aUID, |
|
311 COptionConfig::EFormatterPlugin, |
|
312 COptionConfig::ETBool, |
|
313 KCreateVariantData, |
|
314 1, |
|
315 KTrueFalseOpt, |
|
316 1, |
|
317 KTrueOpt ); |
|
318 err = iConfigList.Append( config ); |
|
319 if(err != KErrNone) |
|
320 { |
|
321 delete config; |
|
322 User::Leave(err); |
|
323 } |
|
324 |
|
325 index ++; |
|
326 } |
|
327 |
|
328 /** |
|
329 ctor nothing really |
|
330 */ |
|
331 |
|
332 CElfOptionsV2::CElfOptionsV2() |
|
333 { |
|
334 |
|
335 } |
|
336 |
|
337 /** |
|
338 dtor frees config parameter list |
|
339 */ |
|
340 CElfOptionsV2::~CElfOptionsV2() |
|
341 { |
|
342 iConfigList.ResetAndDestroy(); |
|
343 } |
|
344 |
|
345 /** |
|
346 Called to obtain the value of the parameter |
|
347 @return actual value of the parameter |
|
348 */ |
|
349 TBool CElfOptionsV2::CreateProcessData() const |
|
350 { |
|
351 return iConfigList[ (TInt)ECreateProcessData ]->ValueAsBool(); |
|
352 } |
|
353 |
|
354 /** |
|
355 Called to obtain the value of the parameter |
|
356 @return actual value of the parameter |
|
357 */ |
|
358 TBool CElfOptionsV2::CreateDataSegments() const |
|
359 { |
|
360 if( CreateSystemWideOnly() ) |
|
361 return EFalse; |
|
362 |
|
363 return iConfigList[ (TInt)ECreateDataSegments ]->ValueAsBool(); |
|
364 } |
|
365 |
|
366 /** |
|
367 Called to obtain the value of the parameter |
|
368 @return actual value of the parameter |
|
369 */ |
|
370 TBool CElfOptionsV2::CreateCodeSegments() const |
|
371 { |
|
372 if( CreateSystemWideOnly() ) |
|
373 return EFalse; |
|
374 |
|
375 return iConfigList[ (TInt)ECreateCodeSegments ]->ValueAsBool(); |
|
376 } |
|
377 |
|
378 /** |
|
379 Called to obtain the value of the parameter |
|
380 @return actual value of the parameter |
|
381 */ |
|
382 TBool CElfOptionsV2::CreateThreadSegments() const |
|
383 { |
|
384 return iConfigList[ (TInt)ECreateThreadSegments ]->ValueAsBool(); |
|
385 } |
|
386 |
|
387 /** |
|
388 Called to obtain the value of the parameter |
|
389 @return actual value of the parameter |
|
390 */ |
|
391 TBool CElfOptionsV2::CreateRegisterSegments() const |
|
392 { |
|
393 if( CreateSystemWideOnly() ) |
|
394 return EFalse; |
|
395 |
|
396 return iConfigList[ (TInt)ECreateRegisterSegments ]->ValueAsBool(); |
|
397 } |
|
398 |
|
399 /** |
|
400 Called to obtain the value of the parameter |
|
401 @return actual value of the parameter |
|
402 */ |
|
403 TBool CElfOptionsV2::CreateExecSegments() const |
|
404 { |
|
405 if( CreateSystemWideOnly() ) |
|
406 return EFalse; |
|
407 |
|
408 return iConfigList[ (TInt)ECreateExecSegments ]->ValueAsBool(); |
|
409 } |
|
410 |
|
411 /** |
|
412 Called to obtain the value of the parameter |
|
413 @return actual value of the parameter |
|
414 */ |
|
415 TBool CElfOptionsV2::CreateProcessSegments() const |
|
416 { |
|
417 return iConfigList[ (TInt)ECreateProcessSegments ]->ValueAsBool(); |
|
418 } |
|
419 |
|
420 /** |
|
421 Called to obtain the value of the parameter |
|
422 @return actual value of the parameter |
|
423 */ |
|
424 TBool CElfOptionsV2::CreateSystemWideOnly() const |
|
425 { |
|
426 return ( ESystemWideOnly == iConfigList[ (TInt)ECreateSystemCrashInfo ]->Value() ); |
|
427 } |
|
428 |
|
429 /** |
|
430 Called to obtain the value of the parameter |
|
431 @return actual value of the parameter |
|
432 */ |
|
433 TBool CElfOptionsV2::CreateSystemCrashInfo() const |
|
434 { |
|
435 |
|
436 switch( iConfigList[ (TInt)ECreateSystemCrashInfo ]->Value() ) |
|
437 { |
|
438 case ESystemWideOnly: |
|
439 case ESystemWideAndCrashedProc: |
|
440 return ETrue; |
|
441 case ECrashedProcessOnly: |
|
442 default: |
|
443 return EFalse; |
|
444 } |
|
445 } |
|
446 |
|
447 /** |
|
448 Called to obtain the value of the parameter |
|
449 @return actual value of the parameter |
|
450 */ |
|
451 TInt CElfOptionsV2::TraceDataToCapture() const |
|
452 { |
|
453 return iConfigList[ (TInt)ECreateTraceData ]->Value(); |
|
454 } |
|
455 |
|
456 /** |
|
457 Called to obtain the value of the parameter |
|
458 @return actual value of the parameter |
|
459 */ |
|
460 TBool CElfOptionsV2::CreateLockDataSegments() const |
|
461 { |
|
462 return iConfigList[ (TInt)ECreateLockSegments ]->Value(); |
|
463 } |
|
464 |
|
465 /** |
|
466 Called to obtain the value of the parameter |
|
467 @return actual value of the parameter |
|
468 */ |
|
469 TBool CElfOptionsV2::CreateRomBuildInfo() const |
|
470 { |
|
471 return iConfigList[ (TInt)ECreateRomInfo ]->Value(); |
|
472 } |
|
473 |
|
474 /** |
|
475 Called to obtain the value of the heap data option |
|
476 @return Whether or not to dump heap data |
|
477 */ |
|
478 TBool CElfOptionsV2::CreateHeapData() const |
|
479 { |
|
480 LOG_MSG2("CElfOptionsV2::CreateHeapData ret %d", iConfigList[(TInt)ECreateHeapInfo]->Value()); |
|
481 return iConfigList[(TInt)ECreateHeapInfo]->Value(); |
|
482 } |
|
483 |
|
484 /** |
|
485 Called to obtain the value of the variant specific data option |
|
486 @return Whether or not to dump variant data |
|
487 */ |
|
488 TBool CElfOptionsV2::CreateVariantSpecificData() const |
|
489 { |
|
490 LOG_MSG2("CElfOptionsV2::CreateVariantSpecificData ret %d", iConfigList[(TInt)ECreateVariantInfo]->Value()); |
|
491 return iConfigList[(TInt)ECreateVariantInfo]->Value(); |
|
492 } |
|
493 |
|
494 /** |
|
495 Called by CDS to ask for the configuration parameters that the formatter implements. |
|
496 @return actual number of implemented config parameters |
|
497 */ |
|
498 TInt CElfOptionsV2::GetNumberConfigParametersL( ) |
|
499 { |
|
500 //LOG_MSG("->CElfOptionsV2::GetNumberConfigParametersL() : returning %d", iConfigList.Count() ); |
|
501 return iConfigList.Count(); |
|
502 } |
|
503 |
|
504 /** |
|
505 Called by CDS to ask for configuration parameter. |
|
506 @param aIndex indicates which parameter to return |
|
507 @return pointer to COptionConfig object representing the requested config parameter. Caller doesn't take ownership of the object! |
|
508 @leave KErrBadHandle if index is out of bounds |
|
509 @see COptionConfig |
|
510 */ |
|
511 COptionConfig * CElfOptionsV2::GetConfigParameterL( const TInt aIndex ) |
|
512 { |
|
513 LOG_MSG2("CElfOptionsV2::GetConfigParameterL Getting index = %d", aIndex); |
|
514 if( ( aIndex < 0 ) || ( aIndex >= iConfigList.Count() ) ) |
|
515 { |
|
516 User::Leave( KErrBadHandle ); |
|
517 } |
|
518 |
|
519 return iConfigList[aIndex]; |
|
520 |
|
521 } |
|
522 |
|
523 /** |
|
524 Called by CDS with response to prompt from user. Plugin interprets |
|
525 the response (eg create file, check permissions, pre-allocate memory etc). |
|
526 |
|
527 @param aIndex Index of parameter to change |
|
528 @param aValue Unused |
|
529 @param aDescValue Path and filename to use |
|
530 @return KErrNone |
|
531 @leave KErrBadHandle if index is out of bounds or one of the other system wide error codes |
|
532 */ |
|
533 TInt CElfOptionsV2::SetConfigParameterL( const TInt aIndex, const TInt32 & aValue, const TDesC & aDescValue ) |
|
534 { |
|
535 LOG_MSG3("->CElfOptionsV2::SetConfigParameterL()\n DesC = %S aIndex = %d", &aDescValue, aIndex); |
|
536 |
|
537 // Make the changes to our internal structures, and reflect such changes in our behaviour |
|
538 |
|
539 if( ( aIndex < 0 ) || ( aIndex > iConfigList.Count() ) ) |
|
540 { |
|
541 LOG_MSG2( "CElfOptionsV2::SetConfigParameterL(): ERROR !* : aIndex=%d is out of bounds\n", aIndex ); |
|
542 User::Leave( KErrBadHandle ); |
|
543 } |
|
544 |
|
545 COptionConfig * config = iConfigList[aIndex]; |
|
546 |
|
547 switch( config->Index() ) |
|
548 { |
|
549 case ECreateProcessData: |
|
550 case ECreateDataSegments: |
|
551 case ECreateCodeSegments: |
|
552 case ECreateThreadSegments: |
|
553 case ECreateRegisterSegments: |
|
554 case ECreateExecSegments: |
|
555 case ECreateProcessSegments: |
|
556 case ECreateHeapInfo: |
|
557 case ECreateVariantInfo: |
|
558 if( 0 == aValue ) |
|
559 { |
|
560 config->Value( EFalse ); |
|
561 } |
|
562 else if( 1 == aValue ) |
|
563 { |
|
564 config->Value( ETrue ); |
|
565 } |
|
566 else |
|
567 { |
|
568 LOG_MSG2( "CElfOptionsV2::SetConfigParameterL(): ERROR !* : invalid value %d\n", aValue ); |
|
569 User::Leave( KErrArgument ); |
|
570 } |
|
571 break; |
|
572 |
|
573 case ECreateSystemCrashInfo: |
|
574 { |
|
575 if( ESystemWideOnly == aValue ) |
|
576 { |
|
577 config->Value( ESystemWideOnly ); |
|
578 } |
|
579 else if( ECrashedProcessOnly == aValue ) |
|
580 { |
|
581 config->Value( ECrashedProcessOnly ); |
|
582 } |
|
583 else if( ESystemWideAndCrashedProc == aValue ) |
|
584 { |
|
585 config->Value( ESystemWideAndCrashedProc ); |
|
586 } |
|
587 else |
|
588 { |
|
589 User::Leave( KErrArgument ); |
|
590 } |
|
591 } |
|
592 break; |
|
593 case ECreateTraceData: |
|
594 { |
|
595 config->Value(aValue); |
|
596 } |
|
597 break; |
|
598 default: |
|
599 break; |
|
600 }//switch |
|
601 |
|
602 LOG_MSG("CElfOptionsV2::SetConfigParameterL finished"); |
|
603 return KErrNone; |
|
604 } |