通过gdb在Windows上的Windows上运行ctest.exe,该gdb通过CMAKE_CROSSCOMPILING_EMULATOR在远程目标上运行

时间:2019-07-15 13:38:31

标签: c++ gdb qnx

我在装有QNX的Windows机器上运行。我已经设置了ctest,以便它通过plink.exe在远程计算机上运行我的单元测试。我想设置一个远程调试器,该调试器在主机上启动ctest,然后将其附加到远程计算机上进行调试。

该测试通过CMAKE_CROSSCOMPILING_EMULATOR通过cmake运行:

set(CMAKE_CROSSCOMPILING_EMULATOR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/runtest.bat" "${CROSSCOMPILING_EMULATOR_IP}" "${CMAKE_BINARY_DIR}")

runtest.bat中的相关行是:

plink.exe "-batch" "-pw" "qnxuser" "qnxuser@%IP%" ".%testfile% %ARGS%"

我需要在gdb.exe中执行哪些调用才能将目标文件附加到调试器?

我已经找到了如何通过gdb.exe直接调用远程进程的方法,但是我可以先调用Windows可执行文件然后附加到远程进程吗?

这些是我在cmake中的宏文件,用于设置单元测试并将其部署到目标:

include(GoogleTest)

# This macro is added on the test targets
macro(gtest_qnx_add_target TARGETNAME)

gtest_qnx_copy_target( ${TARGETNAME} )
gtest_add_tests(TARGET ${TARGETNAME} TEST_LIST ${TARGETNAME}_TESTS)

file(RELATIVE_PATH TARGET_DIR ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
set_tests_properties(${${TARGETNAME}_TESTS} PROPERTIES FIXTURES_REQUIRED TEST_COLLECTION)

endmacro()

macro(gtest_qnx_copy_target TARGETNAME)

gtest_qnx_copy_file(${TARGETNAME} $<TARGET_FILE_NAME:${TARGETNAME}>)

endmacro()

macro(gtest_qnx_copy_file TARGETNAME FILENAME)

file(RELATIVE_PATH TARGET_DIR ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
add_test(NAME MKDIR_${TARGETNAME} COMMAND "plink.exe" "-batch" "-pw" "qnxuser" "qnxuser@${CROSSCOMPILING_EMULATOR_IP}" ". /etc/profile;mkdir -p ./${TARGET_DIR}")
add_test(NAME COPY_${TARGETNAME} COMMAND "pscp.exe" "-batch" "-pw" "qnxuser" "${FILENAME}" "qnxuser@${CROSSCOMPILING_EMULATOR_IP}:./${TARGET_DIR}")
add_test(NAME CHMOD_${TARGETNAME} COMMAND "plink.exe" "-batch" "-pw" "qnxuser" "qnxuser@${CROSSCOMPILING_EMULATOR_IP}" ". /etc/profile;chmod u+x ./${TARGET_DIR}/${FILENAME}")
add_test(NAME REMOVE_${TARGETNAME} COMMAND "plink.exe" "-batch" "-pw" "qnxuser" "qnxuser@${CROSSCOMPILING_EMULATOR_IP}" ". /etc/profile;rm -rf ./${TARGET_DIR}/${FILENAME}")


set_tests_properties(MKDIR_${TARGETNAME} COPY_${TARGETNAME} CHMOD_${TARGETNAME} PROPERTIES FIXTURES_SETUP TEST_COLLECTION)
set_tests_properties(REMOVE_${TARGETNAME} PROPERTIES FIXTURES_CLEANUP TEST_COLLECTION)

set_tests_properties(COPY_${TARGETNAME} PROPERTIES DEPENDS MKDIR_${TARGETNAME})
set_tests_properties(CHMOD_${TARGETNAME} PROPERTIES DEPENDS COPY_${TARGETNAME})

endmacro()

0 个答案:

没有答案