Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use gdb to find a floating point exception in g++ code

I have a g++ program that runs without user input. Somewhere the program is interrupted and it says "Floating point exception." Can gdb help me find what's causing this in my code? How?

like image 558
neuromancer Avatar asked Dec 07 '22 03:12

neuromancer


1 Answers

You can get help on GDB here and at Gnu's site here.

But the basics are this:

$ gdb ./your_program             // start gdb on the program
> run                            // run the program
> run argv1 argv2                // or run it with command line arguments
(floating point exception)       // let it run until exception occurs
> bt                             // bt will show the stack trace

Here are some gdb settings on how to make sure it stops on floating point exceptions.

like image 98
Stephen Avatar answered Dec 09 '22 16:12

Stephen