Subversion Repositories Kolibri OS

Rev

Rev 8876 | Rev 9715 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8876 Rev 9709
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
Line 8... Line 8...
8
$Revision: 8876 $
8
$Revision: 9709 $
9
 
9
 
10
 
10
 
Line 44... Line 44...
44
        cli
44
        cli
45
        mov     eax, ecx
45
        mov     eax, ecx
46
        call    pid_to_slot
46
        call    pid_to_slot
47
        test    eax, eax
47
        test    eax, eax
48
        jz      .ret_bad
48
        jz      .ret_bad
49
        shl     eax, 5
49
        shl     eax, BSF sizeof.APPDATA
50
        push    ebx
50
        push    ebx
51
        mov     ebx, [current_slot_idx]
51
        mov     ebx, [current_slot_idx]
52
        cmp     [SLOT_BASE+eax*8+APPDATA.debugger_slot], ebx
52
        cmp     [SLOT_BASE+eax+APPDATA.debugger_slot], ebx
53
        pop     ebx
53
        pop     ebx
54
        jnz     .ret_bad
54
        jnz     .ret_bad
55
;       clc     ; automatically
55
;       clc     ; automatically
56
        ret
56
        ret
57
.ret_bad:
57
.ret_bad:
Line 61... Line 61...
61
debug_detach:
61
debug_detach:
62
; in: ecx=pid
62
; in: ecx=pid
63
; destroys eax,ebx
63
; destroys eax,ebx
64
        call    get_debuggee_slot
64
        call    get_debuggee_slot
65
        jc      .ret
65
        jc      .ret
66
        and     dword [eax*8+SLOT_BASE+APPDATA.debugger_slot], 0
66
        and     dword [eax+SLOT_BASE+APPDATA.debugger_slot], 0
67
        call    do_resume
67
        call    do_resume
68
.ret:
68
.ret:
69
        sti
69
        sti
70
        ret
70
        ret
Line 71... Line 71...
71
 
71
 
72
debug_terminate:
72
debug_terminate:
73
; in: ecx=pid
73
; in: ecx=pid
74
        call    get_debuggee_slot
74
        call    get_debuggee_slot
75
        jc      debug_detach.ret
75
        jc      debug_detach.ret
76
        mov     ecx, eax
76
        mov     ecx, eax
77
        shr     ecx, 5
77
        shr     ecx, BSF sizeof.APPDATA
78
;        push    2
78
;        push    2
79
;        pop     ebx
79
;        pop     ebx
80
        mov     edx, esi
80
        mov     edx, esi
Line 90... Line 90...
90
;        shl     eax, 5
90
;        shl     eax, 5
91
;        jz      .ret
91
;        jz      .ret
92
        call    get_debuggee_slot
92
        call    get_debuggee_slot
93
        jc      .ret
93
        jc      .ret
94
; } End patch
94
; } End patch
95
        mov     cl, [TASK_TABLE+eax+TASKDATA.state] ; process state
95
        mov     cl, [SLOT_BASE + eax + APPDATA.state] ; process state
96
        test    cl, cl
96
        test    cl, cl
97
        jz      .1
97
        jz      .1
98
        cmp     cl, 5
98
        cmp     cl, 5
99
        jnz     .ret
99
        jnz     .ret
100
        mov     cl, 2
100
        mov     cl, 2
101
.2:
101
.2:
102
        mov     [TASK_TABLE+eax+TASKDATA.state], cl
102
        mov     [SLOT_BASE + eax + APPDATA.state], cl
103
.ret:
103
.ret:
104
        sti
104
        sti
105
        ret
105
        ret
106
.1:
106
.1:
107
        inc     ecx
107
        inc     ecx
108
        jmp     .2
108
        jmp     .2
Line 109... Line 109...
109
 
109
 
110
do_resume:
110
do_resume:
111
        mov     cl, [TASK_TABLE+eax+TASKDATA.state]
111
        mov     cl, [SLOT_BASE + eax + APPDATA.state]
112
        cmp     cl, 1
112
        cmp     cl, 1
113
        jz      .1
113
        jz      .1
114
        cmp     cl, 2
114
        cmp     cl, 2
115
        jnz     .ret
115
        jnz     .ret
116
        mov     cl, 5
116
        mov     cl, 5
117
.2:
117
.2:
118
        mov     [TASK_TABLE+eax+TASKDATA.state], cl
118
        mov     [SLOT_BASE + eax + APPDATA.state], cl
119
.ret:
119
.ret:
120
        ret
120
        ret
121
.1:
121
.1:
122
        dec     ecx
122
        dec     ecx
Line 126... Line 126...
126
; in: ecx=pid
126
; in: ecx=pid
127
; destroys eax,ebx
127
; destroys eax,ebx
128
        cli
128
        cli
129
        mov     eax, ecx
129
        mov     eax, ecx
130
        call    pid_to_slot
130
        call    pid_to_slot
131
        shl     eax, 5
131
        shl     eax, BSF sizeof.APPDATA
132
        jz      .ret
132
        jz      .ret
133
        call    do_resume
133
        call    do_resume
134
.ret:
134
.ret:
135
        sti
135
        sti
136
        ret
136
        ret
Line 153... Line 153...
153
                                  ; TODO legacy 32-bit FPU/MMX context
153
                                  ; TODO legacy 32-bit FPU/MMX context
154
.std_ctx:
154
.std_ctx:
155
        call    get_debuggee_slot
155
        call    get_debuggee_slot
156
        jc      .ret
156
        jc      .ret
Line 157... Line 157...
157
 
157
 
158
        shr     eax, 5
158
        shr     eax, 8
159
        cmp     eax, [fpu_owner]
