Subversion Repositories HelenOS-historic

Rev

Rev 1221 | Rev 1705 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1221 Rev 1702
1
/*
1
/*
2
 * Copyright (C) 2006 Ondrej Palkovsky
2
 * Copyright (C) 2006 Ondrej Palkovsky
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
-
 
29
 /** @addtogroup amd64debug ia32/amd64
-
 
30
 * @ingroup debug
-
 
31
 * @{
-
 
32
 */
-
 
33
/** @file
-
 
34
 */
-
 
35
 
29
#include <arch/debugger.h>
36
#include <arch/debugger.h>
30
#include <console/kconsole.h>
37
#include <console/kconsole.h>
31
#include <console/cmd.h>
38
#include <console/cmd.h>
32
#include <symtab.h>
39
#include <symtab.h>
33
#include <print.h>
40
#include <print.h>
34
#include <panic.h>
41
#include <panic.h>
35
#include <interrupt.h>
42
#include <interrupt.h>
36
#include <arch/asm.h>
43
#include <arch/asm.h>
37
#include <arch/cpu.h>
44
#include <arch/cpu.h>
38
#include <debug.h>
45
#include <debug.h>
39
#include <func.h>
46
#include <func.h>
40
#include <smp/ipi.h>
47
#include <smp/ipi.h>
41
 
48
 
42
typedef struct  {
49
typedef struct  {
43
    __address address;      /**< Breakpoint address */
50
    __address address;      /**< Breakpoint address */
44
    int flags;              /**< Flags regarding breakpoint */
51
    int flags;              /**< Flags regarding breakpoint */
45
    int counter;            /**< How many times the exception occured */
52
    int counter;            /**< How many times the exception occured */
46
} bpinfo_t;
53
} bpinfo_t;
47
 
54
 
48
static bpinfo_t breakpoints[BKPOINTS_MAX];
55
static bpinfo_t breakpoints[BKPOINTS_MAX];
49
SPINLOCK_INITIALIZE(bkpoint_lock);
56
SPINLOCK_INITIALIZE(bkpoint_lock);
50
 
57
 
51
static int cmd_print_breakpoints(cmd_arg_t *argv);
58
static int cmd_print_breakpoints(cmd_arg_t *argv);
52
static cmd_info_t bkpts_info = {
59
static cmd_info_t bkpts_info = {
53
    .name = "bkpts",
60
    .name = "bkpts",
54
    .description = "Print breakpoint table.",
61
    .description = "Print breakpoint table.",
55
    .func = cmd_print_breakpoints,
62
    .func = cmd_print_breakpoints,
56
    .argc = 0,
63
    .argc = 0,
57
};
64
};
58
 
65
 
59
#ifndef CONFIG_DEBUG_AS_WATCHPOINT
66
#ifndef CONFIG_DEBUG_AS_WATCHPOINT
60
 
67
 
61
static int cmd_del_breakpoint(cmd_arg_t *argv);
68
static int cmd_del_breakpoint(cmd_arg_t *argv);
62
static cmd_arg_t del_argv = {
69
static cmd_arg_t del_argv = {
63
    .type = ARG_TYPE_INT
70
    .type = ARG_TYPE_INT
64
};
71
};
65
static cmd_info_t delbkpt_info = {
72
static cmd_info_t delbkpt_info = {
66
    .name = "delbkpt",
73
    .name = "delbkpt",
67
    .description = "delbkpt <number> - Delete breakpoint.",
74
    .description = "delbkpt <number> - Delete breakpoint.",
68
    .func = cmd_del_breakpoint,
75
    .func = cmd_del_breakpoint,
69
    .argc = 1,
76
    .argc = 1,
70
    .argv = &del_argv
77
    .argv = &del_argv
71
};
78
};
72
 
79
 
