Subversion Repositories HelenOS

Rev

Rev 2100 | Rev 2767 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2100 Rev 2441
Line 100... Line 100...
100
};
100
};
101
 
101
 
102
#endif
102
#endif
103
 
103
 
104
/** Print table of active breakpoints */
104
/** Print table of active breakpoints */
105
int cmd_print_breakpoints(cmd_arg_t *argv)
105
int cmd_print_breakpoints(cmd_arg_t *argv __attribute__((unused)))
106
{
106
{
107
    int i;
107
    int i;
108
    char *symbol;
108
    char *symbol;
109
 
109
 
110
    printf("Breakpoint table.\n");
110
    printf("Breakpoint table.\n");
111
    for (i=0; i < BKPOINTS_MAX; i++)
111
    for (i=0; i < BKPOINTS_MAX; i++)
112
        if (breakpoints[i].address) {
112
        if (breakpoints[i].address) {
113
            symbol = get_symtab_entry(breakpoints[i].address);
113
            symbol = get_symtab_entry(breakpoints[i].address);
114
            printf("%d. %p in %s\n",i,
114
            printf("%d. %lx in %s\n", i,
115
                   breakpoints[i].address, symbol);
115
                   breakpoints[i].address, symbol);
116
            printf("     Count(%d) ", breakpoints[i].counter);
116
            printf("     Count(%d) ", breakpoints[i].counter);
117
            printf("\n");
117
            printf("\n");
118
        }
118
        }
119
    return 1;
119
    return 1;
Line 171... Line 171...
171
    }
171
    }
172
}
172
}
173
   
173
   
174
/** Enable hardware breakpoint
174
/** Enable hardware breakpoint
175
 *
175
 *
176
 *
-
 
177
 * @param where Address of HW breakpoint
176
 * @param where Address of HW breakpoint
178
 * @param flags Type of breakpoint (EXECUTE, WRITE)
177
 * @param flags Type of breakpoint (EXECUTE, WRITE)
179
 * @return Debug slot on success, -1 - no available HW breakpoint
178
 * @return Debug slot on success, -1 - no available HW breakpoint
180
 */
179
 */
181
int breakpoint_add(void * where, int flags, int curidx)
180
int breakpoint_add(const void *where, const int flags, int curidx)
182
{
181
{
183
    ipl_t ipl;
182
    ipl_t ipl;
184
    int i;
183
    int i;
185
    bpinfo_t *cur;
184
    bpinfo_t *cur;
186
 
185
 
187
    ASSERT( flags & (BKPOINT_INSTR | BKPOINT_WRITE | BKPOINT_READ_WRITE));
186
    ASSERT(flags & (BKPOINT_INSTR | BKPOINT_WRITE | BKPOINT_READ_WRITE));
188
 
187
 
189
    ipl = interrupts_disable();
188
    ipl = interrupts_disable();
190
    spinlock_lock(&bkpoint_lock);
189
    spinlock_lock(&bkpoint_lock);
191
   
190
   
192
    if (curidx == -1) {
191
    if (curidx == -1) {
193
        /* Find free space in slots */
192
        /* Find free space in slots */
194
        for (i=0; i<BKPOINTS_MAX; i++)
193
        for (i = 0; i < BKPOINTS_MAX; i++)
195
            if (!breakpoints[i].address) {
194
            if (!breakpoints[i].address) {
196
                curidx = i;
195
                curidx = i;
197
                break;
196
                break;
198
            }
197
            }
199
        if (curidx == -1) {
198
        if (curidx == -1) {
Line 221... Line 220...
221
 
220
 
222
    return curidx;
221
    return curidx;
223
}
222
}
224
 
223
 
225
#ifdef amd64
224
#ifdef amd64
226
# define getip(x)  ((x)->rip)
225
#   define getip(x) ((x)->rip)
227
#else
226
#else
228
# define getip(x)  ((x)->eip)
227
#   define getip(x) ((x)->eip)
229
#endif
228
#endif
230
 
229
 
231
static void handle_exception(int slot, istate_t *istate)
230
static void handle_exception(int slot, istate_t *istate)
232
{
231
{
233
    ASSERT(breakpoints[slot].address);
232
    ASSERT(breakpoints[slot].address);
Line 235... Line 234...
235
    /* Handle zero checker */
234
    /* Handle zero checker */
236
    if (! (breakpoints[slot].flags & BKPOINT_INSTR)) {
235
    if (! (breakpoints[slot].flags & BKPOINT_INSTR)) {
237
        if ((breakpoints[slot].flags & BKPOINT_CHECK_ZERO)) {
236
        if ((breakpoints[slot].flags & BKPOINT_CHECK_ZERO)) {
238
            if (*((unative_t *) breakpoints[slot].address) != 0)
237
            if (*((unative_t *) breakpoints[slot].address) != 0)
239
                return;
238
                return;
240
            printf("**** Found ZERO on address %p ****\n",
239
            printf("**** Found ZERO on address %lx (slot %d) ****\n",
241
                   slot, breakpoints[slot].address);
240
                breakpoints[slot].address, slot);
242
        } else {
241
        } else {
243
            printf("Data watchpoint - new data: %p\n",
242
            printf("Data watchpoint - new data: %lx\n",
244
                   *((unative_t *) breakpoints[slot].address));
243
                   *((unative_t *) breakpoints[slot].address));
245
        }
244
        }
246
    }
245
    }
247
    printf("Reached breakpoint %d:%p(%s)\n", slot, getip(istate),
246
    printf("Reached breakpoint %d:%lx(%s)\n", slot, getip(istate),
248
           get_symtab_entry(getip(istate)));
247
           get_symtab_entry(getip(istate)));
249
    printf("***Type 'exit' to exit kconsole.\n");
248
    printf("***Type 'exit' to exit kconsole.\n");
250
    atomic_set(&haltstate,1);
249
    atomic_set(&haltstate,1);
251
    kconsole((void *) "debug");
250
    kconsole((void *) "debug");
252
    atomic_set(&haltstate,0);
251
    atomic_set(&haltstate,0);
Line 311... Line 310...
311
   
310
   
312
    return 1;
311
    return 1;
313
}
312
}
314
#endif
313
#endif
315
 
314
 
316
static void debug_exception(int n, istate_t *istate)
315
static void debug_exception(int n __attribute__((unused)), istate_t *istate)
317
{
316
{
318
    unative_t dr6;
317
    unative_t dr6;
319
    int i;
318
    int i;
320
   
319
   
321
    /* Set RF to restart the instruction  */
320
    /* Set RF to restart the instruction  */
Line 335... Line 334...
335
        }
334
        }
336
    }
335
    }
337
}
336
}
338
 
337
 
339
#ifdef CONFIG_SMP
338
#ifdef CONFIG_SMP
340
static void debug_ipi(int n, istate_t *istate)
339
static void debug_ipi(int n __attribute__((unused)), istate_t *istate __attribute__((unused)))
341
{
340
{
342
    int i;
341
    int i;
343
 
342
 
344
    spinlock_lock(&bkpoint_lock);
343
    spinlock_lock(&bkpoint_lock);
345
    for (i=0; i < BKPOINTS_MAX; i++)
344
    for (i = 0; i < BKPOINTS_MAX; i++)
346
        setup_dr(i);
345
        setup_dr(i);
347
    spinlock_unlock(&bkpoint_lock);
346
    spinlock_unlock(&bkpoint_lock);
348
}
347
}
349
#endif
348
#endif
350
 
349