memspyui/ui/hb/inc/enginewrapper.h
changeset 17 4f2773374eff
child 19 4b22a598b890
equal deleted inserted replaced
15:e11368ed4880 17:4f2773374eff
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * 
       
    16 */
       
    17 
       
    18 #ifndef ENGINEWRAPPER_H_
       
    19 #define ENGINEWRAPPER_H_
       
    20 
       
    21 #include <QObject>
       
    22 
       
    23 #include <memspysession.h>
       
    24 #include <memspyapiprocess.h>
       
    25 
       
    26 typedef quint64 ProcessId;
       
    27 typedef quint64 ThreadId;
       
    28 
       
    29 class MemSpyProcess
       
    30 {
       
    31 public:
       
    32 	MemSpyProcess(CMemSpyApiProcess* process)
       
    33 		: mProcess(process)
       
    34 	{}
       
    35 	
       
    36 	virtual  ~MemSpyProcess() { delete mProcess;	}
       
    37 	
       
    38 	ProcessId id() const { return mProcess->Id(); }
       
    39 	
       
    40 	QString name() const { return QString((QChar*) mProcess->Name().Ptr(), mProcess->Name().Length()); }
       
    41 	
       
    42 	
       
    43 private:
       
    44 	CMemSpyApiProcess *mProcess;
       
    45 };
       
    46 
       
    47 enum ThreadPriority
       
    48 {
       
    49 	ThreadPriorityNull=(-30),
       
    50 	ThreadPriorityMuchLess=(-20),
       
    51 	ThreadPriorityLess=(-10),
       
    52 	ThreadPriorityNormal=0,
       
    53 	ThreadPriorityMore=10,
       
    54 	ThreadPriorityMuchMore=20,
       
    55 	ThreadPriorityRealTime=30,
       
    56 	ThreadPriorityAbsoluteVeryLow=100,
       
    57 	ThreadPriorityAbsoluteLowNormal=150,
       
    58 	ThreadPriorityAbsoluteLow=200,
       
    59 	ThreadPriorityAbsoluteBackgroundNormal=250,
       
    60 	ThreadPriorityAbsoluteBackground=300,
       
    61 	ThreadPriorityAbsoluteForegroundNormal=350,
       
    62 	ThreadPriorityAbsoluteForeground=400,
       
    63 	ThreadPriorityAbsoluteHighNormal=450,
       
    64 	ThreadPriorityAbsoluteHigh=500,
       
    65 	ThreadPriorityAbsoluteRealTime1=810,
       
    66 	ThreadPriorityAbsoluteRealTime2=820,
       
    67 	ThreadPriorityAbsoluteRealTime3=830,
       
    68 	ThreadPriorityAbsoluteRealTime4=840,
       
    69 	ThreadPriorityAbsoluteRealTime5=850,
       
    70 	ThreadPriorityAbsoluteRealTime6=860,
       
    71 	ThreadPriorityAbsoluteRealTime7=870, 
       
    72 	ThreadPriorityAbsoluteRealTime8=880
       
    73 };
       
    74 
       
    75 enum KernelObjectType
       
    76 {
       
    77 	KernelObjectTypeUnknown = -1,
       
    78 	KernelObjectTypeThread = 0,
       
    79 	KernelObjectTypeProcess,
       
    80 	KernelObjectTypeChunk,
       
    81 	KernelObjectTypeLibrary,
       
    82 	KernelObjectTypeSemaphore,
       
    83 	KernelObjectTypeMutex,
       
    84 	KernelObjectTypeTimer,
       
    85 	KernelObjectTypeServer,
       
    86 	KernelObjectTypeSession,
       
    87 	KernelObjectTypeLogicalDevice,
       
    88 	KernelObjectTypePhysicalDevice,
       
    89 	KernelObjectTypeLogicalChannel,
       
    90 	KernelObjectTypeChangeNotifier,
       
    91 	KernelObjectTypeUndertaker,
       
    92 	KernelObjectTypeMsgQueue,
       
    93 	KernelObjectTypePropertyRef,
       
    94 	KernelObjectTypeCondVar
       
    95 };
       
    96 
       
    97 class MemSpyThread
       
    98 {
       
    99 public:
       
   100 	MemSpyThread(CMemSpyApiThread* thread)
       
   101 		: mThread(thread)
       
   102 	{}
       
   103 	
       
   104 	virtual ~MemSpyThread() { delete mThread;	}
       
   105 	
       
   106 	ThreadId id() const { return mThread->Id(); }
       
   107 	
       
   108 	QString name() const { return QString((QChar*) mThread->Name().Ptr(), mThread->Name().Length()); }
       
   109 	
       
   110 	int priority() const { return mThread->ThreadPriority(); }
       
   111 	
       
   112 	
       
   113 private:
       
   114 	CMemSpyApiThread *mThread;
       
   115 };
       
   116 
       
   117 class MemSpyKernelObjectType
       
   118 {
       
   119 public:
       
   120 	MemSpyKernelObjectType(CMemSpyApiKernelObject* type)
       
   121 		: mType(type)
       
   122 	{}
       
   123 	
       
   124 	virtual ~MemSpyKernelObjectType() { delete mType; }
       
   125 	
       
   126 	int id() const { return mType->Type(); }
       
   127 	
       
   128 	QString name() const { return QString((QChar*) mType->Name().Ptr(), mType->Name().Length()); }
       
   129 	
       
   130 private:
       
   131 	CMemSpyApiKernelObject *mType;
       
   132 };
       
   133 
       
   134 class MemSpyKernelObject
       
   135 {
       
   136 public:
       
   137 	MemSpyKernelObject(CMemSpyApiKernelObjectItem* object)
       
   138 		: mObject(object)
       
   139 	{}
       
   140 	
       
   141 	virtual ~MemSpyKernelObject() { delete mObject; }
       
   142 	
       
   143 	int type() const { return mObject->Type(); }
       
   144 	
       
   145 	QString name() const { return QString::fromLatin1((char*)mObject->Name().Ptr(), mObject->Name().Length()); }
       
   146 	
       
   147 	QString nameDetail() const { return QString::fromLatin1((char*)mObject->NameDetail().Ptr(), mObject->NameDetail().Length()); }
       
   148 	
       
   149 	int accessCount() const { return mObject->AccessCount(); }
       
   150 	
       
   151 	int uniqueId() const { return mObject->UniqueID(); }
       
   152 	
       
   153 	unsigned int protection() const { return mObject->Protection(); }
       
   154 	
       
   155 	unsigned int addressOfKernelOwner() const { return reinterpret_cast<unsigned int>(mObject->AddressOfKernelOwner()); }
       
   156 	
       
   157 	unsigned int kernelAddress() const { return reinterpret_cast<unsigned int>(mObject->Handle()); }
       
   158 	
       
   159 	unsigned int addressOfOwningProcess() const { return reinterpret_cast<unsigned int>(mObject->AddressOfOwningProcess()); }
       
   160 	
       
   161 	int id() const { return mObject->Id(); }
       
   162 	
       
   163 	int priority() const { return mObject->Priority(); }
       
   164 	
       
   165 	QString nameOfOwner() const { return QString::fromLatin1((char*)mObject->NameOfOwner().Ptr(), mObject->NameOfOwner().Length()); }
       
   166 	
       
   167 	unsigned int creatorId() const { return mObject->CreatorId(); }
       
   168 	
       
   169 	int attributes() const { return mObject->Attributes(); }
       
   170 	
       
   171 	unsigned int addressOfDataBssStackChunk() const { return reinterpret_cast<unsigned int>(mObject->AddressOfDataBssStackChunk()); }
       
   172 	
       
   173 	unsigned int securityZone() const { return mObject->SecurityZone(); }
       
   174 	
       
   175 	unsigned int size() const { return mObject->Size(); }
       
   176 	
       
   177 	unsigned int maxSize() const { return mObject->MaxSize(); }
       
   178 	
       
   179 	unsigned int bottom() const { return mObject->Bottom(); }
       
   180 	
       
   181 	unsigned int top() const { return mObject->Top(); }
       
   182 	
       
   183 	unsigned int startPos() const { return mObject->StartPos(); }
       
   184 	
       
   185 	unsigned int controllingOwner() const { return mObject->ControllingOwner(); }
       
   186 	
       
   187 	unsigned int restrictions() const { return mObject->Restrictions(); }
       
   188 	
       
   189 	unsigned int mapAttr() const { return mObject->Restrictions(); }
       
   190 	
       
   191 	unsigned int chunkType() const { return mObject->ChunkType(); }
       
   192 	
       
   193 	int mapCount() const { return mObject->MapCount(); }
       
   194 	
       
   195 	unsigned int state() const { return mObject->State(); }
       
   196 	
       
   197 	unsigned int addressOfCodeSeg() const { return reinterpret_cast<unsigned int>(mObject->AddressOfCodeSeg()); }
       
   198 	
       
   199 	unsigned int resetting() const { return mObject->Resetting(); }
       
   200 	
       
   201 	unsigned int order() const { return mObject->Order(); }
       
   202 	
       
   203 	QString version() const { return QString((QChar*) mObject->Version().Name().Ptr(), mObject->Version().Name().Length()); }
       
   204 	
       
   205 	unsigned int parseMask() const { return mObject->ParseMask(); }
       
   206 	
       
   207 	unsigned int unitsMask() const { return mObject->UnitsMask(); }
       
   208 	
       
   209 	unsigned int changes() const { return mObject->Changes(); }
       
   210 	
       
   211 	int count() const { return mObject->Count(); }
       
   212 	
       
   213 	int waitCount() const { return mObject->WaitCount(); }
       
   214 
       
   215 	int sessionType() const { return mObject->SessionType(); }
       
   216 
       
   217 	int timerType() const { return mObject->TimerType(); }
       
   218 	
       
   219 	int timerState() const { return mObject->TimerState(); }
       
   220 	
       
   221 	unsigned int addressOfOwningThread() const { return reinterpret_cast<unsigned int>(mObject->AddressOfOwningThread()); }
       
   222 	
       
   223 	unsigned int addressOfServer() const { return reinterpret_cast<unsigned int>(mObject->AddressOfServer()); }
       
   224 	
       
   225 	unsigned int svrSessionType() const { return mObject->SvrSessionType(); }
       
   226 	
       
   227 	int msgCount() const { return mObject->MsgCount(); }
       
   228 	
       
   229 	int msgLimit() const { return mObject->MsgLimit(); }
       
   230 	
       
   231 	unsigned int totalAccessCount() const { return mObject->TotalAccessCount(); }
       
   232 	
       
   233 	int openChannels() const { return mObject->OpenChannels(); }
       
   234 	
       
   235 private:
       
   236 	CMemSpyApiKernelObjectItem *mObject;
       
   237 };
       
   238 
       
   239 class EngineWrapper : public QObject
       
   240 {
       
   241 public:
       
   242 	virtual ~EngineWrapper();
       
   243 	bool initialize();
       
   244 	
       
   245 	QList<MemSpyProcess*> getProcesses();
       
   246 	
       
   247 	QList<MemSpyThread*> getThreads(ProcessId processId);
       
   248 	
       
   249 	void setThreadPriority(ThreadId threadId, ThreadPriority priority);
       
   250 	
       
   251 	QList<MemSpyKernelObjectType*> getKernelObjectTypes();
       
   252 	
       
   253 	QList<MemSpyKernelObject*> getKernelObjects(int type);
       
   254 	
       
   255 private:
       
   256 	RMemSpySession mSession;
       
   257 	
       
   258 };
       
   259 
       
   260 #endif /* ENGINEWRAPPER_H_ */