73
static int cmd_add_breakpoint(cmd_arg_t *argv);
80
static int cmd_add_breakpoint(cmd_arg_t *argv);
74
static cmd_arg_t add_argv = {
81
static cmd_arg_t add_argv = {
75
    .type = ARG_TYPE_INT
82
    .type = ARG_TYPE_INT
76
};
83
};
77
static cmd_info_t addbkpt_info = {
84
static cmd_info_t addbkpt_info = {
78
    .name = "addbkpt",
85
    .name = "addbkpt",
79
    .description = "addbkpt <&symbol> - new breakpoint.",
86
    .description = "addbkpt <&symbol> - new breakpoint.",
80
    .func = cmd_add_breakpoint,
87
    .func = cmd_add_breakpoint,
81
    .argc = 1,
88
    .argc = 1,
82
    .argv = &add_argv
89
    .argv = &add_argv
83
};
90
};
84
 
91
 
85
static cmd_arg_t addw_argv = {
92
static cmd_arg_t addw_argv = {
86
    .type = ARG_TYPE_INT
93
    .type = ARG_TYPE_INT
87
};
94
};
88
static cmd_info_t addwatchp_info = {
95
static cmd_info_t addwatchp_info = {
89
    .name = "addwatchp",
96
    .name = "addwatchp",
90
    .description = "addbwatchp <&symbol> - new write watchpoint.",
97
    .description = "addbwatchp <&symbol> - new write watchpoint.",
91
    .func = cmd_add_breakpoint,
98
    .func = cmd_add_breakpoint,
92
    .argc = 1,
99
    .argc = 1,
93
    .argv = &addw_argv
100
    .argv = &addw_argv
94
};
101
};
95
 
102
 
96
#endif
103
#endif
97
 
104
 
98
/** Print table of active breakpoints */
105
/** Print table of active breakpoints */
99
int cmd_print_breakpoints(cmd_arg_t *argv)
106
int cmd_print_breakpoints(cmd_arg_t *argv)
100
{
107
{
101
    int i;
108
    int i;
102
    char *symbol;
109
    char *symbol;
103
 
110
 
104
    printf("Breakpoint table.\n");
111
    printf("Breakpoint table.\n");
105
    for (i=0; i < BKPOINTS_MAX; i++)
112
    for (i=0; i < BKPOINTS_MAX; i++)
106
        if (breakpoints[i].address) {
113
        if (breakpoints[i].address) {
107
            symbol = get_symtab_entry(breakpoints[i].address);
114
            symbol = get_symtab_entry(breakpoints[i].address);
108
            printf("%d. %p in %s\n",i,
115
            printf("%d. %p in %s\n",i,
109
                   breakpoints[i].address, symbol);
116
                   breakpoints[i].address, symbol);
110
            printf("     Count(%d) ", breakpoints[i].counter);
117
            printf("     Count(%d) ", breakpoints[i].counter);
111
            printf("\n");
118
            printf("\n");
112
        }
119
        }
113
    return 1;
120
    return 1;
114
}
121
}
115
 
122
 
116
/* Setup DR register according to table */
123
/* Setup DR register according to table */
117
static void setup_dr(int curidx)
124
static void setup_dr(int curidx)
118
{
125
{
119
    __native dr7;
126
    __native dr7;
120
    bpinfo_t *cur = &breakpoints[curidx];
127
    bpinfo_t *cur = &breakpoints[curidx];
121
    int flags = breakpoints[curidx].flags;
128
    int flags = breakpoints[curidx].flags;
122
 
129
 
123
    /* Disable breakpoint in DR7 */
130
    /* Disable breakpoint in DR7 */
124
    dr7 = read_dr7();
131
    dr7 = read_dr7();
125
    dr7 &= ~(0x2 << (curidx*2));
132
    dr7 &= ~(0x2 << (curidx*2));
126
 
133
 
127
    if (cur->address) { /* Setup DR register */
134
    if (cur->address) { /* Setup DR register */
128
        /* Set breakpoint to debug registers */
135
        /* Set breakpoint to debug registers */
129
        switch (curidx) {
136
        switch (curidx) {
130
        case 0:
137
        case 0:
131
            write_dr0(cur->address);
138
            write_dr0(cur->address);
132
            break;
139
            break;
133
        case 1:
140
        case 1:
134
            write_dr1(cur->address);
141
            write_dr1(cur->address);
135
            break;
142
            break;
136
        case 2:
143
        case 2:
137
            write_dr2(cur->address);
144
            write_dr2(cur->address);
138
            break;
145
            break;
139
        case 3:
146
        case 3:
140
            write_dr3(cur->address);
147
            write_dr3(cur->address);
141
            break;
148
            break;
142
        }
149
        }
143
        /* Set type to requested breakpoint & length*/
150
        /* Set type to requested breakpoint & length*/
144
        dr7 &= ~ (0x3 << (16 + 4*curidx));
151
        dr7 &= ~ (0x3 << (16 + 4*curidx));
145
        dr7 &= ~ (0x3 << (18 + 4*curidx));
152
        dr7 &= ~ (0x3 << (18 + 4*curidx));
146
        if ((flags & BKPOINT_INSTR)) {
153
        if ((flags & BKPOINT_INSTR)) {
147
            ;
154
            ;
148
        } else {
155
        } else {
149
            if (sizeof(int) == 4)
156
            if (sizeof(int) == 4)
150
                dr7 |= ((__native) 0x3) << (18 + 4*curidx);
157
                dr7 |= ((__native) 0x3) << (18 + 4*curidx);
151
            else /* 8 */
158
            else /* 8 */
152
                dr7 |= ((__native) 0x2) << (18 + 4*curidx);
159
                dr7 |= ((__native) 0x2) << (18 + 4*curidx);
153
           
160
           
154
            if ((flags & BKPOINT_WRITE))
161
            if ((flags & BKPOINT_WRITE))
155
                dr7 |= ((__native) 0x1) << (16 + 4*curidx);
162
                dr7 |= ((__native) 0x1) << (16 + 4*curidx);
156
            else if ((flags & BKPOINT_READ_WRITE))
163
            else if ((flags & BKPOINT_READ_WRITE))
157
                dr7 |= ((__native) 0x3) << (16 + 4*curidx);
164
                dr7 |= ((__native) 0x3) << (16 + 4*curidx);
158
        }
165
        }
159
 
166
 
160
        /* Enable global breakpoint */
167
        /* Enable global breakpoint */
161
        dr7 |= 0x2 << (curidx*2);
168
        dr7 |= 0x2 << (curidx*2);
162
 
169
 
163
        write_dr7(dr7);
170
        write_dr7(dr7);
164
       
171
       
165
    }
172
    }
166
}
173
}
167
   
174
   
168
/** Enable hardware breakpoint
175
/** Enable hardware breakpoint
169
 *
176
 *
170
 *
177
 *
171
 * @param where Address of HW breakpoint
178
 * @param where Address of HW breakpoint
172
 * @param flags Type of breakpoint (EXECUTE, WRITE)
179
 * @param flags Type of breakpoint (EXECUTE, WRITE)
173
 * @return Debug slot on success, -1 - no available HW breakpoint
180
 * @return Debug slot on success, -1 - no available HW breakpoint
174
 */
181
 */
175
int breakpoint_add(void * where, int flags, int curidx)
182
int breakpoint_add(void * where, int flags, int curidx)
176
{
183
{
177
    ipl_t ipl;
184
    ipl_t ipl;
178
    int i;
185
    int i;
179
    bpinfo_t *cur;
186
    bpinfo_t *cur;
180
 
187
 
181
    ASSERT( flags & (BKPOINT_INSTR | BKPOINT_WRITE | BKPOINT_READ_WRITE));
188
    ASSERT( flags & (BKPOINT_INSTR | BKPOINT_WRITE | BKPOINT_READ_WRITE));
182
 
189
 
183
    ipl = interrupts_disable();
190
    ipl = interrupts_disable();
184
    spinlock_lock(&bkpoint_lock);
191
    spinlock_lock(&bkpoint_lock);
185
   
192
   
186
    if (curidx == -1) {
193
    if (curidx == -1) {
187
        /* Find free space in slots */
194
        /* Find free space in slots */
188
        for (i=0; i<BKPOINTS_MAX; i++)
195
        for (i=0; i<BKPOINTS_MAX; i++)
189
            if (!breakpoints[i].address) {
196
            if (!breakpoints[i].address) {
190
                curidx = i;
197
                curidx = i;
191
                break;
198
                break;
192
            }
199
            }
193
        if (curidx == -1) {
200
        if (curidx == -1) {
194
            /* Too many breakpoints */
201
            /* Too many breakpoints */
195
            spinlock_unlock(&bkpoint_lock);
202
            spinlock_unlock(&bkpoint_lock);
196
            interrupts_restore(ipl);
203
            interrupts_restore(ipl);
197
            return -1;
204
            return -1;
198
        }
205
        }
199
    }
206
    }
200
    cur = &breakpoints[curidx];
207
    cur = &breakpoints[curidx];
201
 
208
 
202
    cur->address = (__address) where;
209
    cur->address = (__address) where;
203
    cur->flags = flags;
210
    cur->flags = flags;
204
    cur->counter = 0;
211
    cur->counter = 0;
205
 
212
 
206
    setup_dr(curidx);
213
    setup_dr(curidx);
207
 
214
 
208
    spinlock_unlock(&bkpoint_lock);
215
    spinlock_unlock(&bkpoint_lock);
209
    interrupts_restore(ipl);
216
    interrupts_restore(ipl);
210
 
217
 
211
    /* Send IPI */
218
    /* Send IPI */
212
#ifdef CONFIG_SMP
219
#ifdef CONFIG_SMP
213
//  ipi_broadcast(VECTOR_DEBUG_IPI);    
220
//  ipi_broadcast(VECTOR_DEBUG_IPI);    
214
#endif  
221
#endif  
215
 
222
 
216
    return curidx;
223
    return curidx;
217
}
224
}
218
 
