Using Mac, I started to write algorithm problems. I could not find a good debug tool on Mac. LLDB can debug directly, but it still does not have vscode fragrance.

If you specify a good value in the program, you can debug it, but you cannot read the value from the console or file input.

This is something that seems to happen on Mac Catalina, but not on other platforms.

I searched a lot of materials, and finally found someone with the same problem under this issue, and finally solved the problem. The key to the problem is to use CodeLLDB plug-in to replace the LLDB plug-in of vscode.

Here only record the key to solve the problem, c/ C ++ debug see the official tutorial.

  1. Download the CodeLLDB plug-in and enable it

  2. Set a goodlaunch.jsontask.jsonFor build and debug startup.

The configuration is as follows and can be directly used:

tasks.json

{
  "version": "2.0.0"."tasks": [{"label": "Build with Clang".// The task name is at the end of the launch.json configuration
          "type": "shell"."command": "clang++"."args": [
              "-std=c++17"."-stdlib=libc++"."${fileBasenameNoExtension}.cpp"."-o"."a.out"."--debug"]."group": {
              "kind": "build"."isDefault": true}}}]Copy the code

launch.json

{
  "version": "0.2.0"."configurations": [{"type": "lldb"."request": "launch"."name": "Debug"."program": "${workspaceFolder}/a.out"."args": []."cwd": "${workspaceFolder}"."preLaunchTask": "Build with Clang"}}]Copy the code

You can change all these things by yourself for compiled names.

Then let’s look at reading input from the console:

Change to file input is also no problem.