How to debug simple C++ program with LLDB + arm64 M1?

Here's a simple C++ program:
Code Block cpp
#include <stdio.h>
int main() {
printf("Hello world\n");
return 0;
}

On my M1 Macbook air, I can compile, run, and debug this program successfully:

Code Block bash
% clang++ hello.cpp -g
% ./a.out
Hello world
% lldb a.out
(lldb) target create "a.out"
Current executable set to '/Users/sam/build/a.out' (x86_64).
(lldb) run
Process 55681 launched: '/Users/sam/build/a.out' (x86_64)
Hello world
Process 55681 exited with status = 0 (0x00000000)

When adding -arch arm64, it builds and runs, as expected:

Code Block bash
% clang++ hello.cpp -g -arch arm64
% ./a.out
Hello world

But debugging seems to fail:
Code Block bash
% lldb a.out
(lldb) target create "a.out"
Current executable set to '/Users/sam/build/a.out' (arm64).
(lldb) run
error: process exited with status -1 (attach failed ((os/kern) invalid argument))

Is there anything special I need to do to get lldb to work with an executable compiled with -arch arm64?



Macbook Air (M1, 2020)
Big Sur 11.0.1

Code Block bash
% clang++ --version
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin20.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin


Code Block bash
% lldb --version
lldb-1200.0.44.2
Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)







Answered by spmish in 672971022
Oops, it appears to be related to using a Terminal that has been run with Rosetta!
Accepted Answer
Oops, it appears to be related to using a Terminal that has been run with Rosetta!
How to debug simple C++ program with LLDB + arm64 M1?
 
 
Q