laitimes

The "Compilation Tool" VS Code Hybrid Debugging C/C++ and Node .js separately debug C/C++ code Mixed debugging C/C++ and Node .js

There are several commonly used ide tools:

vscode, the user experience under various platforms is excellent, the code theme and display effect are the best, and lightweight, less resource consumption; in addition, support for the development of multiple languages, just install the corresponding plug-ins, installation, configuration, learning costs are very low.

The "Compilation Tool" VS Code Hybrid Debugging C/C++ and Node .js separately debug C/C++ code Mixed debugging C/C++ and Node .js

clion, jetbrains company launched a cross-platform ide designed for the development of C / C++, I have to say jetbrains out of the product is trustworthy, the user experience is also very good, I like to use clion debugging cmake project, just a simple introduction of engineering can be normal development and debugging, or very cool and crooked. In addition, after using intellij idea for a period of time to develop Java programs, the development efficiency has been greatly improved, and it is really a magic weapon for Java programmers! Big love! However, because it is based on the Java virtual machine JDK development and operation, so the resource consumption is more, this experience is not very good.

Visual studio, which is often used to debug large programs under windows, is undoubtedly the best development and debugging tool for a large program with a lot of engineering, and is a good choice for beginners and developers of C++. As a small partner once said, it is very convenient to use vs track deadlock problems. For children's shoes that plan to start learning webrtc, it is recommended to start with Windows vs Engineering.

For children's shoes that are often developed in multiple languages, vscode is definitely a wise choice, I use the most C++, node .js mixed development debugging and go language development, and vscode support with docker is also a very cool experience. The following is mainly to talk about "centos7 vscode hybrid debugging c/c++ and node .js engineering".

This article takes node .js developing hello world addon as an example

node.js tool for building c/c++ plugins based on (generate your projects) is node-gyp, which can compile C++ plugin code into a .node file, which is essentially a dynamic library that can automatically generate make, cmake project corresponding to makefile and cmakelist .txt files.

The launch.json file looks like this:

This allows you to execute according to launch.json when starting debugging, and when you mark a breakpoint for C++ code, the program will stop at the breakpoint. At this point, the js code is not in the debug state. In addition, using the lldb plugin can also achieve the same effect, but you need to install the lldb plugin:

The "Compilation Tool" VS Code Hybrid Debugging C/C++ and Node .js separately debug C/C++ code Mixed debugging C/C++ and Node .js

At this point, just change the type to lldb. lldb is a gdb-like implementation of llvm. This plugin is designed to support the llvm compiler.

Start node.js project to start debugging, then start the C/C++ debugger and attach it to the corresponding process, so that while diving into the JS code, you can also debug the code in the C++ addons [1] section and understand the underlying call logic.

The first launch in the configuration is to start node .js code debugging, debug js code, you need to first switch the debug panel to launch. The second item in the configuration is attach c/c++ addon, which switches the debug panel's debug to attach c/c++ addon and then starts again. Here request: "attach", is to let lldb link to the nodejs process to debug, the following pid field is to start, will pop up the drop-down box, and then select the process to link. Once the link is successful, you can breakpoint the C/C++ code.

Problems encountered:

Under centos7, the code is directly launched, the ui interface is white, and the menu and window cannot be rendered

Workaround: code --disable-gpu

By default, code is rendered in the way of starting the gpu, and the virtual machine does not work normally, and it works normally after disable.

Install the lldb plugin, you can't install native debug in the number of installations, just install codelldb.

Using cppdb attach doesn't work properly, and requires processid and program, which works fine after modifying the way to lldb and pid.

Error after installing the lldb plugin:

The "Compilation Tool" VS Code Hybrid Debugging C/C++ and Node .js separately debug C/C++ code Mixed debugging C/C++ and Node .js

Workaround:

After updating glib, I still encounter the following issues:

The "Compilation Tool" VS Code Hybrid Debugging C/C++ and Node .js separately debug C/C++ code Mixed debugging C/C++ and Node .js

Workaround: sudo yum install python3

Well, this article will introduce you here, if you think the content is useful to you, remember to support it!

If you also like programming, think of C/C++! If you also want to make yourself a great programmer with real materials, you might as well start now!

Programming Learning Book Sharing:

The "Compilation Tool" VS Code Hybrid Debugging C/C++ and Node .js separately debug C/C++ code Mixed debugging C/C++ and Node .js

Programming Learning Video Sharing:

The "Compilation Tool" VS Code Hybrid Debugging C/C++ and Node .js separately debug C/C++ code Mixed debugging C/C++ and Node .js

Organize and share (source code learned over the years, project practical videos, project notes, basic introductory tutorials)

Welcome to change careers and learn programming partners, use more information to learn to grow faster than their own thinking!

For C/C++ interested, you can pay attention to the small editor in the background private message me: [programming exchange] let's learn together! You can get some C/C++ project learning video materials! Keyword auto-reply has been set up, and it will be collected automatically!