Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
ir_prof_digest.c File Reference
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <elf_abi.h>
#include <elf_mips.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include "ir_prof.h"
#include "ir_graph_util.h"
Include dependency graph for ir_prof_digest.c:

Go to the source code of this file.

Classes

struct  proc_info
struct  unique_name
struct  map2unique

Defines

#define MALLOC(nbytes)   malloc((size_t)(nbytes))
#define REALLOC(ptr, size)   realloc((void *)(ptr), (size_t)(size))
#define TRUE   1
#define FALSE   0
#define EEOF   -1
#define NOT_FOUND   -1
#define FILE_OTHER   0
#define FILE_EXECUTABLE   1
#define FILE_RELOCATABLE   2
#define FILE_ARCHIVE   3
#define ST_NONE   0
#define ST_NAME   1
#define ST_BIND   2
#define ST_OTHER   3
#define ST_TYPE   4
#define ST_SHNDX   5
#define ELF_TARG_32()   (p_elf_header->e_ident[EI_CLASS] == ELFCLASS32)
#define ASSERT(EX, p)   if (!(EX)) sysfatal(p)
#define NOT_VISITED   1

Functions

void usage ()
void warn (char *const s,...)
void sysfatal (char *const s,...)
void command_line (int argc, char **argv)
char * open_file (char *const objname)
void close_file (char *raw_bits)
Elf64_Ehdrmake_elfheader (char *raw_bits)
Elf64_Shdrmake_sectheader (char *raw_bits)
int is_elf_file (char *raw_bits, char *fname)
unsigned find_section (char *raw_bits, char *name, unsigned type, unsigned type_only)
int verify_counts_file (char *bits, char *fname)
void close_counts_file (char *fname)
counts_entryopen_counts_file (char *fname, long *num_entry, char **count_str)
char * find_and_get_str (ADDR addr, Elf64_Sym *symtab, int symcount, int start, char *strtab)
char * make_name (ADDR addr)
char * get_name (ADDR mem, int idx, Elf64_Sym *symtab, int symcount, int symstart, char *strtab, char *count_strtab)
void put_rec (counts_entry *pc, int idx)
int c_cmp (counts_entry *p1, counts_entry *p2)
int add_unique_name (char *name, ADDR a, unique_name *pun, int size)
int pr_dyn_count (EINDEX idx, long num_entry)
ADDR get_proc_size ()
void pr_vertex_name (int idx)
void pr_count (long *p)
void build_call_graph (counts_entry *pc, long num_entry, Elf64_Sym *symtab, int symcount, int symstart, char *strtab, char *count_strtab)
void process_counts (char *fname, Elf64_Sym *symtab, int symcount, int symstart, char *strtab)
Elf64_Symmake_symtab64 (char *orig, int count)
void get_dynamic_rec (int index, char *dynamic, Elf64_Dyn *dyn)
ADDR get_proc_size (char *name)
void put_proc_name (char *sect_name, ADDR size)
 main (int argc, char **argv)

Variables

char * raw_bits
struct stat statb
int fd_counts
int fd
static char * infile = NULL
static char * tool_name = NULL
static char * sect_name = NULL
static int dump_flag = 0
static int callgraph_flag = 0
static int sort_flag = 0
static int verbose_flag = 0
static void * dummy
static int num_argc = 0
static unsigned warn_flag = FALSE
static unsigned sect_index = 0
static unsigned targ32_flag = 0
static counts_entrycarray
static proc_infoparray
static int num_proc
Elf64_Ehdrp_elf_header
Elf64_Shdrp_sect_header
__uint64_t g_text_start
__uint64_t g_text_end
__uint64_t g_text_size
__uint64_t g_textlo_index
static unique_namepun
static map2uniquec
static char ptmp [] = " (???)"

Define Documentation

#define ASSERT (   EX,
 
)    if (!(EX)) sysfatal(p)
#define EEOF   -1

Definition at line 64 of file ir_prof_digest.c.

Referenced by sysfatal().

#define ELF_TARG_32 ( )    (p_elf_header->e_ident[EI_CLASS] == ELFCLASS32)

Definition at line 111 of file ir_prof_digest.c.

Referenced by get_dynamic_rec(), and make_symtab64().

#define FALSE   0

Definition at line 63 of file ir_prof_digest.c.

Referenced by is_elf_file(), and main().

#define FILE_ARCHIVE   3

Definition at line 70 of file ir_prof_digest.c.

#define FILE_EXECUTABLE   1

Definition at line 68 of file ir_prof_digest.c.

Referenced by is_elf_file().

#define FILE_OTHER   0

