You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a test fails due to a floating point error, it can be challenging to find the location of the offending operation, since the plugin has no knowledge of where the flag was originally set. To aid in debugging, there is a static method you can use to set up a watch:
Unfortunately, the debugger has no knowledge of defined macros such as FE_DIVBYZERO. Therefore, you will need to find out the integer value of the macro you require, and pass that as argument. Here is an minimal example using Gdb, example.cpp:
200
+
{% highlight c++ %}
201
+
#include "CppUTest/TestHarness.h"
202
+
#include "CppUTestExt/IEEE754ExceptionsPlugin.h"
203
+
204
+
static volatile float f = 1.0;
205
+
static volatile IEEE754ExceptionsPlugin plugin; // Make sure this is linked, so the debugger knows it
206
+
207
+
int main(int, char**) {
208
+
f /= 0.0f; // the offending statement
209
+
return 0;
210
+
}
211
+
{% endhighlight %}
212
+
1) Compile the example. Your command line will look roughly like this:
Of course you don't have to use commandline Gdb to do this; you can debug your code from within your favorite IDE (Eclipse, Code::Blocks, ...) following basically the same procedure.
0 commit comments