Object Locks Path
API Reference Manual  /  Simulator API  /  Simulator API Functions  / 

Output

SIM_add_output_handler, SIM_remove_output_handler

Name

SIM_add_output_handler, SIM_remove_output_handler — add or remove output handler

Synopsis

C and DML

#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);

Python

import simics

simics.SIM_add_output_handler(...)
simics.SIM_remove_output_handler(...)

Description

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.

Execution Context

Cell Context

See Also

SIM_write

SIM_write, SIM_flush, SIM_putchar, SIM_puts, SIM_printf_vararg, SIM_printf

Name

SIM_write, SIM_flush, SIM_putchar, SIM_puts, SIM_printf_vararg, SIM_printf — text output routines

Synopsis

C and DML

#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);

Python

import simics

simics.SIM_printf(...)

Description

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.

Execution Context

Cell Context

See Also

SIM_add_output_handler

Object Locks Path