Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/136.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ macos中使用gdb的热点_C++_Linux_Macos_Makefile_Gdb - Fatal编程技术网

C++ macos中使用gdb的热点

C++ macos中使用gdb的热点,c++,linux,macos,makefile,gdb,C++,Linux,Macos,Makefile,Gdb,我总是在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/B

我总是在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无法正确执行,有什么问题

这是我的Makefile:

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)
这是我的Makefile:

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)
在Linux上调试这个程序也不会很愉快:编译它时没有调试符号(
-g
标志)

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

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

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

我建议在OSX上使用
lldb
。官方的
gdb
从未完全支持OSX,苹果的
gdb
也已经停产。我猜这些警告与您的问题有关。看起来我应该添加额外的参数-g,但是应该将此参数放在哪里。感谢Alexander,
lldb
中的命令是否与
gdb
相同?有些相同,有些不相同。