如何在macOS上使用GDB调试器?

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

我目前正在使用运行macOS Mojave版本10.14.5的2012年中期Macbook Pro。我正在尝试使用GDB调试器来调试C语言代码。我已经使用Homebrew在计算机上安装gdb了,但是它似乎不起作用。这是我从VSCode中的终端获得的输出:

steelwinds-MacBook-Pro:Chapter05 steelwind$ gdb ex2_dbg.out
GNU gdb (GDB) 9.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
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-darwin18.7.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
--Type <RET> for more, q to quit, c to continue without paging--<RET>
Type "apropos word" to search for commands related to "word"...
Reading symbols from ex2_dbg.out...
Reading symbols from 
/Users/steelwind/HardWay/CandC++/CandC++/Chapter05/ex2_dbg.out.dSYM/Contents/Resources/
DWARF/ex2_dbg.out...
(gdb) run
Starting program: /Users/steelwind/HardWay/CandC++/CandC++/Chapter05/ex2_dbg.out 
Unable to find Mach task port for process-id 7502: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))
(gdb) q
steelwinds-MacBook-Pro:Chapter05 steelwind$ 

我不确定是否错过了某个步骤,或者是否应该做一些事情而不是使用Homebrew,但是任何建议都是有帮助的。

c unix visual-studio-code gdb gnu
1个回答
1
投票

提示是此行:please check gdb is codesigned - see taskgated(8)

由于Apple的一项安全功能,您需要对GDB进行代码签名。具体操作如下:"please check gdb is codesigned - see taskgated(8)" - How to get gdb installed with homebrew code signed?

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