Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

kdbreak.c File Reference

#include "kdp.h"

Go to the source code of this file.

Functions

VOID KdSetOwedBreakpoints (VOID)
BOOLEAN KdpLowWriteContent (ULONG Index)
BOOLEAN KdpLowRestoreBreakpoint (ULONG Index)
ULONG KdpAddBreakpoint (IN PVOID Address)
BOOLEAN KdpLowWriteContent (IN ULONG Index)
BOOLEAN KdpDeleteBreakpoint (IN ULONG Handle)
BOOLEAN KdpDeleteBreakpointRange (IN PVOID Lower, IN PVOID Upper)
VOID KdpSuspendBreakpoint (ULONG Handle)
VOID KdpSuspendAllBreakpoints (VOID)
BOOLEAN KdpLowRestoreBreakpoint (IN ULONG Index)
VOID KdpRestoreAllBreakpoints (VOID)
VOID KdDeleteAllBreakpoints (VOID)


Function Documentation

VOID KdDeleteAllBreakpoints VOID   ) 
 

Definition at line 1349 of file 4/kdbreak.c.

References BreakpointsSuspended, FALSE, Handle, KdDebuggerEnabled, KdpDeleteBreakpoint(), and KdPitchDebugger.

01352 { 01353 ULONG Handle; 01354 01355 if (KdDebuggerEnabled == FALSE || KdPitchDebugger != FALSE) { 01356 return; 01357 } 01358 01359 BreakpointsSuspended = FALSE; 01360 01361 for ( Handle = 1; Handle <= BREAKPOINT_TABLE_SIZE; Handle++ ) { 01362 KdpDeleteBreakpoint(Handle); 01363 } 01364 01365 return; 01366 } // KdDeleteAllBreakpoints

ULONG KdpAddBreakpoint IN PVOID  Address  ) 
 

Definition at line 60 of file 4/kdbreak.c.

References _BREAKPOINT_ENTRY::Address, _BREAKPOINT_ENTRY::Content, _BREAKPOINT_ENTRY::DirectoryTableBase, DPRINT, FALSE, _BREAKPOINT_ENTRY::Flags, GLOBAL_BREAKPOINT_LIMIT, Index, KD_BREAKPOINT_IA64_MOVL, KD_BREAKPOINT_IN_USE, KD_BREAKPOINT_NEEDS_REPLACE, KD_BREAKPOINT_NEEDS_WRITE, KD_BREAKPOINT_STATE_MASK, KDP_BREAKPOINT_ALIGN, KDP_BREAKPOINT_TYPE, KdpBreakpointInstruction, KdpBreakpointTable, KdpMoveMemory(), KdpOweBreakpoint, KeGetCurrentThread, MmDbgReleaseAddress(), MmDbgWriteCheck(), NULL, and TRUE.

Referenced by KdpWriteBreakpoint(), and KdpWriteBreakPointEx().

