Hi,
After a refactoring of my code, my node segfaults, so I would like to debug it with gdb. I used roslaunch with gdb prefix as indicated in this tutorial.
Nevertheless it seems that I'm able to see the error output. I have removed the "run" parameter to see if I can run it manually, add a breakpoint and so on. It works, but I cannot see neither what I type nor the standard output. For instance if I try typing the unexisting gdb command "hello", I see successfully:
Undefined command: "hello". Try "help".
But if I run a gdb command that is successfully executed (breakpoint main
, print argc
, or whatever....), the prompt does not display anything.
I tried gdb --tty /dev/pts/4
but it redirects only my program, so gdb standard input and output are still invisible.
Moreover I get the error warning: GDB: Failed to set controlling terminal: Operation not permitted
and also [tcsetpgrp failed in terminal_inferior: Inappropriate ioctl for device]
. The last error seems to be a bug of gdb, so I've installed the last version 7.7, it's now solved but I still get the first error and no display except stderr.
What program do you use to debug your nodes? Any tip or trick to redirect the standard input/output in some terminal?
Many thanks
Originally posted by courrier on ROS Answers with karma: 454 on 2014-02-17
Post score: 0
Original comments
Comment by Kamiccolo on 2014-02-17:
Usually if an application does not crash/segfault's on GDB, it's some sort of race condition. Here some tiny manual from Adobe, how to debug multi-threaded applications with GDB. Also, Valgrind should be useful.
One more thing, why the hell there are no automatic tests written, huh? You're going to burn in hell forever for missing that.
Oh, one more thing. Usually system logs (dmesg | tail 100
) contains some handy information about segfaults.
Oh, another thing - instead of redirecting IO from Your program, You could attach to working process from another terminal with GDB as described here:
http://stackoverflow.com/a/11965416/1150918 . gdb -p <pid_of_the_proccess>
, for short.
Comment by demmeln on 2014-02-17:
Are you using the xterm variant from the linked tutorial?