Subversion Repositories HelenOS-historic

Rev

Rev 1705 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1705 Rev 1780
Line 44... Line 44...
44
#include <debug.h>
44
#include <debug.h>
45
#include <func.h>
45
#include <func.h>
46
#include <smp/ipi.h>
46
#include <smp/ipi.h>
47
 
47
 
48
typedef struct  {
48
typedef struct  {
49
    __address address;      /**< Breakpoint address */
49
    uintptr_t address;      /**< Breakpoint address */
50
    int flags;              /**< Flags regarding breakpoint */
50
    int flags;              /**< Flags regarding breakpoint */
51
    int counter;            /**< How many times the exception occured */
51
    int counter;            /**< How many times the exception occured */
52
} bpinfo_t;
52
} bpinfo_t;
53
 
53
 
54
static bpinfo_t breakpoints[BKPOINTS_MAX];
54
static bpinfo_t breakpoints[BKPOINTS_MAX];
Line 120... Line 120...
120
}
120
}
121
 
121
 
122
/* Setup DR register according to table */
122
/* Setup DR register according to table */
123
static void setup_dr(int curidx)
123
static void setup_dr(int curidx)
124
{
124
{
125
    __native dr7;
125
    unative_t dr7;
126
    bpinfo_t *cur = &breakpoints[curidx];
126
    bpinfo_t *cur = &breakpoints[curidx];
127
    int flags = breakpoints[curidx].flags;
127
    int flags = breakpoints[curidx].flags;
128
 
128
 
129
    /* Disable breakpoint in DR7 */
129
    /* Disable breakpoint in DR7 */
130
    dr7 = read_dr7();
130
    dr7 = read_dr7();
Line 151... Line 151...
151
        dr7 &= ~ (0x3 << (18 + 4*curidx));
151
        dr7 &= ~ (0x3 << (18 + 4*curidx));
152
        if ((flags & BKPOINT_INSTR)) {
152
        if ((flags & BKPOINT_INSTR)) {
153
            ;
153
            ;
154
        } else {
154
        } else {
155
            if (sizeof(int) == 4)
155
            if (sizeof(int) == 4)
156
                dr7 |= ((__native) 0x3) << (18 + 4*curidx);
156
                dr7 |= ((unative_t) 0x3) << (18 + 4*curidx);
157
            else /* 8 */
157
            else /* 8 */
158
                dr7 |= ((__native) 0x2) << (18 + 4*curidx);
158
                dr7 |= ((unative_t) 0x2) << (18 + 4*curidx);
159
           
159
           
160
            if ((flags & BKPOINT_WRITE))
160
            if ((flags & BKPOINT_WRITE))
161
                dr7 |= ((__native) 0x1) << (16 + 4*curidx);
161
                dr7 |= ((unative_t) 0x1) << (16 + 4*curidx);
162
            else if ((flags & BKPOINT_READ_WRITE))
162
            else if ((flags & BKPOINT_READ_WRITE))
163
                dr7 |= ((__native) 0x3) << (16 + 4*curidx);
163
                dr7 |= ((unative_t) 0x3) << (16 + 4*curidx);
164
        }
164
        }
165
 
165
 
166
        /* Enable global breakpoint */
166
        /* Enable global breakpoint */
167
        dr7 |= 0x2 << (curidx*2);
167
        dr7 |= 0x2 << (curidx*2);
168
 
168
 
Line 203... Line 203...
203
            return -1;
203
            return -1;
204
        }
204
        }
205
    }
205
    }
206
    cur = &breakpoints[curidx];
206
    cur = &breakpoints[curidx];
207
 
207
 
208
    cur->address = (__address) where;
208
    cur->address = (uintptr_t) where;
209
    cur->flags = flags;
209
    cur->flags = flags;
210
    cur->counter = 0;
210
    cur->counter = 0;
211
 
211
 
212
    setup_dr(curidx);
212
    setup_dr(curidx);
213
 
213
 
Line 233... Line 233...
233
    ASSERT(breakpoints[slot].address);
233
    ASSERT(breakpoints[slot].address);
234
 
234
 
235
    /* Handle zero checker */
235
    /* Handle zero checker */
236
    if (! (breakpoints[slot].flags & BKPOINT_INSTR)) {
236
    if (! (breakpoints[slot].flags & BKPOINT_INSTR)) {
237
        if ((breakpoints[slot].flags & BKPOINT_CHECK_ZERO)) {
237
        if ((breakpoints[slot].flags & BKPOINT_CHECK_ZERO)) {
238
            if (*((__native *) breakpoints[slot].address) != 0)
238
            if (*((unative_t *) breakpoints[slot].address) != 0)
239
                return;
239
                return;
240
            printf("**** Found ZERO on address %p ****\n",
240
            printf("**** Found ZERO on address %p ****\n",
241
                   slot, breakpoints[slot].address);
241
                   slot, breakpoints[slot].address);
242
        } else {
242
        } else {
243
            printf("Data watchpoint - new data: %p\n",
243
            printf("Data watchpoint - new data: %p\n",
244
                   *((__native *) breakpoints[slot].address));
244
                   *((unative_t *) breakpoints[slot].address));
245
        }
245
        }
246
    }
246
    }
247
    printf("Reached breakpoint %d:%p(%s)\n", slot, getip(istate),
247
    printf("Reached breakpoint %d:%p(%s)\n", slot, getip(istate),
248
           get_symtab_entry(getip(istate)));
248
           get_symtab_entry(getip(istate)));
249
    printf("***Type 'exit' to exit kconsole.\n");
249
    printf("***Type 'exit' to exit kconsole.\n");
Line 313... Line 313...
313
}
313
}
314
#endif
314
#endif
315
 
315
 
316
static void debug_exception(int n, istate_t *istate)
316
static void debug_exception(int n, istate_t *istate)
317
{
317
{
318
    __native dr6;
318
    unative_t dr6;
319
    int i;
319
    int i;
320
   
320
   
321
    /* Set RF to restart the instruction  */
321
    /* Set RF to restart the instruction  */
322
#ifdef amd64       
322
#ifdef amd64       
323
    istate->rflags |= RFLAGS_RF;
323
    istate->rflags |= RFLAGS_RF;