kernel/eka/debug/securityServer/src/c_security_svr_async.cpp
branchRCL_3
changeset 21 e7d2d738d3c2
parent 0 a41df078684a
equal deleted inserted replaced
20:597aaf25e343 21:e7d2d738d3c2
    23 
    23 
    24 using namespace Debug;
    24 using namespace Debug;
    25 
    25 
    26 // ctor
    26 // ctor
    27 CSecuritySvrAsync::CSecuritySvrAsync(CSecuritySvrSession* aSession, TProcessId aAgentId)
    27 CSecuritySvrAsync::CSecuritySvrAsync(CSecuritySvrSession* aSession, TProcessId aAgentId)
    28 : CActive(CActive::EPriorityStandard),
    28 	: CActive(CActive::EPriorityStandard),
    29   iSession(aSession),
    29 	iSession(aSession),
    30   iProcessName(NULL),
    30 	iProcessName(NULL),
    31   iAgentId(aAgentId)
    31 	iAgentId(aAgentId),
       
    32 	iEventBalance(0)
    32 	{
    33 	{
    33 	LOG_MSG("CSecuritySvrAsync::CSecuritySvrAsync()");
    34 	LOG_MSG("CSecuritySvrAsync::CSecuritySvrAsync()");
    34 	CActiveScheduler::Add(this);
    35 	CActiveScheduler::Add(this);
    35 	}
    36 	}
    36 
    37 
    70 	}
    71 	}
    71 
    72 
    72 // RunL() completes a previously issued call (currently only GetEvent() completion)
    73 // RunL() completes a previously issued call (currently only GetEvent() completion)
    73 void CSecuritySvrAsync::RunL()
    74 void CSecuritySvrAsync::RunL()
    74 	{
    75 	{
    75 	LOG_MSG("CSecuritySvrAsync::RunL()");
    76 
       
    77 	LOG_MSG3("CSecuritySvrAsync::RunL() &iInfo=0x%08x, iEventBalance=%d", (TUint8*)&iInfo, iEventBalance);
       
    78 
    76 	// Something bad happened in the driver
    79 	// Something bad happened in the driver
    77 	User::LeaveIfError(iStatus.Int());
    80 	User::LeaveIfError(iStatus.Int());
    78 
    81 
    79 	// Write back the event data to the debug agent.
    82 	// Write back the event data to the debug agent.
    80 	// For compatibility we need to check the size of the buffer that the
    83 	// For compatibility we need to check the size of the buffer that the
    94 	TPtr8 data((TUint8*)&iInfo,dataLengthToReturn,dataLengthToReturn);
    97 	TPtr8 data((TUint8*)&iInfo,dataLengthToReturn,dataLengthToReturn);
    95 
    98 
    96 	iMessage.WriteL(1,data,0);
    99 	iMessage.WriteL(1,data,0);
    97 
   100 
    98 	iMessage.Complete(KErrNone);
   101 	iMessage.Complete(KErrNone);
       
   102 	--iEventBalance;
    99 	}
   103 	}
   100 
   104 
   101 // Cancels the oustanding GetEvent call. May cope with other async calls in future.
   105 // Cancels the oustanding GetEvent call. May cope with other async calls in future.
   102 void CSecuritySvrAsync::DoCancel()
   106 void CSecuritySvrAsync::DoCancel()
   103 	{
   107 	{
   104 	LOG_MSG("CSecuritySvrAsync::DoCancel()");
   108 	LOG_MSG2("CSecuritySvrAsync::DoCancel() iEventBalance=%d", iEventBalance);
   105 	iSession->Server().iKernelDriver.CancelGetEvent(iProcessName,iAgentId.Id());
   109 	iSession->Server().iKernelDriver.CancelGetEvent(iProcessName,iAgentId.Id());
   106 
   110 
   107 	iMessage.Complete(KErrCancel);
   111 	iMessage.Complete(KErrCancel);
       
   112 	iEventBalance=0;
   108 	}
   113 	}
   109 
   114 
   110 // Report any leave to the client if possible.
   115 // Report any leave to the client if possible.
   111 TInt CSecuritySvrAsync::RunError(TInt aError)
   116 TInt CSecuritySvrAsync::RunError(TInt aError)
   112 	{
   117 	{
   113 	LOG_MSG("CSecuritySvrAsync::RunError()");
   118 	LOG_MSG2("CSecuritySvrAsync::RunError()=%d", aError);
   114 	iMessage.Complete(aError);
   119 	iMessage.Complete(aError);
   115 
   120 
   116 	return KErrNone;
   121 	return KErrNone;
   117 	}
   122 	}
   118 
   123 
   119 // Start an Asynchronous GetEvent call to the rm_debug.ldd driver
   124 /*
   120 // and activate this Active Object.
   125  * Start an asynchronous GetEvent call to the debug driver
       
   126  * and activates this active object. 
       
   127  */
   121 void CSecuritySvrAsync::GetEvent(const RMessage2& aMessage)
   128 void CSecuritySvrAsync::GetEvent(const RMessage2& aMessage)
   122 	{
   129 	{
   123 	LOG_MSG("CSecuritySvrAsync::GetEvent()");
       
   124 	iMessage = aMessage;
   130 	iMessage = aMessage;
   125 
   131 
       
   132 	iEventBalance++;
       
   133 	LOG_MSG5("CSecuritySvrAsync::GetEvent() this = 0x%08x, iInfo=0x%08x, iStatus=0x%08x \
       
   134 		iEventBalance=%d : >SetActive() > GetEvent() ",
       
   135 		this, &iInfo, &iStatus, iEventBalance );
       
   136 
       
   137 	/* 
       
   138 	SetActive is called before sending the message to the driver so 
       
   139 	that we do not get stray signal panics, since the driver may complete immediately
       
   140  	*/
       
   141 	SetActive();
   126 	iSession->Server().iKernelDriver.GetEvent(iProcessName,iAgentId.Id(),iStatus,iInfo);
   142 	iSession->Server().iKernelDriver.GetEvent(iProcessName,iAgentId.Id(),iStatus,iInfo);
   127 
       
   128 	SetActive();
       
   129 	}
   143 	}
   130 
   144 
   131 // Used for identifying which AO is associated with a debugged process
   145 // Used for identifying which AO is associated with a debugged process
   132 const TDesC8& CSecuritySvrAsync::ProcessName(void)
   146 const TDesC8& CSecuritySvrAsync::ProcessName(void)
   133 {
   147 	{
   134 	LOG_MSG("CSecuritySvrAsync::ProcessName()");
       
   135 	return iProcessName;
   148 	return iProcessName;
   136 }
   149 	}
   137 
   150 
   138 // End of file - c_security_svr_async.cpp
   151 // End of file - c_security_svr_async.cpp
   139 
   152