Debian Codegraph @

runtime/dyninst/uprobes.c

raw
1 /* -*- linux-c -*-
2 * Common functions for using dyninst-based uprobes
3 * Copyright (C) 2012-2013 Red Hat Inc.
4 *
5 * This file is part of systemtap, and is free software. You can
6 * redistribute it and/or modify it under the terms of the GNU General
7 * Public License (GPL); either version 2, or (at your option) any
8 * later version.
9 */
10
11 #ifndef _UPROBES_DYNINST_C_
12 #define _UPROBES_DYNINST_C_
13
14 /* STAPDU: SystemTap Dyninst Uprobes */
15
16 // loc2c-generated code assumes pt_regs are available, so use this to make
17 // sure we always have *something* for it to dereference...
18 static struct pt_regs stapdu_dummy_uregs = {};
19
20 /* These functions implement the ABI in stapdyn.h
21 *
22 * NB: The translator will generate two arrays used here:
23 * struct stapdu_target stapdu_targets[];
24 * struct stapdu_probe stapdu_probes[];
25 */
26
27
28 uint64_t stp_dyninst_target_count(void)
29 {
30 return ARRAY_SIZE(stapdu_targets);
31 }
32
33 const char* stp_dyninst_target_path(uint64_t index)
34 {
35 if (index >= stp_dyninst_target_count())
36 return NULL;
37 return stapdu_targets[index].path;
38 }
39
40
41 uint64_t stp_dyninst_probe_count(void)
42 {
43 return ARRAY_SIZE(stapdu_probes);
44 }
45
46 uint64_t stp_dyninst_probe_target(uint64_t index)
47 {
48 if (index >= stp_dyninst_probe_count())
49 return (uint64_t)-1;
50 return stapdu_probes[index].target;
51 }
52
53 uint64_t stp_dyninst_probe_offset(uint64_t index)
54 {
55 if (index >= stp_dyninst_probe_count())
56 return (uint64_t)-1;
57 return stapdu_probes[index].offset;
58 }
59
60 uint64_t stp_dyninst_probe_semaphore(uint64_t index)
61 {
62 if (index >= stp_dyninst_probe_count())
63 return (uint64_t)-1;
64 return stapdu_probes[index].semaphore;
65 }
66
67 uint64_t stp_dyninst_probe_flags(uint64_t index)
68 {
69 if (index >= stp_dyninst_probe_count())
70 return (uint64_t)-1;
71 return stapdu_probes[index].flags;
72 }
73
74 #endif /* _UPROBES_DYNINST_C_ */
75