Subversion Repositories HelenOS

Rev

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

Rev 3139 Rev 3707
Line 45... Line 45...
45
#include <func.h>
45
#include <func.h>
46
 
46
 
47
bpinfo_t breakpoints[BKPOINTS_MAX];
47
bpinfo_t breakpoints[BKPOINTS_MAX];
48
SPINLOCK_INITIALIZE(bkpoint_lock);
48
SPINLOCK_INITIALIZE(bkpoint_lock);
49
 
49
 
-
 
50
#ifdef CONFIG_KCONSOLE
-
 
51
 
50
static int cmd_print_breakpoints(cmd_arg_t *argv);
52
static int cmd_print_breakpoints(cmd_arg_t *argv);
51
static cmd_info_t bkpts_info = {
53
static cmd_info_t bkpts_info = {
52
    .name = "bkpts",
54
    .name = "bkpts",
53
    .description = "Print breakpoint table.",
55
    .description = "Print breakpoint table.",
54
    .func = cmd_print_breakpoints,
56
    .func = cmd_print_breakpoints,
Line 121... Line 123...
121
    {0xfc000000, 0x0c000000}, /* JAL */
123
    {0xfc000000, 0x0c000000}, /* JAL */
122
    {0xfc1f07ff, 0x00000009}, /* JALR */
124
    {0xfc1f07ff, 0x00000009}, /* JALR */
123
    {0, 0} /* EndOfTable */
125
    {0, 0} /* EndOfTable */
124
};
126
};
125
 
127
 
-
 
128
 
126
/** Test, if the given instruction is a jump or branch instruction
129
/** Test, if the given instruction is a jump or branch instruction
127
 *
130
 *
128
 * @param instr Instruction code
131
 * @param instr Instruction code
129
 * @return true - it is jump instruction, false otherwise
132
 * @return true - it is jump instruction, false otherwise
-
 
133
 *
130
 */
134
 */
131
static bool is_jump(unative_t instr)
135
static bool is_jump(unative_t instr)
132
{
136
{
133
    int i;
137
    int i;
134
 
138
 
Line 265... Line 269...
265
                BKPOINT_FUNCCALL) ? "true" : "false"), symbol);
269
                BKPOINT_FUNCCALL) ? "true" : "false"), symbol);
266
        }
270
        }
267
    return 1;
271
    return 1;
268
}
272
}
269
 
273
 
-
 
274
#endif
-
 
275
 
270
/** Initialize debugger */
276
/** Initialize debugger */
271
void debugger_init()
277
void debugger_init()
272
{
278
{
273
    int i;
279
    int i;
274
 
280
 
275
    for (i = 0; i < BKPOINTS_MAX; i++)
281
    for (i = 0; i < BKPOINTS_MAX; i++)
276
        breakpoints[i].address = NULL;
282
        breakpoints[i].address = NULL;
277
   
283
 
-
 
284
#ifdef CONFIG_KCONSOLE
278
    cmd_initialize(&bkpts_info);
285
    cmd_initialize(&bkpts_info);
279
    if (!cmd_register(&bkpts_info))
286
    if (!cmd_register(&bkpts_info))
280
        panic("could not register command %s\n", bkpts_info.name);
287
        printf("Cannot register command %s\n", bkpts_info.name);
281
 
288
 
282
    cmd_initialize(&delbkpt_info);
289
    cmd_initialize(&delbkpt_info);
283
    if (!cmd_register(&delbkpt_info))
290
    if (!cmd_register(&delbkpt_info))
284
        panic("could not register command %s\n", delbkpt_info.name);
291
        printf("Cannot register command %s\n", delbkpt_info.name);
285
 
292
 
286
    cmd_initialize(&addbkpt_info);
293
    cmd_initialize(&addbkpt_info);
287
    if (!cmd_register(&addbkpt_info))
294
    if (!cmd_register(&addbkpt_info))
288
        panic("could not register command %s\n", addbkpt_info.name);
295
        printf("Cannot register command %s\n", addbkpt_info.name);
289
 
296
 
290
    cmd_initialize(&addbkpte_info);
297
    cmd_initialize(&addbkpte_info);
291
    if (!cmd_register(&addbkpte_info))
298
    if (!cmd_register(&addbkpte_info))
292
        panic("could not register command %s\n", addbkpte_info.name);
299
        printf("Cannot register command %s\n", addbkpte_info.name);
-
 
300
#endif
293
}
301
}
294
 
302
 
295
/** Handle breakpoint
303
/** Handle breakpoint
296
 *
304
 *
297
 * Find breakpoint in breakpoint table.
305
 * Find breakpoint in breakpoint table.
Line 365... Line 373...
365
    if (cur && (cur->flags & BKPOINT_FUNCCALL)) {
373
    if (cur && (cur->flags & BKPOINT_FUNCCALL)) {
366
        /* Allow zero bkfunc, just for counting */
374
        /* Allow zero bkfunc, just for counting */
367
        if (cur->bkfunc)
375
        if (cur->bkfunc)
368
            cur->bkfunc(cur, istate);
376
            cur->bkfunc(cur, istate);
369
    } else {
377
    } else {
370
        printf("***Type 'exit' to exit kconsole.\n");
378
#ifdef CONFIG_KCONSOLE
371
        /* This disables all other processors - we are not SMP,
379
        /* This disables all other processors - we are not SMP,
372
         * actually this gets us to cpu_halt, if scheduler() is run
380
         * actually this gets us to cpu_halt, if scheduler() is run
373
         * - we generally do not want scheduler to be run from debug,
381
         * - we generally do not want scheduler to be run from debug,
374
         *   so this is a good idea
382
         *   so this is a good idea
375
         */
383
         */
376
        atomic_set(&haltstate,1);
384
        atomic_set(&haltstate, 1);
377
        spinlock_unlock(&bkpoint_lock);
385
        spinlock_unlock(&bkpoint_lock);
378
 
386
       
379
        kconsole("debug");
387
        kconsole("debug", "Debug console ready (type 'exit' to continue)\n", false);
380
 
388
       
381
        spinlock_lock(&bkpoint_lock);
389
        spinlock_lock(&bkpoint_lock);
382
        atomic_set(&haltstate,0);
390
        atomic_set(&haltstate, 0);
-
 
391
#endif
383
    }
392
    }
384
    if (cur && cur->address == fireaddr && (cur->flags & BKPOINT_INPROG)) {
393
    if (cur && cur->address == fireaddr && (cur->flags & BKPOINT_INPROG)) {
385
        /* Remove one-shot breakpoint */
394
        /* Remove one-shot breakpoint */
386
        if ((cur->flags & BKPOINT_ONESHOT))
395
        if ((cur->flags & BKPOINT_ONESHOT))
387
            cur->address = NULL;
396
            cur->address = NULL;