Subversion Repositories Kolibri OS

Rev

Rev 9715 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9715 Rev 9911
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2022. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2022. 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: 9715 $
8
$Revision: 9911 $
9
 
9
 
10
 
10
 
Line 42... Line 42...
42
;      CF=0 and eax=slot*0x20 if ok
42
;      CF=0 and eax=slot*0x20 if ok
43
; out: interrupts disabled
43
; out: interrupts disabled
44
        cli
44
        cli
45
        mov     eax, ecx
45
        mov     eax, ecx
46
        call    pid_to_slot
46
        call    pid_to_slot
-
 
47
        ;call     pid_to_appdata
47
        test    eax, eax
48
        test    eax, eax
48
        jz      .ret_bad
49
        jz      .ret_bad
49
        shl     eax, BSF sizeof.APPDATA
50
        shl     eax, BSF sizeof.APPDATA
50
        push    ebx
51
        push    ebx
51
        mov     ebx, [current_slot_idx]
52
        mov     ebx, [current_slot_idx]
52
        cmp     [SLOT_BASE + eax + APPDATA.debugger_slot], ebx
53
        cmp     [SLOT_BASE + eax + APPDATA.debugger_slot], ebx
-
 
54
        ;cmp     [eax + APPDATA.debugger_slot], ebx
53
        pop     ebx
55
        pop     ebx
54
        jnz     .ret_bad
56
        jnz     .ret_bad
55
;       clc     ; automatically
57
;       clc     ; automatically
56
        ret
58
        ret
57
.ret_bad:
59
.ret_bad:
Line 62... Line 64...
62
; in: ecx=pid
64
; in: ecx=pid
63
; destroys eax,ebx
65
; destroys eax,ebx
64
        call    get_debuggee_slot
66
        call    get_debuggee_slot
65
        jc      .ret
67
        jc      .ret
66
        and     dword [eax + SLOT_BASE + APPDATA.debugger_slot], 0
68
        and     dword [eax + SLOT_BASE + APPDATA.debugger_slot], 0
-
 
69
        ;and     dword [eax + APPDATA.debugger_slot], 0
67
        call    do_resume
70
        call    do_resume
68
.ret:
71
.ret:
69
        sti
72
        sti
70
        ret
73
        ret
Line 71... Line 74...
71
 
74
 
72
debug_terminate:
75
debug_terminate:
73
; in: ecx=pid
76
; in: ecx=pid
74
        call    get_debuggee_slot
77
        call    get_debuggee_slot
75
        jc      debug_detach.ret
78
        jc      debug_detach.ret
-
 
79
        mov     ecx, eax
76
        mov     ecx, eax
80
 
-
 
81
        shr     ecx, BSF sizeof.APPDATA
-
 
82
        ;movzx   ecx, ch ; del when sysfn_term... will using APPDATA
77
        shr     ecx, BSF sizeof.APPDATA
83
 
78
;        push    2
84
;        push    2
79
;        pop     ebx
85
;        pop     ebx
80
        mov     edx, esi
86
        mov     edx, esi ; what?
Line 81... Line 87...
81
        jmp     sysfn_terminate
87
        jmp     sysfn_terminate
82
 
88
 
83
debug_suspend:
89
debug_suspend:
Line 91... Line 97...
91
;        jz      .ret
97
;        jz      .ret
92
        call    get_debuggee_slot
98
        call    get_debuggee_slot
93
        jc      .ret
99
        jc      .ret
94
; } End patch
100
; } End patch
95
        mov     cl, [SLOT_BASE + eax + APPDATA.state] ; process state
101
        mov     cl, [SLOT_BASE + eax + APPDATA.state] ; process state
-
 
102
        ;mov     cl, [eax + APPDATA.state] ; process state
96
        test    cl, cl
103
        test    cl, cl
97
        jz      .1
104
        jz      .1
98
        cmp     cl, 5
105
        cmp     cl, TSTATE_WAITING
99
        jnz     .ret
106
        jnz     .ret
100
        mov     cl, 2
107
        mov     cl, TSTATE_WAIT_SUSPENDED
101
.2:
108
.2:
102
        mov     [SLOT_BASE + eax + APPDATA.state], cl
109
        mov     [SLOT_BASE + eax + APPDATA.state], cl
-
 
110
        ;mov     [eax + APPDATA.state], cl
103
.ret:
111
.ret:
104
        sti
112
        sti
105
        ret
113
        ret
106
.1:
114
.1:
107
        inc     ecx
115
        inc     ecx
108
        jmp     .2
116
        jmp     .2
Line 109... Line 117...
109
 
117
 
110
do_resume:
118
do_resume:
-
 
119
        mov     cl, [SLOT_BASE + eax + APPDATA.state]
111
        mov     cl, [SLOT_BASE + eax + APPDATA.state]
120
        ;mov     cl, [eax + APPDATA.state]
112
        cmp     cl, 1
121
        cmp     cl, TSTATE_RUN_SUSPENDED
113
        jz      .1
122
        jz      .1
114
        cmp     cl, 2
123
        cmp     cl, TSTATE_WAIT_SUSPENDED
115
        jnz     .ret
124
        jnz     .ret
116
        mov     cl, 5
125
        mov     cl, TSTATE_WAITING
117
.2:
126
.2:
-
 
127
        mov     [SLOT_BASE + eax + APPDATA.state], cl
118
        mov     [SLOT_BASE + eax + APPDATA.state], cl
128
        ;mov     [eax + APPDATA.state], cl
119
.ret:
129
.ret:
120
        ret
130
        ret
121
.1:
131
.1:
122
        dec     ecx
132
        dec     ecx
Line 138... Line 148...
138
debug_getcontext:
148
debug_getcontext:
139
; in:
149
; in:
140
; ecx=pid
150
; ecx=pid
141
; edx=sizeof(CONTEXT)
151
; edx=sizeof(CONTEXT)
142
; esi->CONTEXT
152
; esi->CONTEXT
143
; destroys eax,ebx,ecx,edx,esi,edi
153
; destroys eax,ebx,ecx,edx,esi,edi, ebp
Line 144... Line 154...
144
 
154
 
145
        xor     ebx, ebx            ; 0 - get only gp regs
155
        xor     ebx, ebx            ; 0 - get only gp regs
146
        cmp     edx, 40
156
        cmp     edx, 40
Line 154... Line 164...
154
.std_ctx:
164
.std_ctx:
155
        call    get_debuggee_slot
165
        call    get_debuggee_slot
156
        jc      .ret
166
        jc      .ret
Line 157... Line 167...
157
 
167
 
-
 
168
        shr     eax, BSF sizeof.APPDATA
-
 
169
        ;movzx   ebp, ah
158
        shr     eax, BSF sizeof.APPDATA
170
 
-
 
171
        cmp     eax, [fpu_owner]
159
        cmp     eax, [fpu_owner]
172
        ;cmp     ebp, [fpu_owner]
160
        jne     @f
173
        jne     @f
161
        inc     bh                ; set swap context flag
174
        inc     bh                ; set swap context flag
162
@@:
175
@@:
163
        shl     eax, BSF sizeof.APPDATA
176
        shl     eax, BSF sizeof.APPDATA
164
        mov     edi, esi
177
        mov     edi, esi
-
 
178
        mov     eax, [SLOT_BASE + eax + APPDATA.pl0_stack]
165
        mov     eax, [SLOT_BASE + eax + APPDATA.pl0_stack]
179
        ;mov     eax, [eax + APPDATA.pl0_stack]
Line 166... Line 180...
166
        lea     esi, [eax + RING0_STACK_SIZE]
180
        lea     esi, [eax + RING0_STACK_SIZE]
167
 
181
 
168
.ring0:
182
.ring0:
Line 230... Line 244...
230
 
244
 
231
        call    get_debuggee_slot
245
        call    get_debuggee_slot
232
        jc      .stiret
246
        jc      .stiret
233
;        mov     esi, edx
247
;        mov     esi, edx
-
 
248
        mov     eax, [eax + SLOT_BASE+APPDATA.pl0_stack]
234
        mov     eax, [eax + SLOT_BASE+APPDATA.pl0_stack]
249
        ;mov     eax, [eax + APPDATA.pl0_stack]
Line 235... Line 250...
235
        lea     edi, [eax + RING0_STACK_SIZE]
250
        lea     edi, [eax + RING0_STACK_SIZE]
236
 
251
 
237
.ring0:
252
.ring0:
Line 266... Line 281...
266
debug_set_drx:
281
debug_set_drx:
267
        call    get_debuggee_slot
282
        call    get_debuggee_slot
268
        jc      .errret
283
        jc      .errret
269
        mov     ebp, eax
284
        mov     ebp, eax
270
        lea     eax, [eax + SLOT_BASE + APPDATA.dbg_regs]
285
        lea     eax, [eax + SLOT_BASE + APPDATA.dbg_regs]
-
 
286
        ;lea     eax, [eax + APPDATA.dbg_regs]
271
; [eax]=dr0, [eax+4]=dr1, [eax+8]=dr2, [eax+C]=dr3
287
; [eax]=dr0, [eax+4]=dr1, [eax+8]=dr2, [eax+C]=dr3
272
; [eax+10]=dr7
288
; [eax+10]=dr7
273
        cmp     esi, OS_BASE
