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 <stdbool.h> 27 28 // Module name, start address, end address, file_offset, 29 // whether to check mount namespace, payload 30 // Callback returning a negative value indicates to stop the iteration 31 typedef int (*bcc_procutils_modulecb)(const char *, uint64_t, uint64_t, 32 uint64_t, bool, void *); 33 // Symbol name, address, payload 34 typedef void (*bcc_procutils_ksymcb)(const char *, uint64_t, void *); 35 36 char *bcc_procutils_which_so(const char *libname, int pid); 37 char *bcc_procutils_which(const char *binpath); 38 int bcc_mapping_is_file_backed(const char *mapname); 39 // Iterate over all executable memory mapping sections of a Process. 40 // All anonymous and non-file-backed mapping sections, namely those 41 // listed in bcc_mapping_is_file_backed, will be ignored. 42 // Returns -1 on error, and 0 on success 43 int bcc_procutils_each_module(int pid, bcc_procutils_modulecb callback, 44 void *payload); 45 // Iterate over all non-data Kernel symbols. 46 // Returns -1 on error, and 0 on success 47 int bcc_procutils_each_ksym(bcc_procutils_ksymcb callback, void *payload); 48 void bcc_procutils_free(const char *ptr); 49 const char *bcc_procutils_language(int pid); 50 51 #ifdef __cplusplus 52 } 53 #endif 54 #endif 55