00066 : 00067 00068 This routine adds an entry to the breakpoint table and returns a handle 00069 to the breakpoint table entry. 00070 00071 Arguments: 00072 00073 Address - Supplies the address where to set the breakpoint. 00074 00075 Return Value: 00076 00077 A value of zero is returned if the specified address is already in the 00078 breakpoint table, there are no free entries in the breakpoint table, the 00079 specified address is not correctly aligned, or the specified address is 00080 not valid. Otherwise, the index of the assigned breakpoint table entry 00081 plus one is returned as the function value. 00082 00083 --*/ 00084 00085 { 00086 00087 KDP_BREAKPOINT_TYPE Content; 00088 ULONG Index; 00089 HARDWARE_PTE Opaque; 00090 PVOID AccessAddress; 00091 00092 //DPRINT(("KD: Setting breakpoint at 0x%08x\n", Address)); 00093 00094 // 00095 // If the specified address is not properly aligned, then return zero. 00096 // 00097 00098 if (((ULONG_PTR)Address & KDP_BREAKPOINT_ALIGN) != 0) { 00099 return 0; 00100 } 00101 00102 00103 // 00104 // Don't allow setting the same breakpoint twice. 00105 // 00106 00107 for (Index = 0; Index < BREAKPOINT_TABLE_SIZE; Index += 1) { 00108 if ((KdpBreakpointTable[Index].Flags & KD_BREAKPOINT_IN_USE) != 0 && 00109 KdpBreakpointTable[Index].Address == Address) { 00110 00111 if ((KdpBreakpointTable[Index].Flags & KD_BREAKPOINT_NEEDS_REPLACE) != 0) { 00112 00113 // 00114 // Breakpoint was set, the page was written out and was not 00115 // accessible when the breakpoint was cleared. Now the breakpoint 00116 // is being set again. Just clear the defer flag: 00117 // 00118 KdpBreakpointTable[Index].Flags &= ~KD_BREAKPOINT_NEEDS_REPLACE; 00119 return Index + 1; 00120 00121 } else { 00122 00123 DPRINT(("KD: Attempt to set breakpoint %08x twice!\n", Address)); 00124 return 0; 00125 00126 } 00127 } 00128 } 00129 00130 // 00131 // Search the breakpoint table for a free entry. 00132 // 00133 00134 for (Index = 0; Index < BREAKPOINT_TABLE_SIZE; Index += 1) { 00135 if (KdpBreakpointTable[Index].Flags == 0) { 00136 break; 00137 } 00138 } 00139 00140 // 00141 // If a free entry was found, then write breakpoint and return the handle 00142 // value plus one. Otherwise, return zero. 00143 // 00144 00145 if (Index == BREAKPOINT_TABLE_SIZE) { 00146 DPRINT(("KD: ran out of breakpoints!\n")); 00147 return 0; 00148 } 00149 00150 00151 //DPRINT(("KD: using Index %d\n", Index)); 00152 00153 // 00154 // Get the instruction to be replaced. If the instruction cannot be read, 00155 // then mark breakpoint as not accessible. 00156 // 00157 00158 if (KdpMoveMemory( 00159 (PCHAR)&Content, 00160 (PCHAR)Address, 00161 sizeof(KDP_BREAKPOINT_TYPE) ) != sizeof(KDP_BREAKPOINT_TYPE)) { 00162 AccessAddress = NULL; 00163 //DPRINT(("KD: memory inaccessible\n")); 00164 } else { 00165 //DPRINT(("KD: memory readable...\n")); 00166 00167 // 00168 // If the specified address is not write accessible, then return zero. 00169 // All references must be made through AccessAddress. 00170 // 00171 00172 AccessAddress = MmDbgWriteCheck((PVOID)Address, &Opaque); 00173 if (AccessAddress == NULL) { 00174 DPRINT(("KD: memory not writable!\n")); 00175 return 0; 00176 } 00177 } 00178 00179 #if defined(_IA64_) 00180 if ( AccessAddress != NULL ) { 00181 KDP_BREAKPOINT_TYPE mBuf; 00182 PVOID BundleAddress; 00183 00184 // change template to type 0 if current instruction is MLI 00185 00186 // read in intruction template if current instruction is NOT slot 0. 00187 // check for two-slot MOVL instruction. Reject request if attempt to 00188 // set break in slot 2 of MLI template. 00189 00190 if (((ULONG_PTR)Address & 0xf) != 0) { 00191 (ULONG_PTR)BundleAddress = (ULONG_PTR)AccessAddress & ~(0xf); 00192 if (KdpMoveMemory( 00193 (PCHAR)&mBuf, 00194 (PCHAR)BundleAddress, 00195 sizeof(KDP_BREAKPOINT_TYPE) 00196 ) != sizeof(KDP_BREAKPOINT_TYPE)) { 00197 //DPRINT(("KD: read 0x%08x template failed\n", BundleAddress)); 00198 MmDbgReleaseAddress(AccessAddress, &Opaque); 00199 return 0; 00200 } else { 00201 if (((mBuf & INST_TEMPL_MASK) >> 1) == 0x2) { 00202 if (((ULONG_PTR)Address & 0xf) == 4) { 00203 // if template= type 2 MLI, change to type 0 00204 mBuf &= ~((INST_TEMPL_MASK >> 1) << 1); 00205 KdpBreakpointTable[Index].Flags |= KD_BREAKPOINT_IA64_MOVL; 00206 if (KdpMoveMemory( 00207 (PCHAR)BundleAddress, 00208 (PCHAR)&mBuf, 00209 sizeof(KDP_BREAKPOINT_TYPE) 00210 ) != sizeof(KDP_BREAKPOINT_TYPE)) { 00211 //DPRINT(("KD: write to 0x%08x template failed\n", BundleAddress)); 00212 MmDbgReleaseAddress(AccessAddress, &Opaque); 00213 return 0; 00214 } 00215 else { 00216 //DPRINT(("KD: change MLI template to type 0 at 0x%08x set\n", Address)); 00217 } 00218 } else { 00219 // set breakpoint at slot 2 of MOVL is illegal 00220 //DPRINT(("KD: illegal to set BP at slot 2 of MOVL at 0x%08x\n", BundleAddress)); 00221 MmDbgReleaseAddress(AccessAddress, &Opaque); 00222 return 0; 00223 } 00224 } 00225 } 00226 } 00227 00228 // insert break instruction 00229 00230 KdpBreakpointTable[Index].Address = Address; 00231 KdpBreakpointTable[Index].Content = Content; 00232 KdpBreakpointTable[Index].Flags &= ~(KD_BREAKPOINT_STATE_MASK); 00233 KdpBreakpointTable[Index].Flags |= KD_BREAKPOINT_IN_USE; 00234 if (Address < (PVOID)GLOBAL_BREAKPOINT_LIMIT) { 00235 KdpBreakpointTable[Index].DirectoryTableBase = 00236 KeGetCurrentThread()->ApcState.Process->DirectoryTableBase[0]; 00237 } 00238 switch ((ULONG_PTR)Address & 0xf) { 00239 case 0: 00240 Content = (Content & ~(INST_SLOT0_MASK)) | (KdpBreakpointInstruction << 5); 00241 break; 00242 00243 case 4: 00244 Content = (Content & ~(INST_SLOT1_MASK)) | (KdpBreakpointInstruction << 14); 00245 break; 00246 00247 case 8: 00248 Content = (Content & ~(INST_SLOT2_MASK)) | (KdpBreakpointInstruction << 23); 00249 break; 00250 00251 default: 00252 MmDbgReleaseAddress(AccessAddress, &Opaque); 00253 //DPRINT(("KD: KdpAddBreakpoint bad instruction slot#\n")); 00254 return 0; 00255 } 00256 if (KdpMoveMemory( 00257 (PCHAR)AccessAddress, 00258 (PCHAR)&Content, 00259 sizeof(KDP_BREAKPOINT_TYPE) 00260 ) != sizeof(KDP_BREAKPOINT_TYPE)) { 00261 00262 MmDbgReleaseAddress(AccessAddress, &Opaque); 00263 //DPRINT(("KD: KdpMoveMemory failed writing BP!\n")); 00264 return 0; 00265 } 00266 else { 00267 //DPRINT(("KD: breakpoint at 0x%08x set\n", Address)); 00268 } 00269 MmDbgReleaseAddress(AccessAddress, &Opaque); 00270 00271 } else { // memory not accessible 00272 KdpBreakpointTable[Index].Address = Address; 00273 KdpBreakpointTable[Index].Flags &= ~(KD_BREAKPOINT_STATE_MASK); 00274 KdpBreakpointTable[Index].Flags |= KD_BREAKPOINT_IN_USE; 00275 KdpBreakpointTable[Index].Flags |= KD_BREAKPOINT_NEEDS_WRITE; 00276 KdpOweBreakpoint = TRUE; 00277 //DPRINT(("KD: breakpoint write deferred\n")); 00278 if (Address < (PVOID)GLOBAL_BREAKPOINT_LIMIT) { 00279 KdpBreakpointTable[Index].DirectoryTableBase = 00280 KeGetCurrentThread()->ApcState.Process->DirectoryTableBase[0]; 00281 } 00282 } 00283 #else 00284 if ( AccessAddress != NULL ) { 00285 KdpBreakpointTable[Index].Address = Address; 00286 KdpBreakpointTable[Index].Content = Content; 00287 KdpBreakpointTable[Index].Flags = KD_BREAKPOINT_IN_USE; 00288 if (Address < (PVOID)GLOBAL_BREAKPOINT_LIMIT) { 00289 KdpBreakpointTable[Index].DirectoryTableBase = 00290 KeGetCurrentThread()->ApcState.Process->DirectoryTableBase[0]; 00291 } 00292 if (KdpMoveMemory( 00293 (PCHAR)AccessAddress, 00294 (PCHAR)&KdpBreakpointInstruction, 00295 sizeof(KDP_BREAKPOINT_TYPE) 00296 ) != sizeof(KDP_BREAKPOINT_TYPE)) { 00297 00298 DPRINT(("KD: KdpMoveMemory failed writing BP!\n")); 00299 } 00300 MmDbgReleaseAddress(AccessAddress, &Opaque); 00301 } else { 00302 KdpBreakpointTable[Index].Address = Address; 00303 KdpBreakpointTable[Index].Flags = KD_BREAKPOINT_IN_USE | KD_BREAKPOINT_NEEDS_WRITE; 00304 KdpOweBreakpoint = TRUE; 00305 //DPRINT(("KD: breakpoint write deferred\n")); 00306 if (Address < (PVOID)GLOBAL_BREAKPOINT_LIMIT) { 00307 KdpBreakpointTable[Index].DirectoryTableBase = 00308 KeGetCurrentThread()->ApcState.Process->DirectoryTableBase[0]; 00309 } 00310 } 00311 #endif // IA64 00312 00313 return Index + 1; 00314 00315 }

BOOLEAN KdpDeleteBreakpoint IN ULONG  Handle  ) 
 

Definition at line 843 of file 4/kdbreak.c.

References DPRINT, FALSE, _BREAKPOINT_ENTRY::Flags, Handle, Index, KD_BREAKPOINT_NEEDS_REPLACE, KD_BREAKPOINT_SUSPENDED, KdpBreakpointTable, KdpLowWriteContent(), and TRUE.

Referenced by KdDeleteAllBreakpoints(), KdpDeleteBreakpointRange(), KdpRestoreBreakpoint(), KdpRestoreBreakPointEx(), and KdpWriteBreakPointEx().

00849 : 00850 00851 This routine deletes an entry from the breakpoint table. 00852 00853 Arguments: 00854 00855 Handle - Supplies the index plus one of the breakpoint table entry 00856 which is to be deleted. 00857 00858 Return Value: 00859 00860 A value of FALSE is returned if the specified handle is not a valid 00861 value or the breakpoint cannot be deleted because the old instruction 00862 cannot be replaced. Otherwise, a value of TRUE is returned. 00863 00864 --*/ 00865 00866 { 00867 ULONG Index = Handle - 1; 00868 00869 // 00870 // If the specified handle is not valid, then return FALSE. 00871 // 00872 00873 if ((Handle == 0) || (Handle > BREAKPOINT_TABLE_SIZE)) { 00874 DPRINT(("KD: Breakpoint %d invalid.\n", Index)); 00875 return FALSE; 00876 } 00877 00878 // 00879 // If the specified breakpoint table entry is not valid, then return FALSE. 00880 // 00881 00882 if (KdpBreakpointTable[Index].Flags == 0) { 00883 //DPRINT(("KD: Breakpoint %d already clear.\n", Index)); 00884 return FALSE; 00885 } 00886 00887 // 00888 // If the breakpoint is already suspended, just delete it from the table. 00889 // 00890 00891 if (KdpBreakpointTable[Index].Flags & KD_BREAKPOINT_SUSPENDED) { 00892 //DPRINT(("KD: Deleting suspended breakpoint %d \n", Index)); 00893 if ( !(KdpBreakpointTable[Index].Flags & KD_BREAKPOINT_NEEDS_REPLACE) ) { 00894 //DPRINT(("KD: already clear.\n")); 00895 KdpBreakpointTable[Index].Flags = 0; 00896 return TRUE; 00897 } 00898 } 00899 00900 // 00901 // Replace the instruction contents. 00902 // 00903 00904 if (KdpLowWriteContent(Index)) { 00905 00906 // 00907 // Delete breakpoint table entry 00908 // 00909 00910 //DPRINT(("KD: Breakpoint %d deleted successfully.\n", Index)); 00911 KdpBreakpointTable[Index].Flags = 0; 00912 } 00913 00914 return TRUE; 00915 }

BOOLEAN KdpDeleteBreakpointRange IN PVOID  Lower,
IN PVOID  Upper
 

Definition at line 919 of file 4/kdbreak.c.

References _BREAKPOINT_ENTRY::Address, FALSE, _BREAKPOINT_ENTRY::Flags, Index, KD_BREAKPOINT_IN_USE, KdpBreakpointTable, and KdpDeleteBreakpoint().

Referenced by KdpSetLoadState(), and KdpSetStateChange().

00926 : 00927 00928 This routine deletes all breakpoints falling in a given range 00929 from the breakpoint table. 00930 00931 Arguments: 00932 00933 Lower - inclusive lower address of range from which to remove BPs. 00934 00935 Upper - include upper address of range from which to remove BPs. 00936 00937 Return Value: 00938 00939 TRUE if any breakpoints removed, FALSE otherwise. 00940 00941 --*/ 00942 00943 { 00944 ULONG Index; 00945 BOOLEAN ReturnStatus = FALSE; 00946 00947 // 00948 // Examine each entry in the table in turn 00949 // 00950 00951 for (Index = 0; Index < BREAKPOINT_TABLE_SIZE; Index++) { 00952 00953 if ( (KdpBreakpointTable[Index].Flags & KD_BREAKPOINT_IN_USE) && 00954 ((KdpBreakpointTable[Index].Address >= Lower) && 00955 (KdpBreakpointTable[Index].Address <= Upper)) 00956 ) { 00957 00958 // 00959 // Breakpoint is in use and falls in range, clear it. 00960 // 00961 00962 ReturnStatus = ReturnStatus || KdpDeleteBreakpoint(Index+1); 00963 } 00964 } 00965 00966 return ReturnStatus; 00967 00968 }

BOOLEAN KdpLowRestoreBreakpoint IN ULONG  Index  ) 
 

Definition at line 1138 of file 4/kdbreak.c.

References _BREAKPOINT_ENTRY::Address, _BREAKPOINT_ENTRY::Content, FALSE, _BREAKPOINT_ENTRY::Flags, Index, KD_BREAKPOINT_IA64_MOVL, KD_BREAKPOINT_NEEDS_REPLACE, KD_BREAKPOINT_NEEDS_WRITE, KDP_BREAKPOINT_TYPE, KdpBreakpointInstruction, KdpBreakpointTable, KdpMoveMemory(), KdpOweBreakpoint, and TRUE.

Referenced by KdpRestoreAllBreakpoints().

01144 : 01145 01146 This routine attempts to write a breakpoint instruction. 01147 The old contents must have already been stored in the 01148 breakpoint record. 01149 01150 Arguments: 01151 01152 Index - Supplies the index of the breakpoint table entry 01153 which is to be written. 01154 01155 Return Value: 01156 01157 Returns TRUE if the breakpoint was written, FALSE if it was 01158 not and has been marked for writing later. 01159 01160 --*/ 01161 01162 { 01163 KDP_BREAKPOINT_TYPE Content; 01164 01165 #if defined(_IA64_) 01166 KDP_BREAKPOINT_TYPE mBuf; 01167 PVOID BundleAddress; 01168 #endif 01169 // 01170 // Does the breakpoint need to be written at all? 01171 // 01172 01173 if (KdpBreakpointTable[Index].Flags & KD_BREAKPOINT_NEEDS_REPLACE) { 01174 01175 // 01176 // The breakpoint was never removed. Clear the flag 01177 // and we are done. 01178 // 01179 01180 KdpBreakpointTable[Index].Flags &= ~KD_BREAKPOINT_NEEDS_REPLACE; 01181 return TRUE; 01182 } 01183 01184 if (KdpBreakpointTable[Index].Content == KdpBreakpointInstruction) { 01185 01186 // 01187 // The instruction is a breakpoint anyway. 01188 // 01189 01190 return TRUE; 01191 } 01192 01193 // 01194 // Replace the instruction contents. 01195 // 01196 01197 #if !defined(_IA64_) 01198 if (KdpBreakpointTable[Index].Content == KdpBreakpointInstruction) { 01199 01200 // 01201 // The instruction is a breakpoint anyway. 01202 // 01203 01204 return TRUE; 01205 } 01206 #endif 01207 01208 // 01209 // Replace the instruction contents. 01210 // 01211 01212 #if defined(_IA64_) 01213 01214 // read in intruction in case the adjacent instruction has been modified. 01215 01216 if (KdpMoveMemory( 01217 (PCHAR)&mBuf, 01218 (PCHAR)KdpBreakpointTable[Index].Address, 01219 sizeof(KDP_BREAKPOINT_TYPE) 01220 ) != sizeof(KDP_BREAKPOINT_TYPE)) { 01221 //DPRINT(("KD: read 0x%p template failed\n", KdpBreakpointTable[Index].Address)); 01222 KdpBreakpointTable[Index].Flags |= KD_BREAKPOINT_NEEDS_WRITE; 01223 KdpOweBreakpoint = TRUE; 01224 return FALSE; 01225 } 01226 01227 switch ((ULONG_PTR)KdpBreakpointTable[Index].Address & 0xf) { 01228 case 0: 01229 mBuf = (mBuf & ~(INST_SLOT0_MASK)) | (KdpBreakpointInstruction << 5); 01230 break; 01231 01232 case 4: 01233 mBuf = (mBuf & ~(INST_SLOT1_MASK)) | (KdpBreakpointInstruction << 14); 01234 break; 01235 01236 case 8: 01237 mBuf = (mBuf & ~(INST_SLOT2_MASK)) | (KdpBreakpointInstruction << 23); 01238 break; 01239 01240 default: 01241 //DPRINT(("KD: KdpAddBreakpoint bad instruction slot#\n")); 01242 return FALSE; 01243 } 01244 if (KdpMoveMemory( 01245 (PCHAR)KdpBreakpointTable[Index].Address, 01246 (PCHAR)&mBuf, 01247 sizeof(KDP_BREAKPOINT_TYPE) 01248 ) != sizeof(KDP_BREAKPOINT_TYPE)) { 01249 01250 //DPRINT(("KD: KdpMoveMemory failed writing BP!\n")); 01251 KdpBreakpointTable[Index].Flags |= KD_BREAKPOINT_NEEDS_WRITE; 01252 KdpOweBreakpoint = TRUE; 01253 return FALSE; 01254 } 01255 else { 01256 01257 // check for two-slot MOVL instruction. Reject request if attempt to 01258 // set break in slot 2 of MLI template. 01259 // change template to type 0 if current instruction is MLI 01260 01261 if (((ULONG_PTR)KdpBreakpointTable[Index].Address & 0xf) != 0) { 01262 (ULONG_PTR)BundleAddress = (ULONG_PTR)KdpBreakpointTable[Index].Address & ~(0xf); 01263 if (KdpMoveMemory( 01264 (PCHAR)&mBuf, 01265 (PCHAR)BundleAddress, 01266 sizeof(KDP_BREAKPOINT_TYPE) 01267 ) != sizeof(KDP_BREAKPOINT_TYPE)) { 01268 //DPRINT(("KD: read template failed at 0x%08x\n", BundleAddress)); 01269 KdpBreakpointTable[Index].Flags |= KD_BREAKPOINT_NEEDS_WRITE; 01270 KdpOweBreakpoint = TRUE; 01271 return FALSE; 01272 } 01273 else { 01274 if (((mBuf & INST_TEMPL_MASK) >> 1) == 0x2) { 01275 if (((ULONG_PTR)KdpBreakpointTable[Index].Address & 0xf) == 4) { 01276 // if template= type 2 MLI, change to type 0 01277 mBuf &= ~((INST_TEMPL_MASK >> 1) << 1); 01278 KdpBreakpointTable[Index].Flags |= KD_BREAKPOINT_IA64_MOVL; 01279 if (KdpMoveMemory( 01280 (PCHAR)BundleAddress, 01281 (PCHAR)&mBuf, 01282 sizeof(KDP_BREAKPOINT_TYPE) 01283 ) != sizeof(KDP_BREAKPOINT_TYPE)) { 01284 //DPRINT(("KD: write to 0x%08x template failed\n", BundleAddress)); 01285 KdpBreakpointTable[Index].Flags |= KD_BREAKPOINT_NEEDS_WRITE; 01286 KdpOweBreakpoint = TRUE; 01287 return FALSE; 01288 } 01289 else { 01290 //DPRINT(("KD: change MLI template to type 0 at 0x%08x set\n", Address)); 01291 } 01292 } else { 01293 // set breakpoint at slot 2 of MOVL is illegal 01294 //DPRINT(("KD: illegal to set BP at slot 2 of MOVL at 0x%08x\n", BundleAddress)); 01295 KdpBreakpointTable[Index].Flags |= KD_BREAKPOINT_NEEDS_WRITE; 01296 KdpOweBreakpoint = TRUE; 01297 return FALSE; 01298 } 01299 } 01300 } 01301 } 01302 //DPRINT(("KD: breakpoint at 0x%08x set\n", Address)); 01303 return TRUE; 01304 } 01305 01306 #else 01307 if (KdpMoveMemory( (PCHAR)KdpBreakpointTable[Index].Address, 01308 (PCHAR)&KdpBreakpointInstruction, 01309 sizeof(KDP_BREAKPOINT_TYPE) ) != sizeof(KDP_BREAKPOINT_TYPE)) { 01310 01311 KdpBreakpointTable[Index].Flags |= KD_BREAKPOINT_NEEDS_WRITE; 01312 KdpOweBreakpoint = TRUE; 01313 return FALSE; 01314 01315 } else { 01316 01317 KdpBreakpointTable[Index].Flags &= ~KD_BREAKPOINT_NEEDS_WRITE; 01318 return TRUE; 01319 } 01320 #endif 01321 01322 }

BOOLEAN KdpLowRestoreBreakpoint ULONG  Index  ) 
 

BOOLEAN KdpLowWriteContent IN ULONG  Index  ) 
 

