Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Vscode-insiders 's docker extension

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the knowledge of "how to use Vscode-insiders 's docker extension". In the operation of practical cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

A brief introduction to Vscode-insiders

VsCode is Microsoft's first lightweight code editor that supports Linux. Its function is between editor and IDE, but it is more inclined to be an editor. There are two versions of Vscode, the blue Vscode is a very stable distribution, and Vscode-insiders, the equivalent of the Bate version, will have some new features.

This article uses Vscode-insiders 's Docker and Remote-Containers extensions to make it easy to debug Apollo projects, but the blue Vscode does not have this debugging capability.

Installation of Vscode-insiders and extension installation of Vscode-insiders

There are two ways to install Vscode-insiders, which are Apt installation and Deb package installation. Vscode-insiders and blue Vscode can be used at the same time, and there is no need to uninstall the blue Vscode to install Vscode-insiders.

Apt installation:

1sudo apt-get update2sudo apt-get install code-insiders

Deb installation:

Download Vscode-insiders 's Deb package at https://code.visualstudio.com/insiders/

1sudo dpkg-I code-insiders_xxx.deb installs Docker and Remote-Containers extensions

Run Vscode-insiders, search for Docker and Remote-Containers extensions in the extension bar, and install them.

You can view a detailed tutorial on the Docker extension in https://code.visualstudio.com/docs/remote/containers.

▲ Docker installation

▲ Remote-Containers installation

Since the Apollo project is developed with C++, you also need to install the C++ extension.

▲ C++ extension

After installation, it is shown in the figure:

▲ Docker and Remote-Containers installation diagram

Configure Vscode-insiders to start Apollo Docker

On how to build Apollo3.5 or 5.0 has been built in Ubuntu14.04 GPU version of Baidu Apollo3.5 autopilot platform details.

1cd apollo2bash docker/scripts/dev_start.sh 3bash docker/scripts/dev_into.sh 4bash scripts/bootstrap.sh configures Apollo in Vscode-insiders

After Apollo Docker starts, open Vscode-insiders, select the Docker icon, and the Apollo image appears, as shown below:

▲ starts Vscode-insiders

Right-click the Apolloauto/apollo:dev-x86_64-xxx image and select Attach visual studio code (blue Vscode does not have this option even if the Docker extension is installed)

▲ check Attach visual studio code

At this point, Vscode will automatically open a new window to load Container. If the word Attached container appears in the lower left corner, it means that Vscode has been loaded.

▲ Vscode loading completed

Then select [Open folder], type / apollo/ and then make sure.

▲ type / apollo/

At this time, Vscode-insiders has loaded the / apollo folder in the Apollo image, then open the extension bar, install the C++ extension in Docker (some computers will install it automatically), and click "reload" after installation.

▲ installs the C++ extension in Docker

Configure the environment as soon as the loading is complete.

▲ loading completed

Debug Apollo module and unit test program debug Apollo unit test program

After completing the environment configuration, select * * Debug * *-> * * Open configuration * * to automatically open the / Apollo/.vscode/launch.json configuration file:

According to your needs, you can debug the Apollo unit test program by modifying the Program and Args parameters. Here is an example:

1 {2 "version": "0.2.0", 3 "configurations": [4 5 {6 "name": "(gdb) Launch", 7 "type": "cppdbg", 8 "request": "launch", 9 "program": "/ apollo/bazel-bin/modules/perception/camera/test/camera_lib_lane_postprocessor_denseline_lane_postprocessor_test" 10 "args": [], 11 "stopAtEntry": false,12 "cwd": "${workspaceFolder}", 13 "environment": [], 14 "externalConsole": false,15 "MIMode": "gdb" 16 "setupCommands": [17 {18 "description": "Enable pretty-printing for gdb", 19 "text": "- enable-pretty-printing", 20 "ignoreFailures": true21} 22] 23} 24] 25}

Open the corresponding test code file, add a breakpoint, and select "debug"-"start debugging" to facilitate code debugging like other IDE.

F10: step debugging

F11: step in

Shift+F11: step out

The stack and variable information can be seen visually on the left:

▲ stack and variable information

After modifying the code, run Build in Docker, and after compilation, you can start debugging again.

Debug Apollo module

The official account of Apollo developer Community once posted "developer said | Analysis of the startup process of each functional module of Apollo3.5", which introduced the module startup process of Apollo3.5 in detail.

By adding a breakpoint in / apollo/cyber/mainboard/mainboard.cc, you can see in detail the startup process of the module (how to load Dag and Conf files for initialization), which greatly facilitates developers to understand and debug the Apollo module.

PS: Apollo3.0 and previous versions can still be debugged in this way, simply by changing Program to the Ros executable path and Args to the corresponding parameters.

1 {2 "version": "0.2.0", 3 "configurations": [4 5 {6 "name": "(gdb) Launch", 7 "type": "cppdbg", 8 "request": "launch", 9 "program": "/ apollo/bazel-bin/cyber/mainboard", 10 "args": ["- d" "/ apollo/modules/drivers/gnss/dag/gnss.dag"], 11 "stopAtEntry": false,12 "cwd": "${workspaceFolder}", 13 "environment": [], 14 "externalConsole": false,15 "MIMode": "gdb" 16 "setupCommands": [17 {18 "description": "Enable pretty-printing for gdb", 19 "text": "- enable-pretty-printing", 20 "ignoreFailures": true21} 22] 23} 24] 25}

▲ debug Apollo board

That's all for "how to use Vscode-insiders 's docker extension". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report