225
 
219
#ifdef amd64
226
#ifdef amd64
220
# define getip(x)  ((x)->rip)
227
# define getip(x)  ((x)->rip)
221
#else
228
#else
222
# define getip(x)  ((x)->eip)
229
# define getip(x)  ((x)->eip)
223
#endif
230
#endif
224
 
231
 
225
static void handle_exception(int slot, istate_t *istate)
232
static void handle_exception(int slot, istate_t *istate)
226
{
233
{
227
    ASSERT(breakpoints[slot].address);
234
    ASSERT(breakpoints[slot].address);
228
 
235
 
229
    /* Handle zero checker */
236
    /* Handle zero checker */
230
    if (! (breakpoints[slot].flags & BKPOINT_INSTR)) {
237
    if (! (breakpoints[slot].flags & BKPOINT_INSTR)) {
231
        if ((breakpoints[slot].flags & BKPOINT_CHECK_ZERO)) {
238
        if ((breakpoints[slot].flags & BKPOINT_CHECK_ZERO)) {
232
            if (*((__native *) breakpoints[slot].address) != 0)
239
            if (*((__native *) breakpoints[slot].address) != 0)
233
                return;
240
                return;
234
            printf("**** Found ZERO on address %p ****\n",
241
            printf("**** Found ZERO on address %p ****\n",
235
                   slot, breakpoints[slot].address);
242
                   slot, breakpoints[slot].address);
236
        } else {
243
        } else {
237
            printf("Data watchpoint - new data: %p\n",
244
            printf("Data watchpoint - new data: %p\n",
238
                   *((__native *) breakpoints[slot].address));
245
                   *((__native *) breakpoints[slot].address));
239
        }
246
        }
240
    }
247
    }
241
    printf("Reached breakpoint %d:%p(%s)\n", slot, getip(istate),
248
    printf("Reached breakpoint %d:%p(%s)\n", slot, getip(istate),
242
           get_symtab_entry(getip(istate)));
249
           get_symtab_entry(getip(istate)));
243
    printf("***Type 'exit' to exit kconsole.\n");
250
    printf("***Type 'exit' to exit kconsole.\n");
244
    atomic_set(&haltstate,1);
251
    atomic_set(&haltstate,1);
245
    kconsole("debug");
252
    kconsole("debug");
246
    atomic_set(&haltstate,0);
253
    atomic_set(&haltstate,0);
247
}
254
}
248
 
255
 
