Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Refactored class containing breakpoint related code from rm_debug_kerneldriver.cpp
25 #ifndef D_RMD_BREAKPOINTS_H
26 #define D_RMD_BREAKPOINTS_H
28 #include <rm_debug_api.h>
29 #include <kernel/kern_priv.h>
30 #include "rm_debug_kerneldriver.h"
32 // fwd declaration of friend classes needed due to re-factoring
33 class DRM_DebugChannel;
40 const TUint32 KArmBreakPoint = 0xE7F123F4;
41 const TUint16 KThumbBreakPoint = 0xDE56;
42 const TUint16 KT2EEBreakPoint = 0xC100; // From ARM ARM DDI0406A, section A9.2.1 Undefined instruction encoding for Thumb2-EE.
44 #define NUMBER_OF_TEMP_BREAKPOINTS 10
46 #define NUMBER_OF_MAX_BREAKPOINTS 100
55 inline TBreakEntry() { Reset(); };
57 inline TBreakEntry(Debug::TBreakId aBreakId, TUint64 aId, TBool aThreadSpecific, TUint32 aAddress, Debug::TArchitectureMode aMode)
62 iThreadSpecific(aThreadSpecific)
64 iInstruction.FillZ(4);
66 iDisabledForStep = EFalse;
67 iObsoleteLibraryBreakpoint = EFalse;
68 iResumeOnceOutOfRange = EFalse;
69 iSteppingInto = EFalse;
80 iMode = Debug::EArmMode;
81 iInstruction.FillZ(4);
83 iDisabledForStep = EFalse;
84 iObsoleteLibraryBreakpoint = EFalse;
85 iResumeOnceOutOfRange = EFalse;
86 iSteppingInto = EFalse;
94 // Unique Id for this breakpoint. Assigned by D_RMD_Breakpoints::DoSetBreak(). @see D_RMD_Breakpoints::DoSetBreak
96 // Consider making the iId into a union of TProcessId, TThreadId, global etc. to make things more obvious
97 // Object Id in which this breakpoint should operate.
99 // Address at which this breakpoint should operate
101 // CPU ISA which this breakpoint uses, e.g. EArmMode/EThumbMode.
102 Debug::TArchitectureMode iMode;
103 // The original instruction which was stored at iAddress.
104 TBuf8<4> iInstruction;
105 TUint32 iPageAddress; //not used: BC if we remove it
107 // Indicates whether this breakpoint has been temporarily replaced with original instruction to enable step-off this breakpoint
108 TBool iDisabledForStep;
109 /* This is used when libraries and processes are removed, so that
110 * the driver can say 'ok' when requested to remove breakpoints
111 * that existed in these cases, rather than 'Not Found'.
113 * Its not logical, but its a BC break if we change it :-(
115 TBool iObsoleteLibraryBreakpoint;
116 // Indicates whether this thread should be resumed after stepping off this breakpoint
117 TBool iResumeOnceOutOfRange;
121 TBool iThreadSpecific;
124 // Indicates how many more instruction steps should occur after hitting this breakpoint
130 This class encapsulates all the data concerning run-mode and stop mode breakpoints
131 as understood by the run-mode and stop-mode debug system.
134 The internal list of breakpoints is currently divided into two sections. The range from
135 0...NUMBER_OF_TEMP_BREAKPOINTS is used internally by the debug driver for implementing
136 stepping. The range from NUMBER_OF_TEMP_BREAKPOINTS to NUMBER_OF_MAX_BREAKPOINTS is used
137 to store information about breakpoints set by the client debug agents.
139 In future, this should change, so that each breakpoint knows what kind of breakpoint it
144 class D_RMD_Breakpoints : public DBase
147 D_RMD_Breakpoints(DRM_DebugChannel* aChannel);
148 ~D_RMD_Breakpoints();
152 // from rm_debug_driver.h
153 TInt DoSetBreak(TInt32 &aBreakId, const TUint64 aId, const TBool aThreadSpecific, const TUint32 aAddress, const Debug::TArchitectureMode aMode );
154 TInt DoEnableBreak(TBreakEntry &aEntry, TBool aSaveOldInstruction);
155 TInt DoClearBreak(const TInt32 aBreakId, TBool aIgnoreTerminatedThreads=EFalse);
156 TInt DoModifyBreak(TModifyBreakInfo* aBreakInfo);
157 TInt DoModifyProcessBreak(TModifyProcessBreakInfo* aBreakInfo);
158 TInt DoBreakInfo(TGetBreakInfo* aBreakInfo);
159 void ClearAllBreakPoints();
160 TInt DisableBreakAtAddress(TUint32 aAddress);
161 TInt DoEnableDisabledBreak(TUint64 aThreadId);
163 void DoRemoveThreadBreaks(TUint64 aThreadId);
164 void RemoveBreaksForProcess(TUint64 aProcessId, TUint32 aCodeAddress, TUint32 aCodeSize);
165 void InvalidateLibraryBreakPoints(TUint32 aCodeAddress, TUint32 aCodeSize);
166 TInt BreakPointCount() const;
167 TBreakEntry* GetNextBreak(const TBreakEntry* aBreakEntry) const;
168 TBool IsTemporaryBreak(const TBreakEntry& aBreakEntry) const;
170 TInt DoGetBreakList(TUint32* aBuffer, const TUint32 aBufSize, const TUint32 aElement, TUint32& aLastElement);
173 // Locked versions of public functions
174 TInt priv_DoSetBreak(TInt32 &aBreakId, const TUint64 aId, const TBool aThreadSpecific, const TUint32 aAddress, const Debug::TArchitectureMode aMode );
175 TInt priv_DoEnableBreak(TBreakEntry &aEntry, TBool aSaveOldInstruction);
176 TInt priv_DoClearBreak(const TInt32 aBreakId, TBool aIgnoreTerminatedThreads);
177 TInt priv_DoModifyBreak(TModifyBreakInfo* aBreakInfo);
178 TInt priv_DoModifyProcessBreak(TModifyProcessBreakInfo* aBreakInfo);
179 TInt priv_DoBreakInfo(TGetBreakInfo* aBreakInfo);
180 TInt priv_DisableBreakAtAddress(TUint32 aAddress);
181 TInt priv_DoEnableDisabledBreak(TUint64 aThreadId);
182 void priv_DoRemoveThreadBreaks(TUint64 aThreadId);
183 void priv_ClearAllBreakPoints();
184 TBool priv_IsTemporaryBreak(const TBreakEntry& aBreakEntry) const;
187 TBool Aligned(TUint32 aAddress, Debug::TArchitectureMode aMode);
188 TInt BreakSize(Debug::TArchitectureMode aMode);
189 TBool BreakpointsOverlap(TBreakEntry& aFirst, TBreakEntry& aSecond);
190 TUint32 BreakInst(Debug::TArchitectureMode aMode);
193 RArray<TBreakEntry> iBreakPointList;
196 DRM_DebugChannel* iChannel; // temporary reference back to DRM_DebugChannel to help with refactoring
198 /* Protect access to the breakpoint list with a DSemaphore
200 * This means that stop-mode debuggers know when the list is being updated by the run-mode debug subsystem.