Commit | Line | Data |
---|---|---|
81614639 | 1 | /* |
c0c0989a | 2 | * SPDX-License-Identifier: LGPL-2.1-only |
a09dac63 | 3 | * |
c0c0989a MJ |
4 | * Copyright (C) 2009 Pierre-Marc Fournier |
5 | * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
a09dac63 PMF |
6 | */ |
7 | ||
68c1021b PMF |
8 | #include <stdio.h> |
9 | #include <unistd.h> | |
b6bf28ec | 10 | #include <sys/mman.h> |
9c67dc50 PMF |
11 | #include <stdarg.h> |
12 | #include <sys/types.h> | |
13 | #include <sys/stat.h> | |
14 | #include <fcntl.h> | |
4486e566 | 15 | #include <signal.h> |
5dba5937 | 16 | #include <string.h> |
3e4e9902 MD |
17 | /* |
18 | * Work-around inet.h missing struct mmsghdr forward declaration, with | |
19 | * triggers a warning when system files warnings are enabled. | |
20 | */ | |
21 | struct mmsghdr; | |
9a396c3c | 22 | #include <arpa/inet.h> |
40b2b5a4 | 23 | #include <stdlib.h> |
f121009f | 24 | #include <stdbool.h> |
68c1021b | 25 | |
deb6e540 | 26 | #define TRACEPOINT_DEFINE |
41aaf8a5 | 27 | #include "ust_tests_hello.h" |
59b161cd | 28 | |
8d938dbd PMF |
29 | void inthandler(int sig) |
30 | { | |
8d8a24c8 | 31 | printf("in SIGUSR1 handler\n"); |
7083f0fe | 32 | tracepoint(ust_tests_hello, tptest_sighandler); |
8d938dbd PMF |
33 | } |
34 | ||
35 | int init_int_handler(void) | |
36 | { | |
37 | int result; | |
38 | struct sigaction act; | |
39 | ||
1ea11eab | 40 | memset(&act, 0, sizeof(act)); |
8d938dbd | 41 | result = sigemptyset(&act.sa_mask); |
81614639 | 42 | if (result == -1) { |
41aaf8a5 | 43 | perror("sigemptyset"); |
8d938dbd PMF |
44 | return -1; |
45 | } | |
46 | ||
47 | act.sa_handler = inthandler; | |
48 | act.sa_flags = SA_RESTART; | |
49 | ||
50 | /* Only defer ourselves. Also, try to restart interrupted | |
51 | * syscalls to disturb the traced program as little as possible. | |
52 | */ | |
8d8a24c8 | 53 | result = sigaction(SIGUSR1, &act, NULL); |
81614639 | 54 | if (result == -1) { |
41aaf8a5 | 55 | perror("sigaction"); |
8d938dbd PMF |
56 | return -1; |
57 | } | |
58 | ||
59 | return 0; | |
60 | } | |
61 | ||
53569322 MD |
62 | void test_inc_count(void); |
63 | ||
8d8a24c8 | 64 | int main(int argc, char **argv) |
b6bf28ec | 65 | { |
9a396c3c | 66 | int i, netint; |
775e7fd8 | 67 | long values[] = { 1, 2, 3 }; |
5dba5937 | 68 | char text[10] = "test"; |
513fc97e MD |
69 | double dbl = 2.0; |
70 | float flt = 2222.0; | |
ff927bae | 71 | int delay = 0; |
f121009f | 72 | bool mybool = 123; /* should print "1" */ |
5f54827b | 73 | |
8d938dbd PMF |
74 | init_int_handler(); |
75 | ||
ff927bae MD |
76 | if (argc == 2) |
77 | delay = atoi(argv[1]); | |
59b161cd | 78 | |
ff927bae | 79 | fprintf(stderr, "Hello, World!\n"); |
8d8a24c8 | 80 | |
ff927bae MD |
81 | sleep(delay); |
82 | ||
83 | fprintf(stderr, "Tracing... "); | |
c95f3a3a | 84 | for (i = 0; i < 1000000; i++) { |
9a396c3c | 85 | netint = htonl(i); |
7083f0fe | 86 | tracepoint(ust_tests_hello, tptest, i, netint, values, |
f121009f | 87 | text, strlen(text), dbl, flt, mybool); |
c95f3a3a | 88 | //usleep(100000); |
8d938dbd | 89 | } |
ff927bae | 90 | fprintf(stderr, " done.\n"); |
68c1021b PMF |
91 | return 0; |
92 | } |