Subversion Repositories HelenOS

Rev

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

Rev 3343 Rev 3742
Line 52... Line 52...
52
} bpinfo_t;
52
} bpinfo_t;
53
 
53
 
54
static bpinfo_t breakpoints[BKPOINTS_MAX];
54
static bpinfo_t breakpoints[BKPOINTS_MAX];
55
SPINLOCK_INITIALIZE(bkpoint_lock);
55
SPINLOCK_INITIALIZE(bkpoint_lock);
56
 
56
 
-
 
57
#ifdef CONFIG_KCONSOLE
-
 
58
 
57
static int cmd_print_breakpoints(cmd_arg_t *argv);
59
static int cmd_print_breakpoints(cmd_arg_t *argv);
58
static cmd_info_t bkpts_info = {
60
static cmd_info_t bkpts_info = {
59
    .name = "bkpts",
61
    .name = "bkpts",
60
    .description = "Print breakpoint table.",
62
    .description = "Print breakpoint table.",
61
    .func = cmd_print_breakpoints,
63
    .func = cmd_print_breakpoints,
Line 97... Line 99...
97
    .func = cmd_add_breakpoint,
99
    .func = cmd_add_breakpoint,
98
    .argc = 1,
100
    .argc = 1,
99
    .argv = &addw_argv
101
    .argv = &addw_argv
100
};
102
};
101
 
103
 
102
#endif
-
 
103
 
-
 
104
/** Print table of active breakpoints */
104
#endif /* CONFIG_DEBUG_AS_WATCHPOINT */
105
int cmd_print_breakpoints(cmd_arg_t *argv __attribute__((unused)))
-
 
106
{
-
 
107
    unsigned int i;
-
 
108
    char *symbol;
-
 
109
 
-
 
110
#ifdef __32_BITS__  
105
#endif /* CONFIG_KCONSOLE */
111
    printf("#  Count Address    In symbol\n");
-
 
112
    printf("-- ----- ---------- ---------\n");
-
 
113
#endif
-
 
114
 
-
 
115
#ifdef __64_BITS__
-
 
116
    printf("#  Count Address            In symbol\n");
-
 
117
    printf("-- ----- ------------------ ---------\n");
-
 
118
#endif
-
 
119
   
-
 
120
    for (i = 0; i < BKPOINTS_MAX; i++)
-
 
121
        if (breakpoints[i].address) {
-
 
122
            symbol = get_symtab_entry(breakpoints[i].address);
-
 
123
 
-
 
124
#ifdef __32_BITS__
-
 
125
            printf("%-2u %-5d %#10zx %s\n", i,
-
 
126
                breakpoints[i].counter, breakpoints[i].address,
-
 
127
                symbol);
-
 
128
#endif
-
 
129
 
-
 
130
#ifdef __64_BITS__
-
 
131
            printf("%-2u %-5d %#18zx %s\n", i,
-
 
132
                breakpoints[i].counter, breakpoints[i].address,
-
 
133
                symbol);
-
 
134
#endif
-
 
135
 
-
 
136
        }
-
 
137
    return 1;
-
 
138
}
-
 
139
 
106
 
140
/* Setup DR register according to table */
107
/* Setup DR register according to table */
141
static void setup_dr(int curidx)
108
static void setup_dr(int curidx)
142
{
109
{
143
    unative_t dr7;
110
    unative_t dr7;
Line 265... Line 232...
265
                *((unative_t *) breakpoints[slot].address));
232
                *((unative_t *) breakpoints[slot].address));
266
        }
233
        }
267
    }
234
    }
268
    printf("Reached breakpoint %d:%lx(%s)\n", slot, getip(istate),
235
    printf("Reached breakpoint %d:%lx(%s)\n", slot, getip(istate),
269
        get_symtab_entry(getip(istate)));
236
        get_symtab_entry(getip(istate)));
-
 
237
 
270
    printf("***Type 'exit' to exit kconsole.\n");
238
#ifdef CONFIG_KCONSOLE
271
    atomic_set(&haltstate,1);
239
    atomic_set(&haltstate, 1);
272
    kconsole((void *) "debug");
240
    kconsole("debug", "Debug console ready (type 'exit' to continue)\n", false);
273
    atomic_set(&haltstate,0);
241
    atomic_set(&haltstate, 0);
