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