当前位置:网站首页>Master vscode remote GDB debugging
Master vscode remote GDB debugging
2022-04-23 15:52:00 【ZONG_ XP】
0 background
Recently, under the Amway of my colleagues , Tried to use vscode do gdb debugging , After use ,“ It's delicious ”.
Don't talk much , What this paper wants to achieve is : stay windows Terminal remote debugging linux The server and arm On embedded devices c++ Code , Yes gdb The configuration and use of debugging shall be sorted out .
Other :《 One article mastery vscode Remote debugging python Code 》
1 Remote connection
First, you need to realize remote connection to the server , Search in plug-in library “remote-ssh”, Double click to download and install ( In the figure below, I have installed ), After installation, remote Explorer appears in the sidebar
Click on + Number , In the pop-up command window, enter ssh Login instruction , Follow the instructions , Enter the password and confirm , You can connect successfully
2 To configure GDB Environmental Science
Create a c++ Code , Here we use 《Linux And C++ Get the system user name 》 For example, the code in , It's simple
#include <unistd.h>
#include <pwd.h>
#include <iostream>
int main()
{
struct passwd* pwd;
uid_t userid;
userid = getuid();
pwd = getpwuid(userid);
std::cout << "pw_name:" << pwd->pw_name << std::endl;
std::cout << "pw_passwd:" << pwd->pw_passwd << std::endl;
std::cout << "pw_uid:" << pwd->pw_uid << std::endl;
std::cout << "pw_gid:" << pwd->pw_gid << std::endl;
std::cout << "pw_gecos:" << pwd->pw_gecos << std::endl;
std::cout << "pw_dir:" << pwd->pw_dir << std::endl;
std::cout << "pw_shell:" << pwd->pw_shell << std::endl;
return 0;
}
Compile as follows , Be sure to add -g Instructions , Otherwise, we can't gdb debugging
g++ -g test.cpp -o test
And then click file - Open folder , Find the created code path , after , In the Explorer on the left, you can see the code file .
Installation is required for the first operation c++ An extension of , In the extension page , install C/C++
Simultaneous search GDB Debug And install
Once installed , Click on “ Operation and commissioning ” Button ,“ establish launch.json” file ,
choice C++(GDB/LLDB) term , Automatic generation launch.json file , The contents are as follows
{
// Use IntelliSense Learn about properties .
// Hover to see the description of an existing property .
// For more information , Please visit : https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": []
}
Follow the content below , Modify the corresponding
{
// Use IntelliSense Learn about properties .
// Hover to see the description of an existing property .
// For more information , Please visit : https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) start-up ", // Configuration name , Displayed in the configuration drop-down menu
"type": "cppdbg", // Configuration type
"request": "launch", // Request configuration type , It can be startup or additional
"program": "${workspaceFolder}/test", // The full path of the program executable ,${workspaceFolder} Indicates the initial path of the remote connection
"args": [], // Command line arguments passed to the program
"stopAtEntry": false,// Optional parameters , If true, The debugger should be at the entrance (main) Stop at
"cwd": "${workspaceFolder}", // Target's working directory
"environment": [], // Indicates the environment variable to be preset
"externalConsole": false,// If true, Start the console for the debug object
"MIMode": "gdb",// The console you want to connect to starts the program
"setupCommands": [ // One or more... Executed to install the base debugger GDB/LLDB command
{
"description": " by gdb Enable neat printing ",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
So far, the environment configuration is completed
3 GDB Debugging method
Click directly on the left side of the number of lines in the source code , You can add breakpoints , After setting the breakpoint , Click on “ Operation and commissioning ”--(gdb) start-up , as follows
You can enter the debug page
You can see the variable value directly in the variable area , Complete commissioning purpose .
Common debugging keys are as follows
F5 Start debugging
F10 Step over
F11 Step by step debugging
shift + F11 Step out
ctrl + shift + F5 Restart debugging
shift + F5 Stop debugging
版权声明
本文为[ZONG_ XP]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231547448963.html
边栏推荐
- Coalesce and repartition of spark operators
- 新动态:SmartMesh和MeshBox的合作新动向
- 大型互联网为什么禁止ip直连
- VIM specifies the line comment and reconciliation comment
- Fastjon2他来了,性能显著提升,还能再战十年
- 一刷313-剑指 Offer 06. 从尾到头打印链表(e)
- Open source project recommendation: 3D point cloud processing software paraview, based on QT and VTK
- Why disable foreign key constraints
- R语言中绘制ROC曲线方法二:pROC包
- Spark 算子之coalesce与repartition
猜你喜欢
随机推荐
Do we media make money now? After reading this article, you will understand
Deletes the least frequently occurring character in the string
贫困的无网地区怎么有钱建设网络?
Merging of Shanzhai version [i]
shell_ two
Multi level cache usage
Date date calculation in shell script
多生成树MSTP的配置
运维流程有多重要,听说一年能省下200万?
时序模型:门控循环单元网络(GRU)
Extract non duplicate integers
Spark 算子之partitionBy
Accumulation of applet knowledge points
提取不重复的整数
Spark 算子之sortBy使用
C language --- advanced pointer
一刷314-剑指 Offer 09. 用两个栈实现队列(e)
R语言中实现作图对象排列的函数总结
Neodynamic Barcode Professional for WPF V11. 0
Leetcode-396 rotation function