-
 
242
#endif
274
}
243
}
275
 
244
 
276
void breakpoint_del(int slot)
245
void breakpoint_del(int slot)
277
{
246
{
278
    bpinfo_t *cur;
247
    bpinfo_t *cur;
Line 297... Line 266...
297
#ifdef CONFIG_SMP
266
#ifdef CONFIG_SMP
298
//  ipi_broadcast(VECTOR_DEBUG_IPI);    
267
//  ipi_broadcast(VECTOR_DEBUG_IPI);    
299
#endif
268
#endif
300
}
269
}
301
 
270
 
302
#ifndef CONFIG_DEBUG_AS_WATCHPOINT
-
 
303
 
271
 
304
/** Remove breakpoint from table */
-
 
305
int cmd_del_breakpoint(cmd_arg_t *argv)
-
 
306
{
-
 
307
    unative_t bpno = argv->intval;
-
 
308
    if (bpno > BKPOINTS_MAX) {
-
 
309
        printf("Invalid breakpoint number.\n");
-
 
310
        return 0;
-
 
311
    }
-
 
312
    breakpoint_del(argv->intval);
-
 
313
    return 1;
-
 
314
}
-
 
315
 
-
 
316
/** Add new breakpoint to table */
-
 
317
static int cmd_add_breakpoint(cmd_arg_t *argv)
-
 
318
{
-
 
319
    int flags;
-
 
320
    int id;
-
 
321
 
-
 
322
    if (argv == &add_argv) {
-
 
323
        flags = BKPOINT_INSTR;
-
 
324
    } else { /* addwatchp */
-
 
325
        flags = BKPOINT_WRITE;
-
 
326
    }
-
 
327
    printf("Adding breakpoint on address: %p\n", argv->intval);
-
 
328
    id = breakpoint_add((void *)argv->intval, flags, -1);
-
 
329
    if (id < 0)
-
 
330
        printf("Add breakpoint failed.\n");
-
 
331
    else
-
 
332
        printf("Added breakpoint %d.\n", id);
-
 
333
   
-
 
334
    return 1;
-
 
335
}
-
 
336
#endif
-
 
337
 
272
 
