VSCode запускает DGB через Makefile - PullRequest
0 голосов
/ 07 июня 2019

У меня есть следующее Makefile, используемое для сборки моего приложения и его модульного тестирования:

GDB=gdb
DEBUG ?= 1
ifeq ($(DEBUG), 1)
    CCFLAGS =-DDEBUG
    RUNPATH =${GDB}
else
    CCFLAGS=-DNDEBUG
    RUNPATH=""
endif

CPP=g++ ${CCFLAGS}
TESTGEN=cxxtestgen
CFLAGS_DBG="-enable-pretty-printing"
TEST_BUILD_PATH="./build/tests"
BUILD_PATH="./build"
TESTS_SRC_PATH="./tests"
SRC_PATH=""

# NORMAL TARGETS
# To Be filled

# RUN TESTS

test_command_parser_gen:
    ${TESTGEN} --error-printer -o ${TESTS_SRC_PATH}/CommandParser/runner.cpp  ./tests/CommandParser/testCommandParser.h

test_command_parser_build: test_command_parser_gen
    ${CPP} -o ${TEST_BUILD_PATH}/commandParser ${TESTS_SRC_PATH}/CommandParser/runner.cpp ./src/tools/command_parser.cpp

test_command_parser_run: test_command_parser_build
    ${RUNPATH} ./build/tests/commandParser

И я хочу иметь возможность отладки с помощью отладчика с помощью команды make.Как вы видите выше, я могу встроить модульный тест в режим отладки с помощью команды make test_command_parser_run DEBUG=1

Но с учетом следующей vscode конфигурации отладки:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Cpp Build debug test",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "cpp build active file",
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}

Как запуститьотладчик с помощью команды make?

...