159
        cmp     eax, [fpu_owner]
160
        jne     @f
160
        jne     @f
161
        inc     bh                ; set swap context flag
161
        inc     bh                ; set swap context flag
162
@@:
162
@@:
163
        shl     eax, 8
163
        shl     eax, BSF sizeof.APPDATA
164
        mov     edi, esi
164
        mov     edi, esi
165
        mov     eax, [eax+SLOT_BASE+APPDATA.pl0_stack]
165
        mov     eax, [eax+SLOT_BASE+APPDATA.pl0_stack]
Line 166... Line 166...
166
        lea     esi, [eax+RING0_STACK_SIZE]
166
        lea     esi, [eax+RING0_STACK_SIZE]
Line 229... Line 229...
229
        jnz     .ret
229
        jnz     .ret
Line 230... Line 230...
230
 
230
 
231
        call    get_debuggee_slot
231
        call    get_debuggee_slot
232
        jc      .stiret
232
        jc      .stiret
233
;        mov     esi, edx
233
;        mov     esi, edx
234
        mov     eax, [eax*8+SLOT_BASE+APPDATA.pl0_stack]
234
        mov     eax, [eax+SLOT_BASE+APPDATA.pl0_stack]
Line 235... Line 235...
235
        lea     edi, [eax+RING0_STACK_SIZE]
235
        lea     edi, [eax+RING0_STACK_SIZE]
236
 
236
 
237
.ring0:
237
.ring0:
Line 265... Line 265...
265
 
265
 
266
debug_set_drx:
266
debug_set_drx:
267
        call    get_debuggee_slot
267
        call    get_debuggee_slot
268
        jc      .errret
268
        jc      .errret
269
        mov     ebp, eax
269
        mov     ebp, eax
270
        lea     eax, [eax*8+SLOT_BASE+APPDATA.dbg_regs]
270
        lea     eax, [eax+SLOT_BASE+APPDATA.dbg_regs]
271
; [eax]=dr0, [eax+4]=dr1, [eax+8]=dr2, [eax+C]=dr3
271
; [eax]=dr0, [eax+4]=dr1, [eax+8]=dr2, [eax+C]=dr3
272
; [eax+10]=dr7
272
; [eax+10]=dr7
273
        cmp     esi, OS_BASE
273
        cmp     esi, OS_BASE
274
        jae     .errret
274
        jae     .errret
Line 292... Line 292...
292
        btr     dword [eax+10h], edx    ; clear L bit
292
        btr     dword [eax+10h], edx    ; clear L bit
293
        test    byte [eax+10h], 55h
293
        test    byte [eax+10h], 55h
294
        jnz     .okret
294
        jnz     .okret
295
;        imul    eax, ebp, tss_step/32
295
;        imul    eax, ebp, tss_step/32
296
;        and     byte [eax + tss_data + TSS._trap], not 1
296
;        and     byte [eax + tss_data + TSS._trap], not 1
297
        and     [ebp*8 + SLOT_BASE+APPDATA.dbg_state], not 1
297
        and     [ebp + SLOT_BASE+APPDATA.dbg_state], not 1
298
.okret:
298
.okret:
299
        and     dword [esp+32], 0
299
        and     dword [esp+32], 0
300
        sti
300
        sti
301
        ret
301
        ret
302
.errret:
302
.errret:
Line 339... Line 339...
339
        not     ebx
339
        not     ebx
340
        and     [eax+10h+2], bx
340
        and     [eax+10h+2], bx
341
        or      [eax+10h+2], dx         ; set R/W and LEN fields
341
        or      [eax+10h+2], dx         ; set R/W and LEN fields
342
;        imul    eax, ebp, tss_step/32
342
;        imul    eax, ebp, tss_step/32
343
;        or      byte [eax + tss_data + TSS._trap], 1
343
;        or      byte [eax + tss_data + TSS._trap], 1
344
        or      [ebp*8 + SLOT_BASE+APPDATA.dbg_state], 1
344
        or      [ebp + SLOT_BASE+APPDATA.dbg_state], 1
345
        jmp     .okret
345
        jmp     .okret
Line 346... Line 346...
346
 
346
 
347
debug_read_process_memory:
347
debug_read_process_memory:
348
; in:
348
; in:
Line 352... Line 352...
352
; esi=address in debuggee
352
; esi=address in debuggee
353
; out: [esp+36]=sizeof(read)
353
; out: [esp+36]=sizeof(read)
354
; destroys all
354
; destroys all
355
        call    get_debuggee_slot
355
        call    get_debuggee_slot
356
        jc      .err
356
        jc      .err
357
        shr     eax, 5
357
        shr     eax, 8
358
        mov     ecx, edi
358
        mov     ecx, edi
359
        call    read_process_memory
359
        call    read_process_memory
360
        sti
360
        sti
361
        mov     dword [esp+32], eax
361
        mov     dword [esp+32], eax
362
        ret
362
        ret
Line 372... Line 372...
372
; esi=address in debuggee
372
; esi=address in debuggee
373
; out: [esp+36]=sizeof(write)
373
; out: [esp+36]=sizeof(write)
374
; destroys all
374
; destroys all
375
        call    get_debuggee_slot
375
        call    get_debuggee_slot
376
        jc      debug_read_process_memory.err
376
        jc      debug_read_process_memory.err
377
        shr     eax, 5
377
        shr     eax, 8
378
        mov     ecx, edi
378
        mov     ecx, edi
379
        call    write_process_memory
379
        call    write_process_memory
380
        sti
380
        sti
381
        mov     [esp+32], eax
381
        mov     [esp+32], eax
382
        ret
382
        ret