Definition at line 67 of file ir_prof_digest.c.

Referenced by main().

#define FILE_RELOCATABLE   2

Definition at line 69 of file ir_prof_digest.c.

#define MALLOC (   nbytes)    malloc((size_t)(nbytes))
#define NOT_FOUND   -1

Definition at line 65 of file ir_prof_digest.c.

Referenced by add_unique_name(), and build_call_graph().

#define NOT_VISITED   1

Referenced by process_counts().

#define REALLOC (   ptr,
  size 
)    realloc((void *)(ptr), (size_t)(size))

Definition at line 55 of file ir_prof_digest.c.

#define ST_BIND   2

Definition at line 74 of file ir_prof_digest.c.

#define ST_NAME   1

Definition at line 73 of file ir_prof_digest.c.

#define ST_NONE   0

Definition at line 72 of file ir_prof_digest.c.

#define ST_OTHER   3

Definition at line 75 of file ir_prof_digest.c.

#define ST_SHNDX   5

Definition at line 77 of file ir_prof_digest.c.

#define ST_TYPE   4

Definition at line 76 of file ir_prof_digest.c.

#define TRUE   1

Definition at line 62 of file ir_prof_digest.c.

Referenced by warn().


Function Documentation

int add_unique_name ( char *  name,
ADDR  a,
unique_name pun,
int  size 
)

Definition at line 581 of file ir_prof_digest.c.

References unique_name::a, ASSERT, MALLOC, unique_name::name, NOT_FOUND, size, and strcpy.

Referenced by build_call_graph().

void build_call_graph ( counts_entry pc,
long  num_entry,
Elf64_Sym symtab,
int  symcount,
int  symstart,
char *  strtab,
char *  count_strtab 
)
int c_cmp ( counts_entry p1,
counts_entry p2 
)

Definition at line 553 of file ir_prof_digest.c.

References counts_entry::count.

Referenced by process_counts().

void close_counts_file ( char *  fname)

Definition at line 439 of file ir_prof_digest.c.

References close, and fd_counts.

Referenced by main().

void close_file ( char *  raw_bits)

Definition at line 243 of file ir_prof_digest.c.

References close, fd, free(), and statb.

Here is the call graph for this function:

void command_line ( int  argc,
char **  argv 
)

Definition at line 168 of file ir_prof_digest.c.

References arg, callgraph_flag, dump_flag, exit(), infile, name, NULL, num_argc, sort_flag, usage(), and verbose_flag.

Referenced by main().

Here is the call graph for this function:

char* find_and_get_str ( ADDR  addr,
Elf64_Sym symtab,
int  symcount,
int  start,
char *  strtab 
)

Definition at line 483 of file ir_prof_digest.c.

References Elf64_Sym::st_name, start, and warn().

Referenced by get_name().

Here is the call graph for this function:

unsigned find_section ( char *  raw_bits,
char *  name,
unsigned  type,
unsigned  type_only 
)

Definition at line 385 of file ir_prof_digest.c.

References Elf64_Ehdr::e_shnum, Elf64_Ehdr::e_shstrndx, and Elf64_Shdr::sh_offset.

Referenced by main().

void get_dynamic_rec ( int  index,
char *  dynamic,
Elf64_Dyn dyn 
)
char* get_name ( ADDR  mem,
int  idx,
Elf64_Sym symtab,
int  symcount,
int  symstart,
char *  strtab,
char *  count_strtab 
)

Definition at line 524 of file ir_prof_digest.c.

References find_and_get_str(), idx, and make_name().

Referenced by build_call_graph(), and process_counts().

Here is the call graph for this function:

Referenced by pr_vertex_name().

ADDR get_proc_size ( char *  name)

Definition at line 851 of file ir_prof_digest.c.

References num_proc, and size.

int is_elf_file ( char *  raw_bits,
char *  fname 
)

Definition at line 362 of file ir_prof_digest.c.

References Elf32_Ehdr::e_ident, Elf32_Ehdr::e_type, EI_CLASS, EI_MAG0, EI_MAG1, EI_MAG2, EI_MAG3, ELFCLASS32, ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3, ET_REL, FALSE, FILE_EXECUTABLE, ret, sysfatal(), and targ32_flag.

Referenced by main().

Here is the call graph for this function:

char* make_name ( ADDR  addr)

Definition at line 512 of file ir_prof_digest.c.

References ASSERT, and MALLOC.

Referenced by get_name().

Elf64_Sym* make_symtab64 ( char *  orig,
int  count 
)
counts_entry* open_counts_file ( char *  fname,
long *  num_entry,
char **  count_str 
)

