当前位置:网站首页>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
边栏推荐
- IronPDF for .NET 2022.4.5455
- Go语言数组,指针,结构体
- The principle and common methods of multithreading and the difference between thread and runnable
- JVM - Chapter 2 - class loader subsystem
- How can poor areas without networks have money to build networks?
- Neodynamic Barcode Professional for WPF V11.0
- Groupby use of spark operator
- Extract non duplicate integers
- Go language, condition, loop, function
- leetcode-374 猜数字大小
猜你喜欢
Large factory technology implementation | industry solution series tutorials
New developments: new trends in cooperation between smartmesh and meshbox
Use bitnami PostgreSQL docker image to quickly set up stream replication clusters
多级缓存使用
一文掌握vscode远程gdb调试
使用 Bitnami PostgreSQL Docker 镜像快速设置流复制集群
大型互联网为什么禁止ip直连
Why is IP direct connection prohibited in large-scale Internet
Multi level cache usage
Partitionby of spark operator
随机推荐
现在做自媒体能赚钱吗?看完这篇文章你就明白了
C language --- string + memory function
Temporal model: long-term and short-term memory network (LSTM)
多生成树MSTP的配置
MySQL集群模式與應用場景
Implement default page
pgpool-II 4.3 中文手册 - 入门教程
Go language slice, range, set
为啥禁用外键约束
Partitionby of spark operator
R语言中实现作图对象排列的函数总结
The principle and common methods of multithreading and the difference between thread and runnable
One brush 313 sword finger offer 06 Print linked list from end to end (E)
Merging of Shanzhai version [i]
Fastjon2他来了,性能显著提升,还能再战十年
Calculate the number of occurrences of a character
Go语言数组,指针,结构体
Upgrade MySQL 5.1 to 5.611
Spark 算子之partitionBy
运维流程有多重要,听说一年能省下200万?