| |||
| Home > Compiler Coding Practices > Examining parameters when integer division-by-zero errors occur in C code | |||
If you want to examine parameters and save them for postmortem
debugging, you can trap __aeabi_idiv0. You
can intervene in all calls to __aeabi_idiv0 by
using the $Super$$ and $Sub$$ mechanism.
To examine parameters when integer division-by-zero occurs:
Prefix __aeabi_idiv0() with $Super$$ to
identify the original unpatched function __aeabi_idiv0().
Use __aeabi_idiv0() prefixed
with $Super$$ to call the original function directly.
Prefix __aeabi_idiv0() with $Sub$$ to
identify the new function to be called in place of the original
version of __aeabi_idiv0().
Use __aeabi_idiv0() prefixed
with $Sub$$ to add processing before or after
the original function __aeabi_idiv0().
Example 36 illustrates
the use of the $Super$$ and $Sub$$ mechanism
to intercept __aeabi_div0.
Example 36. Intercepting __aeabi_div0 using $Super$$ and $Sub$$
extern void $Super$$__aeabi_idiv0(void);
/* this function is called instead of the original __aeabi_idiv0() */
void $Sub$$__aeabi_idiv0()
{
// insert code to process a divide by zero
...
// call the original __aeabi_idiv0 function
$Super$$__aeabi_idiv0();
}