1)debugger support

2)fixed bugs in get_event_for_app()

git-svn-id: svn://kolibrios.org@459 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2007-04-11 18:54:58 +00:00
parent 1bc5430ccc
commit 73baea5f6c
8 changed files with 123 additions and 112 deletions

View File

@ -122,7 +122,6 @@ debug_getcontext:
; destroys eax,ecx,edx,esi,edi ; destroys eax,ecx,edx,esi,edi
cmp ecx, 28h cmp ecx, 28h
jnz .ret jnz .ret
; add edx, std_application_base_address
push ebx push ebx
mov ebx, edx mov ebx, edx
call check_region call check_region
@ -131,19 +130,12 @@ debug_getcontext:
jnz .ret jnz .ret
call get_debuggee_slot call get_debuggee_slot
jc .ret jc .ret
; imul eax, tss_step/32 mov eax, [eax*8+SLOT_BASE+APPDATA.pl0_stack]
; add eax, tss_data lea esi, [eax+RING0_STACK_SIZE]
mov edi, edx mov edi, edx
; cmp [eax+TSS._cs], app_code
; jnz .ring0
; lea esi, [eax+TSS._eip]
; shr ecx, 2
; rep movsd
; jmp .ret
.ring0: .ring0:
; note that following code assumes that all interrupt/exception handlers ; note that following code assumes that all interrupt/exception handlers
; saves ring-3 context by pushad in this order ; saves ring-3 context by pushad in this order
mov esi, [tss._esp0]
; top of ring0 stack: ring3 stack ptr (ss+esp), iret data (cs+eip+eflags), pushad ; top of ring0 stack: ring3 stack ptr (ss+esp), iret data (cs+eip+eflags), pushad
sub esi, 8+12+20h sub esi, 8+12+20h
lodsd ;edi lodsd ;edi
@ -161,7 +153,6 @@ debug_getcontext:
mov [edi+0Ch], eax mov [edi+0Ch], eax
lodsd ;eax lodsd ;eax
mov [edi+8], eax mov [edi+8], eax
;;; add esi, 8 ;ds es
lodsd ;eip lodsd ;eip
mov [edi], eax mov [edi], eax
lodsd ;cs lodsd ;cs
@ -181,7 +172,6 @@ debug_setcontext:
; destroys eax,ecx,edx,esi,edi ; destroys eax,ecx,edx,esi,edi
cmp ecx, 28h cmp ecx, 28h
jnz .ret jnz .ret
; add edx, std_application_base_address
push ebx push ebx
mov ebx, edx mov ebx, edx
call check_region call check_region
@ -190,17 +180,10 @@ debug_setcontext:
jnz .ret jnz .ret
call get_debuggee_slot call get_debuggee_slot
jc .stiret jc .stiret
; imul eax, tss_step/32 mov eax, [eax*8+SLOT_BASE+APPDATA.pl0_stack]
; add eax, tss_data lea edi, [eax+RING0_STACK_SIZE]
mov esi, edx mov esi, edx
; cmp [eax+TSS._cs], app_code
; jnz .ring0
; lea edi, [eax+TSS._eip]
; shr ecx, 2
; rep movsd
; jmp .stiret
.ring0: .ring0:
mov edi, [tss._esp0]
sub edi, 8+12+20h sub edi, 8+12+20h
mov eax, [esi+24h] ;edi mov eax, [esi+24h] ;edi
stosd stosd
@ -217,7 +200,6 @@ debug_setcontext:
stosd stosd
mov eax, [esi+8] ;eax mov eax, [esi+8] ;eax
stosd stosd
;;; add edi, 8 ;ds es
mov eax, [esi] ;eip mov eax, [esi] ;eip
stosd stosd
scasd scasd
@ -237,8 +219,8 @@ debug_set_drx:
lea eax, [eax*8+SLOT_BASE+APPDATA.dbg_regs] lea eax, [eax*8+SLOT_BASE+APPDATA.dbg_regs]
; [eax]=dr0, [eax+4]=dr1, [eax+8]=dr2, [eax+C]=dr3 ; [eax]=dr0, [eax+4]=dr1, [eax+8]=dr2, [eax+C]=dr3
; [eax+10]=dr7 ; [eax+10]=dr7
; add edx, std_application_base_address cmp edx, OS_BASE
jc .errret jae .errret
cmp cl, 3 cmp cl, 3
ja .errret ja .errret
mov ebx, dr7 mov ebx, dr7
@ -257,6 +239,7 @@ debug_set_drx:
jnz .okret jnz .okret
; imul eax, ebp, tss_step/32 ; imul eax, ebp, tss_step/32
; and byte [eax + tss_data + TSS._trap], not 1 ; and byte [eax + tss_data + TSS._trap], not 1
and [ebp*8 + SLOT_BASE+APPDATA.dbg_state], not 1
.okret: .okret:
and dword [esp+36], 0 and dword [esp+36], 0
sti sti
@ -299,6 +282,7 @@ debug_set_drx:
or [eax+10h+2], bx ; set R/W and LEN fields or [eax+10h+2], bx ; set R/W and LEN fields
; imul eax, ebp, tss_step/32 ; imul eax, ebp, tss_step/32
; or byte [eax + tss_data + TSS._trap], 1 ; or byte [eax + tss_data + TSS._trap], 1
or [ebp*8 + SLOT_BASE+APPDATA.dbg_state], 1
jmp .okret jmp .okret
debug_read_process_memory: debug_read_process_memory:
@ -309,7 +293,6 @@ debug_read_process_memory:
; edx=address in debuggee ; edx=address in debuggee
; out: [esp+36]=sizeof(read) ; out: [esp+36]=sizeof(read)
; destroys all ; destroys all
; add esi, std_application_base_address
push ebx push ebx
mov ebx, esi mov ebx, esi
call check_region call check_region
@ -336,7 +319,6 @@ debug_write_process_memory:
; edx=address in debuggee ; edx=address in debuggee
; out: [esp+36]=sizeof(write) ; out: [esp+36]=sizeof(write)
; destroys all ; destroys all
; add esi, std_application_base_address
push ebx push ebx
mov ebx, esi mov ebx, esi
call check_region call check_region
@ -433,28 +415,6 @@ debug_exc:
mov ds, ax mov ds, ax
mov es, ax mov es, ax
mov eax, dr6 mov eax, dr6
test ax, ax
jns @f
; this is exception from task switch
; set DRx registers for task and continue
mov eax, [CURRENT_TASK]
shl eax, 8
add eax, SLOT_BASE+APPDATA.dbg_regs
mov ecx, [eax+0]
mov dr0, ecx
mov ecx, [eax+4]
mov dr1, ecx
mov ecx, [eax+8]
mov dr2, ecx
mov ecx, [eax+0Ch]
mov dr3, ecx
xor ecx, ecx
mov dr6, ecx
mov ecx, [eax+10h]
mov dr7, ecx
restore_ring3_context
iretd
@@:
push eax push eax
xor eax, eax xor eax, eax
mov dr6, eax mov dr6, eax

