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