Loading...
Note: File does not exist in v3.5.6.
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __PERF_DSO
3#define __PERF_DSO
4
5#include <linux/refcount.h>
6#include <linux/types.h>
7#include <linux/rbtree.h>
8#include <sys/types.h>
9#include <stdbool.h>
10#include <stdio.h>
11#include <linux/bitops.h>
12#include "build-id.h"
13#include "mutex.h"
14#include <internal/rc_check.h>
15
16struct machine;
17struct map;
18struct perf_env;
19
20#define DSO__NAME_KALLSYMS "[kernel.kallsyms]"
21#define DSO__NAME_KCORE "[kernel.kcore]"
22
23enum dso_binary_type {
24 DSO_BINARY_TYPE__KALLSYMS = 0,
25 DSO_BINARY_TYPE__GUEST_KALLSYMS,
26 DSO_BINARY_TYPE__VMLINUX,
27 DSO_BINARY_TYPE__GUEST_VMLINUX,
28 DSO_BINARY_TYPE__JAVA_JIT,
29 DSO_BINARY_TYPE__DEBUGLINK,
30 DSO_BINARY_TYPE__BUILD_ID_CACHE,
31 DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO,
32 DSO_BINARY_TYPE__FEDORA_DEBUGINFO,
33 DSO_BINARY_TYPE__UBUNTU_DEBUGINFO,
34 DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO,
35 DSO_BINARY_TYPE__BUILDID_DEBUGINFO,
36 DSO_BINARY_TYPE__SYSTEM_PATH_DSO,
37 DSO_BINARY_TYPE__GUEST_KMODULE,
38 DSO_BINARY_TYPE__GUEST_KMODULE_COMP,
39 DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE,
40 DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP,
41 DSO_BINARY_TYPE__KCORE,
42 DSO_BINARY_TYPE__GUEST_KCORE,
43 DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO,
44 DSO_BINARY_TYPE__BPF_PROG_INFO,
45 DSO_BINARY_TYPE__BPF_IMAGE,
46 DSO_BINARY_TYPE__OOL,
47 DSO_BINARY_TYPE__NOT_FOUND,
48};
49
50enum dso_space_type {
51 DSO_SPACE__USER = 0,
52 DSO_SPACE__KERNEL,
53 DSO_SPACE__KERNEL_GUEST
54};
55
56enum dso_swap_type {
57 DSO_SWAP__UNSET,
58 DSO_SWAP__NO,
59 DSO_SWAP__YES,
60};
61
62enum dso_data_status {
63 DSO_DATA_STATUS_ERROR = -1,
64 DSO_DATA_STATUS_UNKNOWN = 0,
65 DSO_DATA_STATUS_OK = 1,
66};
67
68enum dso_data_status_seen {
69 DSO_DATA_STATUS_SEEN_ITRACE,
70};
71
72enum dso_type {
73 DSO__TYPE_UNKNOWN,
74 DSO__TYPE_64BIT,
75 DSO__TYPE_32BIT,
76 DSO__TYPE_X32BIT,
77};
78
79enum dso_load_errno {
80 DSO_LOAD_ERRNO__SUCCESS = 0,
81
82 /*
83 * Choose an arbitrary negative big number not to clash with standard
84 * errno since SUS requires the errno has distinct positive values.
85 * See 'Issue 6' in the link below.
86 *
87 * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html
88 */
89 __DSO_LOAD_ERRNO__START = -10000,
90
91 DSO_LOAD_ERRNO__INTERNAL_ERROR = __DSO_LOAD_ERRNO__START,
92
93 /* for symsrc__init() */
94 DSO_LOAD_ERRNO__INVALID_ELF,
95 DSO_LOAD_ERRNO__CANNOT_READ_BUILDID,
96 DSO_LOAD_ERRNO__MISMATCHING_BUILDID,
97
98 /* for decompress_kmodule */
99 DSO_LOAD_ERRNO__DECOMPRESSION_FAILURE,
100
101 __DSO_LOAD_ERRNO__END,
102};
103
104#define DSO__SWAP(dso, type, val) \
105({ \
106 type ____r = val; \
107 enum dso_swap_type ___dst = dso__needs_swap(dso); \
108 BUG_ON(___dst == DSO_SWAP__UNSET); \
109 if (___dst == DSO_SWAP__YES) { \
110 switch (sizeof(____r)) { \
111 case 2: \
112 ____r = bswap_16(val); \
113 break; \
114 case 4: \
115 ____r = bswap_32(val); \
116 break; \
117 case 8: \
118 ____r = bswap_64(val); \
119 break; \
120 default: \
121 BUG_ON(1); \
122 } \
123 } \
124 ____r; \
125})
126
127#define DSO__DATA_CACHE_SIZE 4096
128#define DSO__DATA_CACHE_MASK ~(DSO__DATA_CACHE_SIZE - 1)
129
130/*
131 * Data about backing storage DSO, comes from PERF_RECORD_MMAP2 meta events
132 */
133struct dso_id {
134 u32 maj;
135 u32 min;
136 u64 ino;
137 u64 ino_generation;
138};
139
140struct dso_cache {
141 struct rb_node rb_node;
142 u64 offset;
143 u64 size;
144 char data[];
145};
146
147struct dso_data {
148 struct rb_root cache;
149 struct list_head open_entry;
150#ifdef REFCNT_CHECKING
151 struct dso *dso;
152#endif
153 int fd;
154 int status;
155 u32 status_seen;
156 u64 file_size;
157 u64 elf_base_addr;
158 u64 debug_frame_offset;
159 u64 eh_frame_hdr_addr;
160 u64 eh_frame_hdr_offset;
161};
162
163struct dso_bpf_prog {
164 u32 id;
165 u32 sub_id;
166 struct perf_env *env;
167};
168
169struct auxtrace_cache;
170
171DECLARE_RC_STRUCT(dso) {
172 struct mutex lock;
173 struct dsos *dsos;
174 struct rb_root_cached symbols;
175 struct symbol **symbol_names;
176 size_t symbol_names_len;
177 struct rb_root_cached inlined_nodes;
178 struct rb_root_cached srclines;
179 struct rb_root data_types;
180 struct rb_root global_vars;
181
182 struct {
183 u64 addr;
184 struct symbol *symbol;
185 } last_find_result;
186 struct build_id bid;
187 u64 text_offset;
188 u64 text_end;
189 const char *short_name;
190 const char *long_name;
191 void *a2l;
192 char *symsrc_filename;
193#if defined(__powerpc__)
194 void *dwfl; /* DWARF debug info */
195#endif
196 struct nsinfo *nsinfo;
197 struct auxtrace_cache *auxtrace_cache;
198 union { /* Tool specific area */
199 void *priv;
200 u64 db_id;
201 };
202 /* bpf prog information */
203 struct dso_bpf_prog bpf_prog;
204 /* dso data file */
205 struct dso_data data;
206 struct dso_id id;
207 unsigned int a2l_fails;
208 int comp;
209 refcount_t refcnt;
210 enum dso_load_errno load_errno;
211 u16 long_name_len;
212 u16 short_name_len;
213 enum dso_binary_type symtab_type:8;
214 enum dso_binary_type binary_type:8;
215 enum dso_space_type kernel:2;
216 enum dso_swap_type needs_swap:2;
217 bool is_kmod:1;
218 u8 adjust_symbols:1;
219 u8 has_build_id:1;
220 u8 header_build_id:1;
221 u8 has_srcline:1;
222 u8 hit:1;
223 u8 annotate_warned:1;
224 u8 auxtrace_warned:1;
225 u8 short_name_allocated:1;
226 u8 long_name_allocated:1;
227 u8 is_64_bit:1;
228 bool sorted_by_name;
229 bool loaded;
230 u8 rel;
231 char name[];
232};
233
234/* dso__for_each_symbol - iterate over the symbols of given type
235 *
236 * @dso: the 'struct dso *' in which symbols are iterated
237 * @pos: the 'struct symbol *' to use as a loop cursor
238 * @n: the 'struct rb_node *' to use as a temporary storage
239 */
240#define dso__for_each_symbol(dso, pos, n) \
241 symbols__for_each_entry(dso__symbols(dso), pos, n)
242
243static inline void *dso__a2l(const struct dso *dso)
244{
245 return RC_CHK_ACCESS(dso)->a2l;
246}
247
248static inline void dso__set_a2l(struct dso *dso, void *val)
249{
250 RC_CHK_ACCESS(dso)->a2l = val;
251}
252
253static inline unsigned int dso__a2l_fails(const struct dso *dso)
254{
255 return RC_CHK_ACCESS(dso)->a2l_fails;
256}
257
258static inline void dso__set_a2l_fails(struct dso *dso, unsigned int val)
259{
260 RC_CHK_ACCESS(dso)->a2l_fails = val;
261}
262
263static inline bool dso__adjust_symbols(const struct dso *dso)
264{
265 return RC_CHK_ACCESS(dso)->adjust_symbols;
266}
267
268static inline void dso__set_adjust_symbols(struct dso *dso, bool val)
269{
270 RC_CHK_ACCESS(dso)->adjust_symbols = val;
271}
272
273static inline bool dso__annotate_warned(const struct dso *dso)
274{
275 return RC_CHK_ACCESS(dso)->annotate_warned;
276}
277
278static inline void dso__set_annotate_warned(struct dso *dso)
279{
280 RC_CHK_ACCESS(dso)->annotate_warned = 1;
281}
282
283static inline bool dso__auxtrace_warned(const struct dso *dso)
284{
285 return RC_CHK_ACCESS(dso)->auxtrace_warned;
286}
287
288static inline void dso__set_auxtrace_warned(struct dso *dso)
289{
290 RC_CHK_ACCESS(dso)->auxtrace_warned = 1;
291}
292
293static inline struct auxtrace_cache *dso__auxtrace_cache(struct dso *dso)
294{
295 return RC_CHK_ACCESS(dso)->auxtrace_cache;
296}
297
298static inline void dso__set_auxtrace_cache(struct dso *dso, struct auxtrace_cache *cache)
299{
300 RC_CHK_ACCESS(dso)->auxtrace_cache = cache;
301}
302
303static inline struct build_id *dso__bid(struct dso *dso)
304{
305 return &RC_CHK_ACCESS(dso)->bid;
306}
307
308static inline const struct build_id *dso__bid_const(const struct dso *dso)
309{
310 return &RC_CHK_ACCESS(dso)->bid;
311}
312
313static inline struct dso_bpf_prog *dso__bpf_prog(struct dso *dso)
314{
315 return &RC_CHK_ACCESS(dso)->bpf_prog;
316}
317
318static inline bool dso__has_build_id(const struct dso *dso)
319{
320 return RC_CHK_ACCESS(dso)->has_build_id;
321}
322
323static inline void dso__set_has_build_id(struct dso *dso)
324{
325 RC_CHK_ACCESS(dso)->has_build_id = true;
326}
327
328static inline bool dso__has_srcline(const struct dso *dso)
329{
330 return RC_CHK_ACCESS(dso)->has_srcline;
331}
332
333static inline void dso__set_has_srcline(struct dso *dso, bool val)
334{
335 RC_CHK_ACCESS(dso)->has_srcline = val;
336}
337
338static inline int dso__comp(const struct dso *dso)
339{
340 return RC_CHK_ACCESS(dso)->comp;
341}
342
343static inline void dso__set_comp(struct dso *dso, int comp)
344{
345 RC_CHK_ACCESS(dso)->comp = comp;
346}
347
348static inline struct dso_data *dso__data(struct dso *dso)
349{
350 return &RC_CHK_ACCESS(dso)->data;
351}
352
353static inline u64 dso__db_id(const struct dso *dso)
354{
355 return RC_CHK_ACCESS(dso)->db_id;
356}
357
358static inline void dso__set_db_id(struct dso *dso, u64 db_id)
359{
360 RC_CHK_ACCESS(dso)->db_id = db_id;
361}
362
363static inline struct dsos *dso__dsos(struct dso *dso)
364{
365 return RC_CHK_ACCESS(dso)->dsos;
366}
367
368static inline void dso__set_dsos(struct dso *dso, struct dsos *dsos)
369{
370 RC_CHK_ACCESS(dso)->dsos = dsos;
371}
372
373static inline bool dso__header_build_id(struct dso *dso)
374{
375 return RC_CHK_ACCESS(dso)->header_build_id;
376}
377
378static inline void dso__set_header_build_id(struct dso *dso, bool val)
379{
380 RC_CHK_ACCESS(dso)->header_build_id = val;
381}
382
383static inline bool dso__hit(const struct dso *dso)
384{
385 return RC_CHK_ACCESS(dso)->hit;
386}
387
388static inline void dso__set_hit(struct dso *dso)
389{
390 RC_CHK_ACCESS(dso)->hit = 1;
391}
392
393static inline struct dso_id *dso__id(struct dso *dso)
394{
395 return &RC_CHK_ACCESS(dso)->id;
396}
397
398static inline const struct dso_id *dso__id_const(const struct dso *dso)
399{
400 return &RC_CHK_ACCESS(dso)->id;
401}
402
403static inline struct rb_root_cached *dso__inlined_nodes(struct dso *dso)
404{
405 return &RC_CHK_ACCESS(dso)->inlined_nodes;
406}
407
408static inline bool dso__is_64_bit(const struct dso *dso)
409{
410 return RC_CHK_ACCESS(dso)->is_64_bit;
411}
412
413static inline void dso__set_is_64_bit(struct dso *dso, bool is)
414{
415 RC_CHK_ACCESS(dso)->is_64_bit = is;
416}
417
418static inline bool dso__is_kmod(const struct dso *dso)
419{
420 return RC_CHK_ACCESS(dso)->is_kmod;
421}
422
423static inline void dso__set_is_kmod(struct dso *dso)
424{
425 RC_CHK_ACCESS(dso)->is_kmod = 1;
426}
427
428static inline enum dso_space_type dso__kernel(const struct dso *dso)
429{
430 return RC_CHK_ACCESS(dso)->kernel;
431}
432
433static inline void dso__set_kernel(struct dso *dso, enum dso_space_type kernel)
434{
435 RC_CHK_ACCESS(dso)->kernel = kernel;
436}
437
438static inline u64 dso__last_find_result_addr(const struct dso *dso)
439{
440 return RC_CHK_ACCESS(dso)->last_find_result.addr;
441}
442
443static inline void dso__set_last_find_result_addr(struct dso *dso, u64 addr)
444{
445 RC_CHK_ACCESS(dso)->last_find_result.addr = addr;
446}
447
448static inline struct symbol *dso__last_find_result_symbol(const struct dso *dso)
449{
450 return RC_CHK_ACCESS(dso)->last_find_result.symbol;
451}
452
453static inline void dso__set_last_find_result_symbol(struct dso *dso, struct symbol *symbol)
454{
455 RC_CHK_ACCESS(dso)->last_find_result.symbol = symbol;
456}
457
458static inline enum dso_load_errno *dso__load_errno(struct dso *dso)
459{
460 return &RC_CHK_ACCESS(dso)->load_errno;
461}
462
463static inline void dso__set_loaded(struct dso *dso)
464{
465 RC_CHK_ACCESS(dso)->loaded = true;
466}
467
468static inline struct mutex *dso__lock(struct dso *dso)
469{
470 return &RC_CHK_ACCESS(dso)->lock;
471}
472
473static inline const char *dso__long_name(const struct dso *dso)
474{
475 return RC_CHK_ACCESS(dso)->long_name;
476}
477
478static inline bool dso__long_name_allocated(const struct dso *dso)
479{
480 return RC_CHK_ACCESS(dso)->long_name_allocated;
481}
482
483static inline void dso__set_long_name_allocated(struct dso *dso, bool allocated)
484{
485 RC_CHK_ACCESS(dso)->long_name_allocated = allocated;
486}
487
488static inline u16 dso__long_name_len(const struct dso *dso)
489{
490 return RC_CHK_ACCESS(dso)->long_name_len;
491}
492
493static inline const char *dso__name(const struct dso *dso)
494{
495 return RC_CHK_ACCESS(dso)->name;
496}
497
498static inline enum dso_swap_type dso__needs_swap(const struct dso *dso)
499{
500 return RC_CHK_ACCESS(dso)->needs_swap;
501}
502
503static inline void dso__set_needs_swap(struct dso *dso, enum dso_swap_type type)
504{
505 RC_CHK_ACCESS(dso)->needs_swap = type;
506}
507
508static inline struct nsinfo *dso__nsinfo(struct dso *dso)
509{
510 return RC_CHK_ACCESS(dso)->nsinfo;
511}
512
513static inline const struct nsinfo *dso__nsinfo_const(const struct dso *dso)
514{
515 return RC_CHK_ACCESS(dso)->nsinfo;
516}
517
518static inline struct nsinfo **dso__nsinfo_ptr(struct dso *dso)
519{
520 return &RC_CHK_ACCESS(dso)->nsinfo;
521}
522
523void dso__set_nsinfo(struct dso *dso, struct nsinfo *nsi);
524
525static inline u8 dso__rel(const struct dso *dso)
526{
527 return RC_CHK_ACCESS(dso)->rel;
528}
529
530static inline void dso__set_rel(struct dso *dso, u8 rel)
531{
532 RC_CHK_ACCESS(dso)->rel = rel;
533}
534
535static inline const char *dso__short_name(const struct dso *dso)
536{
537 return RC_CHK_ACCESS(dso)->short_name;
538}
539
540static inline bool dso__short_name_allocated(const struct dso *dso)
541{
542 return RC_CHK_ACCESS(dso)->short_name_allocated;
543}
544
545static inline void dso__set_short_name_allocated(struct dso *dso, bool allocated)
546{
547 RC_CHK_ACCESS(dso)->short_name_allocated = allocated;
548}
549
550static inline u16 dso__short_name_len(const struct dso *dso)
551{
552 return RC_CHK_ACCESS(dso)->short_name_len;
553}
554
555static inline struct rb_root_cached *dso__srclines(struct dso *dso)
556{
557 return &RC_CHK_ACCESS(dso)->srclines;
558}
559
560static inline struct rb_root *dso__data_types(struct dso *dso)
561{
562 return &RC_CHK_ACCESS(dso)->data_types;
563}
564
565static inline struct rb_root *dso__global_vars(struct dso *dso)
566{
567 return &RC_CHK_ACCESS(dso)->global_vars;
568}
569
570static inline struct rb_root_cached *dso__symbols(struct dso *dso)
571{
572 return &RC_CHK_ACCESS(dso)->symbols;
573}
574
575static inline struct symbol **dso__symbol_names(struct dso *dso)
576{
577 return RC_CHK_ACCESS(dso)->symbol_names;
578}
579
580static inline void dso__set_symbol_names(struct dso *dso, struct symbol **names)
581{
582 RC_CHK_ACCESS(dso)->symbol_names = names;
583}
584
585static inline size_t dso__symbol_names_len(struct dso *dso)
586{
587 return RC_CHK_ACCESS(dso)->symbol_names_len;
588}
589
590static inline void dso__set_symbol_names_len(struct dso *dso, size_t len)
591{
592 RC_CHK_ACCESS(dso)->symbol_names_len = len;
593}
594
595static inline const char *dso__symsrc_filename(const struct dso *dso)
596{
597 return RC_CHK_ACCESS(dso)->symsrc_filename;
598}
599
600static inline void dso__set_symsrc_filename(struct dso *dso, char *val)
601{
602 RC_CHK_ACCESS(dso)->symsrc_filename = val;
603}
604
605static inline void dso__free_symsrc_filename(struct dso *dso)
606{
607 zfree(&RC_CHK_ACCESS(dso)->symsrc_filename);
608}
609
610static inline enum dso_binary_type dso__symtab_type(const struct dso *dso)
611{
612 return RC_CHK_ACCESS(dso)->symtab_type;
613}
614
615static inline void dso__set_symtab_type(struct dso *dso, enum dso_binary_type bt)
616{
617 RC_CHK_ACCESS(dso)->symtab_type = bt;
618}
619
620static inline u64 dso__text_end(const struct dso *dso)
621{
622 return RC_CHK_ACCESS(dso)->text_end;
623}
624
625static inline void dso__set_text_end(struct dso *dso, u64 val)
626{
627 RC_CHK_ACCESS(dso)->text_end = val;
628}
629
630static inline u64 dso__text_offset(const struct dso *dso)
631{
632 return RC_CHK_ACCESS(dso)->text_offset;
633}
634
635static inline void dso__set_text_offset(struct dso *dso, u64 val)
636{
637 RC_CHK_ACCESS(dso)->text_offset = val;
638}
639
640int dso_id__cmp(const struct dso_id *a, const struct dso_id *b);
641bool dso_id__empty(const struct dso_id *id);
642
643struct dso *dso__new_id(const char *name, const struct dso_id *id);
644struct dso *dso__new(const char *name);
645void dso__delete(struct dso *dso);
646
647int dso__cmp_id(struct dso *a, struct dso *b);
648void dso__set_short_name(struct dso *dso, const char *name, bool name_allocated);
649void dso__set_long_name(struct dso *dso, const char *name, bool name_allocated);
650void __dso__inject_id(struct dso *dso, const struct dso_id *id);
651
652int dso__name_len(const struct dso *dso);
653
654struct dso *dso__get(struct dso *dso);
655void dso__put(struct dso *dso);
656
657static inline void __dso__zput(struct dso **dso)
658{
659 dso__put(*dso);
660 *dso = NULL;
661}
662
663#define dso__zput(dso) __dso__zput(&dso)
664
665bool dso__loaded(const struct dso *dso);
666
667static inline bool dso__has_symbols(const struct dso *dso)
668{
669 return !RB_EMPTY_ROOT(&RC_CHK_ACCESS(dso)->symbols.rb_root);
670}
671
672char *dso__filename_with_chroot(const struct dso *dso, const char *filename);
673
674bool dso__sorted_by_name(const struct dso *dso);
675void dso__set_sorted_by_name(struct dso *dso);
676void dso__sort_by_name(struct dso *dso);
677
678void dso__set_build_id(struct dso *dso, struct build_id *bid);
679bool dso__build_id_equal(const struct dso *dso, struct build_id *bid);
680void dso__read_running_kernel_build_id(struct dso *dso,
681 struct machine *machine);
682int dso__kernel_module_get_build_id(struct dso *dso, const char *root_dir);
683
684char dso__symtab_origin(const struct dso *dso);
685int dso__read_binary_type_filename(const struct dso *dso, enum dso_binary_type type,
686 char *root_dir, char *filename, size_t size);
687bool is_kernel_module(const char *pathname, int cpumode);
688bool dso__needs_decompress(struct dso *dso);
689int dso__decompress_kmodule_fd(struct dso *dso, const char *name);
690int dso__decompress_kmodule_path(struct dso *dso, const char *name,
691 char *pathname, size_t len);
692int filename__decompress(const char *name, char *pathname,
693 size_t len, int comp, int *err);
694
695#define KMOD_DECOMP_NAME "/tmp/perf-kmod-XXXXXX"
696#define KMOD_DECOMP_LEN sizeof(KMOD_DECOMP_NAME)
697
698struct kmod_path {
699 char *name;
700 int comp;
701 bool kmod;
702};
703
704int __kmod_path__parse(struct kmod_path *m, const char *path,
705 bool alloc_name);
706
707#define kmod_path__parse(__m, __p) __kmod_path__parse(__m, __p, false)
708#define kmod_path__parse_name(__m, __p) __kmod_path__parse(__m, __p, true)
709
710void dso__set_module_info(struct dso *dso, struct kmod_path *m,
711 struct machine *machine);
712
713/*
714 * The dso__data_* external interface provides following functions:
715 * dso__data_get_fd
716 * dso__data_put_fd
717 * dso__data_close
718 * dso__data_size
719 * dso__data_read_offset
720 * dso__data_read_addr
721 * dso__data_write_cache_offs
722 * dso__data_write_cache_addr
723 *
724 * Please refer to the dso.c object code for each function and
725 * arguments documentation. Following text tries to explain the
726 * dso file descriptor caching.
727 *
728 * The dso__data* interface allows caching of opened file descriptors
729 * to speed up the dso data accesses. The idea is to leave the file
730 * descriptor opened ideally for the whole life of the dso object.
731 *
732 * The current usage of the dso__data_* interface is as follows:
733 *
734 * Get DSO's fd:
735 * int fd = dso__data_get_fd(dso, machine);
736 * if (fd >= 0) {
737 * USE 'fd' SOMEHOW
738 * dso__data_put_fd(dso);
739 * }
740 *
741 * Read DSO's data:
742 * n = dso__data_read_offset(dso_0, &machine, 0, buf, BUFSIZE);
743 * n = dso__data_read_addr(dso_0, &machine, 0, buf, BUFSIZE);
744 *
745 * Eventually close DSO's fd:
746 * dso__data_close(dso);
747 *
748 * It is not necessary to close the DSO object data file. Each time new
749 * DSO data file is opened, the limit (RLIMIT_NOFILE/2) is checked. Once
750 * it is crossed, the oldest opened DSO object is closed.
751 *
752 * The dso__delete function calls close_dso function to ensure the
753 * data file descriptor gets closed/unmapped before the dso object
754 * is freed.
755 *
756 * TODO
757*/
758int dso__data_get_fd(struct dso *dso, struct machine *machine);
759void dso__data_put_fd(struct dso *dso);
760void dso__data_close(struct dso *dso);
761
762int dso__data_file_size(struct dso *dso, struct machine *machine);
763off_t dso__data_size(struct dso *dso, struct machine *machine);
764ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine,
765 u64 offset, u8 *data, ssize_t size);
766ssize_t dso__data_read_addr(struct dso *dso, struct map *map,
767 struct machine *machine, u64 addr,
768 u8 *data, ssize_t size);
769bool dso__data_status_seen(struct dso *dso, enum dso_data_status_seen by);
770ssize_t dso__data_write_cache_offs(struct dso *dso, struct machine *machine,
771 u64 offset, const u8 *data, ssize_t size);
772ssize_t dso__data_write_cache_addr(struct dso *dso, struct map *map,
773 struct machine *machine, u64 addr,
774 const u8 *data, ssize_t size);
775
776struct map *dso__new_map(const char *name);
777struct dso *machine__findnew_kernel(struct machine *machine, const char *name,
778 const char *short_name, int dso_type);
779
780void dso__reset_find_symbol_cache(struct dso *dso);
781
782size_t dso__fprintf_symbols_by_name(struct dso *dso, FILE *fp);
783size_t dso__fprintf(struct dso *dso, FILE *fp);
784
785static inline enum dso_binary_type dso__binary_type(const struct dso *dso)
786{
787 return RC_CHK_ACCESS(dso)->binary_type;
788}
789
790static inline void dso__set_binary_type(struct dso *dso, enum dso_binary_type bt)
791{
792 RC_CHK_ACCESS(dso)->binary_type = bt;
793}
794
795static inline bool dso__is_vmlinux(const struct dso *dso)
796{
797 enum dso_binary_type bt = dso__binary_type(dso);
798
799 return bt == DSO_BINARY_TYPE__VMLINUX || bt == DSO_BINARY_TYPE__GUEST_VMLINUX;
800}
801
802static inline bool dso__is_kcore(const struct dso *dso)
803{
804 enum dso_binary_type bt = dso__binary_type(dso);
805
806 return bt == DSO_BINARY_TYPE__KCORE || bt == DSO_BINARY_TYPE__GUEST_KCORE;
807}
808
809static inline bool dso__is_kallsyms(const struct dso *dso)
810{
811 return RC_CHK_ACCESS(dso)->kernel && RC_CHK_ACCESS(dso)->long_name[0] != '/';
812}
813
814bool dso__is_object_file(const struct dso *dso);
815
816void dso__free_a2l(struct dso *dso);
817
818enum dso_type dso__type(struct dso *dso, struct machine *machine);
819
820int dso__strerror_load(struct dso *dso, char *buf, size_t buflen);
821
822void reset_fd_limit(void);
823
824u64 dso__find_global_type(struct dso *dso, u64 addr);
825u64 dso__findnew_global_type(struct dso *dso, u64 addr, u64 offset);
826
827/* Check if dso name is of format "/tmp/perf-%d.map" */
828bool perf_pid_map_tid(const char *dso_name, int *tid);
829bool is_perf_pid_map_name(const char *dso_name);
830
831#endif /* __PERF_DSO */