Definition at line 654 of file 4/kdbreak.c.

References _BREAKPOINT_ENTRY::Address, _BREAKPOINT_ENTRY::Content, FALSE, _BREAKPOINT_ENTRY::Flags, Index, KD_BREAKPOINT_IA64_MOVL, KD_BREAKPOINT_NEEDS_REPLACE, KD_BREAKPOINT_NEEDS_WRITE, KDP_BREAKPOINT_TYPE, KdpBreakpointInstruction, KdpBreakpointTable, KdpMoveMemory(), KdpOweBreakpoint, and TRUE.

Referenced by KdpDeleteBreakpoint(), and KdpSuspendBreakpoint().

00660 : 00661 00662 This routine attempts to replace the code that a breakpoint is 00663 written over. This routine, KdpAddBreakpoint, 00664 KdpLowRestoreBreakpoint and KdSetOwedBreakpoints are responsible 00665 for getting data written as requested. Callers should not 00666 examine or use KdpOweBreakpoints, and they should not set the 00667 NEEDS_WRITE or NEEDS_REPLACE flags. 00668 00669 Callers must still look at the return value from this function, 00670 however: if it returns FALSE, the breakpoint record must not be 00671 reused until KdSetOwedBreakpoints has finished with it. 00672 00673 Arguments: 00674 00675 Index - Supplies the index of the breakpoint table entry 00676 which is to be deleted. 00677 00678 Return Value: 00679 00680 Returns TRUE if the breakpoint was removed, FALSE if it was deferred. 00681 00682 --*/ 00683 00684 { 00685 #if defined(_IA64_) 00686 KDP_BREAKPOINT_TYPE mBuf; 00687 PVOID BundleAddress; 00688 #endif 00689 00690 // 00691 // Do the contents need to be replaced at all? 00692 // 00693 00694 if (KdpBreakpointTable[Index].Flags & KD_BREAKPOINT_NEEDS_WRITE) { 00695 00696 // 00697 // The breakpoint was never written out. Clear the flag 00698 // and we are done. 00699 // 00700 00701 KdpBreakpointTable[Index].Flags &= ~KD_BREAKPOINT_NEEDS_WRITE; 00702 //DPRINT(("KD: Breakpoint at 0x%08x never written; flag cleared.\n", 00703 // KdpBreakpointTable[Index].Address)); 00704 return TRUE; 00705 } 00706 00707 #if !defined(_IA64_) 00708 if (KdpBreakpointTable[Index].Content == KdpBreakpointInstruction) { 00709 00710 // 00711 // The instruction is a breakpoint anyway. 00712 // 00713 00714 //DPRINT(("KD: Breakpoint at 0x%08x; instr is really BP; flag cleared.\n", 00715 // KdpBreakpointTable[Index].Address)); 00716 00717 return TRUE; 00718 } 00719 #endif 00720 00721 00722 // 00723 // Restore the instruction contents. 00724 // 00725 00726 #if defined(_IA64_) 00727 // Read in memory since adjancent instructions in the same bundle may have 00728 // been modified after we save them. 00729 if (KdpMoveMemory( 00730 (PCHAR)&mBuf, 00731 (PCHAR)KdpBreakpointTable[Index].Address, 00732 sizeof(KDP_BREAKPOINT_TYPE)) != sizeof(KDP_BREAKPOINT_TYPE)) { 00733 KdpOweBreakpoint = TRUE; 00734 //DPRINT(("KD: read 0x%08x failed\n", KdpBreakpointTable[Index].Address)); 00735 KdpBreakpointTable[Index].Flags |= KD_BREAKPOINT_NEEDS_REPLACE; 00736 return FALSE; 00737 } 00738 else { 00739 00740 switch ((ULONG_PTR)KdpBreakpointTable[Index].Address & 0xf) { 00741 case 0: 00742 mBuf = (mBuf & ~(INST_SLOT0_MASK)) 00743 | (KdpBreakpointTable[Index].Content & INST_SLOT0_MASK); 00744 break; 00745 00746 case 4: 00747 mBuf = (mBuf & ~(INST_SLOT1_MASK)) 00748 | (KdpBreakpointTable[Index].Content & INST_SLOT1_MASK); 00749 break; 00750 00751 case 8: 00752 mBuf = (mBuf & ~(INST_SLOT2_MASK)) 00753 | (KdpBreakpointTable[Index].Content & INST_SLOT2_MASK); 00754 break; 00755 00756 default: 00757 KdpOweBreakpoint = TRUE; 00758 //DPRINT(("KD: illegal instruction address 0x%08x\n", KdpBreakpointTable[Index].Address)); 00759 return FALSE; 00760 } 00761 00762 if (KdpMoveMemory( 00763 (PCHAR)KdpBreakpointTable[Index].Address, 00764 (PCHAR)&mBuf, 00765 sizeof(KDP_BREAKPOINT_TYPE)) != sizeof(KDP_BREAKPOINT_TYPE)) { 00766 KdpOweBreakpoint = TRUE; 00767 //DPRINT(("KD: write to 0x%08x failed\n", KdpBreakpointTable[Index].Address)); 00768 KdpBreakpointTable[Index].Flags |= KD_BREAKPOINT_NEEDS_REPLACE; 00769 return FALSE; 00770 } 00771 else { 00772 00773 if (KdpMoveMemory( 00774 (PCHAR)&mBuf, 00775 (PCHAR)KdpBreakpointTable[Index].Address, 00776 sizeof(KDP_BREAKPOINT_TYPE)) == sizeof(KDP_BREAKPOINT_TYPE)) { 00777 //DPRINT(("\tcontent after memory move = 0x%08x 0x%08x\n", (ULONG)(mBuf >> 32), (ULONG)mBuf)); 00778 } 00779 00780 // restore template to MLI if displaced instruction was MOVL 00781 00782 if (KdpBreakpointTable[Index].Flags & KD_BREAKPOINT_IA64_MOVL) { 00783 (ULONG_PTR)BundleAddress = (ULONG_PTR)KdpBreakpointTable[Index].Address & ~(0xf); 00784 if (KdpMoveMemory( 00785 (PCHAR)&mBuf, 00786 (PCHAR)BundleAddress, 00787 sizeof(KDP_BREAKPOINT_TYPE) 00788 ) != sizeof(KDP_BREAKPOINT_TYPE)) { 00789 KdpOweBreakpoint = TRUE; 00790 //DPRINT(("KD: read template 0x%08x failed\n", KdpBreakpointTable[Index].Address)); 00791 KdpBreakpointTable[Index].Flags |= KD_BREAKPOINT_NEEDS_REPLACE; 00792 return FALSE; 00793 } 00794 else { 00795 mBuf &= ~((INST_TEMPL_MASK >> 1) << 1); // set template to MLI 00796 mBuf |= 0x4; 00797 00798 if (KdpMoveMemory( 00799 (PCHAR)BundleAddress, 00800 (PCHAR)&mBuf, 00801 sizeof(KDP_BREAKPOINT_TYPE) 00802 ) != sizeof(KDP_BREAKPOINT_TYPE)) { 00803 KdpOweBreakpoint = TRUE; 00804 //DPRINT(("KD: write template to 0x%08x failed\n", KdpBreakpointTable[Index].Address)); 00805 KdpBreakpointTable[Index].Flags |= KD_BREAKPOINT_NEEDS_REPLACE; 00806 return FALSE; 00807 } else { 00808 //DPRINT(("KD: Breakpoint at 0x%08x cleared.\n", 00809 // KdpBreakpointTable[Index].Address)); 00810 return TRUE; 00811 } 00812 } 00813 } 00814 else { // not MOVL 00815 //DPRINT(("KD: Breakpoint at 0x%08x cleared.\n", 00816 // KdpBreakpointTable[Index].Address)); 00817 return TRUE; 00818 } 00819 } 00820 } 00821 #else 00822 if (KdpMoveMemory( (PCHAR)KdpBreakpointTable[Index].Address, 00823 (PCHAR)&KdpBreakpointTable[Index].Content, 00824 sizeof(KDP_BREAKPOINT_TYPE) ) != sizeof(KDP_BREAKPOINT_TYPE)) { 00825 00826 KdpOweBreakpoint = TRUE; 00827 KdpBreakpointTable[Index].Flags |= KD_BREAKPOINT_NEEDS_REPLACE; 00828 //DPRINT(("KD: Breakpoint at 0x%08x; unable to clear, flag set.\n", 00829 //KdpBreakpointTable[Index].Address)); 00830 return FALSE; 00831 } else { 00832 //DPRINT(("KD: Breakpoint at 0x%08x cleared.\n", 00833 //KdpBreakpointTable[Index].Address)); 00834 return TRUE; 00835 } 00836 #endif 00837 00838 }

BOOLEAN KdpLowWriteContent ULONG  Index  ) 
 

