|
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 |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalTechnology |
|
21 @released |
|
22 */ |
|
23 |
|
24 #include <e32cons.h> |
|
25 #include <e32debug.h> |
|
26 #include <bacline.h> |
|
27 #include <e32property.h> |
|
28 |
|
29 #include <coredumpinterface.h> |
|
30 #include <debuglogging.h> |
|
31 |
|
32 LOCAL_C void processConfigL() |
|
33 { |
|
34 |
|
35 // Create a CCrashConfig object, the configuration client-side |
|
36 // object of the CoreDump Server . |
|
37 RCoreDumpSession coredumpinterface; |
|
38 |
|
39 TInt ret = coredumpinterface.Connect(); |
|
40 |
|
41 if( KErrNone != ret ) |
|
42 { |
|
43 LOG_MSG2( "requestConfigLoadL():: Could not create a Core Dump configuration object, error=%d", ret ); |
|
44 User::Leave( ret ); |
|
45 } |
|
46 |
|
47 TUint crashes = 1; |
|
48 |
|
49 TInt argc = User::CommandLineLength(); |
|
50 TPtrC configFile(KNullDesC); |
|
51 HBufC* args = NULL; |
|
52 if(argc > 0) |
|
53 { |
|
54 args = HBufC::NewLC(User::CommandLineLength()); |
|
55 TPtr argv = args->Des(); |
|
56 User::CommandLine(argv); |
|
57 |
|
58 TLex lex(*args); |
|
59 |
|
60 while(!lex.Eos()) |
|
61 { |
|
62 if(lex.Get() == '-') |
|
63 { |
|
64 TChar c = lex.Get(); |
|
65 if(c == '-') |
|
66 { |
|
67 TPtrC16 token = lex.NextToken(); |
|
68 c = token[0]; |
|
69 } |
|
70 |
|
71 lex.SkipSpace(); |
|
72 switch(c) |
|
73 { |
|
74 case 'c': |
|
75 lex.Val(crashes); |
|
76 break; |
|
77 case 'f': |
|
78 configFile.Set(lex.NextToken()); |
|
79 break; |
|
80 default: |
|
81 User::Leave(KErrArgument); |
|
82 } |
|
83 } |
|
84 lex.SkipSpace(); |
|
85 } |
|
86 } |
|
87 |
|
88 TRAPD(err, coredumpinterface.LoadConfigL( configFile )); |
|
89 |
|
90 if(err != KErrNone) |
|
91 { |
|
92 LOG_MSG2("unable to load config file! err:%d\n", err ); |
|
93 coredumpinterface.Disconnect(); |
|
94 User::Leave(err); |
|
95 } |
|
96 |
|
97 LOG_MSG2( "Will wait for %u crashes\n", crashes ); |
|
98 |
|
99 RProperty crashCountProperty; |
|
100 User::LeaveIfError( crashCountProperty.Attach( KCoreDumpServUid, ECrashCount ) ); |
|
101 |
|
102 TInt crashCount = 0; |
|
103 do |
|
104 { |
|
105 |
|
106 User::After(5000000); |
|
107 ret = crashCountProperty.Get( crashCount ); |
|
108 LOG_MSG2( " crashCountProperty.Get( crashCount )=%d\n", crashCount ); |
|
109 if ( KErrNone != ret ) |
|
110 { |
|
111 break; |
|
112 } |
|
113 } |
|
114 while( crashes > crashCount ); |
|
115 |
|
116 crashCountProperty.Close(); |
|
117 if(args) |
|
118 { |
|
119 CleanupStack::PopAndDestroy(args); |
|
120 } |
|
121 coredumpinterface.Disconnect(); |
|
122 LOG_MSG( " returned from CleanupStack::PopAndDestroy( cmd );" ); |
|
123 |
|
124 } |
|
125 |
|
126 |
|
127 GLDEF_C TInt E32Main() // main function called by E32 |
|
128 { |
|
129 __UHEAP_MARK; |
|
130 |
|
131 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
132 if(!cleanup) |
|
133 return KErrNoMemory; |
|
134 |
|
135 TRAPD(err,processConfigL()); |
|
136 |
|
137 |
|
138 delete cleanup; |
|
139 __UHEAP_MARKEND; // Check memory leaks |
|
140 |
|
141 return err; |
|
142 } |
|
143 |