查找导致没有IDE的分割故障的位置
我正在研究C ++的一个项目。它很大,由CMAKE创建。安装了所有依赖关系和自由时,它的构建很好。但是,当我运行它时,我会得到分割故障
。
这是事实:没有IDE,在VS代码中使用CMAKE运行此项目。我想知道是否可以在导致分割故障
的代码中找到此位置。我知道此类事情有GDB调试器。我运行了几个命令,这是我得到的:
gdb build/studpark
...
Reading symbols from build/studpark...
(gdb) run
Starting program: /Users/admin/Downloads/StudPark-develop/build/studpark
[New Thread 0x2503 of process 7316]
[New Thread 0x1903 of process 7316]
[New Thread 0x1a03 of process 7316]
warning: unhandled dyld version (17)
Thread 3 received signal SIGSEGV, Segmentation fault.
0x00007ff809bec6b2 in ?? ()
(gdb) backtrace
#0 0x00007ff809bec6b2 in ?? ()
#1 0x00007ff7bfeff510 in ?? ()
#2 0x0000000100002abe in main ()
Backtrace stopped: frame did not save the PC
问题是:是否可以在代码中跟踪并找到导致分割故障的代码中的确切位置?
编辑:我用这些标志编译我的项目:
set(cmake_cxx_flags“ -stdlib = libc ++ -g”)
我的平台是Mac OS。
I'm studying one project in C++. It's quite big, build is created with cmake. After installing all dependencies and libs it's the build is done fine. But when I run it, I get Segmentation fault
.
Here is the thing: There is no IDE, running this project with cmake in VS Code. I wonder if it's possible to find this place in code which causes Segmentation fault
. I know that there is GDB debugger for such things. I run several commands and here's what I get:
gdb build/studpark
...
Reading symbols from build/studpark...
(gdb) run
Starting program: /Users/admin/Downloads/StudPark-develop/build/studpark
[New Thread 0x2503 of process 7316]
[New Thread 0x1903 of process 7316]
[New Thread 0x1a03 of process 7316]
warning: unhandled dyld version (17)
Thread 3 received signal SIGSEGV, Segmentation fault.
0x00007ff809bec6b2 in ?? ()
(gdb) backtrace
#0 0x00007ff809bec6b2 in ?? ()
#1 0x00007ff7bfeff510 in ?? ()
#2 0x0000000100002abe in main ()
Backtrace stopped: frame did not save the PC
The question is: Is it possible to trace and find exact place in code that causes segmentation fault?
EDIT: I compile my project with these flags:
set(CMAKE_CXX_FLAGS "-stdlib=libc++ -g")
My platform is Mac OS.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了一个解决方案的解决方案,这是我所做的:
“ program”:“ $ {workspacefolder}/build/main/main”
以显示我可执行文件的路径。执行这些操作后,我能够以调试模式运行我的程序,并通过断点,帮助我检查项目并在代码中找到错误。
I've found a solution for my case and here's what I've done:
"program": "${workspaceFolder}/build/main"
to show path to my executable file.After doing these actions I was able to run my program in Debug mode with breakpoints which helped me to examine project and find errors in code.