View File

@ -468,13 +468,13 @@ proc page_fault_handler
inc [pg_data.pages_faults] inc [pg_data.pages_faults]
push eax ; push eax
push edx ; push edx
mov edx, 0x400 ;bochs ; mov edx, 0x400 ;bochs
mov al,0xff ;bochs ; mov al,0xff ;bochs
out dx, al ;bochs ; out dx, al ;bochs
pop edx ; pop edx
pop eax ; pop eax
mov ebx, [.err_addr] mov ebx, [.err_addr]
mov eax, [.err_code] mov eax, [.err_code]
@ -591,7 +591,8 @@ align 4
mov esp, ebp mov esp, ebp
popad popad
add esp, 4 add esp, 4
iretd
; iretd
save_ring3_context ;debugger support save_ring3_context ;debugger support

View File

@ -221,6 +221,22 @@ do_change_task:
mov cr0, ecx mov cr0, ecx
inc [context_counter] ;noname & halyavin inc [context_counter] ;noname & halyavin
test [ebx+APPDATA.dbg_state], 1
jnz @F
ret
@@:
mov eax, [ebx+APPDATA.dbg_regs.dr0]
mov dr0, eax
mov eax, [ebx+APPDATA.dbg_regs.dr1]
mov dr1, eax
mov eax, [ebx+APPDATA.dbg_regs.dr2]
mov dr2, eax
mov eax, [ebx+APPDATA.dbg_regs.dr3]
mov dr3, eax
xor eax, eax
mov dr6, eax
mov eax, [ebx+APPDATA.dbg_regs.dr7]
mov dr7, eax
ret ret
align 4 align 4

View File

