0
$\begingroup$

Rosanswers logo

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?

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

It sounds like stdout is being redirected. Have you tried adding the output="screen" option to your node tag?


Originally posted by ahendrix with karma: 47576 on 2014-02-17

This answer was ACCEPTED on the original site

Post score: 7

$\endgroup$
0
$\begingroup$

Rosanswers logo

I´d recommend using a GUI for gdb-based debugging, with QtCreator currently being my favorite. A short description of how to use it is available in this answer. If there are underlying issues with gdb on your machine it might not work correctly, however.


Originally posted by Stefan Kohlbrecher with karma: 24361 on 2014-02-17

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by Kamiccolo on 2014-02-17:
And arguments would be...?

Comment by Stefan Kohlbrecher on 2014-02-18:
There are no arguments, just launch via launch file as usual and attach to the process (or at least that´s the easiest option).

Comment by Kamiccolo on 2014-02-18:
@Stefan Kohlbrecher, the same You can do with console one. Which does not require sticking to specific IDE.

Comment by Stefan Kohlbrecher on 2014-02-18:
Sure, my point was that point and click using a UI is easier for most people as they don´t have to memorize gdb commands :) If you´re already proficient with using gdb from the command line that point is moot of course.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.