Definition at line 446 of file ir_prof_digest.c.

References ASSERT, fd_counts, fstat, MALLOC, open, read, statb, sysfatal(), and verify_counts_file().

Referenced by process_counts().

Here is the call graph for this function:

char* open_file ( char *const  objname)

Definition at line 212 of file ir_prof_digest.c.

References fd, fstat, open, raw_bits, read, and statb.

Referenced by main().

void pr_count ( long *  p)

Definition at line 649 of file ir_prof_digest.c.

Referenced by build_call_graph().

int pr_dyn_count ( EINDEX  idx,
long  num_entry 
)

Definition at line 604 of file ir_prof_digest.c.

References unique_name::a, ASSERT, callee, map2unique::callee, caller, and map2unique::caller.

Referenced by build_call_graph().

void pr_vertex_name ( int  idx)

Definition at line 630 of file ir_prof_digest.c.

References get_proc_size(), name, ptmp, s, and verbose_flag.

Referenced by build_call_graph().

Here is the call graph for this function:

void process_counts ( char *  fname,
Elf64_Sym symtab,
int  symcount,
int  symstart,
char *  strtab 
)

Definition at line 726 of file ir_prof_digest.c.

References ASSERT, build_call_graph(), c_cmp(), callee, caller, callgraph_flag, counts_entry::count, dump_flag, get_name(), MALLOC, NOT_VISITED, open_counts_file(), put_rec(), sort_flag, and verbose_flag.

Referenced by main().

Here is the call graph for this function:

void put_proc_name ( char *  sect_name,
ADDR  size 
)

Definition at line 868 of file ir_prof_digest.c.

References proc_info::name, name, num_proc, size, and proc_info::size.

Referenced by main().

void sysfatal ( char *const  s,
  ... 
)

Definition at line 142 of file ir_prof_digest.c.

References EEOF, errno, exit(), fprintf(), infile, sys_errlist, and tool_name.

Referenced by is_elf_file(), main(), make_elfheader(), make_sectheader(), open_counts_file(), and verify_counts_file().

Here is the call graph for this function:

void usage ( )

Definition at line 116 of file ir_prof_digest.c.

References fprintf(), and tool_name.

Referenced by command_line(), main(), and TI_RES_COUNT_Emit_Note().

Here is the call graph for this function:

int verify_counts_file ( char *  bits,
char *  fname 
)

Definition at line 415 of file ir_prof_digest.c.

References Counts_hdr::c_entry, Counts_hdr::c_ident, C_VERSION, Counts_hdr::c_version, COUNTSMAG0, COUNTSMAG1, COUNTSMAG2, COUNTSMAG3, COUNTSMAG4, COUNTSMAG5, COUNTSMAG6, COUNTSMAG7, and sysfatal().

Referenced by open_counts_file().

Here is the call graph for this function:

void warn ( char *const  s,
  ... 
)

Definition at line 125 of file ir_prof_digest.c.

References fprintf(), infile, tool_name, TRUE, and warn_flag.

Referenced by find_and_get_str(), and Set_addr_saved_expr().

Here is the call graph for this function:


Variable Documentation

map2unique* c [static]

Definition at line 575 of file ir_prof_digest.c.