249
void breakpoint_del(int slot)
256
void breakpoint_del(int slot)
250
{
257
{
251
    bpinfo_t *cur;
258
    bpinfo_t *cur;
252
    ipl_t ipl;
259
    ipl_t ipl;
253
 
260
 
254
    ipl = interrupts_disable();
261
    ipl = interrupts_disable();
255
    spinlock_lock(&bkpoint_lock);
262
    spinlock_lock(&bkpoint_lock);
256
 
263
 
257
    cur = &breakpoints[slot];
264
    cur = &breakpoints[slot];
258
    if (!cur->address) {
265
    if (!cur->address) {
259
        spinlock_unlock(&bkpoint_lock);
266
        spinlock_unlock(&bkpoint_lock);
260
        interrupts_restore(ipl);
267
        interrupts_restore(ipl);
261
        return;
268
        return;
262
    }
269
    }
263
 
270
 
264
    cur->address = NULL;
271
    cur->address = NULL;
265
 
272
 
266
    setup_dr(slot);
273
    setup_dr(slot);
267
 
274
 
268
    spinlock_unlock(&bkpoint_lock);
275
    spinlock_unlock(&bkpoint_lock);
269
    interrupts_restore(ipl);
276
    interrupts_restore(ipl);
270
#ifdef CONFIG_SMP
277
#ifdef CONFIG_SMP
271
//  ipi_broadcast(VECTOR_DEBUG_IPI);    
278
//  ipi_broadcast(VECTOR_DEBUG_IPI);    
272
#endif
279
#endif
273
}
280
}
274
 
281
 
275
#ifndef CONFIG_DEBUG_AS_WATCHPOINT
282
#ifndef CONFIG_DEBUG_AS_WATCHPOINT
276
 
283
 
277
/** Remove breakpoint from table */
284
/** Remove breakpoint from table */
278
int cmd_del_breakpoint(cmd_arg_t *argv)
285
int cmd_del_breakpoint(cmd_arg_t *argv)
279
{
286
{
280
    if (argv->intval < 0 || argv->intval > BKPOINTS_MAX) {
287
    if (argv->intval < 0 || argv->intval > BKPOINTS_MAX) {
281
        printf("Invalid breakpoint number.\n");
288
        printf("Invalid breakpoint number.\n");
282
        return 0;
289
        return 0;
283
    }
290
    }
284
    breakpoint_del(argv->intval);
291
    breakpoint_del(argv->intval);
285
    return 1;
292
    return 1;
286
}
293
}
287
 
294
 
288
/** Add new breakpoint to table */
295
/** Add new breakpoint to table */
289
static int cmd_add_breakpoint(cmd_arg_t *argv)
296
static int cmd_add_breakpoint(cmd_arg_t *argv)
290
{
297
{
291
    int flags;
298
    int flags;
292
    int id;
299
    int id;
293
 
300
 
294
    if (argv == &add_argv) {
301
    if (argv == &add_argv) {
295
        flags = BKPOINT_INSTR;
302
        flags = BKPOINT_INSTR;
296
    } else { /* addwatchp */
303
    } else { /* addwatchp */
297
        flags = BKPOINT_WRITE;
304
        flags = BKPOINT_WRITE;
298
    }
305
    }
299
    printf("Adding breakpoint on address: %p\n", argv->intval);
306
    printf("Adding breakpoint on address: %p\n", argv->intval);
300
    id = breakpoint_add((void *)argv->intval, flags, -1);
307
    id = breakpoint_add((void *)argv->intval, flags, -1);
301
    if (id < 0)
308
    if (id < 0)
302
        printf("Add breakpoint failed.\n");
309
        printf("Add breakpoint failed.\n");
303
    else
310
    else
304
        printf("Added breakpoint %d.\n", id);
311
        printf("Added breakpoint %d.\n", id);
305
   
312
   
306
    return 1;
313
    return 1;
307
}
314
}
308
#endif
315
#endif
309
 
316
 
