Update contrib.
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 requests for the SM interface
23 #include <rm_debug_api.h>
24 #include <sm_debug_api.h>
26 #include "d_rmd_breakpoints.h"
29 #ifdef __LAUNCH_AS_EXTENSION__
31 using namespace Debug;
33 _LIT(KLitLocal,"Local-");
34 _LIT(KColonColon,"::");
37 * This is the generic exit point for all stop mode routines
38 * @param aReturnValue Symbian Error Code to return
39 * @return One of the Symbian wide error codes
41 EXPORT_C TInt StopModeDebug::ExitPoint(const TInt aReturnValue)
47 * This is the routine that shall return lists of information such as
48 * process list or code segment list etc
49 * @pre aItem->iBufferAddress must be word aligned
50 * @param aItem Describes the list to retrieve
51 * @param aCheckConsistent Should we check the mutex on the list
52 * @return One of the Symbian wide error codes
54 EXPORT_C TInt StopModeDebug::GetList(const TListItem* aItem, TBool aCheckConsistent)
58 ((TUint32)aItem->iBufferAddress == 0)||
59 ((TUint32)aItem->iBufferAddress % 4) )
61 return StopModeDebug::ExitPoint(KErrArgument);
64 switch(aItem->iListId)
68 return StopModeDebug::ExitPoint(StopModeDebug::GetCodeSegList(aItem, aCheckConsistent));
72 return StopModeDebug::ExitPoint(StopModeDebug::GetProcessList(aItem, aCheckConsistent));
76 return StopModeDebug::ExitPoint(StopModeDebug::GetStaticInfo(aItem, aCheckConsistent));
80 return StopModeDebug::ExitPoint(KErrUnknown);
85 TInt StopModeDebug::CopyAndExpandDes(const TDesC& aSrc, TDes& aDest)
88 if(aSrc.Length() * 2 > aDest.MaxLength())
93 //get a pointer to the start of the destination descriptor
94 TUint16* destPtr = (TUint16*)aDest.Ptr();
96 //get pointers to the start and end of the aSrc descriptor
97 const TUint8* srcPtr = aSrc.Ptr();
98 const TUint8* srcEnd = srcPtr + aSrc.Length();
100 //copy the characters from aSrc into aDest, expanding to make them 16-bit characters
101 while(srcPtr < srcEnd)
103 *destPtr = (TUint16)*srcPtr;
108 //set aDest's length to reflect the new contents
109 aDest.SetLength(2*aSrc.Length());
114 * This is a function used to test communications with the Stop Mode API
115 * We pass in aItem which is interpreted in a different way to normal to allow
116 * us to test different scenarios:
118 * 1. Sending in aItem.iSize = 0xFFFFFFFF will result in the response buffer being
119 * filled with 0xFFFFFFFF
121 * @param aItem Drives the test according to its parameters
123 EXPORT_C TInt StopModeDebug::TestAPI(const TListItem* aItem)
125 //Check params are valid
126 if(!aItem || ((TUint32)aItem->iBufferAddress % 4) ||
127 ((TUint32)aItem->iBufferAddress == 0) ||
128 (aItem->iBufferSize % 4) )
130 return StopModeDebug::ExitPoint(KErrArgument);
133 //Performs the test function
134 if(aItem->iSize == 0xFFFFFFFF)
136 //Write all 0xFFFFFFFF into the entire buffer
137 TUint8* pos = (TUint8*)aItem->iBufferAddress;
138 while(pos < ( (TUint8*)aItem->iBufferAddress + aItem->iBufferSize) )
145 return StopModeDebug::ExitPoint(KErrNone);
149 * Reads the raw name for this object instead of using API in DObject,
150 * as we can't meet the preconditions
151 * @param DObject object whose name we want
153 void StopModeDebug::GetObjectFullName(const DObject* aObj, TFullName& aName)
157 GetObjectFullName(aObj->iOwner, aName);
158 aName.Append(KColonColon);
163 aName.Append(*aObj->iName);
167 aName.Append(KLitLocal);
168 aName.AppendNumFixedWidth((TInt)aObj,EHex,8);
175 // End of file d_stopmode.cpp