寻找 macOS Sonoma 14.0 上的 Python 脚本代码签名,以便能够使用 gdb 和 lldb 进行调试

问题描述 投票:0回答:1

在 macOS Sonoma 14.0 上,我有一个使用 Intel OneAPI 框架启动的 python 脚本。

在Intel的python3.9(2022.2.0)执行时,进行一些计算后会产生分段错误。

我想在 macOS 上获取此 ssegfault 的回溯。

我尝试使用“gdb”“lldb”,但不可能使用它们,因为据说这些文件没有经过共同设计。

例如,使用 gdb,我得到:

$ gdb -ex run --args python3.9 camb_and_hi_classy_fails.py

输入“run”后,我收到此错误:

gdb -exe run --args python3.9 camb_and_hi_classy_fails.py
GNU gdb (GDB) 13.2
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin22.4.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
Find the GDB manual and other documentation resources online at:
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python3.9...
(No debugging symbols found in python3.9)
(gdb) r
Starting program: /opt/intel/oneapi/intelpython/python3.9/bin/python3.9 camb_and_hi_classy_fails.py
Unable to find Mach task port for process-id 16678: (os/kern) failure (0x5).
(please check gdb is codesigned - see taskgated(8))
(gdb)

使用 lldb,我也遇到同样的错误:

lldb --file python3.9 camb_and_hi_classy_fails.py
(lldb) target create "/opt/intel/oneapi/intelpython/latest/bin/python3.9"
Current executable set to '/opt/intel/oneapi/intelpython/latest/bin/python3.9' (x86_64).
(lldb) settings set -- target.run-args  "camb_and_hi_classy.py"
(lldb) r
error: process exited with status -1 (attach failed (Not allowed to attach to process.  Look in the console messages (Console.app), near the debugserver entries, when the attach failed.  The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.))
(lldb)

我已按照第一个答案中的说明进行操作:

在 mac os x 环境下对可执行应用程序文件进行签名有哪些方法或技术?

也就是说,我做到了:

首先您需要生成自己的证书。

open -a "Keychain Access"
(MENU) Certificate Assistant  Create a Certificate
Enter the Name (for example my-codesign-cert)
Identity Type  Self Signed Root
Certificate Type Code Signing
Check "Let me override defaults" & click Continue.
Enter a unique Serial Number.
Enter a big Validity Period (days), like 3560 & click Continue.
Fill in your personal information & click Continue.
Accept defaults for the rest of the dialog boxes.

并共同设计您的物品:

codesign -s my-codesign-cert path_to_my_binary_executable

然后我做了(尝试了用户和root):

  1. $ codesign -s my-codesign-cert camb_and_hi_classy_fails.py

  2. 对 Python3.9 也做了同样的事情:

    $ codesign -s my-codesign-cert /opt/intel/oneapi/intepython/last/bin/python3.9
    

但我仍然无法在 Mac 上使用

gdb
lldb

我尝试按照此链接上的说明进行操作:

在 mac os x 环境下对可执行应用程序文件进行签名有哪些方法或技术?

macos gdb code-signing lldb code-signing-certificate
1个回答
0
投票

也许您应该共同设计 gdb,而不是脚本?

© www.soinside.com 2019 - 2024. All rights reserved.