author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 02 Sep 2010 21:54:16 +0300 | |
changeset 259 | 57b9594f5772 |
parent 0 | a41df078684a |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1 |
// Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 2 |
// All rights reserved. |
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "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 |
// Responsible for dealing with process lists in the SM framework |
|
15 |
// |
|
16 |
||
17 |
/** |
|
18 |
* @file |
|
19 |
* @internalComponent |
|
20 |
* @prototype |
|
21 |
*/ |
|
22 |
||
23 |
#include <sm_debug_api.h> |
|
24 |
||
25 |
using namespace Debug; |
|
26 |
||
27 |
/** |
|
28 |
* Stop Mode routine to retrieve the process list and place it in the response buffer |
|
29 |
* @param aItem List item describing the list |
|
30 |
* @return One of the system wide error codes |
|
31 |
*/ |
|
32 |
TInt StopModeDebug::GetProcessList(const TListItem* aItem, bool aCheckConsistent) |
|
33 |
{ |
|
34 |
Kern::Printf("\nDumping the process list"); |
|
35 |
||
36 |
if(aItem->iListScope != EScopeGlobal) |
|
37 |
{ |
|
38 |
return KErrArgument; //No other scope makes sense for process list |
|
39 |
} |
|
40 |
||
41 |
//Check that the process obj con lock is ok if required |
|
42 |
DObjectCon* objCon = Kern::Containers()[EProcess]; |
|
43 |
||
44 |
if(aCheckConsistent && objCon->Lock()->iHoldCount) |
|
45 |
{ |
|
46 |
return KErrNotReady; |
|
47 |
} |
|
48 |
||
49 |
//Look at the buffer |
|
50 |
TUint8* buffer = (TUint8*)aItem->iBufferAddress; |
|
51 |
TUint8* bufferPos = Align4(buffer + sizeof(TListReturn)); |
|
52 |
TUint8* bufferEnd = buffer + aItem->iBufferSize; |
|
53 |
||
54 |
TListReturn* listResp = (TListReturn*)buffer; |
|
55 |
listResp->iReqNo = EProcess; |
|
56 |
listResp->iNumberItems = 0; |
|
57 |
listResp->iDataSize = 0; |
|
58 |
||
59 |
DProcess** firstProcess = (DProcess**)objCon->iObjects; |
|
60 |
||
61 |
TInt numProcesses = objCon->Count(); |
|
62 |
for(TInt cnt = 0; cnt < numProcesses; cnt++) |
|
63 |
{ |
|
64 |
//Get process and see if we want to list it |
|
65 |
DProcess* proc = firstProcess[cnt]; |
|
66 |
if(proc && (proc->iId >= aItem->iStartElement) ) |
|
67 |
{ |
|
68 |
TUint32 sizeOfProc = 0; |
|
69 |
TInt err = AppendProcessToBuffer(proc, bufferPos, bufferEnd, sizeOfProc); |
|
70 |
if(KErrNone != err) |
|
71 |
{ |
|
72 |
return err; |
|
73 |
} |
|
74 |
++(listResp->iNumberItems); |
|
75 |
listResp->iDataSize += sizeOfProc; |
|
76 |
bufferPos += sizeOfProc; |
|
77 |
} |
|
78 |
} |
|
79 |
||
80 |
return KErrNone; |
|
81 |
} |
|
82 |
||
83 |
/** |
|
84 |
* Writes the required process details to the stop mode response buffer in the form of a |
|
85 |
* TProcessListEntry structure |
|
86 |
* @param aProc Process to write |
|
87 |
* @param aBuffer Buffer to write to |
|
88 |
* @param aBufferEnd Where the buffer ends |
|
89 |
* @return TInt KErrTooBig if there is no more space in buffer or one of the other system wide error codes |
|
90 |
*/ |
|
91 |
TInt StopModeDebug::AppendProcessToBuffer(DProcess* aProc, TUint8* aBuffer, TUint8* aBufferEnd, TUint32& aProcSize) |
|
92 |
{ |
|
93 |
TFullName procName; |
|
94 |
GetObjectFullName(aProc, procName); |
|
95 |
TUint32 dynamicNameLength = procName.Length(); |
|
96 |
||
97 |
DCodeSeg* codeSeg = aProc->iCodeSeg; |
|
98 |
TUint16 fileNameLength = (codeSeg) ? (*codeSeg->iFileName).Length() : 0; |
|
99 |
||
100 |
//Struct size is unicode so the filenames are twice as long, plus the size of the struct minus one character that |
|
101 |
//lives inside the struct itself. Also, this is word aligned |
|
102 |
TUint32 structSize = Align4( (2*fileNameLength) + (2*dynamicNameLength) + sizeof(TProcessListEntry) - sizeof(TUint16)); |
|
103 |
aProcSize = structSize; |
|
104 |
||
105 |
//Is there space to write this to the buffer |
|
106 |
if(aBuffer + structSize < aBufferEnd) |
|
107 |
{ |
|
108 |
TProcessListEntry& entry = *(TProcessListEntry*)(aBuffer); |
|
109 |
||
110 |
entry.iProcessId = (TUint64)aProc->iId; |
|
111 |
entry.iFileNameLength = fileNameLength; |
|
112 |
entry.iDynamicNameLength = dynamicNameLength; |
|
113 |
entry.iUid3 = aProc->iUids.iUid[2].iUid; |
|
114 |
entry.iAttributes = aProc->iAttributes; |
|
115 |
||
116 |
//Write the filename |
|
117 |
if(codeSeg) |
|
118 |
{ |
|
119 |
//create TPtr to where the file name should be written |
|
120 |
TPtr name = TPtr((TUint8*)&(entry.iNames[0]), fileNameLength*2, fileNameLength*2); |
|
121 |
||
122 |
//copy the file name |
|
123 |
TInt err = CopyAndExpandDes(*codeSeg->iFileName, name); |
|
124 |
if(KErrNone != err) |
|
125 |
{ |
|
126 |
return KErrGeneral; |
|
127 |
} |
|
128 |
} |
|
129 |
||
130 |
//create TPtr to where the dynamic name should be written |
|
131 |
TPtr name = TPtr((TUint8*)(&(entry.iNames[0]) + fileNameLength), dynamicNameLength*2, dynamicNameLength*2); |
|
132 |
||
133 |
//copy the dynamic name |
|
134 |
TInt err = CopyAndExpandDes(procName, name); |
|
135 |
if(KErrNone != err) |
|
136 |
{ |
|
137 |
return KErrGeneral; |
|
138 |
} |
|
139 |
||
140 |
return KErrNone; |
|
141 |
} |
|
142 |
else |
|
143 |
{ |
|
144 |
return KErrTooBig; |
|
145 |
} |
|
146 |
} |
|
147 |
||
148 |