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_PROC_H 17 #define LIBBCC_PROC_H 18 19 #include "bcc_syms.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 #include <stdint.h> 26 #include <stdio.h> 27 #include <stdbool.h> 28 29 30 typedef struct mod_info { 31 char *name; 32 uint64_t start_addr; 33 uint64_t end_addr; 34 long long unsigned int file_offset; 35 uint64_t dev_major; 36 uint64_t dev_minor; 37 uint64_t inode; 38 } mod_info; 39 40 // Module info, whether to check mount namespace, payload 41 // Callback returning a negative value indicates to stop the iteration 42 typedef int (*bcc_procutils_modulecb)(mod_info *, int, void *); 43 44 // Symbol name, address, payload 45 typedef void (*bcc_procutils_ksymcb)(const char *, const char *, uint64_t, void *); 46 47 char *bcc_procutils_which_so(const char *libname, int pid); 48 char *bcc_procutils_which(const char *binpath); 49 int bcc_mapping_is_file_backed(const char *mapname); 50 // Iterate over all executable memory mapping sections of a Process. 51 // All anonymous and non-file-backed mapping sections, namely those 52 // listed in bcc_mapping_is_file_backed, will be ignored. 53 // Returns -1 on error, and 0 on success 54 int bcc_procutils_each_module(int pid, bcc_procutils_modulecb callback, 55 void *payload); 56 57 int _procfs_maps_each_module(FILE *procmaps, int pid, 58 bcc_procutils_modulecb callback, void *payload); 59 // Iterate over all non-data Kernel symbols. 60 // Returns -1 on error, and 0 on success 61 int bcc_procutils_each_ksym(bcc_procutils_ksymcb callback, void *payload); 62 void bcc_procutils_free(const char *ptr); 63 const char *bcc_procutils_language(int pid); 64 65 #ifdef __cplusplus 66 } 67 #endif 68 #endif 69