VOID KdpRestoreAllBreakpoints VOID   ) 
 

Definition at line 1326 of file 4/kdbreak.c.

References BreakpointsSuspended, FALSE, _BREAKPOINT_ENTRY::Flags, Index, KD_BREAKPOINT_IN_USE, KD_BREAKPOINT_SUSPENDED, KdpBreakpointTable, and KdpLowRestoreBreakpoint().

Referenced by KdEnableDebugger().

01329 { 01330 ULONG Index; 01331 01332 BreakpointsSuspended = FALSE; 01333 01334 for ( Index = 0; Index < BREAKPOINT_TABLE_SIZE; Index++ ) { 01335 01336 if ((KdpBreakpointTable[Index].Flags & KD_BREAKPOINT_IN_USE) && 01337 (KdpBreakpointTable[Index].Flags & KD_BREAKPOINT_SUSPENDED) ) { 01338 01339 KdpBreakpointTable[Index].Flags &= ~KD_BREAKPOINT_SUSPENDED; 01340 KdpLowRestoreBreakpoint(Index); 01341 } 01342 } 01343 01344 return; 01345 01346 } // KdpRestoreAllBreakpoints

VOID KdpSuspendAllBreakpoints VOID   ) 
 

Definition at line 989 of file 4/kdbreak.c.