338
static void debug_exception(int n __attribute__((unused)), istate_t *istate)
273
static void debug_exception(int n __attribute__((unused)), istate_t *istate)
339
{
274
{
340
    unative_t dr6;
275
    unative_t dr6;
341
    int i;
276
    int i;
Line 377... Line 312...
377
{
312
{
378
    int i;
313
    int i;
379
 
314
 
380
    for (i = 0; i < BKPOINTS_MAX; i++)
315
    for (i = 0; i < BKPOINTS_MAX; i++)
381
        breakpoints[i].address = NULL;
316
        breakpoints[i].address = NULL;
382
   
317
 
-
 
318
#ifdef CONFIG_KCONSOLE
383
    cmd_initialize(&bkpts_info);
319
    cmd_initialize(&bkpts_info);
384
    if (!cmd_register(&bkpts_info))
320
    if (!cmd_register(&bkpts_info))
385
        panic("could not register command %s\n", bkpts_info.name);
321
        printf("Cannot register command %s\n", bkpts_info.name);
386
 
322
 
387
#ifndef CONFIG_DEBUG_AS_WATCHPOINT
323
#ifndef CONFIG_DEBUG_AS_WATCHPOINT
388
    cmd_initialize(&delbkpt_info);
324
    cmd_initialize(&delbkpt_info);
389
    if (!cmd_register(&delbkpt_info))
325
    if (!cmd_register(&delbkpt_info))
390
        panic("could not register command %s\n", delbkpt_info.name);
326
        printf("Cannot register command %s\n", delbkpt_info.name);
391
 
327
 
392
    cmd_initialize(&addbkpt_info);
328
    cmd_initialize(&addbkpt_info);
393
    if (!cmd_register(&addbkpt_info))
329
    if (!cmd_register(&addbkpt_info))
394
        panic("could not register command %s\n", addbkpt_info.name);
330
        printf("Cannot register command %s\n", addbkpt_info.name);
395
 
331
 
396
    cmd_initialize(&addwatchp_info);
332
    cmd_initialize(&addwatchp_info);
397
    if (!cmd_register(&addwatchp_info))
333
    if (!cmd_register(&addwatchp_info))
398
        panic("could not register command %s\n", addwatchp_info.name);
334
        printf("Cannot register command %s\n", addwatchp_info.name);
-
 
335
#endif /* CONFIG_DEBUG_AS_WATCHPOINT */
399
#endif
336
#endif /* CONFIG_KCONSOLE */
400
   
337
   
401
    exc_register(VECTOR_DEBUG, "debugger", debug_exception);
338
    exc_register(VECTOR_DEBUG, "debugger", debug_exception);
402
#ifdef CONFIG_SMP
339
#ifdef CONFIG_SMP
403
    exc_register(VECTOR_DEBUG_IPI, "debugger_smp", debug_ipi);
340
    exc_register(VECTOR_DEBUG_IPI, "debugger_smp", debug_ipi);
404
#endif
341
#endif
405
}
342
}
406
 
343
 
-
 
344
#ifdef CONFIG_KCONSOLE
-
 
345
/** Print table of active breakpoints */
-
 
346
int cmd_print_breakpoints(cmd_arg_t *argv __attribute__((unused)))
-
 
347
{
-
 
348
    unsigned int i;
-
 
349
    char *symbol;
-
 
350
 
-
 
351
#ifdef __32_BITS__  
-
 
352
    printf("#  Count Address    In symbol\n");
-
 
353
    printf("-- ----- ---------- ---------\n");
-
 
354
#endif
-
 
355
 
-
 
356
#ifdef __64_BITS__
-
 
357
    printf("#  Count Address            In symbol\n");
-
 
358
    printf("-- ----- ------------------ ---------\n");
-
 
359
#endif
-
 
360
   
-
 
361
    for (i = 0; i < BKPOINTS_MAX; i++)
-
 
362
        if (breakpoints[i].address) {
-
 
363
            symbol = get_symtab_entry(breakpoints[i].address);
-
 
364
 
-
 
365
#ifdef __32_BITS__
-
 
366
            printf("%-2u %-5d %#10zx %s\n", i,
-
 
367
                breakpoints[i].counter, breakpoints[i].address,
-
 
368
                symbol);
-
 
369
#endif
-
 
370
 
-
 
371
#ifdef __64_BITS__
-
 
372
            printf("%-2u %-5d %#18zx %s\n", i,
-
 
373
                breakpoints[i].counter, breakpoints[i].address,
-
 
374
                symbol);
-
 
375
#endif
-
 
376
 
-
 
377
        }
-
 
378
    return 1;
-
 
379
}
-
 
380
 
-
 
381
#ifndef CONFIG_DEBUG_AS_WATCHPOINT
-
 
382
 
-
 
383
/** Remove breakpoint from table */
-
 
384
int cmd_del_breakpoint(cmd_arg_t *argv)
-
 
385
{
-
 
386
    unative_t bpno = argv->intval;
-
 
387
    if (bpno > BKPOINTS_MAX) {
-
 
388
        printf("Invalid breakpoint number.\n");
-
 
389
        return 0;
-
 
390
    }
-
 
391
    breakpoint_del(argv->intval);
-
 
392
    return 1;
-
 
393
}
-
 
394
 
-
 
395
/** Add new breakpoint to table */
-
 
396
static int cmd_add_breakpoint(cmd_arg_t *argv)
-
 
397
{
-
 
398
    int flags;
-
 
399
    int id;
-
 
400
 
-
 
401
    if (argv == &add_argv) {
-
 
402
        flags = BKPOINT_INSTR;
-
 
403
    } else { /* addwatchp */
-
 
404
        flags = BKPOINT_WRITE;
-
 
405
    }
-
 
406
    printf("Adding breakpoint on address: %p\n", argv->intval);
-
 
407
    id = breakpoint_add((void *)argv->intval, flags, -1);
-
 
408
    if (id < 0)
-
 
409
        printf("Add breakpoint failed.\n");
-
 
410
    else
-
 
411
        printf("Added breakpoint %d.\n", id);
-
 
412
   
-
 
413
    return 1;
-
 
414
}
-
 
415
#endif /* CONFIG_DEBUG_AS_WATCHPOINT */
-
 
416
#endif /* CONFIG_KCONSOLE */
-
 
417
 
407
/** @}
418
/** @}
408
 */
419
 */