annotate src/breakpoint.d @ 1:4a9dcbd9e54f

-files of 0.13 beta -fixes so that it now compiles with the current dmd version
author marton@basel.hu
date Tue, 05 Apr 2011 20:44:01 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1 /* Ddbg - Win32 Debugger for the D programming language
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
2 * Copyright (c) 2007 Jascha Wetzel
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
3 * All rights reserved. See LICENSE.TXT for details.
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
4 */
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
5 module breakpoint;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
6
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
7 import std.string;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
8 import std.c.string;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
9
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
10 import dbgthread;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
11 import codeview.codeview;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
12 import dbgprocess;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
13 import util;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
14
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
15 import win32.windef;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
16
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
17 enum StepMode {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
18 e_in, e_over, e_out
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
19 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
20
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
21 /**************************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
22 Represents a software breakpoint.
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
23 **************************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
24 class Breakpoint
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
25 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
26 //---------------------------------------------------------------------------------------------
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
27 // constants
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
28 const ubyte BREAKPOINT_OPCODE = 0xccu;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
29
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
30 //---------------------------------------------------------------------------------------------
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
31 // variables
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
32 byte old_opcode;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
33 bool active,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
34 temporary,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
35 deactivate_d_exception_handler,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
36 propagate, /// when hit on a jmp/call/ret instruction, shall be reactivated on it's destination
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
37 hardware;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
38 Breakpoint foreach_end;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
39 Location location;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
40 size_t frame_ptr,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
41 threadId,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
42 old_dr_value;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
43 ubyte dr_index;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
44
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
45 //---------------------------------------------------------------------------------------------
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
46 // properties
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
47 string file() { return location is null?null:location.file; }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
48 uint line() { return location is null?0:location.line; }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
49 uint address() { return location is null?0:location.address; }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
50
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
51
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
52 //---------------------------------------------------------------------------------------------
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
53 // construction
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
54 this(Location loc, bool temp, uint _threadId, bool _hardware=false)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
55 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
56 hardware = _hardware;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
57 threadId = _threadId;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
58 temporary = temp;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
59 location = loc;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
60 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
61
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
62
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
63 //---------------------------------------------------------------------------------------------
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
64 // methods
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
65
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
66 /**
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
67 *
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
68 */
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
69 string toString()
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
70 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
71 string tmp;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
72 tmp.length = 100;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
73 tmp.length = 0;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
74 if ( location.path.length > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
75 tmp ~= format("%s ", location.path);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
76 if ( file.length > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
77 tmp ~= format("%s:%d ", file, line);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
78 if ( location.address > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
79 tmp ~= format("0x%x ", location.address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
80 if ( hardware )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
81 tmp ~= "hw ";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
82 if ( threadId > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
83 tmp ~= format("thread %s", threadId);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
84 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
85 tmp ~= format("all threads");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
86 return tmp;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
87 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
88
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
89 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
90 Restores the opcode that has been overwritten for the given breakpoint.
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
91 Returns success.
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
92 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
93 bool deactivate(DbgProcess proc)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
94 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
95 if ( !active )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
96 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
97 if ( proc is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
98 return false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
99
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
100 if ( hardware )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
101 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
102 if ( threadId == 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
103 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
104 foreach ( thread; proc.threads.values )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
105 clearHWBP(thread, 0);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
106 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
107 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
108 clearHWBP(proc.threads[threadId], 0);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
109 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
110 else if( !proc.writeProcessMemory(location.address, &old_opcode, ubyte.sizeof))
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
111 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
112 DbgIO.println("restoreBreakpoint(): Failed to write original opcode at 0x%x", location.address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
113 return false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
114 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
115
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
116 active = false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
117 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
118 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
119
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
120 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
121 Writes an int 3 opcode at the address of this breakpoint, saving the overwritten code.
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
122 Returns success.
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
123 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
124 bool activate(DbgProcess proc)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
125 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
126 if( active )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
127 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
128 if( location.address == 0 || proc is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
129 return false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
130
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
131 debug DbgIO.println("activating bp at 0x%x", location.address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
132
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
133 if ( hardware )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
134 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
135 if ( threadId == 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
136 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
137 foreach ( thread; proc.threads.values )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
138 setHWBP(thread, location.address, 0);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
139 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
140 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
141 setHWBP(proc.threads[threadId], location.address, 0);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
142 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
143 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
144 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
145 uint oldprot, oldprot2;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
146 ubyte ccByte = cast(ubyte)0xcc;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
147
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
148 if( ubyte.sizeof > proc.readProcessMemory(location.address, &old_opcode, ubyte.sizeof) ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
149 DbgIO.println( "readProcessMemory(): failed to read breakpoint opcode at 0x%08x", location.address );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
150 return false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
151 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
152
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
153 ubyte opcode = BREAKPOINT_OPCODE;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
154 if( ubyte.sizeof > proc.writeProcessMemory(location.address, &opcode, ubyte.sizeof) ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
155 DbgIO.println("writeProcessMemory(): Failed to write breakpoint at 0x%08x", location.address );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
156 return false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
157 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
158 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
159
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
160 active = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
161 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
162 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
163
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
164 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
165
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
166 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
167 void setHWBP(DbgThread thread, size_t address, ubyte index)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
168 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
169 assert(index < 4);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
170
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
171 CONTEXT ctx;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
172 thread.getContext(ctx, CONTEXT_DEBUG_REGISTERS);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
173 DbgIO.println("Dr0 = %x\nDr1 = %x\nDr2 = %x\nDr3 = %x\nDr7 = %x\n", ctx.Dr0, ctx.Dr1, ctx.Dr2, ctx.Dr3, ctx.Dr7);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
174
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
175 old_dr_value = *(&ctx.Dr0 + index);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
176 *(&ctx.Dr0 + index) = address+thread.getDsBase;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
177 dr_index = index;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
178
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
179 ctx.Dr7 |= 1<<10 | (1 << index) | (15 << (16+index*4));
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
180 DbgIO.println("Dr0 = %x\nDr1 = %x\nDr2 = %x\nDr3 = %x\nDr7 = %x\n", ctx.Dr0, ctx.Dr1, ctx.Dr2, ctx.Dr3, ctx.Dr7);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
181 thread.setContext(ctx);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
182 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
183
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
184 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
185
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
186 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
187 void clearHWBP(DbgThread thread, ubyte index)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
188 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
189 assert(index < 4);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
190
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
191 CONTEXT ctx;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
192 thread.getContext(ctx, CONTEXT_DEBUG_REGISTERS);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
193 DbgIO.println("Dr0 = %x\nDr1 = %x\nDr2 = %x\nDr3 = %x\nDr7 = %x\n", ctx.Dr0, ctx.Dr1, ctx.Dr2, ctx.Dr3, ctx.Dr7);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
194
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
195 ctx.Dr7 &= ~((1 << index) | (15 << (16+index*4)));
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
196 DbgIO.println("Dr0 = %x\nDr1 = %x\nDr2 = %x\nDr3 = %x\nDr7 = %x\n", ctx.Dr0, ctx.Dr1, ctx.Dr2, ctx.Dr3, ctx.Dr7);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
197 thread.setContext(ctx);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
198 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
199 }