Mojave에서 gdb를 작동시키는 데 문제가 있습니다.

Mojave에서 gdb를 작동시키는 데 문제가 있습니다.

저는 Macbook Pro에서 Mojave를 실행하고 있습니다. Brew를 통해 gdb 8.3을 설치했습니다.

다음에 제공된 지침에 따라 코드에 서명했습니다.

https://sourceware.org/gdb/wiki/PermissionsDarwin

또한 시스템 무결성을 완전히 꺼서 gdb를 작동시키는 데 문제가 있습니다.

-g로 컴파일된 test_sleep.c라는 간단한 C 프로그램이 있습니다.

내가 달리면

cs_mac > gdb -q  sleep_test
Reading symbols from sleep_test...
Reading symbols from /Users/richard/home/richard/programming_tests/mac/c_tests/examples/sleep_test.dSYM/Contents/Resources/DWARF/sleep_test...
(gdb) b main
Breakpoint 1 at 0x100000f2f: file sleep_test.c, line 7.
(gdb) r
Starting program: /Users/richard/home/richard/programming_tests/mac/c_tests/examples/sleep_test
Unable to find Mach task port for process-id 2590: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))
(gdb

gdb에 코드 서명을 했는데도 일반적인 코드 서명 오류가 발생합니다.

여기에 이미지 설명을 입력하세요.

해결책의 일부는 sudo를 사용하여 gdb를 실행하는 것입니다.

그런 다음 실제로 디버깅할 수 있지만 먼저 12개의 경고가 표시됩니다.

cs_mac > sudo /usr/local/bin/gdb -q sleep_test
Password:
Reading symbols from sleep_test...
Reading symbols from /Users/richard/home/richard/programming_tests/mac/c_tests/examples/sleep_test.dSYM/Contents/Resources/DWARF/sleep_test...
(gdb) b main
Breakpoint 1 at 0x100000f2f: file sleep_test.c, line 7.
(gdb) r
Starting program: /Users/richard/home/richard/programming_tests/mac/c_tests/examples/sleep_test
[New Thread 0x1003 of process 2646]
[New Thread 0xe03 of process 2646]
warning: `/BuildRoot/Library/Caches/com.apple.xbs/Binaries/Libc_darwin/install/TempContent/Objects/Libc.build/libsystem_darwin.dylib.build/Objects-normal/x86_64/bsd.o': can't open to read symbols: No such file or directory.
warning: `/BuildRoot/Library/Caches/com.apple.xbs/Binaries/Libc_darwin/install/TempContent/Objects/Libc.build/libsystem_darwin.dylib.build/Objects-normal/x86_64/darwin_vers.o': can't open to read symbols: No such file or directory.
warning: `/BuildRoot/Library/Caches/com.apple.xbs/Binaries/Libc_darwin/install/TempContent/Objects/Libc.build/libsystem_darwin.dylib.build/Objects-normal/x86_64/dirstat.o': can't open to read symbols: No such file or directory.
warning: `/BuildRoot/Library/Caches/com.apple.xbs/Binaries/Libc_darwin/install/TempContent/Objects/Libc.build/libsystem_darwin.dylib.build/Objects-normal/x86_64/dirstat_collection.o': can't open to read symbols: No such file or directory.
warning: `/BuildRoot/Library/Caches/com.apple.xbs/Binaries/Libc_darwin/install/TempContent/Objects/Libc.build/libsystem_darwin.dylib.build/Objects-normal/x86_64/err.o': can't open to read symbols: No such file or directory.
warning: `/BuildRoot/Library/Caches/com.apple.xbs/Binaries/Libc_darwin/install/TempContent/Objects/Libc.build/libsystem_darwin.dylib.build/Objects-normal/x86_64/exception.o': can't open to read symbols: No such file or directory.
warning: `/BuildRoot/Library/Caches/com.apple.xbs/Binaries/Libc_darwin/install/TempContent/Objects/Libc.build/libsystem_darwin.dylib.build/Objects-normal/x86_64/init.o': can't open to read symbols: No such file or directory.
warning: `/BuildRoot/Library/Caches/com.apple.xbs/Binaries/Libc_darwin/install/TempContent/Objects/Libc.build/libsystem_darwin.dylib.build/Objects-normal/x86_64/mach.o': can't open to read symbols: No such file or directory.
warning: `/BuildRoot/Library/Caches/com.apple.xbs/Binaries/Libc_darwin/install/TempContent/Objects/Libc.build/libsystem_darwin.dylib.build/Objects-normal/x86_64/stdio.o': can't open to read symbols: No such file or directory.
warning: `/BuildRoot/Library/Caches/com.apple.xbs/Binaries/Libc_darwin/install/TempContent/Objects/Libc.build/libsystem_darwin.dylib.build/Objects-normal/x86_64/stdlib.o': can't open to read symbols: No such file or directory.
warning: `/BuildRoot/Library/Caches/com.apple.xbs/Binaries/Libc_darwin/install/TempContent/Objects/Libc.build/libsystem_darwin.dylib.build/Objects-normal/x86_64/string.o': can't open to read symbols: No such file or directory.
warning: `/BuildRoot/Library/Caches/com.apple.xbs/Binaries/Libc_darwin/install/TempContent/Objects/Libc.build/libsystem_darwin.dylib.build/Objects-normal/x86_64/variant.o': can't open to read symbols: No such file or directory.

Thread 2 hit Breakpoint 1, main () at sleep_test.c:7
7    for (i=0;i<10;i++)
(gdb) l
2    #include <unistd.h>
3
4    int main()
5    {
6    int i;
7    for (i=0;i<10;i++)
8        {
9             printf("%d \n",i);
10             sleep(1);
11       }
(gdb) n
9             printf("%d \n",i);
(gdb)

그래서 내 질문은 (1) sudo 없이 gdb가 작동하지 않는 이유와 (2) sudo로 실행하면 모든 경고가 생성되는 이유는 무엇입니까?

다행히도 lldb는 gcc 기반 바이너리에 대해 완벽하게 작동하므로 아마도 gdb를 포기하고 lldb로 전환할 것입니다. 하지만 나는 왜 Apple이 Linux에서 실행하기 쉬운 것을 그렇게 복잡하게 만드는지 여전히 궁금합니다.

관련 정보