Function
uni_seterrfunc
Receive diagnostic events.
Parameters 🔗
| user_data | in | User pointer passed to unimemfunc. |
| callback | in | Error callback routine. |
Discussion 🔗
Associate the function callback with the library’s internal error logger. Anytime a function returns an error callback will be invoked with a description of the error. It is up to the implementation of callback to be thread safe.
The implementation generally invokes callback at the moment the error occurs. Callers are encouraged to set breakpoints in their implementation of callback and view the stack trace to discover the exact cause of the error.
Examples 🔗
This example registers a custom error callback with Unicorn. This callback will be invoked when an error occurs in Unicorn. In practice, you can set a breakpoint within the function for your debugger to pause on and then troubleshoot the error by inspecting the error message.
#include <unicorn.h>
#include <stdio.h>
static void on_error(void *user_data, const char *message)
{
puts(message);
}
int main(void)
{
uni_seterrfunc(NULL, on_error);
return 0;
}