Rev 237 | Rev 380 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 237 | Rev 379 | ||
---|---|---|---|
Line 17... | Line 17... | ||
17 | dd debug_set_drx |
17 | dd debug_set_drx |
Line 18... | Line 18... | ||
18 | 18 | ||
19 | debug_set_event_data: |
19 | debug_set_event_data: |
20 | ; in: ebx = pointer |
20 | ; in: ebx = pointer |
21 | ; destroys eax |
21 | ; destroys eax |
22 | mov eax, [0x3000] |
22 | mov eax, [CURRENT_TASK] |
23 | shl eax, 8 |
23 | shl eax, 8 |
24 | mov [eax+0x80000+APPDATA.dbg_event_mem], ebx |
24 | mov [eax+0x80000+APPDATA.dbg_event_mem], ebx |
Line 25... | Line 25... | ||
25 | ret |
25 | ret |
Line 34... | Line 34... | ||
34 | call pid_to_slot |
34 | call pid_to_slot |
35 | test eax, eax |
35 | test eax, eax |
36 | jz .ret_bad |
36 | jz .ret_bad |
37 | shl eax, 5 |
37 | shl eax, 5 |
38 | push ebx |
38 | push ebx |
39 | mov ebx, [0x3000] |
39 | mov ebx, [CURRENT_TASK] |
40 | cmp [0x80000+eax*8+APPDATA.debugger_slot], ebx |
40 | cmp [0x80000+eax*8+APPDATA.debugger_slot], ebx |
41 | pop ebx |
41 | pop ebx |
42 | jnz .ret_bad |
42 | jnz .ret_bad |
43 | ; clc ; automatically |
43 | ; clc ; automatically |
44 | ret |
44 | ret |
Line 70... | Line 70... | ||
70 | debug_suspend: |
70 | debug_suspend: |
71 | ; in: ebx=pid |
71 | ; in: ebx=pid |
72 | ; destroys eax,ebx |
72 | ; destroys eax,ebx |
73 | call get_debuggee_slot |
73 | call get_debuggee_slot |
74 | jc .ret |
74 | jc .ret |
75 | mov bl, [0x3000+eax+TASKDATA.state] ; process state |
75 | mov bl, [CURRENT_TASK+eax+TASKDATA.state] ; process state |
76 | test bl, bl |
76 | test bl, bl |
77 | jz .1 |
77 | jz .1 |
78 | cmp bl, 5 |
78 | cmp bl, 5 |
79 | jnz .ret |
79 | jnz .ret |
80 | mov bl, 2 |
80 | mov bl, 2 |
81 | .2: mov [0x3000+eax+TASKDATA.state], bl |
81 | .2: mov [CURRENT_TASK+eax+TASKDATA.state], bl |
82 | .ret: |
82 | .ret: |
83 | sti |
83 | sti |
84 | ret |
84 | ret |
85 | .1: |
85 | .1: |
86 | inc ebx |
86 | inc ebx |
87 | jmp .2 |
87 | jmp .2 |
Line 88... | Line 88... | ||
88 | 88 | ||
89 | do_resume: |
89 | do_resume: |
90 | mov bl, [0x3000+eax+TASKDATA.state] |
90 | mov bl, [CURRENT_TASK+eax+TASKDATA.state] |
91 | cmp bl, 1 |
91 | cmp bl, 1 |
92 | jz .1 |
92 | jz .1 |
93 | cmp bl, 2 |
93 | cmp bl, 2 |
94 | jnz .ret |
94 | jnz .ret |
95 | mov bl, 5 |
95 | mov bl, 5 |
96 | .2: mov [0x3000+eax+TASKDATA.state], bl |
96 | .2: mov [CURRENT_TASK+eax+TASKDATA.state], bl |
97 | .ret: ret |
97 | .ret: ret |
98 | .1: dec ebx |
98 | .1: dec ebx |
Line 99... | Line 99... | ||
99 | jmp .2 |
99 | jmp .2 |
Line 378... | Line 378... | ||
378 | jg @f |
378 | jg @f |
379 | .2: |
379 | .2: |
380 | pop ecx |
380 | pop ecx |
381 | pop ecx |
381 | pop ecx |
382 | pop ecx |
382 | pop ecx |
383 | cmp dword [0x3000], 1 |
383 | cmp dword [CURRENT_TASK], 1 |
384 | jnz .notos |
384 | jnz .notos |
385 | cmp [timer_ticks], edi |
385 | cmp [timer_ticks], edi |
386 | jae .ret |
386 | jae .ret |
387 | .notos: |
387 | .notos: |
388 | sti |
388 | sti |
Line 428... | Line 428... | ||
428 | mov eax, dr6 |
428 | mov eax, dr6 |
429 | test ax, ax |
429 | test ax, ax |
430 | jns @f |
430 | jns @f |
431 | ; this is exception from task switch |
431 | ; this is exception from task switch |
432 | ; set DRx registers for task and continue |
432 | ; set DRx registers for task and continue |
433 | mov eax, [0x3000] |
433 | mov eax, [CURRENT_TASK] |
434 | shl eax, 8 |
434 | shl eax, 8 |
435 | add eax, 0x80000+APPDATA.dbg_regs |
435 | add eax, 0x80000+APPDATA.dbg_regs |
436 | mov ecx, [eax+0] |
436 | mov ecx, [eax+0] |
437 | mov dr0, ecx |
437 | mov dr0, ecx |
438 | mov ecx, [eax+4] |
438 | mov ecx, [eax+4] |
Line 451... | Line 451... | ||
451 | push eax |
451 | push eax |
452 | xor eax, eax |
452 | xor eax, eax |
453 | mov dr6, eax |
453 | mov dr6, eax |
454 | ; test if debugging |
454 | ; test if debugging |
455 | cli |
455 | cli |
456 | mov eax, [0x3000] |
456 | mov eax, [CURRENT_TASK] |
457 | shl eax, 8 |
457 | shl eax, 8 |
458 | mov eax, [0x80000+eax+APPDATA.debugger_slot] |
458 | mov eax, [0x80000+eax+APPDATA.debugger_slot] |
459 | test eax, eax |
459 | test eax, eax |
460 | jnz .debug |
460 | jnz .debug |
461 | sti |
461 | sti |
462 | ; not debuggee => say error and terminate |
462 | ; not debuggee => say error and terminate |
463 | add esp, 28h+4 |
463 | add esp, 28h+4 |
464 | mov [error_interrupt], 1 |
464 | mov [error_interrupt], 1 |
465 | call show_error_parameters |
465 | call show_error_parameters |
466 | mov edx, [0x3010] |
466 | mov edx, [TASK_BASE] |
467 | mov byte [edx+TASKDATA.state], 4 |
467 | mov byte [edx+TASKDATA.state], 4 |
468 | jmp change_task |
468 | jmp change_task |
469 | .debug: |
469 | .debug: |
470 | ; we are debugged process, notify debugger and suspend ourself |
470 | ; we are debugged process, notify debugger and suspend ourself |
471 | ; eax=debugger PID |
471 | ; eax=debugger PID |
Line 481... | Line 481... | ||
481 | add cl, cl |
481 | add cl, cl |
482 | inc ecx |
482 | inc ecx |
483 | cmp cl, not 10h |
483 | cmp cl, not 10h |
484 | jnz .l1 |
484 | jnz .l1 |
485 | push edx ; DR6 image |
485 | push edx ; DR6 image |
486 | mov ecx, [0x3010] |
486 | mov ecx, [TASK_BASE] |
487 | push dword [ecx+TASKDATA.pid] ; PID |
487 | push dword [ecx+TASKDATA.pid] ; PID |
488 | push 12 |
488 | push 12 |
489 | pop ecx |
489 | pop ecx |
490 | push 3 ; 3 = debug exception |
490 | push 3 ; 3 = debug exception |
491 | call debugger_notify |
491 | call debugger_notify |
492 | pop ecx |
492 | pop ecx |
493 | pop ecx |
493 | pop ecx |
494 | pop ecx |
494 | pop ecx |
495 | mov edx, [0x3010] |
495 | mov edx, [TASK_BASE] |
496 | mov byte [edx+TASKDATA.state], 1 ; suspended |
496 | mov byte [edx+TASKDATA.state], 1 ; suspended |
497 | call change_task |
497 | call change_task |
498 | restore_ring3_context |
498 | restore_ring3_context |
499 | iretd |
499 | iretd |