Changeset 1e1e5e1 in mainline


Ignore:
Timestamp:
2008-06-14T12:15:27Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b22304b
Parents:
d7c9fcb
Message:

Maintain cache coherence when setting breakpoints in kconsole on mips32.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/mips32/src/debugger.c

    rd7c9fcb r1e1e5e1  
    3434
    3535#include <arch/debugger.h>
     36#include <arch/barrier.h>
    3637#include <memstr.h>
    3738#include <console/kconsole.h>
     
    7374static cmd_info_t addbkpt_info = {
    7475        .name = "addbkpt",
    75         .description = "addbkpt <&symbol> - new bkpoint. Break on J/Branch insts unsupported.",
     76        .description = "addbkpt <&symbol> - new bkpoint. Break on J/Branch "
     77            "insts unsupported.",
    7678        .func = cmd_add_breakpoint,
    7779        .argc = 1,
     
    8587static cmd_info_t addbkpte_info = {
    8688        .name = "addbkpte",
    87         .description = "addebkpte <&symbol> <&func> - new bkpoint. Call func(or Nothing if 0).",
     89        .description = "addebkpte <&symbol> <&func> - new bkpoint. Call "
     90            "func(or Nothing if 0).",
    8891        .func = cmd_add_breakpoint,
    8992        .argc = 2,
     
    9497        uint32_t andmask;
    9598        uint32_t value;
    96 }jmpinstr[] = {
     99} jmpinstr[] = {
    97100        {0xf3ff0000, 0x41000000}, /* BCzF */
    98101        {0xf3ff0000, 0x41020000}, /* BCzFL */
     
    118121        {0xfc000000, 0x0c000000}, /* JAL */
    119122        {0xfc1f07ff, 0x00000009}, /* JALR */
    120         {0,0} /* EndOfTable */
     123        {0, 0} /* EndOfTable */
    121124};
    122125
     
    130133        int i;
    131134
    132         for (i=0;jmpinstr[i].andmask;i++) {
     135        for (i = 0; jmpinstr[i].andmask; i++) {
    133136                if ((instr & jmpinstr[i].andmask) == jmpinstr[i].value)
    134137                        return true;
     
    158161                        spinlock_unlock(&bkpoints_lock);
    159162                        return 0;
    160                 } else if (breakpoints[i].address == (uintptr_t)argv->intval + sizeof(unative_t) || \
    161                            breakpoints[i].address == (uintptr_t)argv->intval - sizeof(unative_t)) {
    162                         printf("Adjacent breakpoints not supported, conflict with %d.\n", i);
     163                } else if (breakpoints[i].address == (uintptr_t)argv->intval +
     164                    sizeof(unative_t) || breakpoints[i].address ==
     165                    (uintptr_t)argv->intval - sizeof(unative_t)) {
     166                        printf("Adjacent breakpoints not supported, conflict "
     167                            "with %d.\n", i);
    163168                        spinlock_unlock(&bkpoints_lock);
    164169                        return 0;
     
    167172        }
    168173
    169         for (i=0; i<BKPOINTS_MAX; i++)
     174        for (i = 0; i < BKPOINTS_MAX; i++)
    170175                if (!breakpoints[i].address) {
    171176                        cur = &breakpoints[i];
     
    186191        } else { /* We are add extended */
    187192                cur->flags = BKPOINT_FUNCCALL;
    188                 cur->bkfunc =   (void (*)(void *, istate_t *)) argv[1].intval;
     193                cur->bkfunc = (void (*)(void *, istate_t *)) argv[1].intval;
    189194        }
    190195        if (is_jump(cur->instruction))
     
    194199        /* Set breakpoint */
    195200        *((unative_t *)cur->address) = 0x0d;
     201        smc_coherence(cur->address);
    196202
    197203        spinlock_unlock(&bkpoint_lock);
     
    200206        return 1;
    201207}
    202 
    203 
    204208
    205209/** Remove breakpoint from table */
     
    230234        }
    231235        ((uint32_t *)cur->address)[0] = cur->instruction;
     236        smc_coherence(((uint32_t *)cur->address)[0]);
    232237        ((uint32_t *)cur->address)[1] = cur->nextinstruction;
     238        smc_coherence(((uint32_t *)cur->address)[1]);
    233239
    234240        cur->address = NULL;
     
    253259                       
    254260                        printf("%-2u %-5d %#10zx %-6s %-7s %-8s %s\n", i,
    255                                 breakpoints[i].counter, breakpoints[i].address,
    256                                 ((breakpoints[i].flags & BKPOINT_INPROG) ? "true" : "false"),
    257                                 ((breakpoints[i].flags & BKPOINT_ONESHOT) ? "true" : "false"),
    258                                 ((breakpoints[i].flags & BKPOINT_FUNCCALL) ? "true" : "false"),
    259                                 symbol);
     261                            breakpoints[i].counter, breakpoints[i].address,
     262                            ((breakpoints[i].flags & BKPOINT_INPROG) ? "true" :
     263                            "false"), ((breakpoints[i].flags & BKPOINT_ONESHOT)
     264                            ? "true" : "false"), ((breakpoints[i].flags &
     265                            BKPOINT_FUNCCALL) ? "true" : "false"), symbol);
    260266                }
    261267        return 1;
     
    267273        int i;
    268274
    269         for (i=0; i<BKPOINTS_MAX; i++)
     275        for (i = 0; i < BKPOINTS_MAX; i++)
    270276                breakpoints[i].address = NULL;
    271277       
     
    306312
    307313        spinlock_lock(&bkpoint_lock);
    308         for (i=0; i<BKPOINTS_MAX; i++) {
     314        for (i = 0; i < BKPOINTS_MAX; i++) {
    309315                /* Normal breakpoint */
    310                 if (fireaddr == breakpoints[i].address \
    311                     && !(breakpoints[i].flags & BKPOINT_REINST)) {
     316                if (fireaddr == breakpoints[i].address &&
     317                    !(breakpoints[i].flags & BKPOINT_REINST)) {
    312318                        cur = &breakpoints[i];
    313319                        break;
    314320                }
    315321                /* Reinst only breakpoint */
    316                 if ((breakpoints[i].flags & BKPOINT_REINST) \
    317                     && (fireaddr == breakpoints[i].address + sizeof(unative_t))) {
     322                if ((breakpoints[i].flags & BKPOINT_REINST) &&
     323                    (fireaddr == breakpoints[i].address + sizeof(unative_t))) {
    318324                        cur = &breakpoints[i];
    319325                        break;
     
    324330                        /* Set breakpoint on first instruction */
    325331                        ((uint32_t *)cur->address)[0] = 0x0d;
     332                        smc_coherence(((uint32_t *)cur->address)[0]);
    326333                        /* Return back the second */
    327334                        ((uint32_t *)cur->address)[1] = cur->nextinstruction;
     335                        smc_coherence(((uint32_t *)cur->address)[1]);
    328336                        cur->flags &= ~BKPOINT_REINST;
    329337                        spinlock_unlock(&bkpoint_lock);
     
    334342               
    335343                if (!(cur->flags & BKPOINT_FUNCCALL))
    336                         printf("***Breakpoint %d: %p in %s.\n", i,
    337                                fireaddr, get_symtab_entry(istate->epc));
     344                        printf("***Breakpoint %d: %p in %s.\n", i, fireaddr,
     345                            get_symtab_entry(istate->epc));
    338346
    339347                /* Return first instruction back */
    340348                ((uint32_t *)cur->address)[0] = cur->instruction;
     349                smc_coherence(cur->address);
    341350
    342351                if (! (cur->flags & BKPOINT_ONESHOT)) {
Note: See TracChangeset for help on using the changeset viewer.