Debian Codegraph @

testsuite/systemtap.syscall/dcookie.c

raw
1 /* COVERAGE: lookup_dcookie */
2
3 #define _GNU_SOURCE
4 #include <stdio.h>
5 #include <unistd.h>
6 #include <sys/syscall.h>
7
8 #define LENGTH 255
9
10 // lookup_dcookie() is a special-purpose system call, currently
11 // used only by the oprofile profiler. Used by v0.4 <= opcontrol <= v0.9.
12 // http://oprofile.sourceforge.net/doc/internals/sample-file-generation.html
13
14 // from oprofile 0.9 source (daemon/opd_cookie.h):
15 typedef unsigned long long cookie_t;
16
17 // from oprofile 0.9 source (daemon/opd_cookie.c):
18 #if (defined(__powerpc__) && !defined(__powerpc64__)) || defined(__hppa__)\
19 || (defined(__s390__) && !defined(__s390x__)) \
20 || (defined(__mips__) && (_MIPS_SIM == _MIPS_SIM_ABI32) \
21 && defined(__MIPSEB__)) \
22 || (defined(__arm__) && defined(__ARM_EABI__) \
23 && defined(__ARMEB__))
24 static inline int lookup_dcookie(cookie_t cookie, char * buf, size_t size)
25 {
26 return syscall(__NR_lookup_dcookie, (unsigned long)(cookie >> 32),
27 (unsigned long)(cookie & 0xffffffff), buf, size);
28 }
29 #elif (defined(__mips__) && (_MIPS_SIM == _MIPS_SIM_ABI32)) \
30 || (defined(__arm__) && defined(__ARM_EABI__)) \
31 || (defined(__tile__) && !defined(__LP64__))
32 static inline int lookup_dcookie(cookie_t cookie, char * buf, size_t size)
33 {
34 return syscall(__NR_lookup_dcookie,
35 (unsigned long)(cookie & 0xffffffff),
36 (unsigned long)(cookie >> 32), buf, size);
37 }
38 #else
39 static inline int lookup_dcookie(cookie_t cookie, char * buf, size_t size)
40 {
41 return syscall(__NR_lookup_dcookie, cookie, buf, size);
42 }
43 #endif
44
45 int main()
46 {
47 char buf[LENGTH];
48 cookie_t c = 0;
49
50 lookup_dcookie(0x12345678abcdefabLL, (char *)0x11223344, LENGTH);
51 //staptest// lookup_dcookie (0x12345678abcdefab, 0x11223344, 0xff) = -NNNN
52
53 lookup_dcookie(-1, (char *)0, 0);
54 //staptest// lookup_dcookie (0xffffffffffffffff, 0x0, 0x0) = -NNNN
55
56 lookup_dcookie(0, (char *)-1, 0);
57 #ifdef __s390__
58 //staptest// lookup_dcookie (0x0, 0x[7]?[f]+, 0x0) = -NNNN
59 #else
60 //staptest// lookup_dcookie (0x0, 0x[f]+, 0x0) = -NNNN
61 #endif
62
63 lookup_dcookie(0, (char *)0, -1);
64 //staptest// lookup_dcookie (0x0, 0x0, 0x[f]+) = -NNNN
65
66
67 return 0;
68 }