In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to debug vscode step by step, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!
How to debug vscode step by step?
Vscode single step debugging
VScode configuration
0. Shortcut key
Ctrl + `opens the default terminal; Ctrl + Shift +` creates a new terminal; Ctrl + Shift + Y opens the debugging console, and then switches the terminal options by itself; ps: `is on the left side of the number 1 on the keyboard.
Related recommendation: vscode getting started tutorial
1. Install clang
Sudo apt-get install clang
2.VScodeDebug
Plug-ins refer to links, but large-scale project configurations are still complex. Many tutorials are configured for a single cpp file. Here is a record of cpp debugging in general vscode configuration:
1. The whole idea is to first carry out mkdir build & & cd build & & cmake.. according to the conventional method. & & make (this step can be done at the vscode terminal or at the system terminal, it doesn't matter. But in order to open a little less interface, it is better to finish in vscode) generate executable file, and then use vscode to step.
two。 Configure launch file: click the Debug icon (Ctrl+Shift+D) in the left sidebar, click the gear icon configure above, and click default configure to automatically generate the launch.json file. When you enter the launch file interface, you can see that the path is .vscode / launch.json/Launch Targets/ (gbd) Launch.
3. Modify the launch file:
{"version": "0.2.0", "configurations": [{"name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder} / build/app/testMonoBA" / / this path is changed to the final generated executable file path and the executable file name "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false,// changes the true here to false Otherwise, he will call the terminal of the system to carry out the actual "MIMode": "gdb", "setupCommands": [{"description": "Enable pretty-printing for gdb", "text": "- enable-pretty-printing", "ignoreFailures": true}] }]}
4. Modify the CMakeLists.txt file:
Cmake_minimum_required (VERSION 2.8) project (slam_demo) set (DEFAULT_BUILD_TYPE "Debug") # change release to debug, or you can delete if (NOT CMAKE_BUILD_TYPE) message directly (STATUS "Setting build type to'${DEFAULT_BUILD_TYPE}'as none was specified.") Set (CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug"Release"MinSizeRel"RelWithDebInfo") endif () set (CMAKE_CXX_FLAGS "- std=c++11") FIND_PACKAGE (OpenMP REQUIRED) if (OPENMP_FOUND) message ("OPENMP FOUND") ADD_DEFINITIONS (- DUSE_OPENMP) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP _ C_FLAGS} ") set (CMAKE_CXX_FLAGS" ${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} ") set (CMAKE_EXE_LINKER_FLAGS" ${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS} ") endif () # set (CMAKE_CXX_FLAGS_DEBUG" ${CMAKE_CXX_FLAGS}-Wno-reorder "CACHE STRING"FORCE) # set (CMAKE_CXX_FLAGS_RELEASE" ${CMAKE_CXX_ FLAGS}-DNDEBUG-Wno-reorder-O2 "CACHE STRING"FORCE) set (CMAKE_CXX_FLAGS_DEBUG" {CMAKE_CXX_FLAGS}-o0-ggbd ") # add statement add_compile_options (- g) # add statement list (APPEND CMAKE_MODULE_PATH" ${PROJECT_SOURCE_DIR} / cmake ") option (BUILD_APPS" Build APPs for slam course "YES) option (BUILD_TESTS" Build test for slam course "No) # third party libs# eigenfind_ Package (Eigen REQUIRED) include_directories (${EIGEN_INCLUDE_DIR}) # opencvfind_package (OpenCV 4 REQUIRED) include_directories (${OpenCV_INCLUDE_DIRS}) # glogfind_package (Glog REQUIRED) include_directories (${GLOG_INCLUDE_DIRS}) # sophusinclude_directories (${PROJECT_SOURCE_DIR} / thirdparty/Sophus) include_directories (${PROJECT_SOURCE_DIR}) add_subdirectory (frontend) add_subdirectory (backend) add_subdirectory (utils) if (BUILD_APPS) add_ Subdirectory (app) endif () if (BUILD_TESTS) enable_testing () add_subdirectory (test) endif ()
5. After the above, re-compile, and then the debugging column in vscode can no longer be grayed out for single-step debugging.
As shown in the figure:
The method of 3.Cmake supporting gdb debugging
SET (CMAKE_BUILD_TYPE "Debug") SET (CMAKE_CXX_FLAGS_DEBUG "$ENV {CXXFLAGS}-O0-Wall-G2-ggdb") SET (CMAKE_CXX_FLAGS_RELEASE "$ENV {CXXFLAGS}-O3-Wall") add_compile_options (- g) # add sentence above is all the content of this article "how to step vscode debugging". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.