context health test

Dear list,

I'd like to see a proper test for context health in RIOT, but I don't really know how to implement it in c.

In order to test natives context switches I wrote this test project: https://github.com/LudwigOrtmann/projects/blob/test_irq/test_irq/main.c

While this test breaks when an involuntary context switch is "unsuccessful" (i.e. there is a significant error in the context switch), it does not really assure the context is healthy.

What I am looking for is a way to make sure that all registers and the stack contents are the same before and after the context switch.

Thanks in advance, Ludwig

Hi!

I'd like to see a proper test for context health in RIOT, but I don't really know how to implement it in c.

Any input on this? Would be very interesting for my MSP430 IRQ problem.

Cheers, Oleg

Hi!

I had to deal with "context sickness" too last week and after some thinking there are two approaches that came to my mind.

1. The C function This one would have to be called as first statement in the context switch function copying register values and stack values to a memory location of the same size. Then before the jump back a second function would subtract the same registers and stack values from the memory locations. If the context is preserved properly the memory locations would all be all null, else there was an error or we changed something with our two functions. This leads me to option

2. The gdb script A less invasive method could be a gdb script. Gdb allows us to define commands which are executed when break/watchpoints are hit. Defining two points on the first and last statement we could log the current state of registers and stacks to some file and compare the values with a script or maybe pipe the output directly to the script and run it in parallel.

Both options would have to be written for ARM and x86 separately while option two seems to be preferable to me since the executed sequence of statements is not changed and that sequence we want to proof to be not harmful.

Cheers, Thomas