Page 1 of 1

Smarttrap hook

Posted: Fri Dec 20, 2013 5:13 pm
by caleb
Is there a way to have an application hook function called when the smarttrap occurs?

I'm trying to monitor and detect a task stack overflow from all tasks. I followed this guide:

http://forum.embeddedethernet.com/viewtopic.php?t=1411

But the kicker was that the "SetAddressWrittenTrap" could only hold one value. What I did, instead, was put a magic-value pattern into the last memory address of each task's stack, and created an infrequent, low-priority monitor thread to verify that all the magic-values are still intact.

I tested it, and got it to work a few times, but what would usually happen is that a normal Access-Error trap would occur first, printing the usual info of which it's not blatantly obvious that a stack overflow occurred. This is where an application hook would come in handy as I could do some stack analysis and print out more info.

Also, there are cases where I do not have access to a serial port, so being able to log a trap into an SD card, over tcp, or into User Flash would be useful.

I'm open to other ideas as well.

Thanks!