How to get lldb to work on M1 Big Sur? This is on an M1 mini, running 11.1 with an updated Xcode.  (All pending updates have been applied.)  SIP has not been disabled (if it can even be, on the M1).
We have a program we're using to test an mmap() failure in our application being ported.  We build the test program like this:
cc -v -arch arm64 -m64 -Wl,-no_adhoc_codesign -o mapfail mapfail.c

Then, we sign it.  It appears to be correctly signed:
@macarm[git:master]$ codesign -vvv mapfail
mapfail: valid on disk
mapfail: satisfies its Designated Requirement
@macarm[git:master]$ 

We have enabled developer mode on the system.  We also added my user to the _developer group.  My user is not an administrator, but I tried it as one and got the same thing.
When we run the program it gets a segmentation fault (SIGSEGV), so we want to debug it with lldb, but this happens:
@macarm[git:master]$ lldb mapfail
(lldb) target create &quot;mapfail&quot;
Current executable set to '/Users/layer/mapfail' (arm64).
(lldb) run
error: process exited with status -1 (attach failed ((os/kern) invalid argument))
(lldb) 

Searches for this have yielded no information, even on the Apple developer forums.
More info.  I tried an entitlement added at codesign time, but that did not work.  Here's the entitlement I used:
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
&lt;plist version=&quot;1.0&quot;&gt;
&lt;dict&gt;
         &lt;key&gt;com.apple.security.get-task-allow&lt;/key&gt;
         &lt;true/&gt;
&lt;/dict&gt;
&lt;/plist&gt;

Anyone see a problem with this XML?
Here's the relevant answer from Apple on the entitlements needed to attach the llvm debugger to a process:

https://developer.apple.com/forums/thread/132797

The entitlement needed on macOS is com.apple.security.get-task-allow and I know how to add that in Xcode, but not yet from the command line compiler. You can verify the same on your Mac using console app to show the logs and then reproduce the error. Then search for debugserver in console and you will see the debugger starting and then failing to attach.
Here's a different error if you try to start Calculator.app in the debugger - it's hardened and doesn't have the entitlement so that fails just like your app - it's not about notarization or code signing, but about the debugging entitlement on the binary.
default 19:30:23.088087-0600    debugserver debugserver will use os_log for internal logging.
default 19:30:23.088429-0600    debugserver debugserver-@(#)PROGRAM:LLDB  PROJECT:lldb-1200.0.44
 for arm64.
default 19:30:23.088489-0600    debugserver Got a connection, waiting for process information for launching or attaching.
error   19:30:23.090348-0600    debugserver error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 17889, &amp;task ) =&gt; err = 0x00000005 ((os/kern) failure)
default 19:30:23.090378-0600    debugserver 1 +0.000000 sec [45e2/0303]: error: ::task_for_pid ( target_tport = 0x0103, pid = 17889, &amp;task ) =&gt; err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0103, pid = 17889, &amp;task ) =&gt; err = 0x00000005 ((os/kern) failure) (0x00000005
default 19:30:23.090329-0600    kernel  macOSTaskPolicy: (com.apple.debugserver) may not get the taskport of (Calculator) (pid: 17889): (Calculator) is hardened, (Calculator) doesn't have get-task-allow, (com.apple.debugserver) is a declared debugger