File: staticlib.c

package info (click to toggle)
eztrace 2.0%2Brepack-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,132 kB
  • sloc: ansic: 23,501; perl: 910; sh: 857; cpp: 771; makefile: 696; fortran: 327; f90: 320; python: 57
file content (42 lines) | stat: -rw-r--r-- 1,002 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* -*- c-file-style: "GNU" -*- */
/*
 * Copyright (C) CNRS, INRIA, Université Bordeaux 1, Télécom SudParis
 * See COPYING in top-level directory.
 */
#define _GNU_SOURCE
#include <eztrace-lib/eztrace.h>
#include <eztrace-lib/eztrace_module.h>

#define CURRENT_MODULE staticlib
DECLARE_CURRENT_MODULE;

int (*libmafunc)(int n);

int mafunc(int n) {
  INTERCEPT_FUNCTION("mafunc", libmafunc);
  FUNCTION_ENTRY;
  int ret = libmafunc(n);
  FUNCTION_EXIT;
  return ret;
}

PPTRACE_START_INTERCEPT_FUNCTIONS(staticlib)
INTERCEPT3("mafunc", libmafunc)
PPTRACE_END_INTERCEPT_FUNCTIONS(staticlib)

static void init_staticlib() {
  INSTRUMENT_FUNCTIONS(staticlib);

  if (eztrace_autostart_enabled())
    eztrace_start();
}

static void finalize_staticlib() {
  eztrace_stop();
}

static void __staticlib_init(void) __attribute__((constructor));
static void __staticlib_init(void) {
  EZT_REGISTER_MODULE(staticlib, "Example module for static instrumentation",
		      init_staticlib, finalize_staticlib);
}