|
192 | 192 |
|
193 | 193 | ### Debugging floating point failures |
194 | 194 |
|
195 | | -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: |
| 195 | +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 are a number of static methods you can use to set up a watch: |
196 | 196 | {% highlight c++ %} |
197 | | -IEEE754ExceptionsPlugin::checkIeee754ExeptionFlag(int flag). |
| 197 | +IEEE754ExceptionsPlugin::checkIeee754OverflowExceptionFlag(); |
| 198 | +IEEE754ExceptionsPlugin::checkIeee754UnderflowExceptionFlag(); |
| 199 | +IEEE754ExceptionsPlugin::checkIeee754InexactExceptionFlag(); |
| 200 | +IEEE754ExceptionsPlugin::checkIeee754DivByZeroExceptionFlag(); |
198 | 201 | {% endhighlight %} |
199 | | -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: |
| 202 | +Here is an minimal example using Gdb, example.cpp: |
200 | 203 | {% highlight c++ %} |
201 | 204 | #include "CppUTest/TestHarness.h" |
202 | 205 | #include "CppUTestExt/IEEE754ExceptionsPlugin.h" |
@@ -234,16 +237,16 @@ Breakpoint 1, main () at example.cpp:8 |
234 | 237 | 8 f /= 0.0f; |
235 | 238 | (gdb) |
236 | 239 | {% endhighlight %} |
237 | | -4) Set up the watch you need (on this particular platform, FE_DIVBYZERO==0x04): |
| 240 | +4) Set up the watch you need: |
238 | 241 | {% highlight bash %} |
239 | | -(gdb) watch IEEE754ExceptionsPlugin::checkIeee754ExeptionFlag(0x04) |
240 | | -Watchpoint 2: IEEE754ExceptionsPlugin::checkIeee754ExeptionFlag(0x04) |
| 242 | +(gdb) watch IEEE754ExceptionsPlugin::checkIeee754DivByZeroExceptionFlag() |
| 243 | +Watchpoint 2: IEEE754ExceptionsPlugin::checkIeee754DivByZeroExceptionFlag() |
241 | 244 | (gdb) |
242 | 245 | {% endhighlight %} |
243 | 246 | 5) Stepping over the offending statement will change the value of your watch: |
244 | 247 | {% highlight bash %} |
245 | 248 | (gdb) next |
246 | | -Watchpoint 2: IEEE754ExceptionsPlugin::checkIeee754ExeptionFlag(0x04) |
| 249 | +Watchpoint 2: IEEE754ExceptionsPlugin::checkIeee754DivByZeroExceptionFlag() |
247 | 250 |
|
248 | 251 | Old value = false |
249 | 252 | New value = true |
|
0 commit comments