Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
#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"
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_Ehdr * | make_elfheader (char *raw_bits) |
Elf64_Shdr * | make_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_entry * | open_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_Sym * | make_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_entry * | carray |
static proc_info * | parray |
static int | num_proc |
Elf64_Ehdr * | p_elf_header |
Elf64_Shdr * | p_sect_header |
__uint64_t | g_text_start |
__uint64_t | g_text_end |
__uint64_t | g_text_size |
__uint64_t | g_textlo_index |
static unique_name * | pun |
static map2unique * | c |
static char | ptmp [] = " (???)" |
Definition at line 113 of file ir_prof_digest.c.
Referenced by add_unique_name(), build_call_graph(), main(), make_name(), make_symtab64(), open_counts_file(), pr_dyn_count(), process_counts(), and put_rec().
#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.
Definition at line 52 of file ir_prof_digest.c.
Referenced by add_unique_name(), build_call_graph(), main(), make_name(), make_symtab64(), open_counts_file(), and process_counts().
#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().
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().
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 | ||
) |
Definition at line 656 of file ir_prof_digest.c.
References add_edge(), add_unique_name(), add_vertex(), ASSERT, build_graph_u(), callee, map2unique::callee, caller, map2unique::caller, d, DEF_EDGE_SIZE, DEF_VERTEX_SIZE, Depth_First_Ordering(), dummy, map2unique::edge_idx, get_name(), GRAPH_root, idx, unique_name::idx, INVALID_VINDEX, MALLOC, name, NOT_FOUND, pr_count(), pr_dyn_count(), pr_vertex_name(), Print_DFN(), and set_edge_u().
Referenced by process_counts().
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 | ) |
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().
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().
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 | ||
) |
Definition at line 834 of file ir_prof_digest.c.
References Elf32_Dyn::d_tag, Elf64_Dyn::d_tag, Elf32_Dyn::d_un, Elf64_Dyn::d_un, Elf32_Dyn::d_val, Elf64_Dyn::d_val, and ELF_TARG_32.
Referenced by main().
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().
ADDR get_proc_size | ( | ) |
Referenced by pr_vertex_name().
ADDR get_proc_size | ( | char * | name | ) |
Definition at line 851 of file ir_prof_digest.c.
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().
main | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 887 of file ir_prof_digest.c.
References ASSERT, close_counts_file(), command_line(), Elf64_Dyn::d_tag, Elf64_Dyn::d_un, Elf64_Dyn::d_val, DT_MIPS_GOTSYM, DT_NULL, Elf64_Ehdr::e_shnum, Elf64_Ehdr::e_shstrndx, exit(), FALSE, FILE_OTHER, find_section(), get_dynamic_rec(), infile, is_elf_file(), make_elfheader(), make_sectheader(), make_symtab64(), MALLOC, num_argc, open_file(), process_counts(), put_proc_name(), raw_bits, Elf64_Shdr::sh_entsize, Elf64_Shdr::sh_name, Elf64_Shdr::sh_offset, Elf64_Shdr::sh_size, SHT_DYNAMIC, SHT_DYNSYM, SHT_PROGBITS, SHT_STRTAB, start, sysfatal(), tool_name, usage(), and verbose_flag.
Elf64_Ehdr* make_elfheader | ( | char * | raw_bits | ) |
Definition at line 264 of file ir_prof_digest.c.
References Elf32_Ehdr::e_ehsize, Elf64_Ehdr::e_ehsize, Elf32_Ehdr::e_entry, Elf64_Ehdr::e_entry, Elf32_Ehdr::e_flags, Elf64_Ehdr::e_flags, Elf32_Ehdr::e_ident, Elf64_Ehdr::e_ident, Elf32_Ehdr::e_machine, Elf64_Ehdr::e_machine, Elf32_Ehdr::e_phentsize, Elf64_Ehdr::e_phentsize, Elf32_Ehdr::e_phnum, Elf64_Ehdr::e_phnum, Elf32_Ehdr::e_phoff, Elf64_Ehdr::e_phoff, Elf32_Ehdr::e_shentsize, Elf64_Ehdr::e_shentsize, Elf32_Ehdr::e_shnum, Elf64_Ehdr::e_shnum, Elf32_Ehdr::e_shoff, Elf64_Ehdr::e_shoff, Elf32_Ehdr::e_shstrndx, Elf64_Ehdr::e_shstrndx, Elf32_Ehdr::e_type, Elf64_Ehdr::e_type, Elf32_Ehdr::e_version, Elf64_Ehdr::e_version, EI_CLASS, EI_NIDENT, ELFCLASS32, sysfatal(), and targ32_flag.
Referenced by main().
Definition at line 512 of file ir_prof_digest.c.
References ASSERT, and MALLOC.
Referenced by get_name().
Elf64_Shdr* make_sectheader | ( | char * | raw_bits | ) |
Definition at line 311 of file ir_prof_digest.c.
References Elf32_Ehdr::e_shnum, Elf64_Ehdr::e_shnum, Elf32_Ehdr::e_shoff, Elf64_Ehdr::e_shoff, Elf64_Shdr::sh_addr, Elf64_Shdr::sh_addralign, Elf64_Shdr::sh_entsize, Elf64_Shdr::sh_flags, Elf64_Shdr::sh_info, Elf64_Shdr::sh_link, Elf64_Shdr::sh_name, Elf64_Shdr::sh_offset, Elf64_Shdr::sh_size, Elf64_Shdr::sh_type, sysfatal(), and targ32_flag.
Referenced by main().
Elf64_Sym* make_symtab64 | ( | char * | orig, |
int | count | ||
) |
Definition at line 807 of file ir_prof_digest.c.
References ASSERT, ELF_TARG_32, MALLOC, Elf32_Sym::st_info, Elf32_Sym::st_other, Elf32_Sym::st_shndx, Elf32_Sym::st_size, and Elf32_Sym::st_value.
Referenced by main().
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().
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().
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().
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 put_rec | ( | counts_entry * | pc, |
int | idx | ||
) |
Definition at line 541 of file ir_prof_digest.c.
References ASSERT, counts_entry::callee, counts_entry::callee_name_idx, counts_entry::caller, counts_entry::caller_name_idx, counts_entry::count, and idx.
Referenced by process_counts().
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().
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().
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().
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().
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.
void* dummy [static] |
Definition at line 87 of file ir_prof_digest.c.
Referenced by _FRU(), _frwd(), _FWU(), _get_value(), _indx_nl(), _RUF(), _s_scan_extensions(), build_call_graph(), cwh_auxst_add_dummy(), DST_set_assoc_idx(), fei_control_list(), final_arg_work(), Generate_Addr_Reset(), IPA_copy_PU(), main(), n_indx(), Print_Pred(), Push_Equiv_Visit_Order(), and ST2F_Is_Dummy_Procedure().
int dump_flag = 0 [static] |
Definition at line 83 of file ir_prof_digest.c.
Referenced by command_line(), and process_counts().
int fd |
Definition at line 60 of file ir_prof_digest.c.
Referenced by _Cif_binread(), _f_opn(), _ft_stopen(), _S2UB(), _S2UO(), _S2UZ(), ascii_usage(), assertCanWriteDir(), Cif_Close(), Cif_Getfiledir(), Cif_Getpos(), Cif_Getrecord(), Cif_Getunitdir(), Cif_Open(), Cif_Putrecord(), Cif_Recgroup(), Cif_Setpos(), cif_VerifyCanWrite(), close_file(), create_temp_file(), f77_map_datapool_(), f77_map_datapool_pad_(), ir_b_create_map(), Machine_Done(), open_arith_file(), open_file(), open_intrinsics_file(), print_buffered_messages(), read_file(), read_strlist(), usdumplockf90_(), usdumplockf90_8_(), usdumpsemaf90_(), usdumpsemaf90_8_(), write_strlist(), and write_unitdir().
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.
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.
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.
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().
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().
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().
Definition at line 90 of file ir_prof_digest.c.
Referenced by warn().