Skip to main content

calltrace_init

Function calltrace_init 

Source
#[unsafe(no_mangle)]
pub extern "C" fn calltrace_init() -> i32
Expand description

Initialize the CallTrace library

This function initializes the global CallTrace state, including:

  • DWARF debug information analyzer
  • Crash signal handlers
  • Performance monitoring counters
  • Configuration from environment variables

§Safety

This function is automatically called when the library is loaded via ctor attributes. It can be called multiple times safely - subsequent calls are no-ops.

§Returns

Always returns 0 for C compatibility.

§Environment Variables

The following environment variables are read during initialization:

  • CALLTRACE_OUTPUT: Output file path
  • CALLTRACE_CAPTURE_ARGS: Enable argument capture (1/true)
  • CALLTRACE_MAX_DEPTH: Maximum call depth (default: 100)
  • CALLTRACE_DEBUG: Enable debug output (1/true)
  • CALLTRACE_PRETTY_JSON: Pretty-print JSON (default: true)

§Examples

Usually called automatically, but can be invoked manually:

// In C code
extern int calltrace_init(void);
int result = calltrace_init(); // Returns 0 on success