为什么 gdb 不为我工作
Why isn't gdb working for me
背景
我目前正在尝试在我的 Rapsberry Pi 上使用 ROS 构建一个自主无人机,它是 运行 一个 Ubuntu MATE 16.04 LTS。目前解决了识别红色圆圈的计算机视觉问题。
具体问题
我不断收到 question. To help me solve this, I have decided to use gdb. However, the command rosrun --prefix 'gdb run --args' zlab_drone vdstab
does not seem to be working for me. zlab_drone
is the name of the package and vdstab
is the name of the executable I am trying to run. Since this is inside a ROS environment, I have grabbed the syntax from here, and used the suggestions in this question 中的错误。
当我调用此命令时,即使使用 tui
,我也会得到一个 SIGSEGV
,当我在 gdb
本身内部调用 list
时,程序不会停留在一个特定的点并不断列出不同的线,直到它超出范围。这是一个很奇怪的问题。
我想我之前使用不同的命令成功地使它在没有这个问题的情况下工作,我想。我只是不记得上次我是如何让它工作的。
好吧,在你提到的 link 中,明确指出你应该使用其中之一:
launch-prefix="xterm -e gdb --args" : run your node in a gdb in a separate xterm window, manually type run to start it
或:
launch-prefix="gdb -ex run --args" : run your node in gdb in the same xterm as your launch without having to type run to start it
所以,看起来您确实错过了一个 -ex,正如 @ks1322 在评论中建议的那样,或者只需输入 运行 开始调试过程。
我发现了 this 独有的与 Raspberry Pi 相关的错误。正如 Peter Bennet 所引用的那样,解决方案基本上涉及:
There is a workaround. Start the program, then from another command
prompt or from an ssh remote login, use gdp -p xxxxx where xxxxx is
the process number. This works without crashing. If you need to debug
something that happens before you can get in from another command
prompt, add to the program a command that stops process at the
beginning of main, for example a call to gets, which will wait for you
to press enter before continuing.
背景
我目前正在尝试在我的 Rapsberry Pi 上使用 ROS 构建一个自主无人机,它是 运行 一个 Ubuntu MATE 16.04 LTS。目前解决了识别红色圆圈的计算机视觉问题。
具体问题
我不断收到 rosrun --prefix 'gdb run --args' zlab_drone vdstab
does not seem to be working for me. zlab_drone
is the name of the package and vdstab
is the name of the executable I am trying to run. Since this is inside a ROS environment, I have grabbed the syntax from here, and used the suggestions in this question 中的错误。
当我调用此命令时,即使使用 tui
,我也会得到一个 SIGSEGV
,当我在 gdb
本身内部调用 list
时,程序不会停留在一个特定的点并不断列出不同的线,直到它超出范围。这是一个很奇怪的问题。
我想我之前使用不同的命令成功地使它在没有这个问题的情况下工作,我想。我只是不记得上次我是如何让它工作的。
好吧,在你提到的 link 中,明确指出你应该使用其中之一:
launch-prefix="xterm -e gdb --args" : run your node in a gdb in a separate xterm window, manually type run to start it
或:
launch-prefix="gdb -ex run --args" : run your node in gdb in the same xterm as your launch without having to type run to start it
所以,看起来您确实错过了一个 -ex,正如 @ks1322 在评论中建议的那样,或者只需输入 运行 开始调试过程。
我发现了 this 独有的与 Raspberry Pi 相关的错误。正如 Peter Bennet 所引用的那样,解决方案基本上涉及:
There is a workaround. Start the program, then from another command prompt or from an ssh remote login, use gdp -p xxxxx where xxxxx is the process number. This works without crashing. If you need to debug something that happens before you can get in from another command prompt, add to the program a command that stops process at the beginning of main, for example a call to gets, which will wait for you to press enter before continuing.