Search code examples
c++cmakegdbrostui

Why isn't gdb working for me


Background

I am currently trying to build an autonomous drone using ROS on my Rapsberry Pi which is running an Ubuntu MATE 16.04 LTS. Solving the Computer Vision problem of recognising red circles as of now.

Specific Problem

I am constantly getting the error I get in this 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.

When I invoke this command, even with tui, I get a SIGSEGV and when I invoke list inside gdb itself, the program does not stay at a particular point and keeps listing a different line till it is out of range. This is quite a weird issue.

I managed to make it work without this issue earlier by using a different command, I reckon. I just cannot remember how I made it work last time.


Solution

  • I found out about this exclusive bug that relates to Raspberry Pi's solely. Basically the solution involves, as quoted by 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.