memspyui/ui/hb/inc/enginewrapper.h
changeset 35 98924d2efce9
parent 19 4b22a598b890
equal deleted inserted replaced
34:e0ec97ec3cc4 35:98924d2efce9
    17 
    17 
    18 #ifndef ENGINEWRAPPER_H_
    18 #ifndef ENGINEWRAPPER_H_
    19 #define ENGINEWRAPPER_H_
    19 #define ENGINEWRAPPER_H_
    20 
    20 
    21 #include <QObject>
    21 #include <QObject>
       
    22 #include <QVariantList>
       
    23 #include <QSettings>
    22 
    24 
    23 #include <memspysession.h>
    25 #include <memspysession.h>
    24 
    26 
    25 typedef quint64 ProcessId;
    27 typedef quint64 ProcessId;
    26 typedef quint64 ThreadId;
    28 typedef quint64 ThreadId;
   100 	ThreadInfoTypeConditionalVariable = EMemSpyThreadInfoItemTypeConditionalVariable,
   102 	ThreadInfoTypeConditionalVariable = EMemSpyThreadInfoItemTypeConditionalVariable,
   101 	ThreadInfoTypeLDD = EMemSpyThreadInfoItemTypeLDD,
   103 	ThreadInfoTypeLDD = EMemSpyThreadInfoItemTypeLDD,
   102 	ThreadInfoTypePDD = EMemSpyThreadInfoItemTypePDD,
   104 	ThreadInfoTypePDD = EMemSpyThreadInfoItemTypePDD,
   103 };
   105 };
   104 
   106 
       
   107 enum DeviceWideOperation
       
   108 {
       
   109 	OutputPhoneInfo = 0,
       
   110 	    
       
   111 	OutputDetailedPhoneInfo,
       
   112 	    
       
   113 	OutputHeapInfo,
       
   114 	    
       
   115 	OutputCompactHeapInfo,
       
   116 	    
       
   117 	OutputHeapCellListing,
       
   118 	    
       
   119 	OutputHeapData,
       
   120 	    
       
   121 	OutputStackInfo,
       
   122 	    
       
   123 	OutputCompactStackInfo,
       
   124 	    
       
   125 	OutputUserStackData,
       
   126 	    
       
   127 	OutputKernelStackData
       
   128 };
       
   129 
       
   130 enum SwmtMode
       
   131 {
       
   132 	SwmtModeBasic = 0,
       
   133 	SwmtModeFull,
       
   134 	SwmtModeCustom
       
   135 };
       
   136 
       
   137 enum HeapDumpsMode
       
   138 {
       
   139 	HeapDumpsModeKernel = 0,
       
   140 	HeapDumpsModeUser,
       
   141 	HeapDumpsModeBoth
       
   142 };
       
   143 
       
   144 enum OutputMode
       
   145 {
       
   146 	OutputModeTrace = 0,
       
   147 	OutputModeFile
       
   148 };
       
   149 
   105 class MemSpyProcess
   150 class MemSpyProcess
   106 {
   151 {
   107 public:
   152 public:
   108 	MemSpyProcess(CMemSpyApiProcess* process)
   153 	MemSpyProcess(CMemSpyApiProcess* process)
   109 		: mProcess(process)
   154 		: mProcess(process)
   110 	{}
   155 	{}
   111 	
   156 	
   112 	virtual  ~MemSpyProcess() { delete mProcess;	}
   157 	virtual  ~MemSpyProcess() { delete mProcess; }
   113 	
   158 	
   114 	ProcessId id() const { return mProcess->Id(); }
   159 	ProcessId id() const { return mProcess->Id(); }
   115 	
   160 	
   116 	QString name() const { return QString((QChar*) mProcess->Name().Ptr(), mProcess->Name().Length()); }
   161 	QString name() const { return QString((QChar*) mProcess->Name().Ptr(), mProcess->Name().Length()); }
   117 	
   162 	
       
   163 	QString exitInfo() const;
       
   164 	
       
   165 	int priority() const { return mProcess->Priority(); }
       
   166 	
       
   167 	int threadCount() const { return mProcess->ThreadCount(); }
       
   168 	
       
   169 	int sid() const { return mProcess->SID(); }
       
   170 	
       
   171 	int vid() const { return mProcess->VID(); }
       
   172 	
       
   173 	bool isDead() const { return mProcess->IsDead(); }
   118 	
   174 	
   119 private:
   175 private:
   120 	CMemSpyApiProcess *mProcess;
   176 	CMemSpyApiProcess *mProcess;
   121 };
   177 };
   122 
   178 
   281 	
   337 	
   282 private:
   338 private:
   283 	CMemSpyApiThreadInfoItem* mItem;
   339 	CMemSpyApiThreadInfoItem* mItem;
   284 };
   340 };
   285 
   341 
       
   342 class MemSpyDwoProgressTracker : public QObject, public CActive
       
   343 {
       
   344 	Q_OBJECT
       
   345 
       
   346 public:
       
   347 	MemSpyDwoProgressTracker(RMemSpySession &session);
       
   348 	virtual ~MemSpyDwoProgressTracker();
       
   349 	
       
   350 public slots:
       
   351 
       
   352 	void start();
       
   353 
       
   354 	void cancel();
       
   355 	
       
   356 protected: // from CActive
       
   357 	
       
   358 	virtual void RunL();
       
   359 	 
       
   360 	virtual void DoCancel();
       
   361 	 
       
   362 	virtual TInt RunError(TInt aError);
       
   363 	
       
   364 signals:
       
   365 	void progress(int progress, const QString& processName);
       
   366 	
       
   367 private:
       
   368 	TMemSpyDeviceWideOperationProgress mProgress;
       
   369 	RMemSpySession mSession;
       
   370 };
       
   371 
       
   372 class MemSpyDwoTracker : public QObject, public CActive
       
   373 {
       
   374 	Q_OBJECT
       
   375 
       
   376 public:
       
   377 	MemSpyDwoTracker(RMemSpySession &session, DeviceWideOperation operation);
       
   378 	virtual ~MemSpyDwoTracker();
       
   379 	
       
   380 public slots:
       
   381 
       
   382 	void start();
       
   383 	
       
   384 	void cancel();
       
   385 	
       
   386 protected: // from CActive
       
   387 	
       
   388 	virtual void RunL();
       
   389 	 
       
   390 	virtual void DoCancel();
       
   391 	 
       
   392 	virtual TInt RunError(TInt aError);
       
   393 	
       
   394 signals:
       
   395 	void finished(int errorCode);
       
   396 	void progress(int progress, const QString& processName);
       
   397 	
       
   398 private:
       
   399 	RMemSpySession mSession;
       
   400 	MemSpyDwoProgressTracker *mProgressTracker;
       
   401 	DeviceWideOperation mOperation;
       
   402 };
       
   403 
       
   404 class MemSpyAsyncTracker : public QObject, public CActive
       
   405 {
       
   406 	Q_OBJECT
       
   407 	
       
   408 public:
       
   409 	
       
   410 	MemSpyAsyncTracker(RMemSpySession& session, void (RMemSpySession::*function)(TRequestStatus&));
       
   411 	
       
   412 	void start();
       
   413 	
       
   414 	virtual void RunL();
       
   415 	
       
   416 	virtual void DoCancel();
       
   417 	
       
   418 	virtual TInt RunError(TInt aError);
       
   419 	
       
   420 signals:
       
   421 	
       
   422 	void finished(int errorCode);
       
   423 	
       
   424 private:
       
   425 	void (RMemSpySession::*mFunction)(TRequestStatus&);
       
   426 	RMemSpySession& mSession;
       
   427 };
       
   428 
       
   429 class MemSpySwmtDumpTracker : public MemSpyAsyncTracker
       
   430 {
       
   431 public:
       
   432 	MemSpySwmtDumpTracker(RMemSpySession& session) : 
       
   433 		MemSpyAsyncTracker(session, &RMemSpySession::ForceSwmtUpdate)
       
   434 	{}
       
   435 };
       
   436 
       
   437 class MemSpyKernelHeapDumpTracker : public MemSpyAsyncTracker
       
   438 {
       
   439 public:
       
   440 	MemSpyKernelHeapDumpTracker(RMemSpySession& session) : 
       
   441 		MemSpyAsyncTracker(session, &RMemSpySession::OutputKernelHeapData)
       
   442 	{}
       
   443 };
       
   444 
       
   445 class MemSpySettings : private QSettings
       
   446 {
       
   447 public:
       
   448 	
       
   449 	MemSpySettings();
       
   450 	
       
   451 	OutputMode outputMode() const;
       
   452 	void setOutputMode(OutputMode mode);
       
   453 	
       
   454 	QString outputPath() const;
       
   455 	void setOutputPath(const QString& path);
       
   456 		
       
   457 	int swmtTimerPeriod() const;
       
   458 	void setSwmtTimerPeriod(int period);
       
   459 	
       
   460 	SwmtMode swmtMode() const;
       
   461 	void setSwmtMode(SwmtMode mode);
       
   462 	
       
   463 	QVariantList swmtCategories() const;
       
   464 	void setSwmtCategories(const QVariantList& categories);
       
   465 	
       
   466 	HeapDumpsMode heapDumpsMode() const;
       
   467 	void setHeapDumpsMode(HeapDumpsMode mode);
       
   468 };
       
   469 
   286 class EngineWrapper : public QObject
   470 class EngineWrapper : public QObject
   287 {
   471 {
   288 public:
   472 	Q_OBJECT
       
   473 	
       
   474 public:
       
   475 	EngineWrapper();
       
   476 	
   289 	virtual ~EngineWrapper();
   477 	virtual ~EngineWrapper();
       
   478 	
   290 	bool initialize();
   479 	bool initialize();
   291 	
   480 	
       
   481 	MemSpySettings& settings();
       
   482 	
       
   483 	const MemSpySettings& settings() const;
       
   484 	
       
   485 	
       
   486 	
   292 	QList<MemSpyProcess*> getProcesses();
   487 	QList<MemSpyProcess*> getProcesses();
   293 	
   488 	
   294 	QList<MemSpyThread*> getThreads(ProcessId processId);
   489 	QList<MemSpyThread*> getThreads(ProcessId processId);
   295 	
   490 	
   296 	QList<MemSpyThreadInfoItem*> getThreadInfo(ThreadId threadId, ThreadInfoType type);
   491 	QList<MemSpyThreadInfoItem*> getThreadInfo(ThreadId threadId, ThreadInfoType type);
   299 	
   494 	
   300 	QList<MemSpyKernelObjectType*> getKernelObjectTypes();
   495 	QList<MemSpyKernelObjectType*> getKernelObjectTypes();
   301 	
   496 	
   302 	QList<MemSpyKernelObject*> getKernelObjects(int type);
   497 	QList<MemSpyKernelObject*> getKernelObjects(int type);
   303 	
   498 	
       
   499 	MemSpyDwoTracker* createDeviceWideOperation(DeviceWideOperation operation);
       
   500 	
       
   501 	MemSpyKernelHeapDumpTracker* createKernelHeapDumpTracker();
       
   502 	
       
   503 	MemSpySwmtDumpTracker* createSwmtDumpTracker();
       
   504 	
       
   505 	void setSwmtSettings(SwmtMode mode, const QVariantList& categories);
       
   506 	
       
   507 	bool isSwmtRunning();
       
   508 	
       
   509 	void startSwmt(int period);
       
   510 	
       
   511 	void stopSwmt();
       
   512 	
       
   513 	void forceSwmtDump();
       
   514 	
       
   515 	void outputKernelHeapData();
       
   516 	
       
   517 	int outputThreadHeapData(const QString& filter);
       
   518 	
       
   519 	void updateOutputSettings();
       
   520 	
   304 private:
   521 private:
   305 	RMemSpySession mSession;
   522 	RMemSpySession mSession;
   306 	
   523 	
       
   524 	bool mSwmtRunning;
       
   525 	
       
   526 	MemSpySettings mSettings;
   307 };
   527 };
   308 
   528 
   309 #endif /* ENGINEWRAPPER_H_ */
   529 #endif /* ENGINEWRAPPER_H_ */