当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
一刷313-剑指 Offer 06. 从尾到头打印链表(e)
Spark 算子之distinct使用
Go language slice, range, set
多生成树MSTP的配置
The principle and common methods of multithreading and the difference between thread and runnable
CAP定理
R语言中绘制ROC曲线方法二:pROC包
Config组件学习笔记
开源项目推荐:3D点云处理软件ParaView,基于Qt和VTK
Spark 算子之交集、并集、差集
Pgpool II 4.3 Chinese Manual - introductory tutorial
Redis master-slave replication process
Merging of Shanzhai version [i]
PS add texture to picture
[open source tool sharing] MCU debugging assistant (oscillograph / modification / log) - linkscope
Spark 算子之coalesce与repartition
Neodynamic Barcode Professional for WPF V11. 0
提取不重复的整数
Mobile finance (for personal use)
JVM-第2章-类加载子系统(Class Loader Subsystem)