310
static void debug_exception(int n, istate_t *istate)
317
static void debug_exception(int n, istate_t *istate)
311
{
318
{
312
    __native dr6;
319
    __native dr6;
313
    int i;
320
    int i;
314
   
321
   
315
    /* Set RF to restart the instruction  */
322
    /* Set RF to restart the instruction  */
316
#ifdef amd64       
323
#ifdef amd64       
317
    istate->rflags |= RFLAGS_RF;
324
    istate->rflags |= RFLAGS_RF;
318
#else
325
#else
319
    istate->eflags |= EFLAGS_RF;
326
    istate->eflags |= EFLAGS_RF;
320
#endif
327
#endif
321
 
328
 
322
    dr6 = read_dr6();
329
    dr6 = read_dr6();
323
    for (i=0; i < BKPOINTS_MAX; i++) {
330
    for (i=0; i < BKPOINTS_MAX; i++) {
324
        if (dr6 & (1 << i)) {
331
        if (dr6 & (1 << i)) {
325
            dr6 &= ~ (1 << i);
332
            dr6 &= ~ (1 << i);
326
            write_dr6(dr6);
333
            write_dr6(dr6);
327
           
334
           
328
            handle_exception(i, istate);
335
            handle_exception(i, istate);
329
        }
336
        }
330
    }
337
    }
331
}
338
}
332
 
339
 
333
#ifdef CONFIG_SMP
340
#ifdef CONFIG_SMP
334
static void debug_ipi(int n, istate_t *istate)
341
static void debug_ipi(int n, istate_t *istate)
335
{
342
{
336
    int i;
343
    int i;
337
 
344
 
338
    spinlock_lock(&bkpoint_lock);
345
    spinlock_lock(&bkpoint_lock);
339
    for (i=0; i < BKPOINTS_MAX; i++)
346
    for (i=0; i < BKPOINTS_MAX; i++)
340
        setup_dr(i);
347
        setup_dr(i);
341
    spinlock_unlock(&bkpoint_lock);
348
    spinlock_unlock(&bkpoint_lock);
342
}
349
}
343
#endif
350
#endif
344
 
351
 
345
/** Initialize debugger */
352
/** Initialize debugger */
346
void debugger_init()
353
void debugger_init()
347
{
354
{
348
    int i;
355
    int i;
349
 
356
 
350
    for (i=0; i<BKPOINTS_MAX; i++)
357
    for (i=0; i<BKPOINTS_MAX; i++)
351
        breakpoints[i].address = NULL;
358
        breakpoints[i].address = NULL;
352
   
359
   
353
    cmd_initialize(&bkpts_info);
360
    cmd_initialize(&bkpts_info);
354
    if (!cmd_register(&bkpts_info))
361
    if (!cmd_register(&bkpts_info))
355
        panic("could not register command %s\n", bkpts_info.name);
362
        panic("could not register command %s\n", bkpts_info.name);
356
 
363
 
357
#ifndef CONFIG_DEBUG_AS_WATCHPOINT
364
#ifndef CONFIG_DEBUG_AS_WATCHPOINT
358
    cmd_initialize(&delbkpt_info);
365
    cmd_initialize(&delbkpt_info);
359
    if (!cmd_register(&delbkpt_info))
366
    if (!cmd_register(&delbkpt_info))
360
        panic("could not register command %s\n", delbkpt_info.name);
367
        panic("could not register command %s\n", delbkpt_info.name);
361
 
368
 
362
    cmd_initialize(&addbkpt_info);
369
    cmd_initialize(&addbkpt_info);
363
    if (!cmd_register(&addbkpt_info))
370
    if (!cmd_register(&addbkpt_info))
364
        panic("could not register command %s\n", addbkpt_info.name);
371
        panic("could not register command %s\n", addbkpt_info.name);
365
 
372
 
366
    cmd_initialize(&addwatchp_info);
373
    cmd_initialize(&addwatchp_info);
367
    if (!cmd_register(&addwatchp_info))
374
    if (!cmd_register(&addwatchp_info))
368
        panic("could not register command %s\n", addwatchp_info.name);
375
        panic("could not register command %s\n", addwatchp_info.name);
369
#endif
376
#endif
370
   
377
   
371
    exc_register(VECTOR_DEBUG, "debugger",
378
    exc_register(VECTOR_DEBUG, "debugger",
372
             debug_exception);
379
             debug_exception);
373
#ifdef CONFIG_SMP
380
#ifdef CONFIG_SMP
374
    exc_register(VECTOR_DEBUG_IPI, "debugger_smp",
381
    exc_register(VECTOR_DEBUG_IPI, "debugger_smp",
375
             debug_ipi);
382
             debug_ipi);
376
#endif
383
#endif
377
}
384
}
-
 
385
 
-
 
386
 /** @}
-
 
387
 */
-
 
388
 
378
 
389