289
        cmp     esi, OS_BASE
274
        jae     .errret
290
        jae     .errret
275
        cmp     dl, 3
291
        cmp     dl, 3
Line 293... Line 309...
293
        test    byte [eax + 10h], 55h
309
        test    byte [eax + 10h], 55h
294
        jnz     .okret
310
        jnz     .okret
295
;        imul    eax, ebp, tss_step/32
311
;        imul    eax, ebp, tss_step/32
296
;        and     byte [eax + tss_data + TSS._trap], not 1
312
;        and     byte [eax + tss_data + TSS._trap], not 1
297
        and     [SLOT_BASE + ebp + APPDATA.dbg_state], not 1
313
        and     [SLOT_BASE + ebp + APPDATA.dbg_state], not 1
-
 
314
        ;and     [ebp + APPDATA.dbg_state], not 1
298
.okret:
315
.okret:
299
        and     dword [esp+32], 0
316
        and     dword [esp + SYSCALL_STACK.eax], 0
300
        sti
317
        sti
301
        ret
318
        ret
302
.errret:
319
.errret:
303
        sti
320
        sti
304
        mov     dword [esp+32], 1
321
        mov     dword [esp + SYSCALL_STACK.eax], 1
305
        ret
322
        ret
306
.errret2:
323
.errret2:
307
        sti
324
        sti
308
        mov     dword [esp+32], 2
325
        mov     dword [esp + SYSCALL_STACK.eax], 2
309
        ret
326
        ret
310
.new:
327
.new:
311
; add new breakpoint
328
; add new breakpoint
312
; dl=index; dh=flags; esi=address
329
; dl=index; dh=flags; esi=address
313
        test    dh, 0xF0
330
        test    dh, 0xF0
Line 340... Line 357...
340
        and     [eax + 10h+2], bx
357
        and     [eax + 10h+2], bx
341
        or      [eax + 10h+2], dx         ; set R/W and LEN fields
358
        or      [eax + 10h+2], dx         ; set R/W and LEN fields
342
;        imul    eax, ebp, tss_step/32
359
;        imul    eax, ebp, tss_step/32
343
;        or      byte [eax + tss_data + TSS._trap], 1
360
;        or      byte [eax + tss_data + TSS._trap], 1
344
        or      [SLOT_BASE + ebp + APPDATA.dbg_state], 1
361
        or      [SLOT_BASE + ebp + APPDATA.dbg_state], 1
-
 
362
        ;or      [ebp + APPDATA.dbg_state], 1
345
        jmp     .okret
363
        jmp     .okret
Line 346... Line 364...
346
 
364
 
347
debug_read_process_memory:
365
debug_read_process_memory:
348
; in:
366
; in:
Line 353... Line 371...
353
; out: [esp+36]=sizeof(read)
371
; out: [esp+36]=sizeof(read)
354
; destroys all
372
; destroys all
355
        call    get_debuggee_slot
373
        call    get_debuggee_slot
356
        jc      .err
374
        jc      .err
357
        shr     eax, BSF sizeof.APPDATA
375
        shr     eax, BSF sizeof.APPDATA
-
 
376
        ;movzx   eax,ah
358
        mov     ecx, edi
377
        mov     ecx, edi
359
        call    read_process_memory
378
        call    read_process_memory
360
        sti
379
        sti
361
        mov     dword [esp+32], eax
380
        mov     dword [esp + SYSCALL_STACK.eax], eax
362
        ret
381
        ret
363
.err:
382
.err:
364
        or      dword [esp+32], -1
383
        or      dword [esp + SYSCALL_STACK.eax], -1
365
        ret
384
        ret
Line 366... Line 385...
366
 
385
 
367
debug_write_process_memory:
386
debug_write_process_memory:
368
; in:
387
; in:
Line 373... Line 392...
373
; out: [esp+36]=sizeof(write)
392
; out: [esp+36]=sizeof(write)
374
; destroys all
393
; destroys all
375
        call    get_debuggee_slot
394
        call    get_debuggee_slot
376
        jc      debug_read_process_memory.err
395
        jc      debug_read_process_memory.err
377
        shr     eax, BSF sizeof.APPDATA
396
        shr     eax, BSF sizeof.APPDATA
-
 
397
        ;movzx   eax,ah
378
        mov     ecx, edi
398
        mov     ecx, edi
379
        call    write_process_memory
399
        call    write_process_memory
380
        sti
400
        sti
381
        mov     [esp+32], eax
401
        mov     [esp + SYSCALL_STACK.eax], eax
382
        ret
402
        ret
Line 383... Line 403...
383
 
403
 
384
debugger_notify:
404
debugger_notify:
385
; in: eax=debugger slot
405
; in: eax=debugger slot