hi everyone,
I need to know if it is possible to modify or add information with the throwing exception. When the software use EnableSmartTraps() information is send to the RS-232 and you can see information about register and other think... but i would add my own information, like the value of variable x or y etc...if it possible?
and the same time i try to find example to use the try catch to try to find what is cause the throwing exception in the software...but the example i found is all the time in thread for UDP application...
I just try{...my code}catch() { iprintf("value of x %d",x);}... or something like that.
Thanks Yanick.
Throwing exception with EnableSmartTraps() and try catch
Re: Throwing exception with EnableSmartTraps() and try catch
When a smarttrap is occurs it means a fatal error has happened. In most cases it also means that it is not possible for the application to proceed any further. Smarttrap is very minimal code that runs in an trap interrupt and attempts to recover stack and system information and then prints it out using a very minimal polling serial driver. This is sort of like if your application caused a blue screen of death on a windows machine. It would not be possible to catch that error and print it out the terminal since the OS and system is already crashed beyond recovery.
You can try to modify the source for smarttrap to print out your variable:
C:\nburn\system\smarttrap.cpp
Stdio will not work here since the OS is not operational. To print you must use the local_out functions such as Local_OutHex and Local_OutString. Depending on the variable it may also trigger another trap and then you will see no info, just a reboot.
You should also use WinAddr2Line to decode the address information in the smarttrap message. Read the smarttrap chapter of the NetBurnerTools documentation:
C:\nburn\docs\NetBurnerPcTools
You can try to modify the source for smarttrap to print out your variable:
C:\nburn\system\smarttrap.cpp
Stdio will not work here since the OS is not operational. To print you must use the local_out functions such as Local_OutHex and Local_OutString. Depending on the variable it may also trigger another trap and then you will see no info, just a reboot.
You should also use WinAddr2Line to decode the address information in the smarttrap message. Read the smarttrap chapter of the NetBurnerTools documentation:
C:\nburn\docs\NetBurnerPcTools
Re: Throwing exception with EnableSmartTraps() and try catch
Two things to consider:
1. have found that very often "iprintf" or one of its cousins is the cause of many traps. You can have a sprintf or printf that takes a flag like %f then you change the underlying variable from float to int and forget to change the printf that uses it and you will crash. I have recently been converting everything over to use cout from <iostream> since it is typesafe.
2. I believe exception handling is turned off by default so if you want to try/catch you need to remember to turn it on by clearing the checkbox as shown in the image.
1. have found that very often "iprintf" or one of its cousins is the cause of many traps. You can have a sprintf or printf that takes a flag like %f then you change the underlying variable from float to int and forget to change the printf that uses it and you will crash. I have recently been converting everything over to use cout from <iostream> since it is typesafe.
2. I believe exception handling is turned off by default so if you want to try/catch you need to remember to turn it on by clearing the checkbox as shown in the image.
- Attachments
-
- ExceptionHandlingOff.png (143.2 KiB) Viewed 4188 times
Re: Throwing exception with EnableSmartTraps() and try catch
Tod brings up a good point and solution, but I would also consider just using printf instead of iprintf. Adding all the C++ STL stuff will take up a lot of memory resources. The difference between iprintf and printf is that you save space if you don't link in the floating point library.
Re: Throwing exception with EnableSmartTraps() and try catch