References BreakpointsSuspended, Handle, KdpSuspendBreakpoint(), and TRUE.

Referenced by KdDisableDebugger().

00992 { 00993 ULONG Handle; 00994 00995 BreakpointsSuspended = TRUE; 00996 00997 for ( Handle = 1; Handle <= BREAKPOINT_TABLE_SIZE; Handle++ ) { 00998 KdpSuspendBreakpoint(Handle); 00999 } 01000 01001 return; 01002 01003 } // KdpSuspendAllBreakpoints

VOID KdpSuspendBreakpoint ULONG  Handle  ) 
 

Definition at line 971 of file 4/kdbreak.c.

References _BREAKPOINT_ENTRY::Flags, Handle, Index, KD_BREAKPOINT_IN_USE, KD_BREAKPOINT_SUSPENDED, KdpBreakpointTable, and KdpLowWriteContent().

Referenced by KdpSuspendAllBreakpoints().

00974 { 00975 ULONG Index = Handle - 1; 00976 00977 if ( (KdpBreakpointTable[Index].Flags & KD_BREAKPOINT_IN_USE) && 00978 !(KdpBreakpointTable[Index].Flags & KD_BREAKPOINT_SUSPENDED) ) { 00979 00980 KdpBreakpointTable[Index].Flags |= KD_BREAKPOINT_SUSPENDED; 00981 KdpLowWriteContent(Index); 00982 } 00983 00984 return; 00985 00986 } // KdpSuspendBreakpoint

VOID KdSetOwedBreakpoints VOID   ) 
 

Referenced by KiMemoryFault().


Generated on Sat May 15 19:44:25 2004 for test by doxygen 1.3.7