"gdb가 코드 서명되었는지 확인하십시오-taskgated (8) 참조"-홈브류 코드 서명으로 gdb를 설치하는 방법은 무엇입니까?
나는 osx 10.8.4 아래에 있으며 homebrew와 함께 gdb 7.5.1을 설치했습니다 (동기 부여는 --with-python 등과 같은 새로운 기능으로 새로운 gdb를 얻습니다 ...)
C ++ Eclipse 프로젝트 내에서 디버그를 실행할 때 짧은 이야기는 다음과 같습니다.
Error in final launch sequence
Failed to execute MI command:
-exec-run
Error message from debugger back end:
Unable to find Mach task port for process-id 46234: (os/kern) failure (0x5).
(please check gdb is codesigned - see taskgated(8))
Unable to find Mach task port for process-id 46234: (os/kern) failure (0x5).
(please check gdb is codesigned - see taskgated(8))
코드 서명에 대한 다양한 제안을 따랐습니다.
그래서 나는 :
- 인증서 설정
- gdb-> codesign -s gdb-cert / usr / local / bin / gdb에 서명합니다.
Eclipse에서 디버깅을 다시 실행하면 위와 동일한 오류가 발생합니다. "(gdb가 코드 서명되었는지 확인하십시오-taskgated (8) 참조)".
gdb를 이전 gdb (Eclipse의 gdb 환경 설정) / usr / libexec / gdb / gdb-i386-apple-darwin으로 다시 설정하면 디버깅이 예상대로 실행됩니다.
거기에 해결책 / 힌트가 있습니까?
고마워
Pelle
이 오류는 OSX가 바이너리가 다른 프로세스 pid에 액세스하기 위해 디지털 서명을 요구하는 pid 액세스 정책을 구현하기 때문에 발생합니다. 다른 프로세스에 대한 gdb 액세스를 활성화하려면 먼저 바이너리에 코드 서명을해야합니다. 이 서명은 사용자가 생성하고 시스템에 등록해야하는 특정 인증서에 따라 다릅니다.
코드 서명 인증서를 생성하려면 키 체인 접근 애플리케이션을 엽니 다. 메뉴 키 체인 접근-> 인증서 지원-> 인증서 생성…을 선택합니다.
인증서 이름 (예 : gdb-cert)을 선택하고 ID 유형을 자체 서명 된 루트로 설정하고 인증서 유형을 코드 서명으로 설정 한 다음 기본값 덮어 쓰기를 선택합니다. 인증서 위치 지정 화면이 나타날 때까지 계속을 여러 번 클릭 한 다음 키 체인을 시스템으로 설정하십시오.
인증서를 두 번 클릭하고 신뢰 섹션을 열고 코드 서명을 항상 신뢰로 설정하십시오. 키 체인 접근 애플리케이션을 종료합니다.
taskgated 서비스를 다시 시작하고 바이너리에 서명합니다.
$ sudo killall taskgated
$ codesign -fs gdb-cert "$(which gdb)"
출처 http://andresabino.com/2015/04/14/codesign-gdb-on-mac-os-x-yosemite-10-10-2/
macOS 10.12 (Sierra) 이상에서는 다음을 수행해야합니다.
gdb 7.12.1 이상 사용 또한 gdb가 셸을 사용하여 디버깅 할 프로그램을 시작하지 못하도록합니다. gdb 내에서 다음 명령을 사용할 수 있습니다.
set startup-with-shell off
이 마지막 명령을 홈 디렉토리의 .gdbinit 파일에 넣을 수도 있습니다.이 경우 gdb를 시작할 때마다 자동으로 적용됩니다.
echo "set startup-with-shell off" >> ~/.gdbinit
출처 : https://sourceware.org/gdb/wiki/BuildingOnDarwin
이 방법으로 코드 서명하지 않고 OSX 10.9에서 gdb를 작동하도록 만들었습니다 ( 여기에 설명되어 있음 ).
macports와 함께 gdb를 설치합니다. (건너 뛸 수 있음)
-
sudo nano /System/Library/LaunchDaemons/com.apple.taskgated.plist
옵션 문자열을 22 행, 열 27 에서
-s
로 변경하십시오-sp
. 컴퓨터를 재부팅하십시오.
gdb를 사용하십시오. Mac 포트와 함께 설치했다면 'ggdb'명령을 사용해야합니다. 또는 구성 파일에 별칭을 만들었습니다.
별칭 gdb = 'ggdb'
그런 다음 'gdb'명령을 사용하십시오.
GDB에서 동일한 문제가 발생했습니다. 나는 Mac OS X 10.8.5
일명 Mountain Lion 아래에서 달리고 있습니다. GDB 버전을 사용하고 7.7.1
있습니다.
다음 명령으로 테스트 프로그램을 컴파일했습니다.
g++ -o gdb-sample.out -g gdb-sample.cpp
명령을 입력하면 gdb sample.out
동일한 암호 오류 메시지가 나타납니다.
"Unable to find Mach task port for process-id 46234: (os/kern) failure (0x5). (please check gdb is codesigned - see taskgated(8))"
그러나이 오류 메시지는 붉은 청어입니다.
내가 찾은 해결책은 수퍼 유저 계정을 사용하여 GDB를 호출하는 것입니다.
sudo gdb sample.out.
그것은 나를 위해 잘 작동합니다.
그리고 그 시점부터 sudo를 사용하지 않고 GDB example.out을 실행할 수 있습니다.
이것이 다른 사람들에게 도움이되고 효과가 있기를 바랍니다. 그렇지 않은 경우 회신하십시오.
Sierra 10.12.6 (이상) 및 Homebrew를 사용하는 모든 사용자에게 /usr/local/bin/gdb
심볼릭 링크입니다 /usr/local/Cellar/gdb/8.0/bin/gdb
(또는 모든 버전, 예 :) 8.0.1
.
링크와 대상을 모두 코드 서명해야합니다.
codesign -fs gdb-cert /usr/local/bin/gdb
codesign -fs gdb-cert "/usr/local/Cellar/gdb/8.0/bin/gdb"
또는 다음을 greadlink
통해 설치 한 경우 brew install coreutils
:
codesign -fs gdb-cert $(which gdb)
codesign -fs gdb-cert $(greadlink -f $(which gdb))
None of this worked for me and I had to go with a long run. Here is a full list of steps I've done to get it working.
- Create a certificate to sign the gdb.
Unfortunately, system certificate gave me Unknown Error = -2,147,414,007
which is very helpful, so I had to go with a workaround. KeyChain Assistant -> Create certificate ->
Pick login
, gdb-cert
, Code Signing
Copy/move certificate to the System keychain (enter password)
- Select certificate (
gdb-cert
) clickGet info
->Trust Always
- Disable
startup-with-shell
Enter in console: set startup-with-shell off
Remember configuration: echo "set startup-with-shell off" >> ~/. gdbinit
- Enable Root User
Go to System Preferences
-> Users & Groups
-> Unlock it
-> Login Options
-> Network Account Server
-> Join
-> Unlock it
-> Edit
(menu) -> Enable Root User
sudo killall taskgated
- Finally sign gdb
codesign -fs gdb-cert "$(which gdb)"
- Disable Root User (Step 4)
- Reboot if still does not work. (if nothing else works, most likely it works already)
PS. I end up using lldb
because it just works (tutorial)
I wonder if the global change in the highest voted answer here has some unintended consequences.
Rather than enabling the old Tiger convention, taskgated does allow signed code to run. So it might be better to just get a signed cert for gdb, similar to the answer here.
After this I was able to sudo
use gdb. If you need to use gdb w/o sudo then perhaps this link will help though, disclaimer, I haven't tried it yet because using sudo
is an ok solution for now`.
I upgraded to gdb 8.3
and was not able to make things working. This helped me:
codesign --entitlements gdb.xml -fs gdb-cert /usr/local/bin/gdb
Where content of gdb.xml
is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.cs.disable-executable-page-protection</key>
<true/>
<key>com.apple.security.cs.debugger</key>
<true/>
<key>com.apple.security.get-task-allow</key>
<true/>
</dict>
</plist>
I found this solution here: https://timnash.co.uk/getting-gdb-to-semi-reliably-work-on-mojave-macos/
Note: Without the entitlement I was able to run gdb
only with sudo
.
This may not be related. You can use lldb on macos instead of gdb. You don't need this hassle to install gdb.
lldb(http://lldb.llvm.org) is already installed by default in High Sierra
gdb 8.3;
My problem is the same as the guy above, solved by
codesign --entitlements gdb.xml -fs gdb-cert /usr/local/bin/gdb
'code' 카테고리의 다른 글
상수 목록의 인라인 인스턴스화 (0) | 2020.09.09 |
---|---|
.NET 콘솔에서 JSON WebService를 호출하는 가장 좋은 방법 (0) | 2020.09.09 |
CountDownLatch 대 세마포 (0) | 2020.09.09 |
bash의 변수에 개행을 삽입하려고 시도 함 (0) | 2020.09.09 |
Java JTable 설정 열 너비 (0) | 2020.09.08 |