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