Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode LLDB on MacOS error when starting debugging session

I'm trying to configure VSCode for compiling/debugging C++ programs on MacOS. I am using the following launch.json file:

enter image description here

When I try and start a debugging session, I get the following error:

Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
ERROR: Unable to start debugging. Unexpected LLDB output from command "-exec-run". process 
exited with status -1 (attach failed ((os/kern) invalid argument))
The program '/path/to/Development/C++/helloworld/main' has exited with code 42 
(0x0000002a).

It is worth mentioning that I am using an M1 Macbook, so x86_64 is not the correct architecture. I'm assuming that this is the reason for the error.

I can't seem to find any reference to this error anywhere online, does anyone know how I can solve this?

Edit: Adding "targetArchitecture": "ARM64" removed the warning, but does not fix the error.

like image 222
Jr795 Avatar asked Apr 26 '21 16:04

Jr795


People also ask

What is LLDB in Vscode?

Introduction. The lldb-vscode extension packages the command line tool of the same name that implements the Visual Studio Code Debug API.

What is GDB LLDB?

GDB is debugger part of the GNU project created to work along the GNU compiler. LLDB is debugger part of the LLVM project created to work along LLVM compiler.

How do I debug with LLDB-mi on macOS?

Debugging with LLDB-MI on macOS The debug adapter for the C/C++ extension utilizes the machine interface mode for both gdb and lldb. To use this interface in lldb, the extension utilizes lldb-mi. The lldb-mi executable was built from the GitHub lldb-mi repository and has a dependency on the LLDB.framework, which is part of Xcode.

What is LLDB-VSCode?

Introduction. The lldb-vscode extension packages the command line tool of the same name that implements the Visual Studio Code Debug API. lldb-vscode has two unique features. The first is that it launches lldb's CommandInterpreter in a Terinal pane instead of shoehorning the CommandInterpreter into the Debug Console as many other VSCode debug...

How do I enable LLDB debugging in Xcode?

Open a terminal. Run xcode-select --install. Confirm the prompt. Below is an example launch.json debug configuration entry for lldb: You may see a dialog saying "Developer Tools Access needs to take control of another process for debugging to continue." If you get this prompt, you will have to enter your username and password to allow debugging.

How do I debug LLDB in developer tools access?

Below is an example launch.json debug configuration entry for lldb: You may see a dialog saying "Developer Tools Access needs to take control of another process for debugging to continue." If you get this prompt, you will have to enter your username and password to allow debugging.


1 Answers

I had the same problem and I found that VScode does not support a debugger for ARM64 binaries yet. Here is the issue link.

However, it works if you use another extension. Install CodeLLDB and set "type": "lldb" on launch.json like below.

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
      {
        "name": "clang++ - Build and debug active file",
        "type": "lldb",
        "request": "launch",
        "program": "${fileDirname}/${fileBasenameNoExtension}",
        "args": [],
        "cwd": "${workspaceFolder}",
        "preLaunchTask": "clang++ build active file"
      }
    ]
  }

You can check quick start guide of vscode-lldb repository.

Note that preLaunchTask's value should be the same as the label's value in your task.json.

like image 109
Shin Min-Young Avatar answered Oct 29 '22 05:10

Shin Min-Young