'Cannot debug executable with lldb on macOS M1: attach failed ((os/kern) invalid argument

I am trying to debug a C executable compiled for arm64 on an Apple M1 MacBook Pro, running macOS Monterey. However, when I try to run the program in lldb, I receive the following error:

(lldb) run
error: process exited with status -1 (attach failed ((os/kern) invalid argument))


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source