我试图在Ubuntu上使用VS Code调试C程序.我已成功构建项目.我使用bin / show dat命令从终端调用它并且它可以工作.
在VS Code中,我安装了C调试工具,而不是创建launch.json和tasks.json.这两个文件将在下面附上.
现在我可以按F5成功启动该程序,效果很好.但是主要功能第一行的断点没有被击中.
任何人都可以给我一些建议我该如何解决这个问题?
感谢您的时间.如果需要更多信息,请告诉我.
文件launch.json的内容
{
// 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": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/show",
"preLaunchTask": "build",
"args": ["${workspaceFolder}/dat"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
文件tasks.json的内容
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "make"
}
]
}
调试控制台的内容如下
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
.
Find the GDB manual and other documentation resources online at:
.
For help, type "help".
Type "apropos word" to search for commands related to "word".
=cmd-param-changed,param="pagination",value="off"
Stopped due to shared library event (no libraries added or removed)
Loaded '/lib64/ld-linux-x86-64.so.2'. Symbols loaded.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Breakpoint 1, 0x00000000004243a0 in main ()
使用MakeFile和CMakeLists.txt进行更新
生成文件
all: .configured
cmake --build .build
.PHONY: test
test:
cmake -H. -B.build
CTEST_OUTPUT_ON_FAILURE=true cmake --build .build --target test
config: .build
ccmake -H. -B.build
touch .configured
.configured: .build
ifeq ($(CMAKE_GENERATOR),Ninja)
cmake -H. -B.build -G "Ninja"
else
cmake -H. -B.build -G "Unix Makefiles"
endif
touch .configured
.build:
mkdir -p .build
clean: .build
cmake --build .build --target clean
-rm -rf .build
rm -f .configured
DOC = doc/
docu: docu_html docu_latex docu_hl
echo
echo
echo + Reference documentation generated: $(DOC)html/index.html
echo + Reference documentation generated: $(DOC)refman.pdf
echo + Highlevel documentation generated: $(DOC)documentation_HL.pdf
echo
docu_html:
doxygen doc/doxygen.cfg
cd $(DOC) ; zip -q html.zip html/*
echo
echo
docu_latex:
$(MAKE) -C $(DOC)latex
cd $(DOC)latex ; dvips refman
cd $(DOC)latex ; ps2pdf14 refman.ps refman.pdf
cp $(DOC)latex/refman.pdf $(DOC)
docu_hl: $(DOC)high_level_doc/documentation.tex
cd $(DOC)high_level_doc ; latex documentation.tex
cd $(DOC)high_level_doc ; bibtex documentation
cd $(DOC)high_level_doc ; latex documentation.tex
cd $(DOC)high_level_doc ; dvips documentation
cd $(DOC)high_level_doc ; ps2pdf14 documentation.ps ../documentation_HL.pdf
的CMakeLists.txt
cmake_minimum_required (VERSION 2.8.2)
project (3DTK)
if(POLICY CMP0025)
#necessary to build with custom clang on macOS
cmake_policy(SET CMP0025 NEW)
endif()
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/3rd