INF and/or NAN (global) exception during debug
-
Needed that Visual studio pause the application and tells me a message when an infinite number or a NAN is generated so I can debug and remove the causes. Any flag available on the solution's properties? Thanks
Russell
You can put a breakpoint and set the breakpoint condition as something that check the value. Then start debug run. VS will break the execution once the condition is met. Btw, I don't think that there is a specific condition check like NAN or infinite (in C/C++). But you can check the range of value depending on the variable type. For example, long n can be checked something like ( (unsigned long) n > 0x7FFFFFFF ).
- ns ami -
modified on Tuesday, September 29, 2009 11:19 PM
-
You can put a breakpoint and set the breakpoint condition as something that check the value. Then start debug run. VS will break the execution once the condition is met. Btw, I don't think that there is a specific condition check like NAN or infinite (in C/C++). But you can check the range of value depending on the variable type. For example, long n can be checked something like ( (unsigned long) n > 0x7FFFFFFF ).
- ns ami -
modified on Tuesday, September 29, 2009 11:19 PM
In that cases I think it is possible to use functions like isnan() and isinf(). Other test like you wrote probably will fail because you can't use standard math in that cases. But the problem is that I have to find when and where the problem happens to set some addictional line to let the algorithm be safer. So I can't check every single line with breakpoints (only the lines of the algorithm that I'm testing are more than 10000 and on different files). It is surely needed an help from the debugger, it have to check for us and open a dialog like happens for ASSERTs so we can work. :(( It looks strange that there isn't any option that can be set into the debugger...
Russell
-
You can put a breakpoint and set the breakpoint condition as something that check the value. Then start debug run. VS will break the execution once the condition is met. Btw, I don't think that there is a specific condition check like NAN or infinite (in C/C++). But you can check the range of value depending on the variable type. For example, long n can be checked something like ( (unsigned long) n > 0x7FFFFFFF ).
- ns ami -
modified on Tuesday, September 29, 2009 11:19 PM
Nishad S wrote:
long n can be checked something like ( n > 0x7FFFFFFF ).
How? If you add
1
to that value, it becomes negative, thus failing the test."Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
In that cases I think it is possible to use functions like isnan() and isinf(). Other test like you wrote probably will fail because you can't use standard math in that cases. But the problem is that I have to find when and where the problem happens to set some addictional line to let the algorithm be safer. So I can't check every single line with breakpoints (only the lines of the algorithm that I'm testing are more than 10000 and on different files). It is surely needed an help from the debugger, it have to check for us and open a dialog like happens for ASSERTs so we can work. :(( It looks strange that there isn't any option that can be set into the debugger...
Russell
Russell' wrote:
only the lines of the algorithm that I'm testing are more than 10000 and on different files
Sounds like a very complicated algorithm!
Russell' wrote:
It looks strange that there isn't any option that can be set into the debugger
Well if the program doesn't signal anything on these errors how is the debugger supposed to recognise it, apart from checking the results of every instruction in the program. Consider how long that may take to run.
-
Russell' wrote:
only the lines of the algorithm that I'm testing are more than 10000 and on different files
Sounds like a very complicated algorithm!
Russell' wrote:
It looks strange that there isn't any option that can be set into the debugger
Well if the program doesn't signal anything on these errors how is the debugger supposed to recognise it, apart from checking the results of every instruction in the program. Consider how long that may take to run.
It doesn't matter how long it will take: this is simply an advanced-debug step, the release version will not contain this big amount of addictional operation. ... and without this help we surely will lost more and more time going to check all the code :doh: Also because this algorithm works for some set of data, but dont' works for other sets (probably because for some reasons the numbers becames too small). X|
Russell
-
Needed that Visual studio pause the application and tells me a message when an infinite number or a NAN is generated so I can debug and remove the causes. Any flag available on the solution's properties? Thanks
Russell
I have not tried this. According to the docs[^] you can use
_controlfp()
to unmask floating point exceptions, which are all masked by default, by specifying the_MCW_EM
mask. Also maybe check out _fpieee_flt()[^] and _fpclass()[^]
You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it!
-
I have not tried this. According to the docs[^] you can use
_controlfp()
to unmask floating point exceptions, which are all masked by default, by specifying the_MCW_EM
mask. Also maybe check out _fpieee_flt()[^] and _fpclass()[^]
You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it!
-
Needed that Visual studio pause the application and tells me a message when an infinite number or a NAN is generated so I can debug and remove the causes. Any flag available on the solution's properties? Thanks
Russell
-
Nishad S wrote:
long n can be checked something like ( n > 0x7FFFFFFF ).
How? If you add
1
to that value, it becomes negative, thus failing the test."Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
It looks exactly the type of tip that I was looking for! ;) I'll let you know if it is the right way after some tests. Thank you
Russell