SIM_add_output_handler, SIM_remove_output_handler — add or remove output handler
#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML
void
SIM_add_output_handler(void (*NOTNULL f)(lang_void *user_data,
const char *text,
size_t length),
lang_void *user_data);
void
SIM_remove_output_handler(void (*NOTNULL f)(lang_void *user_data,
const char *text,
size_t length),
lang_void *user_data);
import simics
simics.SIM_add_output_handler(...)
simics.SIM_remove_output_handler(...)
SIM_add_output_handler registers f(user_data, text, length) to be called whenever there is text output from Simics.
text contains length bytes of output data. user_data is passed unchanged to the output handler.
SIM_remove_output_handler removes f as an output recipient. If user_data is NULL, all output handlers with the same function will be removed; otherwise, only those with equal user_data will be removed.
The C function is a thin wrapper that delegates to the OutputTee mechanism in simics._output.
Output handlers must be thread-safe in order to handle output from different threads properly. There will only be one activation of each handler at a given instant so strict re-entrancy is not required, but proper locking around resources shared with other code should be in place.
Cell Context
SIM_write, SIM_flush, SIM_putchar, SIM_puts, SIM_printf_vararg, SIM_printf — text output routines
#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML
int
SIM_write(const void *NOTNULL src, int length);
int
SIM_flush();
int
SIM_putchar(int c);
int
SIM_puts(const char *NOTNULL s);
int
SIM_printf(const char *NOTNULL format, ...);
// not available in DML
int
SIM_printf_vararg(const char *NOTNULL format, va_list ap);
import simics
simics.SIM_printf(...)
These are the Simics versions of the write, putchar, puts, printf, vprintf, and fflush C library functions. The arguments and return values are the same as for the library functions, except for SIM_write which does not take any file argument.
The output will be sent to stdout, but more output recipients can be added using the SIM_add_output_handler function. Output is line buffered. SIM_flush will force output of an unterminated line.
Cell Context