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 #q222530.
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.
UPDATES
So, I try to run my program with the command:
rosrun --prefix 'gdb run --args' zlab_drone vdstab
and I get:
GNU gdb (Ubuntu 7.11-0ubuntu1) 7.11
Copyright (C) 2016 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 "arm-linux-gnueabihf".
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 /home/sharan/catkin_ws/devel/lib/zlab_drone/vdstab...done.
(gdb)
Which is all okay till now. Now I run start
, at which point I get:
(gdb) start
Temporary breakpoint 1 at 0x1e436: file /home/sharan/catkin_ws/src/zlab_drone/src/vidStab.cpp, line 136.
Starting program: /home/sharan/catkin_ws/devel/lib/zlab_drone/vdstab
Program received signal SIGSEGV, Segmentation fault.
0x76fd9822 in ?? () from /lib/ld-linux-armhf.so.3
(gdb)
Which is a bit weird. To see where the segmentation fault is, I try to list
. The first time I get this:
(gdb) list
122 // warpAffine(cv_ptr->image, orig_warped, invTrans.rowRange(0,2),
123 // Size());
124
125 // Publishing (Only uncomment, if you're sure nothing is broken
126 // in this section)
127 /*
128 cv_ptr->image = orig_warped;
129 image_pub_.publish(cv_ptr->toImageMsg());
130 */
131 }
(gdb)
The second time, I get this:
(gdb) list
132
133 };
134
135 int main(int argc, char** argv)
136 {
137 ros::init(argc, argv, "video_stabilizer");
138 Tracker tr;
139 ros::spin();
140 return 0;
141 }
(gdb)
Third:
(gdb)
142 ...
Seems like your terminal state might be funky. Try running
stty sane
to reset it before you start your node.@ahendrix nope, invoked
stty sane
and restarted the program but I still get the error:I even restarted the Raspberry Pi.
I don't think @ahendrix' comment was meant as a solution to your
SEGFAULT
, but it could've been a way to getgdb
to behave again.@gvdhoorn Yeah, I got that, but I was just expanding on the fault that I am getting
To clarify: running
stty sane
should fix the issue where runninglist
in gdb produces unending output, but it won't fix your segfault. The segfault is almost certainly a bug in your code.Yes of course, I get that. But it is obviously buggy, as it should manually go to the start of
main
and then approach the segfault throughstep
ornext
.It sounds like you're expecting things from gdb that it doesn't do by default. Can you edit your question to include the full text of your debugging session?
yeah, I've posted exactly what I get when I open up gdb. The thing is, I didn't get this, last time I ran gdb, where I used specific syntax.