Ask Your Question

Breakpoint in ROS_ASSERT

asked 2014-07-07 05:19:34 -0500

Wolf gravatar image

Is it possible to set a debug breakpoint in ROS_ASSERT (gdb, Eclipse..) which only stops the program execution if the assertion fails so I can inspect the stack when the assertion fails?

It would work, if it would be like this:

if ( !( cond ) )
 ROS_ASSERT( cond );  // set breakpoint here

But without the surrounding if statement, the ROS_ASSERT is only in one line, and if I set a breakpoint there it will stop always, not only if the assertion fails.....

Any ideas on this? Thank you!

edit retag flag offensive close merge delete



ROS_ASSERT calls abort(). You might be able to trap that directly.

dornhege gravatar image dornhege  ( 2014-07-07 05:24:17 -0500 )edit

+1 Works! Thank you!

Wolf gravatar image Wolf  ( 2014-07-07 07:09:10 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-07-08 02:14:36 -0500

Wolf gravatar image

As @dornhege stated ROS_ASSERT calls abort. The SIGABRT can be trapped directly using gdb (in my case it even did by default;) ). Note that the thereby the SIGABRT is handled, so the process 'survives' the ROS_ASSERT. You still need to kill it via gbd....

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-07-07 05:19:34 -0500

Seen: 301 times

Last updated: Jul 08 '14