@ -898,6 +898,12 @@ wait_mutex:
pop eax pop eax
ret ret
EFL_IF equ 0x0200
EFL_IOPL1 equ 0x1000
EFL_IOPL2 equ 0x2000
EFL_IOPL3 equ 0x3000
align 4 align 4
proc set_app_params stdcall,slot:dword, params:dword,\ proc set_app_params stdcall,slot:dword, params:dword,\
cmd_line:dword, app_path:dword, flags:dword cmd_line:dword, app_path:dword, flags:dword
@ -1018,12 +1024,10 @@ proc set_app_params stdcall,slot:dword, params:dword,\
mov [ebx+REG_ECX], eax mov [ebx+REG_ECX], eax
mov [ebx+REG_EAX], eax mov [ebx+REG_EAX], eax
; mov [ebx+REG_EFL_2], dword 0x1002
mov eax, [esi+0x08] ;app_eip mov eax, [esi+0x08] ;app_eip
mov [ebx+REG_EIP], eax ;app_entry mov [ebx+REG_EIP], eax ;app_entry
mov [ebx+REG_CS], dword app_code mov [ebx+REG_CS], dword app_code
mov [ebx+REG_EFLAGS], dword 0x1202 mov [ebx+REG_EFLAGS], dword EFL_IOPL1+EFL_IF
mov eax, [esi+0x0C] ;app_esp mov eax, [esi+0x0C] ;app_esp
mov [ebx+REG_APP_ESP], eax ;app_stack mov [ebx+REG_APP_ESP], eax ;app_stack

View File

@ -1,7 +1,36 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;OS_BASE equ 0x80000000 format MS COFF
;new_app_base equ 0x60400000
;PROC_BASE equ OS_BASE+0x0080000 include 'proc32.inc'
include 'imports.inc'
PG_SW equ 0x003
page_tabs equ 0xFDC00000 ;hack
OS_BASE equ 0x80000000
SLOT_BASE equ (OS_BASE+0x0080000)
TASK_COUNT equ (OS_BASE+0x0003004)
CURRENT_TASK equ (OS_BASE+0x0003000)
struc APPOBJ ;common object header
{
.magic dd ? ;
.destroy dd ? ;internal destructor
.fd dd ? ;next object in list
.bk dd ? ;prev object in list
.pid dd ? ;owner id
};
virtual at 0
APPOBJ APPOBJ
end virtual
struc IOCTL struc IOCTL
{ .handle dd ? { .handle dd ?
@ -12,10 +41,9 @@ struc IOCTL
.out_size dd ? .out_size dd ?
} }
virtual at 0
;public START IOCTL IOCTL
;public service_proc end virtual
;public version
DEBUG equ 1 DEBUG equ 1
@ -164,13 +192,19 @@ CONNECTION_SIZE equ 7*4
UART_VERSION equ 0x12345678 ;debug UART_VERSION equ 0x12345678 ;debug
proc init_uart_service stdcall, state:dword public START
public service_proc
public version
section '.flat' code readable align 16
proc START stdcall, state:dword
cmp [state], 1 cmp [state], 1
jne .stop jne .stop
mov eax, UART_SIZE mov eax, UART_SIZE
call malloc call Kmalloc
test eax, eax test eax, eax
jz .fail jz .fail
@ -184,7 +218,7 @@ proc init_uart_service stdcall, state:dword
mov eax, [com1] mov eax, [com1]
mov [eax+UART.base], COM_1_BASE mov [eax+UART.base], COM_1_BASE
stdcall alloc_kernel_space, 32768 stdcall AllocKernelSpace, 32768
mov edi, [com1] mov edi, [com1]
mov edx, eax mov edx, eax
@ -197,7 +231,7 @@ proc init_uart_service stdcall, state:dword
add eax, 8192 add eax, 8192
mov [edi+UART.xmit_top], eax mov [edi+UART.xmit_top], eax
call alloc_page call AllocPage
test eax, eax test eax, eax
jz .fail jz .fail
@ -206,7 +240,7 @@ proc init_uart_service stdcall, state:dword
mov [page_tabs+edx*4], eax mov [page_tabs+edx*4], eax
mov [page_tabs+edx*4+8], eax mov [page_tabs+edx*4+8], eax
call alloc_page call AllocPage
test eax, eax test eax, eax
jz .fail jz .fail
@ -214,7 +248,7 @@ proc init_uart_service stdcall, state:dword
mov [page_tabs+edx*4+4], eax mov [page_tabs+edx*4+4], eax
mov [page_tabs+edx*4+12], eax mov [page_tabs+edx*4+12], eax
call alloc_page call AllocPage
test eax, eax test eax, eax
jz .fail jz .fail
@ -222,7 +256,7 @@ proc init_uart_service stdcall, state:dword
mov [page_tabs+edx*4+16], eax mov [page_tabs+edx*4+16], eax
mov [page_tabs+edx*4+24], eax mov [page_tabs+edx*4+24], eax
call alloc_page call AllocPage
test eax, eax test eax, eax
jz .fail jz .fail
@ -243,9 +277,8 @@ proc init_uart_service stdcall, state:dword
mov eax, edi mov eax, edi
call uart_reset.internal ;eax= uart call uart_reset.internal ;eax= uart
stdcall attach_int_handler, COM_1_IRQ, com_1_isr stdcall AttachIntHandler, COM_1_IRQ, com_1_isr
stdcall reg_service, sz_uart_srv, uart_proc stdcall RegService, sz_uart_srv, service_proc
mov [eax+SRV.entry], init_uart_service
ret ret
.fail: .fail:
.stop: .stop:
@ -273,7 +306,7 @@ PORT_READ equ 8
PORT_WRITE equ 9 PORT_WRITE equ 9
align 4 align 4
proc uart_proc stdcall, ioctl:dword proc service_proc stdcall, ioctl:dword
mov ebx, [ioctl] mov ebx, [ioctl]
mov eax, [ebx+io_code] mov eax, [ebx+io_code]
@ -555,7 +588,7 @@ uart_open:
.do_wait: .do_wait:
cmp dword [esi+UART.lock],0 cmp dword [esi+UART.lock],0
je .get_lock je .get_lock
call change_task ; call change_task
jmp .do_wait jmp .do_wait
.get_lock: .get_lock:
mov eax, 1 mov eax, 1
@ -570,7 +603,7 @@ uart_open:
shl ebx, 5 shl ebx, 5
mov ebx, [CURRENT_TASK+ebx+4] mov ebx, [CURRENT_TASK+ebx+4]
mov eax, CONNECTION_SIZE mov eax, CONNECTION_SIZE
call create_kernel_object call CreateObject
pop esi ;uart pop esi ;uart
test eax, eax test eax, eax
jz .fail jz .fail
@ -599,7 +632,7 @@ uart_close:
jne .fail jne .fail
.destroy: .destroy:
push [eax+CONNECTION.uart] push [eax+CONNECTION.uart]
call destroy_kernel_object ;eax= object call DestroyObject ;eax= object
pop eax ;eax= uart pop eax ;eax= uart
test eax, eax test eax, eax
jz .fail jz .fail
@ -901,8 +934,9 @@ isr_modem:
align 4 align 4
com1 dd 0 divisor dw 2304, 1536, 1047, 857, 768, 384
com2 dd 0 dw 192, 96, 64, 58, 48, 32
dw 24, 16, 12, 6, 3, 2, 1
align 4 align 4
uart_func dd 0 ;SRV_GETVERSION uart_func dd 0 ;SRV_GETVERSION
@ -921,15 +955,12 @@ isr_action dd isr_modem
dd isr_recieve dd isr_recieve
dd isr_line dd isr_line
;version dd 0x00040000 version dd 0x00040000
divisor dw 2304, 1536, 1047, 857, 768, 384
dw 192, 96, 64, 58, 48, 32
dw 24, 16, 12, 6, 3, 2, 1
sz_uart_srv db 'UART',0 sz_uart_srv db 'UART',0
align 4
com1 rd 1
com2 rd 1

View File

@ -601,23 +601,24 @@ no_eventoccur5:
;mov edi,[TASK_BASE] ; IPC ;mov edi,[TASK_BASE] ; IPC
test [edi+TASKDATA.event_mask],dword 01000000b test [edi+TASKDATA.event_mask],dword 01000000b
jz no_ipc jz no_ipc
mov eax,[current_slot] mov eax, [CURRENT_TASK]
test [eax+APPDATA.event_mask],dword 01000000b shl eax, 8
test [eax+SLOT_BASE+APPDATA.event_mask],dword 01000000b
jz no_ipc jz no_ipc
and [eax+APPDATA.event_mask],dword 0xffffffff-01000000b and [eax+SLOT_BASE+APPDATA.event_mask],dword 0xffffffff-01000000b
popad popad
mov eax,7 mov eax,7
ret ret
no_ipc: no_ipc:
;mov edi,[TASK_BASE] ; STACK ;mov edi,[TASK_BASE] ; STACK
test [edi+TASKDATA.event_mask],dword 10000000b test [edi+TASKDATA.event_mask],dword 10000000b
jz no_stack_event jz no_stack_event
mov eax,[current_slot] mov eax, [CURRENT_TASK]
test [eax+APPDATA.event_mask],dword 10000000b shl eax, 8
test [eax+SLOT_BASE+APPDATA.event_mask],dword 10000000b
jz no_stack_event jz no_stack_event
and [eax+APPDATA.event_mask],dword 0xffffffff-10000000b and [eax+SLOT_BASE+APPDATA.event_mask],dword 0xffffffff-10000000b
popad popad
mov eax,8 mov eax,8
ret ret
@ -625,10 +626,11 @@ no_stack_event:
test byte [edi+TASKDATA.event_mask+1], 1 ; DEBUG test byte [edi+TASKDATA.event_mask+1], 1 ; DEBUG
jz .test_IRQ jz .test_IRQ
mov eax, [current_slot] mov eax, [CURRENT_TASK]
test byte [eax+APPDATA.event_mask+1], byte 1 shl eax, 8
test byte [eax+SLOT_BASE+APPDATA.event_mask+1], byte 1
jz .test_IRQ jz .test_IRQ
and byte [eax+APPDATA.event_mask+1], not 1 and byte [eax+SLOT_BASE+APPDATA.event_mask+1], not 1
popad popad
mov eax, 9 mov eax, 9
ret ret

View File

@ -1639,7 +1639,6 @@ sys_setup_err:
mov [esp+36],dword -1 mov [esp+36],dword -1
ret ret
align 4 align 4
sys_getsetup: sys_getsetup:
@ -3363,18 +3362,17 @@ mouse_not_active:
jz nobackgr jz nobackgr
mov [REDRAW_BACKGROUND],byte 2 mov [REDRAW_BACKGROUND],byte 2
call change_task call change_task
mov [draw_data+32 + RECT.left],dword 0 mov [draw_data+32 + RECT.left],dword 0
mov [draw_data+32 + RECT.top],dword 0 mov [draw_data+32 + RECT.top],dword 0
mov eax,[ScreenWidth] mov eax,[ScreenWidth]
mov ebx,[ScreenHeight] mov ebx,[ScreenHeight]
mov [draw_data+32 + RECT.right],eax mov [draw_data+32 + RECT.right],eax
mov [draw_data+32 + RECT.bottom],ebx mov [draw_data+32 + RECT.bottom],ebx
call drawbackground call drawbackground
mov [REDRAW_BACKGROUND],byte 0 mov [REDRAW_BACKGROUND],byte 0
mov [MOUSE_BACKGROUND],byte 0 mov [MOUSE_BACKGROUND],byte 0
nobackgr: nobackgr:
; system shutdown request ; system shutdown request
@ -3390,7 +3388,7 @@ mouse_not_active:
mov edx,OS_BASE+0x3040 mov edx,OS_BASE+0x3040
movzx ecx,byte [SYS_SHUTDOWN] movzx ecx,byte [SYS_SHUTDOWN]
add ecx,5 add ecx,5
markz: markz:
mov [edx+TASKDATA.state],byte 3 mov [edx+TASKDATA.state],byte 3
add edx,0x20 add edx,0x20
loop markz loop markz
@ -3404,14 +3402,14 @@ mouse_not_active:
cmp [SYS_SHUTDOWN],byte 0 cmp [SYS_SHUTDOWN],byte 0
je system_shutdown je system_shutdown
noshutdown: noshutdown:
mov eax,[TASK_COUNT] ; termination mov eax,[TASK_COUNT] ; termination
mov ebx,TASK_DATA+TASKDATA.state mov ebx,TASK_DATA+TASKDATA.state
mov esi,1 mov esi,1
newct: newct:
mov cl,[ebx] mov cl,[ebx]
cmp cl,byte 3 cmp cl,byte 3
jz terminate jz terminate
@ -3426,8 +3424,6 @@ mouse_not_active:
ret ret
; redraw screen ; redraw screen
redrawscreen: redrawscreen:

View File

@ -125,8 +125,9 @@ struc APPDATA
.bk_obj dd ? ;+60 .bk_obj dd ? ;+60
.saved_esp dd ? ;+64 .saved_esp dd ? ;+64
.io_map rd 2 ;+68 .io_map rd 2 ;+68
.dbg_state dd ? ;+76
db 52 dup(?) ;+76 db 48 dup(?) ;+80
.wnd_shape dd ? ;+128 .wnd_shape dd ? ;+128
.wnd_shape_scale dd ? ;+132 .wnd_shape_scale dd ? ;+132