|
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 // Tests the Core Dump Server and the Debug Security Server |
|
15 // by debugging the same executable. This is not possible but should fail |
|
16 // gracefully. This is done as follows: |
|
17 // 1 Start a client of the DSS called CRunModeAgent |
|
18 // 2 Start a test debug application (crashapp.exe) |
|
19 // 3 Actively attach to crashapp.exe |
|
20 // 4 Start coredumpscript.exe, which starts the Core Dump Server |
|
21 // and then loads the saved config. If the configuration has been set |
|
22 // to observe the crashapp.exe, the DSS should not allow this. |
|
23 // |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <e32cons.h> |
|
27 #include <e32debug.h> |
|
28 #include <rm_debug_api.h> |
|
29 |
|
30 |
|
31 class CRunModeAgent : public CBase |
|
32 { |
|
33 public: |
|
34 static CRunModeAgent* NewL(); |
|
35 ~CRunModeAgent(); |
|
36 void ClientAppL(); |
|
37 |
|
38 private: |
|
39 CRunModeAgent(); |
|
40 void ConstructL(); |
|
41 void AttachToDSS(); |
|
42 void SetupAndAttachToDSS(); |
|
43 |
|
44 private: |
|
45 Debug::RSecuritySvrSession iServSession; |
|
46 }; |
|
47 |
|
48 |
|
49 |
|
50 using namespace Debug; |
|
51 |
|
52 /** |
|
53 This is the version of the security server that we have developed our code against |
|
54 and it comes from the interface definition of the DSS at the time of compilation. |
|
55 */ |
|
56 const TVersion securityServerVersion( |
|
57 KDebugServMajorVersionNumber, |
|
58 KDebugServMinorVersionNumber, |
|
59 KDebugServPatchVersionNumber ); |
|
60 |
|
61 CRunModeAgent::CRunModeAgent() |
|
62 // |
|
63 // CRunModeAgent constructor |
|
64 // |
|
65 { |
|
66 } |
|
67 |
|
68 CRunModeAgent* CRunModeAgent::NewL() |
|
69 // |
|
70 // CRunModeAgent::NewL |
|
71 // |
|
72 { |
|
73 CRunModeAgent* self = new(ELeave) CRunModeAgent(); |
|
74 |
|
75 self->ConstructL(); |
|
76 |
|
77 return self; |
|
78 } |
|
79 |
|
80 CRunModeAgent::~CRunModeAgent() |
|
81 // |
|
82 // CRunModeAgent destructor |
|
83 // |
|
84 { |
|
85 iServSession.Close(); |
|
86 } |
|
87 |
|
88 |
|
89 void CRunModeAgent::ConstructL() |
|
90 // |
|
91 // CRunModeAgent::ConstructL |
|
92 // |
|
93 { |
|
94 // nothing to do here |
|
95 } |
|
96 |
|
97 |
|
98 void CRunModeAgent::SetupAndAttachToDSS() |
|
99 { |
|
100 TInt err = iServSession.Connect(securityServerVersion); |
|
101 if (err != KErrNone) |
|
102 { |
|
103 User::Panic(_L("Can't open server session"), err); |
|
104 } |
|
105 } |
|
106 |
|
107 |
|
108 _LIT( KCrashAppFileName,"z:\\sys\\bin\\crashapp.exe"); |
|
109 _LIT( KCoreDumpServerClientProc,"z:\\sys\\bin\\coredumpscript.exe"); |
|
110 |
|
111 |
|
112 void CRunModeAgent::ClientAppL() |
|
113 { |
|
114 |
|
115 RDebug::Printf( "CRunModeAgent::ClientAppL\n" ); |
|
116 |
|
117 SetupAndAttachToDSS(); |
|
118 |
|
119 |
|
120 RProcess iCrashProcess; |
|
121 RDebug::Printf( "Creating crashing application\n" ); |
|
122 TInt err = iCrashProcess.Create( KCrashAppFileName, KNullDesC ); |
|
123 RDebug::Printf( " iCrashProcess.Create( KCrashAppFileName ) returned %d\n", err ); |
|
124 User::After( 2000000 ); |
|
125 iCrashProcess.Resume(); |
|
126 |
|
127 //attach to process actively |
|
128 err = iServSession.AttachExecutable( KCrashAppFileName, EFalse ); |
|
129 RDebug::Printf( " iServSession.AttachExecutable( KCrashAppFileName, EFalse ) returned %d\n", err ); |
|
130 User::After( 2000000 ); |
|
131 |
|
132 RProcess iCoreDumpServerClientProc; |
|
133 RDebug::Printf( "Creating Core Dump Server Client Proc\n" ); |
|
134 err = iCoreDumpServerClientProc.Create( KCoreDumpServerClientProc, KNullDesC ); |
|
135 RDebug::Printf( " iCoreDumpServerClientProc.Create( KCoreDumpServerClientProc ) returned %d\n", err ); |
|
136 User::After( 2000000 ); |
|
137 iCoreDumpServerClientProc.Resume(); |
|
138 User::After( 5000000 ); |
|
139 |
|
140 iServSession.DetachExecutable( KCrashAppFileName ); |
|
141 |
|
142 } |
|
143 |
|
144 |
|
145 |
|
146 GLDEF_C TInt E32Main() |
|
147 { |
|
148 TInt ret = KErrNone; |
|
149 |
|
150 |
|
151 CTrapCleanup* trap = CTrapCleanup::New(); |
|
152 if (!trap) |
|
153 return KErrNoMemory; |
|
154 |
|
155 |
|
156 CRunModeAgent *RunModeAgent = NULL; |
|
157 TRAPD(err, RunModeAgent = CRunModeAgent::NewL()); |
|
158 if (RunModeAgent != NULL && err == KErrNone) |
|
159 { |
|
160 __UHEAP_MARK; |
|
161 TRAP(ret,RunModeAgent->ClientAppL()); |
|
162 __UHEAP_MARKEND; |
|
163 |
|
164 delete RunModeAgent; |
|
165 } |
|
166 |
|
167 delete trap; |
|
168 |
|
169 return ret; |
|
170 } |