sl@0: // Copyright (c) 2004-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: // sl@0: sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: @released sl@0: */ sl@0: sl@0: #ifndef __RM_DEBUG_DRIVER_H__ sl@0: #define __RM_DEBUG_DRIVER_H__ sl@0: sl@0: #include "d_rmd_stepping.h" sl@0: #include "d_rmd_breakpoints.h" sl@0: #include "d_driver_event_info.h" sl@0: sl@0: // From mmboot.h header sl@0: const TLinAddr KDataSectionEnd =0x40000000u; sl@0: const TLinAddr KRomLinearBase =0xF8000000u; sl@0: sl@0: sl@0: #define ROM_LINEAR_BASE KRomLinearBase sl@0: sl@0: // Result checking sl@0: #define ReturnIfError(x) { TInt y = x; if (KErrNone != y) return y; } sl@0: sl@0: // sl@0: // class DRM_DebugDriverFactory sl@0: // sl@0: class DRM_DebugDriverFactory : public DLogicalDevice sl@0: { sl@0: public: sl@0: sl@0: DRM_DebugDriverFactory(); sl@0: virtual TInt Install(); sl@0: virtual void GetCaps(TDes8& aDes) const; sl@0: virtual TInt Create(DLogicalChannelBase*& aChannel); sl@0: }; sl@0: sl@0: class DRM_DebugEventHandler; sl@0: // sl@0: // DRM_DebugChannel sl@0: // sl@0: class DRM_DebugChannel : public DLogicalChannel sl@0: { sl@0: public: sl@0: sl@0: DRM_DebugChannel(DLogicalDevice* aLogicalDevice); sl@0: ~DRM_DebugChannel(); sl@0: sl@0: virtual TInt DoCreate(TInt aUnit, const TDesC* anInfo, const TVersion& aVer); sl@0: virtual void HandleMsg(TMessageBase* aMsg); sl@0: virtual TInt SendMsg(TMessageBase* aMsg); sl@0: TInt SendRequest(TMessageBase* aMsg); sl@0: sl@0: //called from the event handler sl@0: TBool RemoveProcess(TAny* a1, TAny* a2); sl@0: TBool StartThread(TAny* a1, TAny* a2); sl@0: TBool AddLibrary(TAny* a1, TAny* a2); sl@0: TBool RemoveLibrary(TAny* a1, TAny* a2); sl@0: TBool HandleEventKillThread(TAny* a1, TAny* a2); sl@0: TBool HandleSwException(TAny* a1, TAny* a2); sl@0: TBool HandleHwException(TAny* a1, TAny* a2); sl@0: TBool HandleUserTrace(TAny* a1, TAny* a2); sl@0: TBool HandleUnsupportedEvent(TAny* a1, TAny* a2) { return EFalse; } sl@0: TBool HandleAddProcessEvent(TAny* a1, TAny* a2); sl@0: TBool HandleRemoveProcessEvent(TAny* a1, TAny* a2); sl@0: sl@0: // Used to be able to signal events to the DSS sl@0: DThread* ClientThread(void) {return iClientThread; }; sl@0: sl@0: protected: sl@0: virtual void DoCancel(TInt aReqNo); sl@0: virtual void DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2); sl@0: virtual TInt DoControl(TInt aFunction, TAny *a1, TAny *a2); sl@0: sl@0: private: sl@0: TInt PreAsyncGetValue(Debug::TEventInfo* aValue, TRequestStatus* aStatus); sl@0: TInt CreateDfcQ(); sl@0: void DestroyDfcQ(); sl@0: TBool HandleInvalidOpCodeException(TDriverEventInfo& aEventInfo, DThread* aCurrentThread); sl@0: sl@0: TInt SetBreak(TSetBreakInfo* aBreakInfo); sl@0: TInt StepRange(DThread* aThread, TRM_DebugStepInfo* aStepInfo); sl@0: TInt ReadMemory(DThread* aThread, TRM_DebugMemoryInfo* aMemoryInfo); sl@0: TInt WriteMemory(DThread* aThread, TRM_DebugMemoryInfo* aMemoryInfo); sl@0: TInt ReadRegistersLegacy(DThread* aThread, TRM_DebugRegisterInfo* aRegisterInfo); sl@0: TInt WriteRegistersLegacy(DThread* aThread, const TRM_DebugRegisterInfo* aRegisterInfo); sl@0: TInt ReadRegisters(DThread* aThread, TRM_DebugRegisterInformation* aRegisterInfo) const; sl@0: TInt WriteRegisters(DThread* aThread, TRM_DebugRegisterInformation* aRegisterInfo) const; sl@0: TInt GetProcessInfo(TInt aIndex, TRM_DebugTaskInfo* aTaskInfo); sl@0: TInt GetThreadInfo(TInt aIndex, TRM_DebugTaskInfo* aTaskInfo); sl@0: TInt GetList(TListInformation* aListInformation) const; sl@0: sl@0: TInt Step(const TUint32 aThreadId, const TUint32 aNumSteps); sl@0: TInt KillProcess(const TUint32 aProcessId, const TInt aReason); sl@0: sl@0: //Crash Flash sl@0: TInt ReadCrashLog(TFlashInfo* aBuffer); sl@0: TInt WriteCrashLog(TFlashInfo* aBuffer) const; sl@0: TInt EraseCrashLog(); sl@0: sl@0: // Stop/go sl@0: TInt DoSuspendThread(DThread *aThread); sl@0: TInt DoResumeThread(DThread *aThread); sl@0: TInt DoStepRange(DThread *aThread, const TUint32 aStartAddress, const TUint32 aStopAddress, TBool aStepInto, TBool aResumeOnceOutOfRange, const TUint32 aNumSteps, TBool aUserRequest = EFalse); sl@0: TInt DoReadMemory(const DThread *aThread, const TUint32 aAddress, const TUint32 aLength, TDes8 &aData) const; sl@0: TInt DoWriteMemory(DThread *aThread, const TUint32 aAddress, const TUint32 aLength, TDes8 &aData); sl@0: TInt DoReadRegisters(DThread *aThread, const TInt16 aFirstRegister, const TInt16 aLastRegister, TDes8 &aValues); sl@0: TInt DoReadRegisters(DThread *aThread, const TDesC8 &aRegisterIds, TDes8 &aRegisterValues, TDes8 &aRegisterFlags) const; sl@0: TInt DoWriteRegisters(DThread *aThread, const TInt16 aFirstRegister, const TInt16 aLastRegister, TDesC8 &aValues); sl@0: TInt DoWriteRegisters(DThread *aThread, const TDesC8 &aRegisterIds, TDesC8 &aRegisterValues, TDes8 &aRegisterFlags) const; sl@0: TInt DoGetProcessInfo(const TInt aIndex, TRM_DebugTaskInfo *aInfo); sl@0: TInt DoGetThreadInfo(const TInt aIndex, TRM_DebugTaskInfo *aInfo); sl@0: TBool DoSecurityCheck(); sl@0: sl@0: TInt TryToReadMemory(const DThread *aThread, const TAny *aSrc, TAny *aDest, const TUint32 aLength) const; sl@0: TInt TryToWriteMemory(const DThread *aThread, TAny *aDest, const TAny *aSrc, const TUint32 aLength); sl@0: TInt32 ReadRegister(DThread *aThread, TInt aNum); sl@0: TInt32 ReadDebugRegisterValue(DThread *aThread, const Debug::TRegisterInfo aDebugRegisterId, T4ByteRegisterValue &aValue) const; sl@0: TInt32 ReadKernelRegisterValue(DThread *aThread, const TArmReg aKernelRegisterId, T4ByteRegisterValue &aValue) const; sl@0: sl@0: void NotifyEvent(const TDriverEventInfo& aEventInfo); sl@0: sl@0: TInt GetTRegisterInfo(const TDesC8 &aRegisterIds, const TUint aIndex, Debug::TRegisterInfo &aValue) const; sl@0: TInt GetDebugRegisterId(const TArmReg aKernelRegister, Debug::TRegisterInfo& aDebugRegister) const; sl@0: TInt GetKernelRegisterId(const Debug::TRegisterInfo aDebugRegister, TArmReg& aKernelRegister) const; sl@0: TBool GetFlagAtOffset(const TUint32 aFlags, const TArmReg aIndex) const; sl@0: sl@0: TInt AllocAndReadDes(DThread *aThread, const TDesC8& aSrcDes, TPtr8& aDestDes, const TBool aReadFromClient=ETrue, const TUint aOffset=0) const; sl@0: sl@0: TInt AttachProcess(TAny* a1, TAny* a2); sl@0: TInt DetachProcess(TAny* a1, TAny* a2); sl@0: TInt DetachAgent(TAny* a1, TAny* a2); sl@0: TInt SetEventAction(TAny* a1, TAny* a2); sl@0: TBool CheckSuspended(const DThread *aThread) const; sl@0: sl@0: // Needed so moved functions can access iBreakpoint list and related functions sl@0: friend class D_RMD_Breakpoints; sl@0: // Needed so moved functions can access stepping functionality sl@0: friend class DRMDStepping; sl@0: sl@0: // helper function was previously in rm_debug_kerneldriver.cpp sl@0: inline TInt Bitcount(TUint32 val) sl@0: { sl@0: TInt nbits; sl@0: sl@0: for (nbits = 0; val != 0; nbits++) sl@0: { sl@0: val &= val - 1; // delete rightmost 1-bit in val sl@0: } sl@0: sl@0: return nbits; sl@0: } sl@0: sl@0: // Security critical - this returns whether the specified process is debuggable or not sl@0: TInt IsDebuggable(const TUint32 aProcessId); sl@0: sl@0: private: sl@0: DThread* iClientThread; sl@0: DRM_DebugEventHandler* iEventHandler; sl@0: sl@0: TUint32 iExcludedROMAddressStart; sl@0: TUint32 iExcludedROMAddressEnd; sl@0: sl@0: TUint32 iPageSize; sl@0: sl@0: RArray iDebugProcessList; //processes that we are debugging sl@0: sl@0: D_RMD_Breakpoints* iBreakManager; // new D_RMD_Breakpoints sl@0: sl@0: DRMDStepping* iStepper; // new DRMDStepping sl@0: sl@0: DSemaphore* iStepLock; // Synchronisation for stepping code. sl@0: sl@0: TDynamicDfcQue* iDfcQ; sl@0: sl@0: TBool iInitialisedCodeModifier; // Ensures we control its lifetime sl@0: sl@0: TClientDataRequest* iAsyncGetValueRequest; sl@0: }; sl@0: sl@0: #endif //__RM_DEBUG_DRIVER_H__