Subversion Repositories HelenOS

Rev

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

Rev 2942 Rev 2943
Line 43... Line 43...
43
#include "../../../main.h"
43
#include "../../../main.h"
44
#include "../../../include/arch.h"
44
#include "../../../include/arch.h"
45
 
45
 
46
#define OPCODE_INT3     0xCC
46
#define OPCODE_INT3     0xCC
47
 
47
 
-
 
48
static breakpoint_t *lifted_brkpt;
-
 
49
 
48
void arch_breakpoint_add(uintptr_t addr)
50
void arch_breakpoint_add(uintptr_t addr)
49
{
51
{
50
    char brkp[1];
52
    char brkp[1];
51
    int rc;
53
    int rc;
52
    breakpoint_t *brk;
54
    breakpoint_t *brk;
53
    int i;
55
    int i;
54
 
56
 
55
    brk = NULL;
57
    brk = NULL;
56
    for (i = 0; i < MAX_BRKPTS; i++)
58
    for (i = 1; i < MAX_BRKPTS; i++)
57
        if (brk_list[i].set == 0) { brk = brk_list+i; break; }
59
        if (brk_list[i].set == 0) { brk = brk_list+i; break; }
58
 
60
 
59
    if (!brk) {
61
    if (!brk) {
60
        cons_printf("too many breakpoints\n");
62
        cons_printf("too many breakpoints\n");
61
        return;
63
        return;
Line 67... Line 69...
67
    rc = udebug_mem_write(app_phone, brkp, addr, 1);
69
    rc = udebug_mem_write(app_phone, brkp, addr, 1);
68
    cons_printf("udebug_mem_write() -> %d\n", rc);
70
    cons_printf("udebug_mem_write() -> %d\n", rc);
69
 
71
 
70
    brk->addr = addr;
72
    brk->addr = addr;
71
    brk->set = 1;
73
    brk->set = 1;
-
 
74
 
-
 
75
    cons_printf("Added breakpoint %d\n", i);
72
}
76
}
73
 
77
 
-
 
78
void arch_breakpoint_remove(int id)
-
 
79
{
-
 
80
    int rc;
-
 
81
 
-
 
82
    if (id < 1 || id >= MAX_BRKPTS || brk_list[id].set == 0) {
-
 
83
        cons_printf("No such breakpoint\n");
-
 
84
        return;
-
 
85
    }
-
 
86
 
-
 
87
    if (lifted_brkpt == &brk_list[id]) {
-
 
88
        lifted_brkpt = NULL;
-
 
89
    } else {
-
 
90
            rc = udebug_mem_write(app_phone, &brk_list[id].arch.back, brk_list[id].addr, 1);
-
 
91
        if (rc < 0) { printf("error writing mem\n"); return; }     
-
 
92
    }
-
 
93
 
-
 
94
    brk_list[id].set = 0;
-
 
95
 
-
 
96
    cons_printf("Breakpoint removed\n");
-
 
97
}
-
 
98
 
74
static breakpoint_t *lifted_brkpt;
99
void arch_breakpoint_list(void)
-
 
100
{
-
 
101
    int i;
-
 
102
 
-
 
103
    for (i = 0; i < MAX_BRKPTS; ++i) {
-
 
104
        if (brk_list[i].set != 0) {
-
 
105
            printf("Breakpoint %d at 0x%lx\n", i, brk_list[i].addr);
-
 
106
        }
-
 
107
    }
-
 
108
}
75
 
109
 
76
void arch_event_breakpoint(thash_t thread_hash)
110
void arch_event_breakpoint(thash_t thread_hash)
77
{
111
{
78
    static istate_t istate;
112
    static istate_t istate;
79
    int rc;
113
    int rc;
Line 159... Line 193...
159
 
193
 
160
    rc = udebug_regs_read(app_phone, dt->hash, &istate);
194
    rc = udebug_regs_read(app_phone, dt->hash, &istate);
161
    if (rc < 0) { printf("regs read failed\n"); return; }
195
    if (rc < 0) { printf("regs read failed\n"); return; }
162
 
196
 
163
    if (enable) istate.eflags |= 0x0100; /* trap flag */
197
    if (enable) istate.eflags |= 0x0100; /* trap flag */
164
    else istate.eflags &= ~0x0100; /* trap flag */
198
    else if (!lifted_brkpt) istate.eflags &= ~0x0100; /* trap flag */
165
 
199
 
166
    rc = udebug_regs_write(app_phone, dt->hash, &istate);  
200
    rc = udebug_regs_write(app_phone, dt->hash, &istate);  
167
    if (rc < 0) { printf("regs write failed\n"); return; }
201
    if (rc < 0) { printf("regs write failed\n"); return; }
168
 
202
 
169
    dt->arch.singlestep = enable;
203
    dt->arch.singlestep = enable;