简体   繁体   English

点云库应用难以调试,可能是由于线程?

[英]Point cloud library apps difficult to debug, possibly due to threading?

I'm using the Point Cloud Library with cmake for compilation, and I've got it building in debug mode, but my program doesn't seg fault or abort in the way I'd expect it to. 我正在使用带有cmake的Point Cloud Library进行编译,并且我已经在调试模式下构建了它,但是我的程序没有按照我期望的方式分割错误或中止。

Specifically, I get messages like this: 具体来说,我得到这样的消息:

(gdb) run bunny
Starting program: debug/our_cvfh bunny
libc++abi.dylib: terminating
[New Thread 0x170b of process 80178]

Program received signal SIGABRT, Aborted.
0x00007fff88c6f866 in ?? ()
(gdb) bt
#0  0x00007fff88c6f866 in ?? ()
#1  0x00007fff8bb5235c in ?? ()
#2  0x0000000000000000 in ?? ()
(gdb) break rec/registered_views_source.h:305
Cannot access memory at address 0x961d60

In this case, I know where the error is, but I'd like to be able to backtrace it and see what called the function in this case. 在这种情况下,我知道错误的位置,但我希望能够回溯它并查看在这种情况下调用函数的内容。

Is PCL creating another thread, and that's why I can't backtrace? PCL是否会创建另一个线程,这就是我无法回溯的原因? I'm not doing any visualizations right now, so I can't figure out why it'd be using threading. 我现在没有做任何可视化,所以我无法弄清楚为什么它会使用线程。

I've also tried running the program in the debug directory instead of from my source root directory. 我也尝试在调试目录中运行程序,而不是从源根目录运行。 Here's another example of it not working: 这是另一个不起作用的例子:

$ gdb our_cvfh
GNU gdb (GDB) 7.7
Copyright (C) 2014 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-darwin13.1.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 "apropos word" to search for commands related to "word"...
Reading symbols from our_cvfh...done.
run (gdb) run
Starting program: /Users/jwoods/Projects/lidargl/fpfh/debug/our_cvfh
[New Thread 0x170b of process 33571]

Program received signal SIGSEGV, Segmentation fault.
0x000000010016cdec in ?? ()
(gdb) bt
#0  0x000000010016cdec in ?? ()
#1  0x00007fff5fbfbd08 in ?? ()
#2  0x00007fff5fbfbcc0 in ?? ()
#3  0x00007fff5fbfbcc8 in ?? ()
#4  0x00007fff5fbfbcc8 in ?? ()
#5  0x00007fff5fbfbcc8 in ?? ()
#6  0xffffffffffffffff in ?? ()
#7  0x00007fff5fbfbcc8 in ?? ()
#8  0x00007fff5fbfbcc8 in ?? ()
#9  0x00007fff5fbfbcc0 in ?? ()
#10 0x00007fff5fbfbcc0 in ?? ()
#11 0x00007fff5fbfbcc8 in ?? ()
#12 0x00007fff5fbfbcc8 in ?? ()
#13 0x00007fff5fbfbcc8 in ?? ()
#14 0x00007fff5fbff4a8 in ?? ()
#15 0x00007fff5fbff4d8 in ?? ()
#16 0x00007fff5fbff420 in ?? ()
#17 0x00007fff5fbff4d8 in ?? ()
#18 0x0000000000000000 in ?? ()
(gdb)

gdb works fine when I'm not using CMake, so my guess is it has something to do with CMake. 当我不使用CMake时gdb工作正常,所以我的猜测是它与CMake有关。 This doesn't seem to present a problem for anyone else, which tells me it may also have to do with the fact that I'm using CMake with Mac OS X. 对于其他任何人来说这似乎都没有问题,这告诉我它可能也与我在Mac OS X上使用CMake的事实有关。

How do I get my normal GDB behavior? 我如何获得正常的GDB行为?

Update 更新

I can run dsymutil my_output_binary in order to generate the debugging symbols (following make ). 我可以运行dsymutil my_output_binary以生成调试符号(在make )。 This is a workaround. 这是一种解决方法。 I'd like it to be done automatically, and amn't sure why it's not. 我希望它能自动完成,并且不确定为什么不是。 The dsymutil strategy works for most segfaults, but doesn't work for some cases of SIGABRT. dsymutil策略适用于大多数段错误,但对SIGABRT的某些情况不起作用。 Here is the output: 这是输出:

Calling compute <--- normal std::cerr output of my program, single-threaded
Assertion failed: (index >= 0 && index < size()), function operator[], file /usr/local/Cellar/eigen/3.2.1/include/eigen3/Eigen/src/Core/DenseCoeffsBase.h, line 378.
[New Thread 0x170b of process 64108]

Program received signal SIGABRT, Aborted.
0x00007fff84999866 in ?? ()
(gdb) bt
#0  0x00007fff84999866 in ?? ()
#1  0x00007fff862c335c in ?? ()
#2  0x0000000000000000 in ?? ()
(gdb) info threads
  Id   Target Id         Frame
  2    Thread 0x170b of process 64108 0x00007fff8499a662 in ?? ()
* 1    Thread 0x1503 of process 64108 0x00007fff84999866 in ?? ()
(gdb)

Note that my program is not itself multi-threaded, but it appears to be making use of a library which is creating threads — or at least that's what I gather from the gdb output. 请注意,我的程序本身并不是多线程的,但似乎是在使用创建线程的库 - 或者至少是我从gdb输出中收集的内容。

I've tried disabling threading with Eigen, which is used by PCL. 我已经尝试使用PCL使用的Eigen禁用线程。

Interestingly, lldb is able to generate the backtraces, but I'm curious as to why GDB can't. 有趣的是, lldb能够产生回溯,但我很好奇为什么GDB不能。

Other than simply using LLDB in lieu of GDB, I haven't figured out how to debug threads. 除了简单地使用LLDB代替GDB之外,我还没有想出如何调试线程。

However, I have figured out how to automatically produce debugging symbols! 但是,我已经想出如何自动生成调试符号! Hooray. 万岁。

You need three files: 你需要三个文件:

Put these in your project's cmake/Modules/ directory. 将它们放在项目的cmake/Modules/目录中。

In CMakeLists.txt , you'll need the following lines after your project declaration: CMakeLists.txt ,项目声明后需要以下几行:

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/")

if (APPLE) # this if statement is optional, but you definitely need the include()
  include(UseDebugSymbols)
endif (APPLE)

That will look in the appropriate location. 这将在适当的位置查看。

I should note that I made another change to my project simultaneously, which may also be useful to you. 我应该注意到我同时对我的项目进行了另一次更改,这对您也很有用。 In my add_executable line, right after the name of the target, I added MACOSX_BUNDLE . 在我的add_executable行中, add_executable目标名称后,我添加了MACOSX_BUNDLE This flag will cause it to be compiled as a .app instead of a regular binary. 此标志将使其编译为.app而不是常规二进制文件。 Here's an example from my project: 这是我项目的一个例子:

add_executable(pose MACOSX_BUNDLE pose.cpp rec/global_nn_recognizer_cvfh.cpp rec/global_nn_recognizer_cvfh.hpp rec/render_views_tesselated_sphere.cpp)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM