So this post has a couple of questions:
1. What does the stack look like when a signal is caught (via registering your own function with signal()). The reason that I ask is because I did a little assembly hacking to get the ebp register value and thus manually look through the stack, since the ra value is right after the ebp value. This works when I try it normally, its just when I try calling it from within the signal handler that i get really weird values. I tried looking them up via the nm utility but the range on the function ptrs all started with 4 whereas the values I was getting started with a 6.
2. So I was thinking that in macros in conjunction with signals would allow me to do the trick of a try catch type block. I could change catch to some random label and insert another random label after the catch. Then, i replace the try with a function call to set global variables with the location of the two previously mentioned labels and the current values of all the registers. Next, when the signal is caught, I replace all the values of the current registers with the saves versions and lastly goto the appropriate label (the catch block). Lastly, the macro would insert a goto finish label at the end of the try block so as to skip the catch block.
As far as what I dont know how to do in all that is two things. First, I dont know how to get the preprocessor to insert unique labels in the correct spots. Anyone know how? And secondly, I dont think that the signal handler can simply change the registers and jump since theres some state somewhere else that I need to unravel, right?
Any help with all of this is greatly appreciated,