0
|
1 |
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file
|
|
20 |
@internalTechnology
|
|
21 |
@released
|
|
22 |
*/
|
|
23 |
|
|
24 |
#ifndef __RM_DEBUG_DRIVER_H__
|
|
25 |
#define __RM_DEBUG_DRIVER_H__
|
|
26 |
|
|
27 |
#include "d_rmd_stepping.h"
|
|
28 |
#include "d_rmd_breakpoints.h"
|
|
29 |
#include "d_driver_event_info.h"
|
|
30 |
|
|
31 |
// From mmboot.h header
|
|
32 |
const TLinAddr KDataSectionEnd =0x40000000u;
|
|
33 |
const TLinAddr KRomLinearBase =0xF8000000u;
|
|
34 |
|
|
35 |
|
|
36 |
#define ROM_LINEAR_BASE KRomLinearBase
|
|
37 |
|
|
38 |
// Result checking
|
|
39 |
#define ReturnIfError(x) { TInt y = x; if (KErrNone != y) return y; }
|
|
40 |
|
|
41 |
//
|
|
42 |
// class DRM_DebugDriverFactory
|
|
43 |
//
|
|
44 |
class DRM_DebugDriverFactory : public DLogicalDevice
|
|
45 |
{
|
|
46 |
public:
|
|
47 |
|
|
48 |
DRM_DebugDriverFactory();
|
|
49 |
virtual TInt Install();
|
|
50 |
virtual void GetCaps(TDes8& aDes) const;
|
|
51 |
virtual TInt Create(DLogicalChannelBase*& aChannel);
|
|
52 |
};
|
|
53 |
|
|
54 |
class DRM_DebugEventHandler;
|
|
55 |
//
|
|
56 |
// DRM_DebugChannel
|
|
57 |
//
|
|
58 |
class DRM_DebugChannel : public DLogicalChannel
|
|
59 |
{
|
|
60 |
public:
|
|
61 |
|
|
62 |
DRM_DebugChannel(DLogicalDevice* aLogicalDevice);
|
|
63 |
~DRM_DebugChannel();
|
|
64 |
|
|
65 |
virtual TInt DoCreate(TInt aUnit, const TDesC* anInfo, const TVersion& aVer);
|
|
66 |
virtual void HandleMsg(TMessageBase* aMsg);
|
|
67 |
virtual TInt SendMsg(TMessageBase* aMsg);
|
|
68 |
TInt SendRequest(TMessageBase* aMsg);
|
|
69 |
|
|
70 |
//called from the event handler
|
|
71 |
TBool RemoveProcess(TAny* a1, TAny* a2);
|
|
72 |
TBool StartThread(TAny* a1, TAny* a2);
|
|
73 |
TBool AddLibrary(TAny* a1, TAny* a2);
|
|
74 |
TBool RemoveLibrary(TAny* a1, TAny* a2);
|
|
75 |
TBool HandleEventKillThread(TAny* a1, TAny* a2);
|
|
76 |
TBool HandleSwException(TAny* a1, TAny* a2);
|
|
77 |
TBool HandleHwException(TAny* a1, TAny* a2);
|
|
78 |
TBool HandleUserTrace(TAny* a1, TAny* a2);
|
|
79 |
TBool HandleUnsupportedEvent(TAny* a1, TAny* a2) { return EFalse; }
|
|
80 |
TBool HandleAddProcessEvent(TAny* a1, TAny* a2);
|
|
81 |
TBool HandleRemoveProcessEvent(TAny* a1, TAny* a2);
|
|
82 |
|
|
83 |
// Used to be able to signal events to the DSS
|
|
84 |
DThread* ClientThread(void) {return iClientThread; };
|
|
85 |
|
|
86 |
protected:
|
|
87 |
virtual void DoCancel(TInt aReqNo);
|
|
88 |
virtual void DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2);
|
|
89 |
virtual TInt DoControl(TInt aFunction, TAny *a1, TAny *a2);
|
|
90 |
|
|
91 |
private:
|
|
92 |
TInt PreAsyncGetValue(Debug::TEventInfo* aValue, TRequestStatus* aStatus);
|
|
93 |
TInt CreateDfcQ();
|
|
94 |
void DestroyDfcQ();
|
|
95 |
TBool HandleInvalidOpCodeException(TDriverEventInfo& aEventInfo, DThread* aCurrentThread);
|
|
96 |
|
|
97 |
TInt SetBreak(TSetBreakInfo* aBreakInfo);
|
|
98 |
TInt StepRange(DThread* aThread, TRM_DebugStepInfo* aStepInfo);
|
|
99 |
TInt ReadMemory(DThread* aThread, TRM_DebugMemoryInfo* aMemoryInfo);
|
|
100 |
TInt WriteMemory(DThread* aThread, TRM_DebugMemoryInfo* aMemoryInfo);
|
|
101 |
TInt ReadRegistersLegacy(DThread* aThread, TRM_DebugRegisterInfo* aRegisterInfo);
|
|
102 |
TInt WriteRegistersLegacy(DThread* aThread, const TRM_DebugRegisterInfo* aRegisterInfo);
|
|
103 |
TInt ReadRegisters(DThread* aThread, TRM_DebugRegisterInformation* aRegisterInfo) const;
|
|
104 |
TInt WriteRegisters(DThread* aThread, TRM_DebugRegisterInformation* aRegisterInfo) const;
|
|
105 |
TInt GetProcessInfo(TInt aIndex, TRM_DebugTaskInfo* aTaskInfo);
|
|
106 |
TInt GetThreadInfo(TInt aIndex, TRM_DebugTaskInfo* aTaskInfo);
|
|
107 |
TInt GetList(TListInformation* aListInformation) const;
|
|
108 |
|
|
109 |
TInt Step(const TUint32 aThreadId, const TUint32 aNumSteps);
|
|
110 |
TInt KillProcess(const TUint32 aProcessId, const TInt aReason);
|
|
111 |
|
|
112 |
//Crash Flash
|
|
113 |
TInt ReadCrashLog(TFlashInfo* aBuffer);
|
|
114 |
TInt WriteCrashLog(TFlashInfo* aBuffer) const;
|
|
115 |
TInt EraseCrashLog();
|
|
116 |
|
|
117 |
// Stop/go
|
|
118 |
TInt DoSuspendThread(DThread *aThread);
|
|
119 |
TInt DoResumeThread(DThread *aThread);
|
|
120 |
TInt DoStepRange(DThread *aThread, const TUint32 aStartAddress, const TUint32 aStopAddress, TBool aStepInto, TBool aResumeOnceOutOfRange, const TUint32 aNumSteps, TBool aUserRequest = EFalse);
|
|
121 |
TInt DoReadMemory(const DThread *aThread, const TUint32 aAddress, const TUint32 aLength, TDes8 &aData) const;
|
|
122 |
TInt DoWriteMemory(DThread *aThread, const TUint32 aAddress, const TUint32 aLength, TDes8 &aData);
|
|
123 |
TInt DoReadRegisters(DThread *aThread, const TInt16 aFirstRegister, const TInt16 aLastRegister, TDes8 &aValues);
|
|
124 |
TInt DoReadRegisters(DThread *aThread, const TDesC8 &aRegisterIds, TDes8 &aRegisterValues, TDes8 &aRegisterFlags) const;
|
|
125 |
TInt DoWriteRegisters(DThread *aThread, const TInt16 aFirstRegister, const TInt16 aLastRegister, TDesC8 &aValues);
|
|
126 |
TInt DoWriteRegisters(DThread *aThread, const TDesC8 &aRegisterIds, TDesC8 &aRegisterValues, TDes8 &aRegisterFlags) const;
|
|
127 |
TInt DoGetProcessInfo(const TInt aIndex, TRM_DebugTaskInfo *aInfo);
|
|
128 |
TInt DoGetThreadInfo(const TInt aIndex, TRM_DebugTaskInfo *aInfo);
|
|
129 |
TBool DoSecurityCheck();
|
|
130 |
|
|
131 |
TInt TryToReadMemory(const DThread *aThread, const TAny *aSrc, TAny *aDest, const TUint32 aLength) const;
|
|
132 |
TInt TryToWriteMemory(const DThread *aThread, TAny *aDest, const TAny *aSrc, const TUint32 aLength);
|
|
133 |
TInt32 ReadRegister(DThread *aThread, TInt aNum);
|
|
134 |
TInt32 ReadDebugRegisterValue(DThread *aThread, const Debug::TRegisterInfo aDebugRegisterId, T4ByteRegisterValue &aValue) const;
|
|
135 |
TInt32 ReadKernelRegisterValue(DThread *aThread, const TArmReg aKernelRegisterId, T4ByteRegisterValue &aValue) const;
|
|
136 |
|
|
137 |
void NotifyEvent(const TDriverEventInfo& aEventInfo);
|
|
138 |
|
|
139 |
TInt GetTRegisterInfo(const TDesC8 &aRegisterIds, const TUint aIndex, Debug::TRegisterInfo &aValue) const;
|
|
140 |
TInt GetDebugRegisterId(const TArmReg aKernelRegister, Debug::TRegisterInfo& aDebugRegister) const;
|
|
141 |
TInt GetKernelRegisterId(const Debug::TRegisterInfo aDebugRegister, TArmReg& aKernelRegister) const;
|
|
142 |
TBool GetFlagAtOffset(const TUint32 aFlags, const TArmReg aIndex) const;
|
|
143 |
|
|
144 |
TInt AllocAndReadDes(DThread *aThread, const TDesC8& aSrcDes, TPtr8& aDestDes, const TBool aReadFromClient=ETrue, const TUint aOffset=0) const;
|
|
145 |
|
|
146 |
TInt AttachProcess(TAny* a1, TAny* a2);
|
|
147 |
TInt DetachProcess(TAny* a1, TAny* a2);
|
|
148 |
TInt DetachAgent(TAny* a1, TAny* a2);
|
|
149 |
TInt SetEventAction(TAny* a1, TAny* a2);
|
|
150 |
TBool CheckSuspended(const DThread *aThread) const;
|
|
151 |
|
|
152 |
// Needed so moved functions can access iBreakpoint list and related functions
|
|
153 |
friend class D_RMD_Breakpoints;
|
|
154 |
// Needed so moved functions can access stepping functionality
|
|
155 |
friend class DRMDStepping;
|
|
156 |
|
|
157 |
// helper function was previously in rm_debug_kerneldriver.cpp
|
|
158 |
inline TInt Bitcount(TUint32 val)
|
|
159 |
{
|
|
160 |
TInt nbits;
|
|
161 |
|
|
162 |
for (nbits = 0; val != 0; nbits++)
|
|
163 |
{
|
|
164 |
val &= val - 1; // delete rightmost 1-bit in val
|
|
165 |
}
|
|
166 |
|
|
167 |
return nbits;
|
|
168 |
}
|
|
169 |
|
|
170 |
// Security critical - this returns whether the specified process is debuggable or not
|
|
171 |
TInt IsDebuggable(const TUint32 aProcessId);
|
|
172 |
|
|
173 |
private:
|
|
174 |
DThread* iClientThread;
|
|
175 |
DRM_DebugEventHandler* iEventHandler;
|
|
176 |
|
|
177 |
TUint32 iExcludedROMAddressStart;
|
|
178 |
TUint32 iExcludedROMAddressEnd;
|
|
179 |
|
|
180 |
TUint32 iPageSize;
|
|
181 |
|
|
182 |
RArray<Debug::TProcessInfo> iDebugProcessList; //processes that we are debugging
|
|
183 |
|
|
184 |
D_RMD_Breakpoints* iBreakManager; // new D_RMD_Breakpoints
|
|
185 |
|
|
186 |
DRMDStepping* iStepper; // new DRMDStepping
|
|
187 |
|
|
188 |
DSemaphore* iStepLock; // Synchronisation for stepping code.
|
|
189 |
|
|
190 |
TDynamicDfcQue* iDfcQ;
|
|
191 |
|
|
192 |
TBool iInitialisedCodeModifier; // Ensures we control its lifetime
|
|
193 |
|
|
194 |
TClientDataRequest<Debug::TEventInfo>* iAsyncGetValueRequest;
|
|
195 |
};
|
|
196 |
|
|
197 |
#endif //__RM_DEBUG_DRIVER_H__
|