gpt4 book ai didi

c++ - 在 macos 中热用 gdb

转载 作者:太空宇宙 更新时间:2023-11-04 13:00:21 25 4
gpt4 key购买 nike

我一直在 Linux 中使用 gdb,它工作正常,这是我第一次在 mac 中使用 gdb,这与 Linux 不同。

(gdb) b main
Breakpoint 1 at 0x100000ec4
(gdb) r
Starting program: /Users/vinllen/code/tmp/lhm/homework
warning: Could not open OSO archive file "/BinaryCache/corecrypto/corecrypto-233.1.2~26/Symbols/BuiltProducts/libcorecrypto_static.a"
warning: `/BinaryCache/coreTLS/coreTLS-35.20.2~10/Objects/coretls.build/coretls.build/Objects-normal/x86_64/system_coretls_vers.o': can't open to read symbols: No such file or directory.
warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.20.2~10/Symbols/BuiltProducts/libcoretls_ciphersuites.a"
warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.20.2~10/Symbols/BuiltProducts/libcoretls_handshake.a"
warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.20.2~10/Symbols/BuiltProducts/libcoretls_record.a"
warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.20.2~10/Symbols/BuiltProducts/libcoretls_stream_parser.a"

Breakpoint 1, 0x0000000100000ec4 in main ()
(gdb) l
No symbol table is loaded. Use the "file" command.
(gdb) n
Single stepping until exit from function main,
which has no line number information.

看起来命令ln 不能正确执行,问题是什么?

这是我的生成文件:

objects = main.o conversion.o slitemlist.o uims.o testdrivers.o

homework:$(objects)
g++ -o homework $(objects)

conversion.o: conversion.h base.h
slitemlist.o: slitemlist.h base.h
uims.o: conversion.h base.h conversion.h slitemlist.h
testdrivers.o: testdrivers.h

.PHONY: clean
clean:
rm homework $(objects)

最佳答案

Here is my Makefile:

不会在 Linux 上调试这个程序会很愉快:您编译它时没有调试符号(-g 标志)。

您真正的问题不是“我如何在 MacOS 上使用 GDB”,而是“我如何编写 Makefile 以便我可以调试”。

你应该在你的 Makefile 中添加这样一行:

CFLAGS = -g
CXFLAGS = -g # if building C++

关于c++ - 在 macos 中热用 gdb,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34080178/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com