Ctest and remote debugging

This commit is contained in:
Stefan Liebl 2023-03-08 15:45:12 +01:00
parent 4c68ea9d9d
commit 3e3df40bff

View File

@ -67,11 +67,9 @@ function s:ProjectSet(project_type, project_base_dir)
execute 'set path+=' . s:ProjectSrcDir.'/**' execute 'set path+=' . s:ProjectSrcDir.'/**'
execute 'set path+=' . g:ProjectBuildDir.'/**' execute 'set path+=' . g:ProjectBuildDir.'/**'
let s:oselas_include = '/sysroot-arm-cortexa8-linux-gnueabi/usr/include' let s:oselas_include = '/sysroot-arm-cortexa8-linux-gnueabi/usr/include'
" let s:oselas_gdb = '/opt/OSELAS.Toolchain-2018.12.0/arm-v7a-linux-gnueabi/gcc-8.2.1-glibc-2.28-binutils-2.31.1-kernel-3.6-sanitized/bin/arm-v7a-linux-gnueabi-gdb' let s:oselas_gdb_4 = '/opt/OSELAS.Toolchain-2012.12.1/arm-cortexa8-linux-gnueabi/gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized/bin/arm-cortexa8-linux-gnueabi-gdb'
let s:oselas_gdb = '/opt/OSELAS.Toolchain-2012.12.1/arm-cortexa8-linux-gnueabi/gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized/bin/arm-cortexa8-linux-gnueabi-gdb' let s:oselas_gdb = '/opt/OSELAS.Toolchain-2021.07.0/arm-v7a-linux-gnueabihf/gcc-11.1.1-clang-12.0.0-glibc-2.33-binutils-2.36.1-kernel-5.12.4-sanitized/bin/arm-v7a-linux-gnueabihf-gdb'
" let s:oselas_gdb = '/opt/OSELAS.Toolchain-2020.08.0/arm-v7a-linux-gnueabi/gcc-10.2.1-clang-10.0.1-glibc-2.32-binutils-2.35-kernel-5.8-sanitized/bin/arm-v7a-linux-gnueabi-gdb'
let s:jlink_path = '/home/stefan/opt/SEGGER/JLink_Linux_V654a_x86_64' let s:jlink_path = '/home/stefan/opt/SEGGER/JLink_Linux_V654a_x86_64'
" let s:jlink_path = '/home/stefan/opt/SEGGER/JLink_Linux_V688b_x86_64'
if (g:project_type == 'dlcpro') if (g:project_type == 'dlcpro')
let s:Program = '/device-control/device-control' let s:Program = '/device-control/device-control'
@ -79,9 +77,10 @@ function s:ProjectSet(project_type, project_base_dir)
let g:ProgramRemote = '/opt/app/bin/device-control' let g:ProgramRemote = '/opt/app/bin/device-control'
set wildignore-=**/firmware/src/device-control/** set wildignore-=**/firmware/src/device-control/**
set wildignore+=**/shg-firmware/** set wildignore+=**/shg-firmware/**
let s:makegoals = ['artifacts-firmware', 'artifacts', 'device-control', 'user-interface', 'doxygen', 'fw-updates', 'shg-firmware', 'can-updater', 'specalyser', 'docu-ul0', 'code-generation', 'dependency-graphs', 'clean', 'distclean', 'help', 'jamplayer', 'dlcpro-slot'] let s:makegoals = ['artifacts-firmware', 'artifacts', 'device-control', 'user-interface', 'doxygen', 'fw-updates', 'shg-firmware', 'can-updater', 'specalyser', 'docu-ul0', 'code-generation', 'dependency-graphs', 'decof', 'decof-sdk', 'clean', 'distclean', 'help', 'jamplayer', 'dlcpro-slot']
let s:makeprg = 'make' let s:makeprg = 'make'
let g:DeviceIP = 'DLC_PRO__040083' let g:DeviceIP = 'DLC_PRO__040083'
let g:DebugRemote = v:true
let g:GdbPort = '2345' let g:GdbPort = '2345'
let g:GccRoot = "/opt/OSELAS.Toolchain-2012.12.1/arm-cortexa8-linux-gnueabi/gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized" let g:GccRoot = "/opt/OSELAS.Toolchain-2012.12.1/arm-cortexa8-linux-gnueabi/gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized"
let g:termdebugger = s:oselas_gdb let g:termdebugger = s:oselas_gdb
@ -102,6 +101,7 @@ function s:ProjectSet(project_type, project_base_dir)
let s:makegoals = ['artifacts-firmware', 'artifacts', 'device-control', 'user-interface', 'doxygen', 'fw-updates', 'shg-firmware', 'can-updater', 'specalyser', 'docu-ul0', 'code-generation', 'dependency-graphs', 'clean', 'distclean', 'help', 'jamplayer', 'dlcpro-slot'] let s:makegoals = ['artifacts-firmware', 'artifacts', 'device-control', 'user-interface', 'doxygen', 'fw-updates', 'shg-firmware', 'can-updater', 'specalyser', 'docu-ul0', 'code-generation', 'dependency-graphs', 'clean', 'distclean', 'help', 'jamplayer', 'dlcpro-slot']
let s:makeprg = 'make' let s:makeprg = 'make'
let g:DeviceIP = 'DLC_PRO__040083' let g:DeviceIP = 'DLC_PRO__040083'
let g:DebugRemote = v:true
let g:GdbPort = '2345' let g:GdbPort = '2345'
let g:GccRoot = "/opt/OSELAS.Toolchain-2012.12.1/arm-cortexa8-linux-gnueabi/gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized" let g:GccRoot = "/opt/OSELAS.Toolchain-2012.12.1/arm-cortexa8-linux-gnueabi/gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized"
let g:termdebugger = s:oselas_gdb let g:termdebugger = s:oselas_gdb
@ -119,6 +119,7 @@ function s:ProjectSet(project_type, project_base_dir)
let s:makegoals = [] let s:makegoals = []
let s:makeprg = 'make' let s:makeprg = 'make'
let g:DeviceIP = 'DLC_PRO__040083' let g:DeviceIP = 'DLC_PRO__040083'
let g:DebugRemote = v:true
let g:GdbPort = '2345' let g:GdbPort = '2345'
let g:GccRoot = "/opt/OSELAS.Toolchain-2012.12.1/arm-cortexa8-linux-gnueabi/gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized" let g:GccRoot = "/opt/OSELAS.Toolchain-2012.12.1/arm-cortexa8-linux-gnueabi/gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized"
let g:termdebugger = s:oselas_gdb let g:termdebugger = s:oselas_gdb
@ -136,6 +137,7 @@ function s:ProjectSet(project_type, project_base_dir)
let s:makegoals = [] let s:makegoals = []
let s:makeprg = 'make' let s:makeprg = 'make'
let g:DeviceIP = 'DLC_PRO__040083' let g:DeviceIP = 'DLC_PRO__040083'
let g:DebugRemote = v:true
let g:GdbPort = '2345' let g:GdbPort = '2345'
let g:GccRoot = "/opt/OSELAS.Toolchain-2012.12.1/arm-cortexa8-linux-gnueabi/gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized" let g:GccRoot = "/opt/OSELAS.Toolchain-2012.12.1/arm-cortexa8-linux-gnueabi/gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized"
let g:termdebugger = s:oselas_gdb let g:termdebugger = s:oselas_gdb
@ -153,11 +155,12 @@ function s:ProjectSet(project_type, project_base_dir)
let s:makegoals = ['artifacts-firmware', 'artifacts', 'device-control', 'user-interface', 'doxygen', 'fw-updates', 'shg-firmware', 'can-updater', 'specalyser', 'docu-ul0', 'code-generation', 'dependency-graphs', 'clean', 'distclean', 'help', 'jamplayer', 'dlcpro-slot'] let s:makegoals = ['artifacts-firmware', 'artifacts', 'device-control', 'user-interface', 'doxygen', 'fw-updates', 'shg-firmware', 'can-updater', 'specalyser', 'docu-ul0', 'code-generation', 'dependency-graphs', 'clean', 'distclean', 'help', 'jamplayer', 'dlcpro-slot']
let s:makeprg = 'make' let s:makeprg = 'make'
let g:DeviceIP = 'DLC_PRO__040083' let g:DeviceIP = 'DLC_PRO__040083'
let g:DebugRemote = v:true
let g:GdbPort = '6666' let g:GdbPort = '6666'
let g:GccRoot = "/opt/OSELAS.Toolchain-2012.12.1/arm-cortexa8-linux-gnueabi/gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized" let g:GccRoot = "/opt/OSELAS.Toolchain-2012.12.1/arm-cortexa8-linux-gnueabi/gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized"
let g:termdebugger = s:oselas_gdb let g:termdebugger = s:oselas_gdb
execute 'ConqueGdbExe '.g:GccRoot.'/bin/arm-cortexa8-linux-gnueabi-gdb' execute 'ConqueGdbExe '.g:GccRoot.'/bin/arm-cortexa8-linux-gnueabi-gdb'
let g:SshOpts = '-o ForwardAgent=yes -o ProxyCommand="ssh -q -W shg:22 root@%h" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR' let g:SshOpts = '-o ForwardAgent=yes -o ProxyCommand="ssh -o RemoteCommand=none -q -W shg:22 root@%h" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR'
let g:SshOpts2 = "-L localhost:1998:localhost:1998 -L localhost:1999:localhost:1999" let g:SshOpts2 = "-L localhost:1998:localhost:1998 -L localhost:1999:localhost:1999"
execute 'set path+=' . g:GccRoot . s:oselas_include execute 'set path+=' . g:GccRoot . s:oselas_include
" let g:ycm_clangd_args = ['-I'.g:GccRoot . s:oselas_include] " let g:ycm_clangd_args = ['-I'.g:GccRoot . s:oselas_include]
@ -167,6 +170,7 @@ function s:ProjectSet(project_type, project_base_dir)
let s:makegoals = [] let s:makegoals = []
let s:makeprg = 'make' let s:makeprg = 'make'
let g:termdebugger = 'gdb' let g:termdebugger = 'gdb'
let g:DebugRemote = v:false
elseif (g:project_type == 'topmode') elseif (g:project_type == 'topmode')
let s:Program = '/topmode' let s:Program = '/topmode'
let s:Elffile = s:Program let s:Elffile = s:Program
@ -174,6 +178,7 @@ function s:ProjectSet(project_type, project_base_dir)
let s:makegoals = [] let s:makegoals = []
let s:makeprg = 'make' let s:makeprg = 'make'
let g:DeviceIP = 'topmode_stefan' let g:DeviceIP = 'topmode_stefan'
let g:DebugRemote = v:true
let g:GdbPort = '2345' let g:GdbPort = '2345'
let g:GccRoot = "/opt/OSELAS.Toolchain-2011.11.3/arm-cortexa8-linux-gnueabi/gcc-4.6.2-glibc-2.14.1-binutils-2.21.1a-kernel-2.6.39-sanitized" let g:GccRoot = "/opt/OSELAS.Toolchain-2011.11.3/arm-cortexa8-linux-gnueabi/gcc-4.6.2-glibc-2.14.1-binutils-2.21.1a-kernel-2.6.39-sanitized"
let g:termdebugger = s:oselas_gdb let g:termdebugger = s:oselas_gdb
@ -188,11 +193,13 @@ function s:ProjectSet(project_type, project_base_dir)
let s:makegoals = [] let s:makegoals = []
let s:makeprg = 'make' let s:makeprg = 'make'
let g:termdebugger = 'gdb' let g:termdebugger = 'gdb'
let g:DebugRemote = v:false
elseif (g:project_type == 'digifalc') elseif (g:project_type == 'digifalc')
let s:Program = '/digifalc-image.bin' let s:Program = '/digifalc-image.bin'
let s:Elffile = '/application/digifalc.elf' let s:Elffile = '/application/digifalc.elf'
let s:makegoals = ['firmware-update', 'html-docs', 'doxygen', 'digifalc.elf', 'bootloader.elf'] let s:makegoals = ['firmware-update', 'html-docs', 'doxygen', 'digifalc.elf', 'bootloader.elf']
let s:makeprg = 'cmake --build . --target' let s:makeprg = 'cmake --build . --target'
let g:DebugRemote = v:true
let g:GdbPort = '2331' let g:GdbPort = '2331'
let g:GccRoot = '/opt/gcc-arm-none-eabi-8-2019-q3-update' let g:GccRoot = '/opt/gcc-arm-none-eabi-8-2019-q3-update'
let g:termdebugger = g:GccRoot.'/bin/arm-none-eabi-gdb' let g:termdebugger = g:GccRoot.'/bin/arm-none-eabi-gdb'
@ -202,6 +209,7 @@ function s:ProjectSet(project_type, project_base_dir)
let s:Elffile = '/application/servo-board.elf' let s:Elffile = '/application/servo-board.elf'
let s:makegoals = ['firmware-update', 'html-docs', 'doxygen', 'servo-board.elf', 'bootloader.elf'] let s:makegoals = ['firmware-update', 'html-docs', 'doxygen', 'servo-board.elf', 'bootloader.elf']
let s:makeprg = 'cmake --build . --target' let s:makeprg = 'cmake --build . --target'
let g:DebugRemote = v:true
let g:GdbPort = '2331' let g:GdbPort = '2331'
let g:GccRoot = '/home/stefan/opt/gcc/gcc-arm-none-eabi-8-2019-q3-update' let g:GccRoot = '/home/stefan/opt/gcc/gcc-arm-none-eabi-8-2019-q3-update'
let g:termdebugger = g:GccRoot.'/bin/arm-none-eabi-gdb' let g:termdebugger = g:GccRoot.'/bin/arm-none-eabi-gdb'
@ -211,6 +219,7 @@ function s:ProjectSet(project_type, project_base_dir)
let s:Elffile = '/application/dl-motor.elf' let s:Elffile = '/application/dl-motor.elf'
let s:makegoals = ['firmware-update', 'html-docs', 'doxygen', 'dl-motor.elf', 'bootloader.elf'] let s:makegoals = ['firmware-update', 'html-docs', 'doxygen', 'dl-motor.elf', 'bootloader.elf']
let s:makeprg = 'cmake --build . --target' let s:makeprg = 'cmake --build . --target'
let g:DebugRemote = v:true
let g:GdbPort = '2331' let g:GdbPort = '2331'
let g:GccRoot = '/home/stefan/opt/gcc/gcc-arm-none-eabi-9-2020-q2-update' let g:GccRoot = '/home/stefan/opt/gcc/gcc-arm-none-eabi-9-2020-q2-update'
let g:termdebugger = g:GccRoot.'/bin/arm-none-eabi-gdb' let g:termdebugger = g:GccRoot.'/bin/arm-none-eabi-gdb'
@ -221,6 +230,7 @@ function s:ProjectSet(project_type, project_base_dir)
let s:Elffile = '/firmware/operation_panel_'.g:stm32_target.'.elf' let s:Elffile = '/firmware/operation_panel_'.g:stm32_target.'.elf'
let s:makegoals = ['artifacts'] let s:makegoals = ['artifacts']
let s:makeprg = 'cmake --build . --target' let s:makeprg = 'cmake --build . --target'
let g:DebugRemote = v:true
let g:GdbPort = '3333' let g:GdbPort = '3333'
let g:GccRoot = '/home/stefan/opt/gcc/gcc-arm-none-eabi-9-2020-q2-update' let g:GccRoot = '/home/stefan/opt/gcc/gcc-arm-none-eabi-9-2020-q2-update'
let g:termdebugger = g:GccRoot.'/bin/arm-none-eabi-gdb' let g:termdebugger = g:GccRoot.'/bin/arm-none-eabi-gdb'
@ -232,6 +242,7 @@ function s:ProjectSet(project_type, project_base_dir)
let s:Elffile = '/firmware/operation_panel_'.g:stm32_target.'.elf' let s:Elffile = '/firmware/operation_panel_'.g:stm32_target.'.elf'
let s:makegoals = ['artifacts'] let s:makegoals = ['artifacts']
let s:makeprg = 'cmake --build . --target' let s:makeprg = 'cmake --build . --target'
let g:DebugRemote = v:true
let g:GdbPort = '3333' let g:GdbPort = '3333'
let g:GccRoot = '/home/stefan/opt/gcc/gcc-arm-none-eabi-9-2020-q2-update' let g:GccRoot = '/home/stefan/opt/gcc/gcc-arm-none-eabi-9-2020-q2-update'
let g:termdebugger = g:GccRoot.'/bin/arm-none-eabi-gdb' let g:termdebugger = g:GccRoot.'/bin/arm-none-eabi-gdb'
@ -240,6 +251,7 @@ function s:ProjectSet(project_type, project_base_dir)
elseif (g:project_type == 'decof') elseif (g:project_type == 'decof')
let s:makegoals = ['all'] let s:makegoals = ['all']
let s:makeprg = 'cmake --build . --target' let s:makeprg = 'cmake --build . --target'
let g:DebugRemote = v:false
else else
echo "no project" echo "no project"
endif endif
@ -263,12 +275,16 @@ function s:ProjectSet(project_type, project_base_dir)
command! -complete=custom,GetAllMakeCompletions -nargs=* MakeCmd call s:Make('<args>', 0) command! -complete=custom,GetAllMakeCompletions -nargs=* MakeCmd call s:Make('<args>', 0)
command! MakeTestBuild call s:MakeTestBuild() command! MakeTestBuild call s:MakeTestBuild()
command! -nargs=* Ctest call s:Ctest('<args>', 0) command! -nargs=* Ctest call s:Ctest('<args>', 0)
command! -nargs=1 MakeCheck call s:MakeCheck('<args>', 0) command! -nargs=* Ctest1 call s:Ctest1('<args>', 0)
command! -nargs=* Ctest2 call s:Ctest2('<args>', 0)
command! -nargs=* Ctest3 call s:Ctest3('<args>', 0)
command! -nargs=? MakeCheck call s:MakeCheck('<args>', 0)
" cmake " cmake
command! -nargs=1 -complete=custom,CmakeBuildTypes Cmake call s:Cmake('<args>', 0) command! -nargs=1 -complete=custom,CmakeBuildTypes Cmake call s:Cmake('<args>', 0)
function! CmakeBuildTypes(ArgLead, CmdLine, CorsorPos) function! CmakeBuildTypes(ArgLead, CmdLine, CorsorPos)
return join(['Debug', 'RelWithDebInfo'], "\n") return join(['Debug', 'RelWithDebInfo'], "\n")
" return join(['Debug', 'RelWithDebInfo', '-DHARDWARE_DLCSMART=ON'], "\n")
endfunction endfunction
" configure quickfix window for asyncrun " configure quickfix window for asyncrun
@ -306,6 +322,8 @@ function s:ProjectSet(project_type, project_base_dir)
" little helpers " little helpers
command! -nargs=? BuildDirStash call s:BuildDirStash('<args>') command! -nargs=? BuildDirStash call s:BuildDirStash('<args>')
command! -complete=custom,GetAllStashedBuildDirs -nargs=? BuildDirUnStash call s:BuildDirUnStash('<args>') command! -complete=custom,GetAllStashedBuildDirs -nargs=? BuildDirUnStash call s:BuildDirUnStash('<args>')
let $QT_FONT_DPI=96 " Size for qt-application in debugger
endfunction endfunction
@ -332,10 +350,18 @@ function s:MakeTestBuild()
call s:BuildDirUnStash('save') call s:BuildDirUnStash('save')
endfunction endfunction
function s:MakeCheck(args, async_mode) function s:MakeCheck(filename, async_mode)
let &makeprg = s:ProjectSrcDir.'/tools/static-check.py' let &makeprg = s:ProjectSrcDir.'/tools/static-check.py'
call asyncrun#quickfix_toggle(10, 1) call asyncrun#quickfix_toggle(10, 1)
execute 'AsyncRun -mode='.a:async_mode.' -save=2 -program=make -cwd='.g:ProjectBuildDir. ' @ --infile='.a:args if a:filename != ''
let args = '--infile='.a:filename
else
let args = '--infile=%'
endif
if exists("g:analyser")
let args .= ' --analyser='.g:analyser
endif
execute 'AsyncRun -mode='.a:async_mode.' -save=2 -program=make -cwd='.g:ProjectBuildDir. ' @ '.args
endfunction endfunction
function s:Cmake(build_type, async_mode) function s:Cmake(build_type, async_mode)
@ -377,9 +403,52 @@ function s:Cmake(build_type, async_mode)
endfunction endfunction
function s:Ctest(args, async_mode) function s:Ctest(args, async_mode)
let cmd = 'ctest --build-and-test ./src unit-tests --build-generator "Unix Makefiles" --build-target unit_tests --nocompress-output -T Test --build-options -DCMAKE_BUILD_TYPE=Debug --test-command ctest' let cmd = 'ctest --build-and-test ../src . --build-generator "Unix Makefiles" --build-target unit_tests --nocompress-output -T Test --build-options -DCMAKE_BUILD_TYPE=Debug --test-command ctest'
call asyncrun#quickfix_toggle(10, 1) call asyncrun#quickfix_toggle(10, 1)
execute 'AsyncRun -mode='.a:async_mode.' -save=2 -cwd='.s:ProjectBaseDir.' @ ' . cmd .' '. a:args execute 'AsyncRun -mode='.a:async_mode.' -save=2 -cwd='.s:ProjectBaseDir.'/unit-tests @ ' . cmd .' '. a:args
endfunction
function s:Ctestx(args, async_mode)
let unit_test_dirname = 'unit-tests'
let unit_test_dir = s:ProjectBaseDir . '/' . unit_test_dirname
if !isdirectory('./unit-tests')
call mkdir('./unit-tests')
endif
let cmake_cmd = 'cmake --build-generator "Unix Makefiles" --build-target unit_tests -DCMAKE_BUILD_TYPE=Debug ../'.g:ProjectSrcDirRel
let build_cmd = 'cmake --build . -j --target unit_tests'
let ctest_cmd = 'ctest --nocompress-output -T Test'
call asyncrun#quickfix_toggle(10, 1)
execute 'AsyncRun -mode=1 -save=2 -cwd='.unit_test_dir.' @ ' . cmake_cmd
execute 'AsyncRun -mode=1 -save=2 -cwd='.unit_test_dir.' @ ' . build_cmd
execute 'AsyncRun -mode='.a:async_mode.' -save=2 -cwd='.unit_test_dir.' @ ' . ctest_cmd .' '. a:args
endfunction
function s:Ctest1(args, async_mode)
let unit_test_dirname = 'unit-tests'
let unit_test_dir = s:ProjectBaseDir . '/' . unit_test_dirname
if !isdirectory(unit_test_dir)
call mkdir(unit_test_dir)
endif
call asyncrun#quickfix_toggle(10, 1)
" let cmake_cmd = 'cmake --build-generator "Unix Makefiles" --build-target unit_tests -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=ON ../'.g:ProjectSrcDirRel . ' '. a:args
let cmake_cmd = 'cmake -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=ON ../'.g:ProjectSrcDirRel . ' '. a:args
execute 'AsyncRun -mode=1 -save=2 -cwd='.unit_test_dir.' @ ' . cmake_cmd
endfunction
function s:Ctest2(args, async_mode)
let unit_test_dirname = 'unit-tests'
let unit_test_dir = s:ProjectBaseDir . '/' . unit_test_dirname
let build_cmd = 'cmake --build . -j --target unit_tests ' . a:args
call asyncrun#quickfix_toggle(10, 1)
execute 'AsyncRun -mode=1 -save=2 -cwd='.unit_test_dir.' @ ' . build_cmd
endfunction
function s:Ctest3(args, async_mode)
let unit_test_dirname = 'unit-tests'
let unit_test_dir = s:ProjectBaseDir . '/' . unit_test_dirname
let ctest_cmd = 'ctest --nocompress-output -T Test'
call asyncrun#quickfix_toggle(10, 1)
execute 'AsyncRun -mode='.a:async_mode.' -save=2 -cwd='.unit_test_dir.' @ ' . ctest_cmd .' '. a:args
endfunction endfunction
function s:Call_and_log(cmd) function s:Call_and_log(cmd)
@ -402,11 +471,11 @@ endfunction
"endfunction "endfunction
function s:DlcproEmission(state) function s:DlcproEmission(state)
call s:Call_and_log('ssh '.g:SshOpts.' root@'.g:DeviceIP.' "echo '.a:state.' > /sys/bus/i2c/devices/200-0028/emission_button_state"') call s:Call_and_log('ssh -o RemoteCommand=none '.g:SshOpts.' root@'.g:DeviceIP.' "echo '.a:state.' > /sys/bus/i2c/devices/200-0028/emission_button_state"')
endfunction endfunction
function s:DlcproShutup() function s:DlcproShutup()
call s:Call_and_log('ssh '.g:SshOpts.' root@'.g:DeviceIP.' "modprobe -r tam3517_buzzer"') call s:Call_and_log('ssh -o RemoteCommand=none '.g:SshOpts.' root@'.g:DeviceIP.' "modprobe -r tam3517_buzzer"')
endfunction endfunction
function s:JLinkFlashProgram() function s:JLinkFlashProgram()
@ -414,11 +483,11 @@ function s:JLinkFlashProgram()
endfunction endfunction
function s:DeviceUpdateProgramLinux() function s:DeviceUpdateProgramLinux()
call s:Call_and_log('ssh '.g:SshOpts.' root@'.g:DeviceIP.' "killall -q gdbserver start-dc.sh '.fnamemodify(g:ProgramRemote, ':t').'"') call s:Call_and_log('ssh -o RemoteCommand=none '.g:SshOpts.' root@'.g:DeviceIP.' "killall -q gdbserver start-dc.sh '.fnamemodify(g:ProgramRemote, ':t').'"')
sleep 2 sleep 2
" call s:Call_and_log('ssh '.g:SshOpts.' root@'.g:DeviceIP.' "killall -q -9 gdbserver start-dc.sh '.g:ProgramRemote.'"') " call s:Call_and_log('ssh -o RemoteCommand=none '.g:SshOpts.' root@'.g:DeviceIP.' "killall -q -9 gdbserver start-dc.sh '.g:ProgramRemote.'"')
call s:Call_and_log('ssh '.g:SshOpts.' root@'.g:DeviceIP.' "killall -q -9 gdbserver start-dc.sh '.fnamemodify(g:ProgramRemote, ':t').'"') call s:Call_and_log('ssh -o RemoteCommand=none '.g:SshOpts.' root@'.g:DeviceIP.' "killall -q -9 gdbserver start-dc.sh '.fnamemodify(g:ProgramRemote, ':t').'"')
let r = s:Call_and_log('ssh '.g:SshOpts.' root@'.g:DeviceIP.' "mount -o rw,remount / && rm -f '.g:ProgramRemote.'" && scp '.g:SshOpts.' "'.g:Program.'" "root@'.g:DeviceIP.':'.g:ProgramRemote.'"') let r = s:Call_and_log('ssh -o RemoteCommand=none '.g:SshOpts.' root@'.g:DeviceIP.' "mount -o rw,remount / && rm -f '.g:ProgramRemote.'" && scp '.g:SshOpts.' "'.g:Program.'" "root@'.g:DeviceIP.':'.g:ProgramRemote.'"')
return r return r
endfunction endfunction
@ -426,24 +495,21 @@ function s:DeviceFirmwareUpdateStartLinux()
let r = s:DeviceUpdateProgramLinux() let r = s:DeviceUpdateProgramLinux()
if (r == 0) if (r == 0)
let workdir = 'cd /opt/app &&' let workdir = 'cd /opt/app &&'
call s:Call_and_log('ssh '.g:SshOpts.' -f root@'.g:DeviceIP.' "{ '.workdir.' '.g:ProgramRemote.' 2>&1 | logger -t "'.g:ProgramRemote.'" -p user.err; } &"') call s:Call_and_log('ssh -o RemoteCommand=none '.g:SshOpts.' -f root@'.g:DeviceIP.' "{ '.workdir.' '.g:ProgramRemote.' 2>&1 | logger -t "'.g:ProgramRemote.'" -p user.err; } &"')
endif endif
endfunction endfunction
function s:DeviceStartGdbServer() function s:DeviceStartGdbServer()
if ((g:project_type == 'digifalc') || (g:project_type == 'servoboard') || (g:project_type == 'dl-motor')) if ((g:project_type == 'digifalc') || (g:project_type == 'servoboard') || (g:project_type == 'dl-motor'))
call s:Call_and_log('pkill --full JLinkGDBServer') call s:Call_and_log('pkill --full JLinkGDBServer')
" call s:Call_and_log('/opt/SEGGER/JLink/JLinkGDBServer -if SWD -device STM32H743XI &')
" call s:Call_and_log('/opt/SEGGER/JLink/JLinkGDBServer -if SWD -device STM32H743ZI2 &')
" call s:Call_and_log('/opt/SEGGER/JLink/JLinkGDBServer -if SWD -device STM32H743ZI &')
call s:Call_and_log(s:jlink_path.'/JLinkGDBServer -if SWD -device STM32H743ZI &') call s:Call_and_log(s:jlink_path.'/JLinkGDBServer -if SWD -device STM32H743ZI &')
elseif ((g:project_type == 'operation-panel-f1') || (g:project_type == 'operation-panel-f4')) elseif ((g:project_type == 'operation-panel-f1') || (g:project_type == 'operation-panel-f4'))
call s:Call_and_log('pkill --full openocd') call s:Call_and_log('pkill --full openocd')
call s:Call_and_log('openocd -f interface/stlink.cfg -f target/'.s:stm_cfg.'.cfg &') call s:Call_and_log('openocd -f interface/stlink.cfg -f target/'.s:stm_cfg.'.cfg &')
else else
call s:Call_and_log('pkill --full gdbserver') call s:Call_and_log('pkill --full gdbserver')
call s:Call_and_log('ssh '.g:SshOpts.' root@'.g:DeviceIP.' "killall -q -9 gdbserver start-dc.sh '.fnamemodify(g:ProgramRemote, ':t').'"') call s:Call_and_log('ssh -o RemoteCommand=none '.g:SshOpts.' root@'.g:DeviceIP.' "killall -q -9 gdbserver start-dc.sh '.fnamemodify(g:ProgramRemote, ':t').'"')
call s:Call_and_log('ssh '.g:SshOpts.' -L localhost:'.g:GdbPort.':localhost:'.g:GdbPort.' "root@'.g:DeviceIP.'" '.g:SshOpts2.' gdbserver --multi localhost:'.g:GdbPort.' &') call s:Call_and_log('ssh -o RemoteCommand=none '.g:SshOpts.' -L localhost:'.g:GdbPort.':localhost:'.g:GdbPort.' "root@'.g:DeviceIP.'" '.g:SshOpts2.' gdbserver --multi localhost:'.g:GdbPort.' &')
endif endif
endfunction endfunction
@ -451,13 +517,12 @@ function s:DeviceStartGdbServerAttach()
if ((g:project_type == 'digifalc') || (g:project_type == 'servoboard') || (g:project_type == 'dl-motor')) if ((g:project_type == 'digifalc') || (g:project_type == 'servoboard') || (g:project_type == 'dl-motor'))
else else
call s:Call_and_log('pkill --full gdbserver') call s:Call_and_log('pkill --full gdbserver')
call s:Call_and_log('ssh '.g:SshOpts.' -L localhost:'.g:GdbPort.':localhost:'.g:GdbPort.' "root@'.g:DeviceIP.'" '.g:SshOpts2.' "gdbserver localhost:'.g:GdbPort.' --attach \`pidof '.fnamemodify(g:ProgramRemote, ':t').'\` &"') call s:Call_and_log('ssh -o RemoteCommand=none '.g:SshOpts.' -L localhost:'.g:GdbPort.':localhost:'.g:GdbPort.' "root@'.g:DeviceIP.'" '.g:SshOpts2.' "gdbserver localhost:'.g:GdbPort.' --attach \`pidof '.fnamemodify(g:ProgramRemote, ':t').'\` &"')
endif endif
endfunction endfunction
function s:SendToTerm(command) function s:SendToTerm(command)
call term_sendkeys('', a:command . "\n") call term_sendkeys('', a:command . "\n")
sleep 1
endfunction endfunction
function s:SendToConque(command) function s:SendToConque(command)
@ -465,7 +530,7 @@ function s:SendToConque(command)
endfunction endfunction
function s:SendToDebugger(command) function s:SendToDebugger(command)
if ((g:project_type == 'digifalc') || (g:project_type == 'servoboard') || (g:project_type == 'dl-motor') || (g:project_type == 'operation-panel-f1') || (g:project_type == 'operation-panel-f4')) if !exists("s:UseConqueGdb")
call s:SendToTerm(a:command) call s:SendToTerm(a:command)
else else
call s:SendToConque(a:command) call s:SendToConque(a:command)
@ -473,13 +538,14 @@ function s:SendToDebugger(command)
endfunction endfunction
function s:StartDebugger(elffile, attach) function s:StartDebugger(elffile, attach)
if ((g:project_type == 'dlcpro-gui') ||(g:project_type == 'digifalc') || (g:project_type == 'servoboard') || (g:project_type == 'dl-motor') || (g:project_type == 'operation-panel-f1') || (g:project_type == 'operation-panel-f4')) if !exists("s:UseConqueGdb")
if (a:attach == 0) if (a:attach == 0)
Termdebug Termdebug
else else
execute 'Termdebug ' . a:elffile execute 'Termdebug ' . a:elffile
endif endif
else else
echom 'Using ConqueGdb'
if (a:attach == 0) if (a:attach == 0)
ConqueGdbTab ConqueGdbTab
else else
@ -496,32 +562,34 @@ function s:DeviceDebug(attach)
if (r != 0) if (r != 0)
echoerr "DeviceFirmwareUpdate() failed!" echoerr "DeviceFirmwareUpdate() failed!"
else else
sleep 2 if (g:DebugRemote == v:false)
call s:DeviceStartGdbServer() call s:StartDebugger(g:Elffile, a:attach)
sleep 2 call s:SendToDebugger('file '.g:Elffile)
call s:StartDebugger(g:Elffile, a:attach)
" call s:SendToDebugger('')
call s:SendToDebugger('target extended-remote localhost:'.g:GdbPort)
if exists("g:ProgramRemote")
call s:SendToDebugger('set remote exec-file '.g:ProgramRemote)
endif
call s:SendToDebugger('file '.g:Elffile)
" call s:SendToDebugger('y')
sleep 3
if ((g:project_type == 'operation-panel-f1') || (g:project_type == 'operation-panel-f4'))
call s:SendToDebugger('y')
call s:SendToDebugger('monitor reset')
call s:SendToDebugger('load')
call s:SendToDebugger('break main')
else
call s:SendToDebugger('break main') call s:SendToDebugger('break main')
call s:SendToDebugger('run') call s:SendToDebugger('run')
" call s:SendToDebugger('y') else
call s:DeviceStartGdbServer()
sleep 1
call s:StartDebugger(g:Elffile, a:attach)
call s:SendToDebugger('target extended-remote localhost:'.g:GdbPort)
if exists("g:ProgramRemote")
call s:SendToDebugger('set remote exec-file '.g:ProgramRemote)
endif
call s:SendToDebugger('file '.g:Elffile)
if ((g:project_type == 'operation-panel-f1') || (g:project_type == 'operation-panel-f4'))
call s:SendToDebugger('y')
call s:SendToDebugger('monitor reset')
call s:SendToDebugger('load')
call s:SendToDebugger('break main')
else
call s:SendToDebugger('break main')
call s:SendToDebugger('run')
endif
execute '2hide'
endif endif
endif endif
else else
call s:DeviceStartGdbServerAttach() call s:DeviceStartGdbServerAttach()
sleep 1
call s:StartDebugger(a:attach) call s:StartDebugger(a:attach)
call s:SendToDebugger('target remote localhost:'.g:GdbPort) call s:SendToDebugger('target remote localhost:'.g:GdbPort)
" get remote src path with gdb: info sources or gdb: break main " get remote src path with gdb: info sources or gdb: break main
@ -590,7 +658,7 @@ function s:DlcproRegtestCmd(ip, powerswitch_ip, powerplug, laser_count, laser_ty
let archive_dir = g:ProjectBuildDir."/artifacts" let archive_dir = g:ProjectBuildDir."/artifacts"
let license_builddir = s:ProjectBaseDir.'/build.license' let license_builddir = s:ProjectBaseDir.'/build.license'
let licensetool = license_builddir."/libdlcprolicense/dlcprolicense-tool" let licensetool = license_builddir."/dlcprolicense-tool/dlcprolicense-tool"
let $JENKINS_URL = g:jenkins_url let $JENKINS_URL = g:jenkins_url
let test_cmd = let test_cmd =