Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Functions
dwarf-aux.c File Reference
#include <stdbool.h>
#include "util.h"
#include "debug.h"
#include "dwarf-aux.h"

Go to the source code of this file.

Data Structures

struct  __addr_die_search_param
 
struct  __instance_walk_param
 
struct  __line_walk_param
 
struct  __find_variable_param
 

Functions

const charcu_find_realpath (Dwarf_Die *cu_die, const char *fname)
 
const charcu_get_comp_dir (Dwarf_Die *cu_die)
 
int cu_find_lineinfo (Dwarf_Die *cu_die, unsigned long addr, const char **fname, int *lineno)
 
int cu_walk_functions_at (Dwarf_Die *cu_die, Dwarf_Addr addr, int(*callback)(Dwarf_Die *, void *), void *data)
 
bool die_compare_name (Dwarf_Die *dw_die, const char *tname)
 
int die_get_call_lineno (Dwarf_Die *in_die)
 
Dwarf_Die * die_get_type (Dwarf_Die *vr_die, Dwarf_Die *die_mem)
 
Dwarf_Die * die_get_real_type (Dwarf_Die *vr_die, Dwarf_Die *die_mem)
 
bool die_is_signed_type (Dwarf_Die *tp_die)
 
int die_get_data_member_location (Dwarf_Die *mb_die, Dwarf_Word *offs)
 
const chardie_get_call_file (Dwarf_Die *in_die)
 
Dwarf_Die * die_find_child (Dwarf_Die *rt_die, int(*callback)(Dwarf_Die *, void *), void *data, Dwarf_Die *die_mem)
 
Dwarf_Die * die_find_realfunc (Dwarf_Die *cu_die, Dwarf_Addr addr, Dwarf_Die *die_mem)
 
Dwarf_Die * die_find_inlinefunc (Dwarf_Die *sp_die, Dwarf_Addr addr, Dwarf_Die *die_mem)
 
int die_walk_instances (Dwarf_Die *or_die, int(*callback)(Dwarf_Die *, void *), void *data)
 
int die_walk_lines (Dwarf_Die *rt_die, line_walk_callback_t callback, void *data)
 
at @addr in @sp_die.
Dwarf_Die * die_find_variable_at (Dwarf_Die *sp_die, const char *name, Dwarf_Addr addr, Dwarf_Die *die_mem)
 
in @st_die.
Dwarf_Die * die_find_member (Dwarf_Die *st_die, const char *name, Dwarf_Die *die_mem)
 
int die_get_typename (Dwarf_Die *vr_die, char *buf, int len)
 
int die_get_varname (Dwarf_Die *vr_die, char *buf, int len)
 

Function Documentation

int cu_find_lineinfo ( Dwarf_Die *  cu_die,
unsigned long  addr,
const char **  fname,
int lineno 
)

cu_find_lineinfo - Get a line number and file name for given address : a CU DIE : An address : a pointer which returns the file name string : a pointer which returns the line number

Find a line number and file name for in .

Definition at line 81 of file dwarf-aux.c.

const char* cu_find_realpath ( Dwarf_Die *  cu_die,
const char fname 
)

cu_find_realpath - Find the realpath of the target file : A DIE(dwarf information entry) of CU(compilation Unit) : The tail filename of the target file

Find the real(long) path of in .

Definition at line 32 of file dwarf-aux.c.

const char* cu_get_comp_dir ( Dwarf_Die *  cu_die)

cu_get_comp_dir - Get the path of compilation directory : a CU DIE

Get the path of compilation directory of given . Since this depends on DW_AT_comp_dir, older gcc will not embedded it. In that case, this returns NULL.

Definition at line 64 of file dwarf-aux.c.

int cu_walk_functions_at ( Dwarf_Die *  cu_die,
Dwarf_Addr  addr,
int(*)(Dwarf_Die *, void *)  callback,
void data 
)

cu_walk_functions_at - Walk on function DIEs at given address : A CU DIE : An address : A callback which called with found DIEs : A user data

Walk on function DIEs at given in . Passed DIEs should be subprogram or inlined-subroutines.

Definition at line 111 of file dwarf-aux.c.

bool die_compare_name ( Dwarf_Die *  dw_die,
const char tname 
)

die_compare_name - Compare diename and tname : a DIE : a string of target name

Compare the name of and . Return false if has no name.

Definition at line 139 of file dwarf-aux.c.

Dwarf_Die* die_find_child ( Dwarf_Die *  rt_die,
int(*)(Dwarf_Die *, void *)  callback,
void data,
Dwarf_Die *  die_mem 
)

die_find_child - Generic DIE search function in DIE tree : a root DIE : a callback function : a user data passed to the callback function : a buffer for result DIE

Trace DIE tree from and call for each child DIE. If returns DIE_FIND_CB_END, this stores the DIE into and returns it. If returns DIE_FIND_CB_CONTINUE, this continues to trace the tree. Optionally, can return DIE_FIND_CB_CHILD and DIE_FIND_CB_SIBLING, those means trace only the children and trace only the siblings respectively. Returns NULL if can't find any appropriate DIE.

Definition at line 358 of file dwarf-aux.c.

