Commit | Line | Data |
---|---|---|
e72d66a6 | 1 | /* |
9d16b343 MJ |
2 | * Copyright (C) 2009 Pierre-Marc Fournier |
3 | * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
e72d66a6 | 4 | * |
9d16b343 | 5 | * SPDX-License-Identifier: LGPL-2.1-only |
e72d66a6 | 6 | * |
e72d66a6 DG |
7 | */ |
8 | ||
28f23191 | 9 | #include <arpa/inet.h> |
e72d66a6 DG |
10 | #include <fcntl.h> |
11 | #include <signal.h> | |
28f23191 JG |
12 | #include <stdarg.h> |
13 | #include <stdio.h> | |
e72d66a6 | 14 | #include <stdlib.h> |
28f23191 JG |
15 | #include <string.h> |
16 | #include <sys/mman.h> | |
17 | #include <sys/stat.h> | |
18 | #include <sys/types.h> | |
19 | #include <unistd.h> | |
e72d66a6 DG |
20 | |
21 | #define TRACEPOINT_DEFINE | |
22 | #include "tp.h" | |
23 | ||
28f23191 | 24 | static void inthandler(int sig __attribute__((unused))) |
e72d66a6 DG |
25 | { |
26 | } | |
27 | ||
28f23191 | 28 | static int init_int_handler(void) |
e72d66a6 DG |
29 | { |
30 | int result; | |
31 | struct sigaction act; | |
32 | ||
33 | memset(&act, 0, sizeof(act)); | |
34 | result = sigemptyset(&act.sa_mask); | |
35 | if (result == -1) { | |
36 | perror("sigemptyset"); | |
37 | return -1; | |
38 | } | |
39 | ||
40 | act.sa_handler = inthandler; | |
41 | act.sa_flags = SA_RESTART; | |
42 | ||
43 | /* Only defer ourselves. Also, try to restart interrupted | |
44 | * syscalls to disturb the traced program as little as possible. | |
45 | */ | |
46 | result = sigaction(SIGUSR1, &act, NULL); | |
47 | if (result == -1) { | |
48 | perror("sigaction"); | |
49 | return -1; | |
50 | } | |
51 | ||
52 | return 0; | |
53 | } | |
54 | ||
55 | int main(int argc, char **argv) | |
56 | { | |
57 | int i, netint; | |
58 | long values[] = { 1, 2, 3 }; | |
59 | char text[10] = "test"; | |
60 | double dbl = 2.0; | |
61 | float flt = 2222.0; | |
62 | int delay = 0; | |
63 | ||
64 | init_int_handler(); | |
65 | ||
66 | if (argc == 2) | |
67 | delay = atoi(argv[1]); | |
68 | ||
69 | sleep(delay); | |
70 | ||
71 | for (i = 0; i < 1000000; i++) { | |
72 | netint = htonl(i); | |
28f23191 | 73 | tracepoint(tp, tptest, i, netint, values, text, strlen(text), dbl, flt); |
e72d66a6 DG |
74 | } |
75 | ||
76 | return 0; | |
77 | } |