First public contribution.
1 // Copyright (c) 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 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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Responsible for dealing with process lists in the SM framework
23 #ifdef __LAUNCH_AS_EXTENSION__
25 #include <rm_debug_api.h>
26 #include <sm_debug_api.h>
27 #include "d_rmd_breakpoints.h"
29 using namespace Debug;
32 * Stop Mode routine to retrieve the process list and place it in the response buffer
33 * @param aItem List item describing the list
34 * @return One of the system wide error codes
36 TInt StopModeDebug::GetProcessList(const TListItem* aItem, bool aCheckConsistent)
38 Kern::Printf("\nDumping the process list");
40 if(aItem->iListScope != EScopeGlobal)
42 return KErrArgument; //No other scope makes sense for process list
45 //Check that the process obj con lock is ok if required
46 DObjectCon* objCon = Kern::Containers()[EProcess];
48 if(aCheckConsistent && objCon->Lock()->iHoldCount)
54 TUint8* buffer = (TUint8*)aItem->iBufferAddress;
55 TUint8* bufferPos = Align4(buffer + sizeof(TListReturn));
56 TUint8* bufferEnd = buffer + aItem->iBufferSize;
58 TListReturn* listResp = (TListReturn*)buffer;
59 listResp->iReqNo = EProcess;
60 listResp->iNumberItems = 0;
61 listResp->iDataSize = 0;
63 DProcess** firstProcess = (DProcess**)objCon->iObjects;
65 TInt numProcesses = objCon->Count();
66 for(TInt cnt = 0; cnt < numProcesses; cnt++)
68 //Get process and see if we want to list it
69 DProcess* proc = firstProcess[cnt];
70 if(proc && (proc->iId >= aItem->iStartElement) )
72 TUint32 sizeOfProc = 0;
73 TInt err = AppendProcessToBuffer(proc, bufferPos, bufferEnd, sizeOfProc);
78 ++(listResp->iNumberItems);
79 listResp->iDataSize += sizeOfProc;
80 bufferPos += sizeOfProc;
88 * Writes the required process details to the stop mode response buffer in the form of a
89 * TProcessListEntry structure
90 * @param aProc Process to write
91 * @param aBuffer Buffer to write to
92 * @param aBufferEnd Where the buffer ends
93 * @return TInt KErrTooBig if there is no more space in buffer or one of the other system wide error codes
95 TInt StopModeDebug::AppendProcessToBuffer(DProcess* aProc, TUint8* aBuffer, TUint8* aBufferEnd, TUint32& aProcSize)
98 GetObjectFullName(aProc, procName);
99 TUint32 dynamicNameLength = procName.Length();
101 DCodeSeg* codeSeg = aProc->iCodeSeg;
102 TUint16 fileNameLength = (codeSeg) ? (*codeSeg->iFileName).Length() : 0;
104 //Struct size is unicode so the filenames are twice as long, plus the size of the struct minus one character that
105 //lives inside the struct itself. Also, this is word aligned
106 TUint32 structSize = Align4( (2*fileNameLength) + (2*dynamicNameLength) + sizeof(TProcessListEntry) - sizeof(TUint16));
107 aProcSize = structSize;
109 //Is there space to write this to the buffer
110 if(aBuffer + structSize < aBufferEnd)
112 TProcessListEntry& entry = *(TProcessListEntry*)(aBuffer);
114 entry.iProcessId = (TUint64)aProc->iId;
115 entry.iFileNameLength = fileNameLength;
116 entry.iDynamicNameLength = dynamicNameLength;
117 entry.iUid3 = aProc->iUids.iUid[2].iUid;
118 entry.iAttributes = aProc->iAttributes;
123 //create TPtr to where the file name should be written
124 TPtr name = TPtr((TUint8*)&(entry.iNames[0]), fileNameLength*2, fileNameLength*2);
127 TInt err = CopyAndExpandDes(*codeSeg->iFileName, name);
134 //create TPtr to where the dynamic name should be written
135 TPtr name = TPtr((TUint8*)(&(entry.iNames[0]) + fileNameLength), dynamicNameLength*2, dynamicNameLength*2);
137 //copy the dynamic name
138 TInt err = CopyAndExpandDes(procName, name);