Dwarf_Die* die_find_inlinefunc ( Dwarf_Die *  sp_die,
Dwarf_Addr  addr,
Dwarf_Die *  die_mem 
)

die_find_inlinefunc - Search an inlined function at given address : a CU DIE which including : target address : a buffer for result DIE

Search an inlined function DIE which includes . Stores the DIE to and returns it if found. Returns NULl if failed. If several inlined functions are expanded recursively, this trace it and returns deepest one.

Definition at line 448 of file dwarf-aux.c.

Dwarf_Die* die_find_member ( Dwarf_Die *  st_die,
const char name,
Dwarf_Die *  die_mem 
)

Definition at line 765 of file dwarf-aux.c.

Dwarf_Die* die_find_realfunc ( Dwarf_Die *  cu_die,
Dwarf_Addr  addr,
Dwarf_Die *  die_mem 
)

die_find_realfunc - Search a non-inlined function at given address : a CU DIE which including : target address : a buffer for result DIE

Search a non-inlined function DIE which includes . Stores the DIE to and returns it if found. Returns NULl if failed.

Definition at line 412 of file dwarf-aux.c.

Dwarf_Die* die_find_variable_at ( Dwarf_Die *  sp_die,
const char name,
Dwarf_Addr  addr,
Dwarf_Die *  die_mem 
)

Definition at line 737 of file dwarf-aux.c.

const char* die_get_call_file ( Dwarf_Die *  in_die)

die_get_call_file - Get callsite file name of inlined function instance : a DIE of an inlined function instance

Get call-site file name of . This means from which file the inline function is called.

Definition at line 328 of file dwarf-aux.c.

int die_get_call_lineno ( Dwarf_Die *  in_die)

die_get_call_lineno - Get callsite line number of inline-function instance : a DIE of an inlined function instance

Get call-site line number of . This means from where the inline function is called.

Definition at line 153 of file dwarf-aux.c.

int die_get_data_member_location ( Dwarf_Die *  mb_die,
Dwarf_Word *  offs 
)

die_get_data_member_location - Get the data-member offset : a DIE of a member of a data structure : The offset of the member in the data structure

Get the offset of in the data structure including , and stores result offset to . If any error occurs this returns errno.

Definition at line 273 of file dwarf-aux.c.

Dwarf_Die* die_get_real_type ( Dwarf_Die *  vr_die,
Dwarf_Die *  die_mem 
)

die_get_real_type - Get a type die, but skip qualifiers and typedef : a DIE of a variable : where to store a type DIE

Get a DIE of the type of given variable (), and store it to die_mem. Return NULL if fails to get a type DIE. If the type is qualifiers (e.g. const) or typedef, this skips it and tries to find real type (structure or basic types, e.g. int).

Definition at line 212 of file dwarf-aux.c.

Dwarf_Die* die_get_type ( Dwarf_Die *  vr_die,
Dwarf_Die *  die_mem 
)

die_get_type - Get type DIE : a DIE of a variable : where to store a type DIE

Get a DIE of the type of given variable (), and store it to die_mem. Return NULL if fails to get a type DIE.

Definition at line 173 of file dwarf-aux.c.

int die_get_typename ( Dwarf_Die *  vr_die,
char buf,
int  len 
)

die_get_typename - Get the name of given variable DIE : a variable DIE : a buffer for result type name : a max-length of

Get the name of and stores it to . Return the actual length of type name if succeeded. Return -E2BIG if is not enough long, and Return -ENOENT if failed to find type name. Note that the result will stores typedef name if possible, and stores "*(function_type)" if the type is a function pointer.

Definition at line 784 of file dwarf-aux.c.

int die_get_varname ( Dwarf_Die *  vr_die,
char buf,
int  len 
)

die_get_varname - Get the name and type of given variable DIE : a variable DIE : a buffer for type and variable name : the max-length of

Get the name and type of and stores it in as "type\tname".

Definition at line 829 of file dwarf-aux.c.

bool die_is_signed_type ( Dwarf_Die *  tp_die)

die_is_signed_type - Check whether a type DIE is signed or not : a DIE of a type

Get the encoding of and return true if the encoding is signed.

Definition at line 254 of file dwarf-aux.c.

int die_walk_instances ( Dwarf_Die *  or_die,
int(*)(Dwarf_Die *, void *)  callback,
void data 
)

die_walk_instances - Walk on instances of given DIE : an abstract original DIE : a callback function which is called with instance DIE : user data

Walk on the instances of give . must be an inlined function declartion. This returns the return value of if it returns non-zero value, or -ENOENT if there is no instance.

Definition at line 516 of file dwarf-aux.c.

int die_walk_lines ( Dwarf_Die *  rt_die,
line_walk_callback_t  callback,
void data 
)

die_walk_lines - Walk on lines inside given DIE : a root DIE (CU, subprogram or inlined_subroutine) : callback routine : user data

Walk on all lines inside given and call on each line. If the is a function, walk only on the lines inside the function, otherwise must be a CU DIE. Note that this walks not only dwarf line list, but also function entries and inline call-site.

Definition at line 628 of file dwarf-aux.c.