sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of the License "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: // Purpose: Kernel-side tracking of process state
sl@0: // 
sl@0: //
sl@0:  
sl@0: #ifndef D_PROCESS_TRACKER_H
sl@0: #define D_PROCESS_TRACKER_H
sl@0: 
sl@0: #include "d_target_process.h"
sl@0: 
sl@0: // The global class which tracks all debugged processes.
sl@0: // 
sl@0: // Note that multiple debug agents may attach to a process,
sl@0: // as the security server will ensure only one is an 'active'
sl@0: // agent, preventing conflicts. Other agents will be 'passive',
sl@0: // typically interested only in recording events.
sl@0: //
sl@0: // The above requirement generates the requirement for the class
sl@0: // to track the agent IDs, as multiple debug agents may be interested
sl@0: // in a process.
sl@0: 
sl@0: class DProcessTracker : public DBase
sl@0: {
sl@0: public:
sl@0: 	DProcessTracker();
sl@0: 	~DProcessTracker();
sl@0: 
sl@0: 	TInt AttachProcess(const TDesC8& aProcessName, TUint64 aAgentId);
sl@0: 
sl@0: 	TInt DetachProcess(const TDesC8& aProcessName, TUint64 aAgentId);
sl@0: 
sl@0: 	TInt DetachAgent(TUint64 aAgentId);
sl@0: 
sl@0: 	DTargetProcess* FindProcess(const TDesC8& aProcessName);
sl@0: 
sl@0: 	DTargetProcess* FuzzyFindProcess(const TDesC8& aProcessName);
sl@0: 
sl@0: 	TBool CheckSuspended(const TUint64 aTargetThreadId) const;
sl@0: 	TBool CheckSuspended(DThread* aTargetThread) const;
sl@0: 	TInt SuspendThread(DThread* aTargetThread, TBool aFreezeThread=EFalse);
sl@0: 	TInt ResumeThread(DThread* aTargetThread);
sl@0: 	void FSWait();
sl@0: 
sl@0: private:
sl@0: 	TInt RemoveSuspendedThread(DThread* aThread);
sl@0: 	TInt AddSuspendedThread(DThread* aThread);
sl@0: 	HBuf* GetFileName(DThread* aThread) const;
sl@0: 
sl@0: private:
sl@0: 	RPointerArray<DTargetProcess> iProcesses;
sl@0: };
sl@0: 
sl@0: // static global object
sl@0: extern DProcessTracker TheDProcessTracker;
sl@0: 
sl@0: #endif // D_PROCESS_TRACKER_H