1*387f9dfdSAndroid Build Coastguard Worker /* 2*387f9dfdSAndroid Build Coastguard Worker * Copyright (c) 2016 GitHub, Inc. 3*387f9dfdSAndroid Build Coastguard Worker * 4*387f9dfdSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*387f9dfdSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*387f9dfdSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*387f9dfdSAndroid Build Coastguard Worker * 8*387f9dfdSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*387f9dfdSAndroid Build Coastguard Worker * 10*387f9dfdSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*387f9dfdSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*387f9dfdSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*387f9dfdSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*387f9dfdSAndroid Build Coastguard Worker * limitations under the License. 15*387f9dfdSAndroid Build Coastguard Worker */ 16*387f9dfdSAndroid Build Coastguard Worker #ifndef LIBBCC_USDT_H 17*387f9dfdSAndroid Build Coastguard Worker #define LIBBCC_USDT_H 18*387f9dfdSAndroid Build Coastguard Worker 19*387f9dfdSAndroid Build Coastguard Worker #ifdef __cplusplus 20*387f9dfdSAndroid Build Coastguard Worker extern "C" { 21*387f9dfdSAndroid Build Coastguard Worker #endif 22*387f9dfdSAndroid Build Coastguard Worker 23*387f9dfdSAndroid Build Coastguard Worker #include <stdint.h> 24*387f9dfdSAndroid Build Coastguard Worker 25*387f9dfdSAndroid Build Coastguard Worker void *bcc_usdt_new_frompid(int pid, const char *path); 26*387f9dfdSAndroid Build Coastguard Worker void *bcc_usdt_new_frompath(const char *path); 27*387f9dfdSAndroid Build Coastguard Worker void bcc_usdt_close(void *usdt); 28*387f9dfdSAndroid Build Coastguard Worker 29*387f9dfdSAndroid Build Coastguard Worker struct bcc_usdt { 30*387f9dfdSAndroid Build Coastguard Worker const char *provider; 31*387f9dfdSAndroid Build Coastguard Worker const char *name; 32*387f9dfdSAndroid Build Coastguard Worker const char *bin_path; 33*387f9dfdSAndroid Build Coastguard Worker // Virtual address semaphore is found at 34*387f9dfdSAndroid Build Coastguard Worker uint64_t semaphore; 35*387f9dfdSAndroid Build Coastguard Worker int num_locations; 36*387f9dfdSAndroid Build Coastguard Worker int num_arguments; 37*387f9dfdSAndroid Build Coastguard Worker // Offset from start of file where semaphore is at 38*387f9dfdSAndroid Build Coastguard Worker uint64_t semaphore_offset; 39*387f9dfdSAndroid Build Coastguard Worker }; 40*387f9dfdSAndroid Build Coastguard Worker 41*387f9dfdSAndroid Build Coastguard Worker struct bcc_usdt_location { 42*387f9dfdSAndroid Build Coastguard Worker uint64_t address; 43*387f9dfdSAndroid Build Coastguard Worker const char *bin_path; 44*387f9dfdSAndroid Build Coastguard Worker }; 45*387f9dfdSAndroid Build Coastguard Worker 46*387f9dfdSAndroid Build Coastguard Worker #define BCC_USDT_ARGUMENT_NONE 0x0 47*387f9dfdSAndroid Build Coastguard Worker #define BCC_USDT_ARGUMENT_CONSTANT 0x1 48*387f9dfdSAndroid Build Coastguard Worker #define BCC_USDT_ARGUMENT_DEREF_OFFSET 0x2 49*387f9dfdSAndroid Build Coastguard Worker #define BCC_USDT_ARGUMENT_DEREF_IDENT 0x4 50*387f9dfdSAndroid Build Coastguard Worker #define BCC_USDT_ARGUMENT_BASE_REGISTER_NAME 0x8 51*387f9dfdSAndroid Build Coastguard Worker #define BCC_USDT_ARGUMENT_INDEX_REGISTER_NAME 0x10 52*387f9dfdSAndroid Build Coastguard Worker #define BCC_USDT_ARGUMENT_SCALE 0x20 53*387f9dfdSAndroid Build Coastguard Worker 54*387f9dfdSAndroid Build Coastguard Worker struct bcc_usdt_argument { 55*387f9dfdSAndroid Build Coastguard Worker int size; 56*387f9dfdSAndroid Build Coastguard Worker int valid; 57*387f9dfdSAndroid Build Coastguard Worker long long constant; 58*387f9dfdSAndroid Build Coastguard Worker int deref_offset; 59*387f9dfdSAndroid Build Coastguard Worker const char *deref_ident; 60*387f9dfdSAndroid Build Coastguard Worker const char *base_register_name; 61*387f9dfdSAndroid Build Coastguard Worker const char *index_register_name; 62*387f9dfdSAndroid Build Coastguard Worker int scale; 63*387f9dfdSAndroid Build Coastguard Worker }; 64*387f9dfdSAndroid Build Coastguard Worker 65*387f9dfdSAndroid Build Coastguard Worker typedef void (*bcc_usdt_cb)(struct bcc_usdt *); 66*387f9dfdSAndroid Build Coastguard Worker void bcc_usdt_foreach(void *usdt, bcc_usdt_cb callback); 67*387f9dfdSAndroid Build Coastguard Worker int bcc_usdt_get_location(void *usdt, const char *provider_name, 68*387f9dfdSAndroid Build Coastguard Worker const char *probe_name, 69*387f9dfdSAndroid Build Coastguard Worker int index, struct bcc_usdt_location *location); 70*387f9dfdSAndroid Build Coastguard Worker int bcc_usdt_get_argument(void *usdt, const char *provider_name, 71*387f9dfdSAndroid Build Coastguard Worker const char *probe_name, 72*387f9dfdSAndroid Build Coastguard Worker int location_index, int argument_index, 73*387f9dfdSAndroid Build Coastguard Worker struct bcc_usdt_argument *argument); 74*387f9dfdSAndroid Build Coastguard Worker 75*387f9dfdSAndroid Build Coastguard Worker int bcc_usdt_enable_probe(void *, const char *, const char *); 76*387f9dfdSAndroid Build Coastguard Worker int bcc_usdt_addsem_probe(void *, const char *, const char *, int16_t); 77*387f9dfdSAndroid Build Coastguard Worker #define BCC_USDT_HAS_FULLY_SPECIFIED_PROBE 78*387f9dfdSAndroid Build Coastguard Worker int bcc_usdt_enable_fully_specified_probe(void *, const char *, const char *, 79*387f9dfdSAndroid Build Coastguard Worker const char *); 80*387f9dfdSAndroid Build Coastguard Worker int bcc_usdt_addsem_fully_specified_probe(void *, const char *, const char *, 81*387f9dfdSAndroid Build Coastguard Worker const char *, int16_t); 82*387f9dfdSAndroid Build Coastguard Worker const char *bcc_usdt_genargs(void **ctx_array, int len); 83*387f9dfdSAndroid Build Coastguard Worker const char *bcc_usdt_get_probe_argctype( 84*387f9dfdSAndroid Build Coastguard Worker void *ctx, const char* probe_name, const int arg_index 85*387f9dfdSAndroid Build Coastguard Worker ); 86*387f9dfdSAndroid Build Coastguard Worker const char *bcc_usdt_get_fully_specified_probe_argctype( 87*387f9dfdSAndroid Build Coastguard Worker void *ctx, const char* provider_name, const char* probe_name, const int arg_index 88*387f9dfdSAndroid Build Coastguard Worker ); 89*387f9dfdSAndroid Build Coastguard Worker 90*387f9dfdSAndroid Build Coastguard Worker typedef void (*bcc_usdt_uprobe_cb)(const char *, const char *, uint64_t, int); 91*387f9dfdSAndroid Build Coastguard Worker void bcc_usdt_foreach_uprobe(void *usdt, bcc_usdt_uprobe_cb callback); 92*387f9dfdSAndroid Build Coastguard Worker 93*387f9dfdSAndroid Build Coastguard Worker #ifdef __cplusplus 94*387f9dfdSAndroid Build Coastguard Worker } 95*387f9dfdSAndroid Build Coastguard Worker #endif 96*387f9dfdSAndroid Build Coastguard Worker #endif 97