Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. INF and/or NAN (global) exception during debug

INF and/or NAN (global) exception during debug

Scheduled Pinned Locked Moved C / C++ / MFC
csharpvisual-studiodebuggingquestion
11 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R 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

    N Offline
    N Offline
    Nishad S
    wrote on last edited by
    #2

    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

    R D 2 Replies Last reply
    0
    • N Nishad S

      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

      R Offline
      R Offline
      Russell
      wrote on last edited by
      #3

      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

      L 1 Reply Last reply
      0
      • N Nishad S

        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

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #4

        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

        N 1 Reply Last reply
        0
        • R Russell

          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

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #5

          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.

          R 1 Reply Last reply
          0
          • L Lost User

            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.

            R Offline
            R Offline
            Russell
            wrote on last edited by
            #6

            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

            1 Reply Last reply
            0
            • R 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

              P Offline
              P Offline
              PJ Arends
              wrote on last edited by
              #7

              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!

              R 1 Reply Last reply
              0
              • P PJ Arends

                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!

                R Offline
                R Offline
                Russell
                wrote on last edited by
                #8

                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

                P 1 Reply Last reply
                0
                • R 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

                  R Offline
                  R Offline
                  Rick York
                  wrote on last edited by
                  #9

                  in addition to _fpclass there are _isnan and _finite. A class wrapping up _fpclass is probably the way to go. :)

                  1 Reply Last reply
                  0
                  • D David Crow

                    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

                    N Offline
                    N Offline
                    Nishad S
                    wrote on last edited by
                    #10

                    Yes. I have updated my reply. ((unsigned long) n > 0x7FFFFFFF)

                    - ns ami -

                    1 Reply Last reply
                    0
                    • R Russell

                      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

                      P Offline
                      P Offline
                      PJ Arends
                      wrote on last edited by
                      #11

                      Russell' wrote:

                      I'll let you know if it is the right way after some tests.

                      Just wondering if it worked for you or not.


                      You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it!

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups