Linux Perf
dso.c File Reference
#include <asm/bug.h>
#include <linux/kernel.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include "compress.h"
#include "path.h"
#include "symbol.h"
#include "srcline.h"
#include "dso.h"
#include "machine.h"
#include "auxtrace.h"
#include "util.h"
#include "debug.h"
#include "string2.h"
#include "vdso.h"
Include dependency graph for dso.c:

Go to the source code of this file.

Functions

char dso__symtab_origin (const struct dso *dso)
 
int dso__read_binary_type_filename (const struct dso *dso, enum dso_binary_type type, char *root_dir, char *filename, size_t size)
 
bool is_supported_compression (const char *ext)
 
bool is_kernel_module (const char *pathname, int cpumode)
 
bool decompress_to_file (const char *ext, const char *filename, int output_fd)
 
bool dso__needs_decompress (struct dso *dso)
 
static int decompress_kmodule (struct dso *dso, const char *name, char *tmpbuf)
 
int dso__decompress_kmodule_fd (struct dso *dso, const char *name)
 
int dso__decompress_kmodule_path (struct dso *dso, const char *name, char *pathname, size_t len)
 
int __kmod_path__parse (struct kmod_path *m, const char *path, bool alloc_name, bool alloc_ext)
 
void dso__set_module_info (struct dso *dso, struct kmod_path *m, struct machine *machine)
 
static LIST_HEAD (dso__data_open)
 
static void dso__list_add (struct dso *dso)
 
static void dso__list_del (struct dso *dso)
 
static void close_first_dso (void)
 
static int do_open (char *name)
 
static int __open_dso (struct dso *dso, struct machine *machine)
 
static void check_data_close (void)
 
static int open_dso (struct dso *dso, struct machine *machine)
 
static void close_data_fd (struct dso *dso)
 
static void close_dso (struct dso *dso)
 
static rlim_t get_fd_limit (void)
 
void reset_fd_limit (void)
 
static bool may_cache_fd (void)
 
void dso__data_close (struct dso *dso)
 
static void try_to_open_dso (struct dso *dso, struct machine *machine)
 
int dso__data_get_fd (struct dso *dso, struct machine *machine)
 
void dso__data_put_fd (struct dso *dso __maybe_unused)
 
bool dso__data_status_seen (struct dso *dso, enum dso_data_status_seen by)
 
static void dso_cache__free (struct dso *dso)
 
static struct dso_cachedso_cache__find (struct dso *dso, u64 offset)
 
static struct dso_cachedso_cache__insert (struct dso *dso, struct dso_cache *new)
 
static ssize_t dso_cache__memcpy (struct dso_cache *cache, u64 offset, u8 *data, u64 size)
 
static ssize_t dso_cache__read (struct dso *dso, struct machine *machine, u64 offset, u8 *data, ssize_t size)
 
static ssize_t dso_cache_read (struct dso *dso, struct machine *machine, u64 offset, u8 *data, ssize_t size)
 
static ssize_t cached_read (struct dso *dso, struct machine *machine, u64 offset, u8 *data, ssize_t size)
 
static int data_file_size (struct dso *dso, struct machine *machine)
 
off_t dso__data_size (struct dso *dso, struct machine *machine)
 
static ssize_t data_read_offset (struct dso *dso, struct machine *machine, u64 offset, u8 *data, ssize_t size)
 
ssize_t dso__data_read_offset (struct dso *dso, struct machine *machine, u64 offset, u8 *data, ssize_t size)
 
ssize_t dso__data_read_addr (struct dso *dso, struct map *map, struct machine *machine, u64 addr, u8 *data, ssize_t size)
 
struct mapdso__new_map (const char *name)
 
struct dsomachine__findnew_kernel (struct machine *machine, const char *name, const char *short_name, int dso_type)
 
static struct dso__dso__findlink_by_longname (struct rb_root *root, struct dso *dso, const char *name)
 
static struct dso__dso__find_by_longname (struct rb_root *root, const char *name)
 
void dso__set_long_name (struct dso *dso, const char *name, bool name_allocated)
 
void dso__set_short_name (struct dso *dso, const char *name, bool name_allocated)
 
static void dso__set_basename (struct dso *dso)
 
int dso__name_len (const struct dso *dso)
 
bool dso__loaded (const struct dso *dso)
 
bool dso__sorted_by_name (const struct dso *dso)
 
void dso__set_sorted_by_name (struct dso *dso)
 
struct dsodso__new (const char *name)
 
void dso__delete (struct dso *dso)
 
struct dsodso__get (struct dso *dso)
 
void dso__put (struct dso *dso)
 
void dso__set_build_id (struct dso *dso, void *build_id)
 
bool dso__build_id_equal (const struct dso *dso, u8 *build_id)
 
void dso__read_running_kernel_build_id (struct dso *dso, struct machine *machine)
 
int dso__kernel_module_get_build_id (struct dso *dso, const char *root_dir)
 
bool __dsos__read_build_ids (struct list_head *head, bool with_hits)
 
void __dsos__add (struct dsos *dsos, struct dso *dso)
 
void dsos__add (struct dsos *dsos, struct dso *dso)
 
struct dso__dsos__find (struct dsos *dsos, const char *name, bool cmp_short)
 
struct dsodsos__find (struct dsos *dsos, const char *name, bool cmp_short)
 
struct dso__dsos__addnew (struct dsos *dsos, const char *name)
 
struct dso__dsos__findnew (struct dsos *dsos, const char *name)
 
struct dsodsos__findnew (struct dsos *dsos, const char *name)
 
size_t __dsos__fprintf_buildid (struct list_head *head, FILE *fp, bool(skip)(struct dso *dso, int parm), int parm)
 
size_t __dsos__fprintf (struct list_head *head, FILE *fp)
 
size_t dso__fprintf_buildid (struct dso *dso, FILE *fp)
 
size_t dso__fprintf (struct dso *dso, FILE *fp)
 
enum dso_type dso__type (struct dso *dso, struct machine *machine)
 
int dso__strerror_load (struct dso *dso, char *buf, size_t buflen)
 

Variables

static const char *const debuglink_paths []
 
struct {
   const char *   fmt
 
   int(*   decompress )(const char *input, int output)
 
compressions []
 
static long dso__data_open_cnt
 
static pthread_mutex_t dso__data_open_lock = PTHREAD_MUTEX_INITIALIZER
 
static rlim_t fd_limit
 

Function Documentation

◆ __dso__find_by_longname()

static struct dso* __dso__find_by_longname ( struct rb_root *  root,
const char *  name 
)
static

Definition at line 1098 of file dso.c.

Here is the call graph for this function:

◆ __dso__findlink_by_longname()

static struct dso* __dso__findlink_by_longname ( struct rb_root *  root,
struct dso dso,
const char *  name 
)
static

Definition at line 1049 of file dso.c.

◆ __dsos__add()

void __dsos__add ( struct dsos dsos,
struct dso dso 
)

Definition at line 1345 of file dso.c.

Here is the call graph for this function:

◆ __dsos__addnew()

struct dso* __dsos__addnew ( struct dsos dsos,
const char *  name 
)

Definition at line 1401 of file dso.c.

Here is the call graph for this function:

◆ __dsos__find()

struct dso* __dsos__find ( struct dsos dsos,
const char *  name,
bool  cmp_short 
)

Definition at line 1379 of file dso.c.

Here is the call graph for this function:

◆ __dsos__findnew()

struct dso* __dsos__findnew ( struct dsos dsos,
const char *  name 
)

Definition at line 1414 of file dso.c.

Here is the call graph for this function:

◆ __dsos__fprintf()

size_t __dsos__fprintf ( struct list_head *  head,
FILE *  fp 
)

Definition at line 1445 of file dso.c.

Here is the call graph for this function:

◆ __dsos__fprintf_buildid()

size_t __dsos__fprintf_buildid ( struct list_head *  head,
FILE *  fp,
bool(skip)(struct dso *dso, int parm)  ,
int  parm 
)

Definition at line 1430 of file dso.c.

Here is the call graph for this function:

◆ __dsos__read_build_ids()

bool __dsos__read_build_ids ( struct list_head *  head,
bool  with_hits 
)

Definition at line 1320 of file dso.c.

Here is the call graph for this function:

◆ __kmod_path__parse()

int __kmod_path__parse ( struct kmod_path m,
const char *  path,
bool  alloc_name,
bool  alloc_ext 
)

Definition at line 334 of file dso.c.

Here is the call graph for this function:

◆ __open_dso()

static int __open_dso ( struct dso dso,
struct machine machine 
)
static

Definition at line 466 of file dso.c.

Here is the call graph for this function:

◆ cached_read()

static ssize_t cached_read ( struct dso dso,
struct machine machine,
u64  offset,
u8 *  data,
ssize_t  size 
)
static

Definition at line 874 of file dso.c.

Here is the call graph for this function:

◆ check_data_close()

static void check_data_close ( void  )
static

Definition at line 616 of file dso.c.

Here is the call graph for this function:

◆ close_data_fd()

static void close_data_fd ( struct dso dso)
static

Definition at line 539 of file dso.c.

Here is the call graph for this function:

◆ close_dso()

static void close_dso ( struct dso dso)
static

dso_close - Close DSO data file : dso object

Close 's data file descriptor and updates list/count of open DSO objects.

Definition at line 556 of file dso.c.

Here is the call graph for this function:

◆ close_first_dso()

static void close_first_dso ( void  )
static

Definition at line 561 of file dso.c.

Here is the call graph for this function:

◆ data_file_size()

static int data_file_size ( struct dso dso,
struct machine machine 
)
static

Definition at line 903 of file dso.c.

Here is the call graph for this function:

◆ data_read_offset()

static ssize_t data_read_offset ( struct dso dso,
struct machine machine,
u64  offset,
u8 *  data,
ssize_t  size 
)
static

Definition at line 959 of file dso.c.

Here is the call graph for this function:

◆ decompress_kmodule()

static int decompress_kmodule ( struct dso dso,
const char *  name,
char *  tmpbuf 
)
static

Definition at line 260 of file dso.c.

Here is the call graph for this function:

◆ decompress_to_file()

bool decompress_to_file ( const char *  ext,
const char *  filename,
int  output_fd 
)

Definition at line 242 of file dso.c.

◆ do_open()

static int do_open ( char *  name)
static

Definition at line 445 of file dso.c.

Here is the call graph for this function:

◆ dso__build_id_equal()

bool dso__build_id_equal ( const struct dso dso,
u8 *  build_id 
)

Definition at line 1282 of file dso.c.

◆ dso__data_close()

void dso__data_close ( struct dso dso)

dso__data_close - Close DSO data file : dso object

External interface to close 's data file descriptor.

Definition at line 630 of file dso.c.

Here is the call graph for this function:

◆ dso__data_get_fd()

int dso__data_get_fd ( struct dso dso,
struct machine machine 
)

dso__data_get_fd - Get dso's data file descriptor : dso object : machine object

External interface to find dso's file, open it and returns file descriptor. It should be paired with dso__data_put_fd() if it returns non-negative value.

Definition at line 678 of file dso.c.

Here is the call graph for this function:

◆ dso__data_put_fd()

void dso__data_put_fd ( struct dso *dso  __maybe_unused)

Definition at line 694 of file dso.c.

◆ dso__data_read_addr()

ssize_t dso__data_read_addr ( struct dso dso,
struct map map,
struct machine machine,
u64  addr,
u8 *  data,
ssize_t  size 
)

dso__data_read_addr - Read data from dso address : dso object : machine object : virtual memory address : buffer to store data : size of the buffer

External interface to read data from dso address.

Definition at line 1005 of file dso.c.

Here is the call graph for this function:

◆ dso__data_read_offset()

ssize_t dso__data_read_offset ( struct dso dso,
struct machine machine,
u64  offset,
u8 *  data,
ssize_t  size 
)

dso__data_read_offset - Read data from dso file offset : dso object : machine object : file offset : buffer to store data : size of the buffer

External interface to read data from dso file offset. Open dso data file and use cached_read to get the data.

Definition at line 986 of file dso.c.

Here is the call graph for this function:

◆ dso__data_size()

off_t dso__data_size ( struct dso dso,
struct machine machine 
)

dso__data_size - Return dso data size : dso object : machine object

Return: dso data size

Definition at line 950 of file dso.c.

Here is the call graph for this function:

◆ dso__data_status_seen()

bool dso__data_status_seen ( struct dso dso,
enum dso_data_status_seen  by 
)

Definition at line 699 of file dso.c.

◆ dso__decompress_kmodule_fd()

int dso__decompress_kmodule_fd ( struct dso dso,
const char *  name 
)

Definition at line 291 of file dso.c.

Here is the call graph for this function:

◆ dso__decompress_kmodule_path()

int dso__decompress_kmodule_path ( struct dso dso,
const char *  name,
char *  pathname,
size_t  len 
)

Definition at line 301 of file dso.c.

Here is the call graph for this function:

◆ dso__delete()

void dso__delete ( struct dso dso)

Definition at line 1232 of file dso.c.

Here is the call graph for this function:

◆ dso__fprintf()

size_t dso__fprintf ( struct dso dso,
FILE *  fp 
)

Definition at line 1465 of file dso.c.

Here is the call graph for this function:

◆ dso__fprintf_buildid()

size_t dso__fprintf_buildid ( struct dso dso,
FILE *  fp 
)

Definition at line 1457 of file dso.c.

Here is the call graph for this function:

◆ dso__get()

struct dso* dso__get ( struct dso dso)

Definition at line 1263 of file dso.c.

◆ dso__kernel_module_get_build_id()

int dso__kernel_module_get_build_id ( struct dso dso,
const char *  root_dir 
)

Definition at line 1299 of file dso.c.

Here is the call graph for this function:

◆ dso__list_add()

static void dso__list_add ( struct dso dso)
static

Definition at line 429 of file dso.c.

◆ dso__list_del()

static void dso__list_del ( struct dso dso)
static

Definition at line 435 of file dso.c.

Here is the call graph for this function:

◆ dso__loaded()

bool dso__loaded ( const struct dso dso)

Definition at line 1181 of file dso.c.

◆ dso__name_len()

int dso__name_len ( const struct dso dso)

Definition at line 1171 of file dso.c.

◆ dso__needs_decompress()

bool dso__needs_decompress ( struct dso dso)

Definition at line 254 of file dso.c.

◆ dso__new()

struct dso* dso__new ( const char *  name)

Definition at line 1196 of file dso.c.

Here is the call graph for this function:

◆ dso__new_map()

struct map* dso__new_map ( const char *  name)

Definition at line 1013 of file dso.c.

Here is the call graph for this function:

◆ dso__put()

void dso__put ( struct dso dso)

Definition at line 1270 of file dso.c.

Here is the call graph for this function:

◆ dso__read_binary_type_filename()

int dso__read_binary_type_filename ( const struct dso dso,
enum dso_binary_type  type,
char *  root_dir,
char *  filename,
size_t  size 
)

Definition at line 57 of file dso.c.

Here is the call graph for this function:

◆ dso__read_running_kernel_build_id()

void dso__read_running_kernel_build_id ( struct dso dso,
struct machine machine 
)

Definition at line 1287 of file dso.c.

Here is the call graph for this function:

◆ dso__set_basename()

static void dso__set_basename ( struct dso dso)
static

Definition at line 1145 of file dso.c.

Here is the call graph for this function:

◆ dso__set_build_id()

void dso__set_build_id ( struct dso dso,
void *  build_id 
)

Definition at line 1276 of file dso.c.

Here is the call graph for this function:

◆ dso__set_long_name()

void dso__set_long_name ( struct dso dso,
const char *  name,
bool  name_allocated 
)

Definition at line 1104 of file dso.c.

Here is the call graph for this function:

◆ dso__set_module_info()

void dso__set_module_info ( struct dso dso,
struct kmod_path m,
struct machine machine 
)

Definition at line 407 of file dso.c.

Here is the call graph for this function:

◆ dso__set_short_name()

void dso__set_short_name ( struct dso dso,
const char *  name,
bool  name_allocated 
)

Definition at line 1132 of file dso.c.

Here is the call graph for this function:

◆ dso__set_sorted_by_name()

void dso__set_sorted_by_name ( struct dso dso)

Definition at line 1191 of file dso.c.

◆ dso__sorted_by_name()

bool dso__sorted_by_name ( const struct dso dso)

Definition at line 1186 of file dso.c.

◆ dso__strerror_load()

int dso__strerror_load ( struct dso dso,
char *  buf,
size_t  buflen 
)

Definition at line 1497 of file dso.c.

◆ dso__symtab_origin()

char dso__symtab_origin ( const struct dso dso)

Definition at line 30 of file dso.c.

◆ dso__type()

enum dso_type dso__type ( struct dso dso,
struct machine machine 
)

Definition at line 1483 of file dso.c.

Here is the call graph for this function:

◆ dso_cache__find()

static struct dso_cache* dso_cache__find ( struct dso dso,
u64  offset 
)
static

Definition at line 729 of file dso.c.

◆ dso_cache__free()

static void dso_cache__free ( struct dso dso)
static

Definition at line 712 of file dso.c.

Here is the call graph for this function:

◆ dso_cache__insert()

static struct dso_cache* dso_cache__insert ( struct dso dso,
struct dso_cache new 
)
static

Definition at line 755 of file dso.c.

◆ dso_cache__memcpy()

static ssize_t dso_cache__memcpy ( struct dso_cache cache,
u64  offset,
u8 *  data,
u64  size 
)
static

Definition at line 789 of file dso.c.

Here is the call graph for this function:

◆ dso_cache__read()

static ssize_t dso_cache__read ( struct dso dso,
struct machine machine,
u64  offset,
u8 *  data,
ssize_t  size 
)
static

Definition at line 800 of file dso.c.

Here is the call graph for this function:

◆ dso_cache_read()

static ssize_t dso_cache_read ( struct dso dso,
struct machine machine,
u64  offset,
u8 *  data,
ssize_t  size 
)
static

Definition at line 857 of file dso.c.

Here is the call graph for this function:

◆ dsos__add()

void dsos__add ( struct dsos dsos,
struct dso dso 
)

Definition at line 1372 of file dso.c.

Here is the call graph for this function:

◆ dsos__find()

struct dso* dsos__find ( struct dsos dsos,
const char *  name,
bool  cmp_short 
)

Definition at line 1392 of file dso.c.

Here is the call graph for this function:

◆ dsos__findnew()

struct dso* dsos__findnew ( struct dsos dsos,
const char *  name 
)

Definition at line 1421 of file dso.c.

Here is the call graph for this function:

◆ get_fd_limit()

static rlim_t get_fd_limit ( void  )
static

Definition at line 569 of file dso.c.

◆ is_kernel_module()

bool is_kernel_module ( const char *  pathname,
int  cpumode 
)

Definition at line 216 of file dso.c.

◆ is_supported_compression()

bool is_supported_compression ( const char *  ext)

Definition at line 205 of file dso.c.

◆ LIST_HEAD()

static LIST_HEAD ( dso__data_open  )
static

◆ machine__findnew_kernel()

struct dso* machine__findnew_kernel ( struct machine machine,
const char *  name,
const char *  short_name,
int  dso_type 
)

Definition at line 1024 of file dso.c.

Here is the call graph for this function:

◆ may_cache_fd()

static bool may_cache_fd ( void  )
static

Definition at line 600 of file dso.c.

Here is the call graph for this function:

◆ open_dso()

static int open_dso ( struct dso dso,
struct machine machine 
)
static

dso_close - Open DSO data file : dso object

Open 's data file descriptor and updates list/count of open DSO objects.

Definition at line 516 of file dso.c.

Here is the call graph for this function:

◆ reset_fd_limit()

void reset_fd_limit ( void  )

Definition at line 595 of file dso.c.

◆ try_to_open_dso()

static void try_to_open_dso ( struct dso dso,
struct machine machine 
)
static

Definition at line 637 of file dso.c.

Here is the call graph for this function:

Variable Documentation

◆ compressions

const { ... } compressions[]
Initial value:
= {
{ NULL, NULL },
}

◆ debuglink_paths

const char* const debuglink_paths[]
static
Initial value:
= {
"%.0s%s",
"%s/%s",
"%s/.debug/%s",
"/usr/lib/debug%s/%s"
}

Definition at line 23 of file dso.c.

◆ decompress

int(* decompress) (const char *input, int output)

Definition at line 194 of file dso.c.

◆ dso__data_open_cnt

long dso__data_open_cnt
static

Definition at line 426 of file dso.c.

◆ dso__data_open_lock

pthread_mutex_t dso__data_open_lock = PTHREAD_MUTEX_INITIALIZER
static

Definition at line 427 of file dso.c.

◆ fd_limit

rlim_t fd_limit
static

Definition at line 588 of file dso.c.

◆ fmt

const char* fmt

Definition at line 193 of file dso.c.