系統 - VxWorks - 如何透過DBG Debug



參考資訊:
https://forums.windriver.com/t/vxworks-software-development-kit-sdk/43
https://d13321s3lxgewa.cloudfront.net/downloads/wrsdk-vxworks7-docs/2309/README_qemu.html

main.c

#include <stdio.h>
#include <iosLib.h>
 
int myProbe(void)
{
    printf("Test\n");
    return OK;
}

編譯

$ source ~/wrsdk-vxworks7-qemu/sdkenv.sh
$ wr-cc --version
    clang version 16.0.0.1

$ wr-cc main.c -o main -dkm -ggdb

啟動QEMU

$ cd
$ sudo python3 -m pyftpdlib -p 21 -u target -P vxTarget -i 127.0.0.1 -d $HOME -w

$ cd ~/wrsdk-vxworks7-qemu
$ qemu-system-x86_64 -m 512M -kernel vxsdk/bsps/itl_generic_3_0_0_3/vxWorks \
    -net nic -net user,hostfwd=tcp::1534-:1534,hostfwd=tcp::2345-:2345 \
    -display none -serial stdio -monitor none \
    -append "bootline:fs(0,0)host:vxWorks h=10.0.2.2 e=10.0.2.15 u=target pw=vxTarget o=gei0"

Debug DKM

-> ld < main
-> b myProbe
-> period 1,myProbe
    Break at 0xffffffff8c5a60a0: myProbe             Task: 0xffff8000001f9810 (t1)

-> l
                myProbe:
    0xffffffff8c5a60a0  55                      PUSH           %RBP
    0xffffffff8c5a60a1  48 89 e5                MOV            %RBP, %RSP
    0xffffffff8c5a60a4  48 c7 c7 b6 60 5a 8c    MOV            %RDI, $0x8c5a60b6
    0xffffffff8c5a60ab  31 c0                   XOR            %EAX, %EAX
    0xffffffff8c5a60ad  e8 de 3f 00 f4          CALL           printf
    0xffffffff8c5a60b2  31 c0                   XOR            %EAX, %EAX
    0xffffffff8c5a60b4  5d                      POP            %RBP
    0xffffffff8c5a60b5  c3                      RET            
    0xffffffff8c5a60b6  54                      PUSH           %RSP
    0xffffffff8c5a60b7  65 73 74                JNB            0xffffffff8c5a612f
    value = 0 = 0x0

-> so
    rax        = 0x0000000000000000   r8         = 0x0000000000000000
    rbx        = 0x0000000000000000   r9         = 0x0000000000000000
    rcx        = 0x0000000000000000   r10        = 0xffffffff8c5a60a0
    rdx        = 0x0000000000000000   r11        = 0x0000000000000000
    rsi        = 0x0000000000000000   r12        = 0x0000000000000000
    rdi        = 0x0000000000000000   r13        = 0x0000000000000000
    rsp        = 0xffff80000c2c2f10   r14        = 0x0000000000000000
    rbp        = 0xffff80000c2c2f70   r15        = 0x0000000000000000
    pc         = 0xffffffff8c5a60a1   eflags     = 0x0000000000000282
    tlsbase    = 0xffff80000c305fb0
    0xffffffff8c5a60a1  48 89 e5                MOV            %RBP, %RSP

-> c
    Test