Referenced by __cdiv(), __cptofcd(), __zdiv(), _Cif_binread(), _cnvrt_toupper(), _FRN(), _g_charstr(), _g_complx(), _get_holl(), _get_quoholl(), _getname(), _getnlval(), _gocthex(), _indx_nl(), _nexdata(), _nlrdent(), _nlread(), _rnl90to77(), LINEX::Add_access(), LOOPINFO::Add_bound(), ar_divide_complex(), ar_multiply_complex(), ascii_c_entry(), ascii_c_entry_end(), ascii_c_lint_directive(), ascii_c_macro_def(), ascii_c_message(), ascii_c_object(), ascii_c_opts(), ascii_c_tag(), ascii_cc_entry(), ascii_cc_enum(), ascii_cc_obj(), ascii_cc_type(), ascii_cdir_doshared(), ascii_comblk(), ascii_const(), ascii_continuation(), ascii_endunit(), ascii_entry(), ascii_f90_callsite(), ascii_f90_comblk(), ascii_f90_const(), ascii_f90_derived_type(), ascii_f90_entry(), ascii_f90_int_block(), ascii_f90_label(), ascii_f90_misc_opts(), ascii_f90_namelist(), ascii_f90_object(), ascii_f90_rename(), ascii_file(), ascii_geometry(), ascii_label(), ascii_message(), ascii_misc_opts(), ascii_namelist(), ascii_object(), ascii_orig_cmd(), ascii_unit(), ascii_usage(), asmname(), Atoi_KMG(), c_a_to_q(), c_q_div(), c_q_sqrt(), cal_rch(), cal_rwd(), cal_wch(), catmsgfmt(), Cif_Putrecord(), cwh_auxst_add_item(), cwh_auxst_find_dummy_len(), cwh_stab_adjust_name(), cwh_stk_count_STRs(), dbg_tokens(), DST_nput_char(), Emit_Definitions(), Extract_Complex_Imag(), Extract_Complex_Real(), Extract_Quad_Hi(), Extract_Quad_Lo(), filltype(), g_charstr(), g_complx(), g_octhex(), get_holl(), Get_Numeric_Flag(), get_quoholl(), Host_To_Targ(), Host_To_Targ_Complex(), Host_To_Targ_Complex_4(), Host_To_Targ_Complex_Quad(), Host_To_Targ_Float(), Host_To_Targ_Float_4(), Host_To_Targ_Quad(), Host_To_Targ_String(), Host_To_Targ_UV(), IPA_WN_Move_Maps_PU(), is_numeric_equal(), llist(), Make_Complex(), MDhash(), LINEX::Merge(), n_getn(), n_indx(), nex_data(), Output_Character(), Process_Command_Line(), RNL(), SCALAR_INFO::Set_callsite_id(), ALIAS_RULE::Set_context(), Set_ST_class(), Set_ST_classes(), Set_ST_sym_class(), SIMPNODE_SimplifyIntrinsic(), skip_old_rii_controls(), strlist(), LINEX::Subtract(), Targ_Conv(), Targ_Hexfptoc(), Targ_WhirlOp(), to_upper(), TY2C_Prepend_Alignment_Type(), vstr_append(), WNL(), ANL_FILE_MNGR::Write_Char(), and ANL_CBUF::Write_Char().

int callgraph_flag = 0 [static]

Definition at line 84 of file ir_prof_digest.c.

Referenced by command_line(), and process_counts().

counts_entry* carray [static]

Definition at line 93 of file ir_prof_digest.c.

int dump_flag = 0 [static]

Definition at line 83 of file ir_prof_digest.c.

Referenced by command_line(), and process_counts().

int fd_counts

Definition at line 60 of file ir_prof_digest.c.

Referenced by close_counts_file(), and open_counts_file().

Definition at line 107 of file ir_prof_digest.c.

Definition at line 108 of file ir_prof_digest.c.

Definition at line 106 of file ir_prof_digest.c.

Definition at line 109 of file ir_prof_digest.c.

char* infile = NULL [static]

Definition at line 80 of file ir_prof_digest.c.

Referenced by Cif_Make_Cifconv(), command_line(), main(), sysfatal(), and warn().

int num_argc = 0 [static]

Definition at line 88 of file ir_prof_digest.c.

Referenced by command_line(), and main().

int num_proc [static]

Definition at line 101 of file ir_prof_digest.c.

Referenced by get_proc_size(), and put_proc_name().

Definition at line 103 of file ir_prof_digest.c.

Definition at line 104 of file ir_prof_digest.c.

proc_info* parray [static]

Definition at line 100 of file ir_prof_digest.c.

char ptmp[] = " (???)" [static]

Definition at line 627 of file ir_prof_digest.c.

Referenced by pr_vertex_name(), and REGION_search_set().

unique_name* pun [static]

Definition at line 574 of file ir_prof_digest.c.

char* raw_bits

Definition at line 58 of file ir_prof_digest.c.

Referenced by main(), and open_file().

unsigned sect_index = 0 [static]

Definition at line 91 of file ir_prof_digest.c.

char* sect_name = NULL [static]

Definition at line 82 of file ir_prof_digest.c.

int sort_flag = 0 [static]

Definition at line 85 of file ir_prof_digest.c.

Referenced by command_line(), and process_counts().

struct stat statb

Definition at line 59 of file ir_prof_digest.c.

Referenced by close_file(), open_counts_file(), and open_file().

unsigned targ32_flag = 0 [static]

Definition at line 92 of file ir_prof_digest.c.

Referenced by is_elf_file(), make_elfheader(), and make_sectheader().

char* tool_name = NULL [static]

Definition at line 81 of file ir_prof_digest.c.

Referenced by main(), sysfatal(), usage(), and warn().

int verbose_flag = 0 [static]

Definition at line 86 of file ir_prof_digest.c.

Referenced by command_line(), main(), pr_vertex_name(), and process_counts().

unsigned warn_flag = FALSE [static]

Definition at line 90 of file ir_prof_digest.c.

Referenced by warn().

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines