dwarf-20120410/0000750000175000017500000000000011741100175011762 5ustar daveadaveadwarf-20120410/dwarfexample/0000750000175000017500000000000011741100175014441 5ustar daveadaveadwarf-20120410/dwarfexample/ChangeLog20090000640000175000017500000000071711741100175016534 0ustar daveadaveaAugust 7, 2009 David Anderson * frame1.c: This is a new example that uses frame functions. July 21, 2009 David Anderson * simplereader.c: After cur_die = sib_die; nothing was printing cur_die, so added a print call after the assignment. July 8, 2009 David Anderson * Makefile: New trivial Makefile to build the example. * simplereader.c: New trivial example using libdwarf. dwarf-20120410/dwarfexample/Makefile0000640000175000017500000000053111741100175016101 0ustar daveadavea LIBDIR= -L../libdwarf LIBS= -ldwarf -lelf CFLAGS= -Wall -I../libdwarf all: simplereader frame1 simplereader: simplereader.c $(CC) $(CFLAGS) simplereader.c -o simplereader $(LIBDIR) $(LIBS) frame1: frame1.c $(CC) $(CFLAGS) frame1.c -o frame1 $(LIBDIR) $(LIBS) clean: rm -f simplereader.o rm -f simplereader rm -f frame1 rm -f frame1.o dwarf-20120410/dwarfexample/ChangeLog20100000640000175000017500000000106711741100175016523 0ustar daveadaveaApril 26, 2010 David Anderson * simplereader.c: Now prints all TAGs regardless of whether a DIE has a DW_AT_name attribute. All names print an "" pair so it's easy to recognize empty names and names with embedded spaces. March 31, 2010 David Anderson * simplereader.c: Added a new option --names which shows additional detail on getting attributes and source file information. January 3, 2010 David Anderson * frame1.c, simplereader.c: Update copyright year. dwarf-20120410/dwarfexample/frame1.c0000640000175000017500000003172211741100175015766 0ustar daveadavea/* Copyright (c) 2009-2010 David Anderson. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the example nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY David Anderson ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL David Anderson BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* simplereader.c This is an example of code reading dwarf .debug_frame. It is kept as simple as possible to expose essential features. It does not do all possible error reporting or error handling. It specifically calls dwarf_expand_frame_instructions() to verify that works without crashing! To use, try make ./frame1 frame1 */ #include /* For open() */ #include /* For open() */ #include /* For open() */ #include /* For exit() */ #include /* For close() */ #include /* For strcmp* */ #include #include #include "dwarf.h" #include "libdwarf.h" static void read_frame_data(Dwarf_Debug dbg); static void print_fde_instrs(Dwarf_Debug dbg, Dwarf_Fde fde, int fdenum, Dwarf_Error *error); static void print_regtable(Dwarf_Fde fde,Dwarf_Regtable3 *tab3,int oldrulecount, Dwarf_Debug dbg,Dwarf_Error *error); static void print_cie_instrs(Dwarf_Debug dbg,Dwarf_Cie cie,Dwarf_Error *error); #define UNDEF_VAL 2000 #define SAME_VAL 2001 #define CFA_VAL 2002 int main(int argc, char **argv) { Dwarf_Debug dbg = 0; int fd = -1; const char *filepath = ""; int res = DW_DLV_ERROR; Dwarf_Error error; Dwarf_Handler errhand = 0; Dwarf_Ptr errarg = 0; int regtabrulecount = 0; if(argc < 2) { fd = 0; /* stdin */ } else { filepath = argv[1]; fd = open(filepath,O_RDONLY); } if(fd < 0) { printf("Failure attempting to open %s\n",filepath); } res = dwarf_init(fd,DW_DLC_READ,errhand,errarg, &dbg,&error); if(res != DW_DLV_OK) { printf("Giving up, dwarf_init failed, cannot do DWARF processing\n"); exit(1); } /* Do this setting after init before any real operations. These return the old values, but here we do not need to know the old values. The sizes and values here are higher than most ABIs and entirely arbitrary. The setting of initial_value to the same as undefined-value (the other possible choice being same-value) is arbitrary, different ABIs do differ, and you have to know which is right. */ regtabrulecount=1999; dwarf_set_frame_undefined_value(dbg, UNDEF_VAL); dwarf_set_frame_rule_initial_value(dbg, UNDEF_VAL); dwarf_set_frame_same_value(dbg,SAME_VAL); dwarf_set_frame_cfa_value(dbg,CFA_VAL); dwarf_set_frame_rule_table_size(dbg,regtabrulecount); read_frame_data(dbg); res = dwarf_finish(dbg,&error); if(res != DW_DLV_OK) { printf("dwarf_finish failed!\n"); } close(fd); return 0; } static void read_frame_data(Dwarf_Debug dbg) { Dwarf_Error error; Dwarf_Signed cie_element_count = 0; Dwarf_Signed fde_element_count = 0; Dwarf_Cie *cie_data = 0; Dwarf_Fde *fde_data = 0; int res = DW_DLV_ERROR; Dwarf_Signed fdenum = 0; res = dwarf_get_fde_list(dbg,&cie_data,&cie_element_count, &fde_data,&fde_element_count,&error); if(res == DW_DLV_NO_ENTRY) { printf("No frame data present "); exit(0); } if( res == DW_DLV_ERROR) { printf("Error reading frame data "); exit(1); } printf( "%" DW_PR_DSd " cies present. " "%" DW_PR_DSd " fdes present. \n", cie_element_count,fde_element_count); /*if(fdenum >= fde_element_count) { printf("Want fde %d but only %" DW_PR_DSd " present\n",fdenum, fde_element_count); exit(1); }*/ for(fdenum = 0; fdenum < fde_element_count; ++fdenum) { Dwarf_Cie cie = 0; printf("Print cie of fde %" DW_PR_DSd "\n",fdenum); res = dwarf_get_cie_of_fde(fde_data[fdenum],&cie,&error); if(res != DW_DLV_OK) { printf("Error accessing fdenum %" DW_PR_DSd " to get its cie\n",fdenum); exit(1); } print_cie_instrs(dbg,cie,&error); printf("Print fde %" DW_PR_DSd "\n",fdenum); print_fde_instrs(dbg,fde_data[fdenum],fdenum,&error); } /* Done with the data. */ dwarf_fde_cie_list_dealloc(dbg,cie_data,cie_element_count, fde_data, fde_element_count); return; } static void print_cie_instrs(Dwarf_Debug dbg,Dwarf_Cie cie,Dwarf_Error *error) { int res = DW_DLV_ERROR; Dwarf_Unsigned bytes_in_cie = 0; Dwarf_Small version = 0; char *augmentation = 0; Dwarf_Unsigned code_alignment_factor = 0; Dwarf_Signed data_alignment_factor = 0; Dwarf_Half return_address_register_rule = 0; Dwarf_Ptr instrp = 0; Dwarf_Unsigned instr_len = 0; res = dwarf_get_cie_info(cie,&bytes_in_cie, &version, &augmentation, &code_alignment_factor, &data_alignment_factor, &return_address_register_rule, &instrp,&instr_len,error); if(res != DW_DLV_OK) { printf("Unable to get cie info!\n"); exit(1); } } static void print_frame_instrs(Dwarf_Debug dbg,Dwarf_Frame_Op *frame_op_list, Dwarf_Signed frame_op_count) { Dwarf_Signed i = 0; printf("Base op. Ext op. Reg. Offset. Instr-offset.\n"); for(i = 0; i < frame_op_count; ++i) { printf("[%" DW_PR_DSd "]", i); printf(" %d. ", frame_op_list[i].fp_base_op); printf(" %d. ", frame_op_list[i].fp_extended_op); printf(" %" DW_PR_DSd ". ", frame_op_list[i].fp_offset); printf(" 0x%" DW_PR_DUx ". ", frame_op_list[i].fp_instr_offset); printf("\n"); } } static void print_fde_instrs(Dwarf_Debug dbg, Dwarf_Fde fde,int fdenum, Dwarf_Error *error) { int res; Dwarf_Addr lowpc = 0; Dwarf_Unsigned func_length = 0; Dwarf_Ptr fde_bytes; Dwarf_Unsigned fde_byte_length = 0; Dwarf_Off cie_offset = 0; Dwarf_Signed cie_index = 0; Dwarf_Off fde_offset = 0; Dwarf_Addr arbitrary_addr = 0; Dwarf_Addr actual_pc = 0; Dwarf_Regtable3 tab3; int oldrulecount = 0; Dwarf_Ptr outinstrs = 0; Dwarf_Unsigned instrslen = 0; Dwarf_Frame_Op * frame_op_list = 0; Dwarf_Signed frame_op_count = 0; Dwarf_Cie cie = 0; res = dwarf_get_fde_range(fde,&lowpc,&func_length,&fde_bytes, &fde_byte_length,&cie_offset,&cie_index,&fde_offset,error); if(res != DW_DLV_OK) { printf("Problem getting fde range \n"); exit(1); } arbitrary_addr = lowpc + (func_length/2); printf("function low pc 0x%" DW_PR_DUx " and length 0x%" DW_PR_DUx " and addr we choose 0x%" DW_PR_DUx "\n", lowpc,func_length,arbitrary_addr); /* 1 is arbitrary. We are winding up getting the rule count here while leaving things unchanged. */ oldrulecount = dwarf_set_frame_rule_table_size(dbg,1); dwarf_set_frame_rule_table_size(dbg,oldrulecount); tab3.rt3_reg_table_size = oldrulecount; tab3.rt3_rules = (struct Dwarf_Regtable_Entry3_s *) malloc( sizeof(struct Dwarf_Regtable_Entry3_s)* oldrulecount); if (!tab3.rt3_rules) { printf("Unable to malloc for %d rules\n",oldrulecount); exit(1); } res = dwarf_get_fde_info_for_all_regs3(fde,arbitrary_addr , &tab3,&actual_pc,error); if(res != DW_DLV_OK) { printf("dwarf_get_fde_info_for_all_regs3 failed!\n"); exit(1); } print_regtable(fde,&tab3,oldrulecount,dbg,error); res = dwarf_get_fde_instr_bytes(fde,&outinstrs,&instrslen,error); if(res != DW_DLV_OK) { printf("dwarf_get_fde_instr_bytes failed!\n"); exit(1); } res = dwarf_get_cie_of_fde(fde,&cie,error); if(res != DW_DLV_OK) { printf("Error getting cie from fde\n"); exit(1); } res = dwarf_expand_frame_instructions(cie, outinstrs,instrslen,&frame_op_list, &frame_op_count,error); if(res != DW_DLV_OK) { printf("dwarf_expand_frame_instructions failed!\n"); exit(1); } printf("Frame op count: %" DW_PR_DUu "\n",frame_op_count); print_frame_instrs(dbg,frame_op_list,frame_op_count); dwarf_dealloc(dbg,frame_op_list, DW_DLA_FRAME_BLOCK); free(tab3.rt3_rules); } static void print_reg(int r) { switch(r) { case SAME_VAL: printf(" %d SAME_VAL ",r); break; case UNDEF_VAL: printf(" %d UNDEF_VAL ",r); break; case CFA_VAL: printf(" %d (CFA) ",r); break; default: printf(" r%d ",r); break; } } static void print_one_regentry(const char *prefix,Dwarf_Fde fde,Dwarf_Debug dbg, int oldrulecount,struct Dwarf_Regtable_Entry3_s *entry, Dwarf_Error * error) { int is_cfa = !strcmp("cfa",prefix); printf("%s ",prefix); printf("type: %d %s ", entry->dw_value_type, (entry->dw_value_type == DW_EXPR_OFFSET)? "DW_EXPR_OFFSET": (entry->dw_value_type == DW_EXPR_VAL_OFFSET)? "DW_EXPR_VAL_OFFSET": (entry->dw_value_type == DW_EXPR_EXPRESSION)? "DW_EXPR_EXPRESSION": (entry->dw_value_type == DW_EXPR_VAL_EXPRESSION)? "DW_EXPR_VAL_EXPRESSION": "Unknown"); switch(entry->dw_value_type) { case DW_EXPR_OFFSET: print_reg(entry->dw_regnum); printf(" offset_rel? %d ",entry->dw_offset_relevant); if(entry->dw_offset_relevant) { printf(" offset %" DW_PR_DSd " " , entry->dw_offset_or_block_len); if(is_cfa) { printf("defines cfa value"); } else { printf("address of value is CFA plus signed offset"); } if(!is_cfa && entry->dw_regnum != CFA_VAL) { printf(" compiler botch, regnum != CFA_VAL"); } } else { printf("value in register"); } break; case DW_EXPR_VAL_OFFSET: print_reg(entry->dw_regnum); printf(" offset %" DW_PR_DSd " " , entry->dw_offset_or_block_len); if(is_cfa) { printf("does this make sense? No?"); } else { printf("value at CFA plus signed offset"); } if(!is_cfa && entry->dw_regnum != CFA_VAL) { printf(" compiler botch, regnum != CFA_VAL"); } break; case DW_EXPR_EXPRESSION: print_reg(entry->dw_regnum); printf(" offset_rel? %d ",entry->dw_offset_relevant); printf(" offset %" DW_PR_DSd " " , entry->dw_offset_or_block_len); printf("Block ptr set? %s ",entry->dw_block_ptr?"yes":"no"); printf(" Value is at address given by expr val "); /* printf(" block-ptr 0x%" DW_PR_DUx " ", (Dwarf_Unsigned)entry->dw_block_ptr); */ break; case DW_EXPR_VAL_EXPRESSION: printf(" expression byte len %" DW_PR_DSd " " , entry->dw_offset_or_block_len); printf("Block ptr set? %s ",entry->dw_block_ptr?"yes":"no"); printf(" Value is expr val "); if(!entry->dw_block_ptr) { printf("Compiler botch. "); } /* printf(" block-ptr 0x%" DW_PR_DUx " ", (Dwarf_Unsigned)entry->dw_block_ptr); */ break; } printf("\n"); } static void print_regtable(Dwarf_Fde fde,Dwarf_Regtable3 *tab3,int oldrulecount, Dwarf_Debug dbg,Dwarf_Error *error) { int r; /* We won't print too much. A bit arbitrary. */ int max = 10; if(max > tab3->rt3_reg_table_size) { max = tab3->rt3_reg_table_size; } print_one_regentry("cfa",fde,dbg,oldrulecount,&tab3->rt3_cfa_rule, error); for(r = 0; r < max; r++) { char rn[30]; snprintf(rn,sizeof(rn),"reg %d",r); print_one_regentry(rn, fde,dbg,oldrulecount,tab3->rt3_rules+r, error); } } dwarf-20120410/dwarfexample/simplereader.c0000640000175000017500000002645611741100175017277 0ustar daveadavea/* Copyright (c) 2009-2010 David Anderson. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the example nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY David Anderson ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL David Anderson BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* simplereader.c This is an example of code reading dwarf .debug_info. It is kept as simple as possible to expose essential features. It does not do all possible error reporting or error handling. The --names option adds some extra printing. To use, try make ./simplereader simplereader */ #include /* For open() */ #include /* For open() */ #include /* For open() */ #include /* For exit() */ #include /* For close() */ #include #include #include #include "dwarf.h" #include "libdwarf.h" struct srcfilesdata { char ** srcfiles; Dwarf_Signed srcfilescount; int srcfilesres; }; static void read_cu_list(Dwarf_Debug dbg); static void print_die_data(Dwarf_Debug dbg, Dwarf_Die print_me,int level, struct srcfilesdata *sf); static void get_die_and_siblings(Dwarf_Debug dbg, Dwarf_Die in_die,int in_level, struct srcfilesdata *sf); static void resetsrcfiles(Dwarf_Debug dbg,struct srcfilesdata *sf); static int namesoptionon = 0; int main(int argc, char **argv) { Dwarf_Debug dbg = 0; int fd = -1; const char *filepath = ""; int res = DW_DLV_ERROR; Dwarf_Error error; Dwarf_Handler errhand = 0; Dwarf_Ptr errarg = 0; if(argc < 2) { fd = 0; /* stdin */ } else { int i = 0; for(i = 1; i < (argc-1) ; ++i) { if(strcmp(argv[i],"--names") == 0) { namesoptionon=1; } else { printf("Unknown argument \"%s\" ignored\n",argv[i]); } } filepath = argv[i]; fd = open(filepath,O_RDONLY); } if(argc > 2) { } if(fd < 0) { printf("Failure attempting to open \"%s\"\n",filepath); } res = dwarf_init(fd,DW_DLC_READ,errhand,errarg, &dbg,&error); if(res != DW_DLV_OK) { printf("Giving up, cannot do DWARF processing\n"); exit(1); } read_cu_list(dbg); res = dwarf_finish(dbg,&error); if(res != DW_DLV_OK) { printf("dwarf_finish failed!\n"); } close(fd); return 0; } static void read_cu_list(Dwarf_Debug dbg) { Dwarf_Unsigned cu_header_length = 0; Dwarf_Half version_stamp = 0; Dwarf_Unsigned abbrev_offset = 0; Dwarf_Half address_size = 0; Dwarf_Unsigned next_cu_header = 0; Dwarf_Error error; int cu_number = 0; for(;;++cu_number) { struct srcfilesdata sf; sf.srcfilesres = DW_DLV_ERROR; sf.srcfiles = 0; sf.srcfilescount = 0; Dwarf_Die no_die = 0; Dwarf_Die cu_die = 0; int res = DW_DLV_ERROR; res = dwarf_next_cu_header(dbg,&cu_header_length, &version_stamp, &abbrev_offset, &address_size, &next_cu_header, &error); if(res == DW_DLV_ERROR) { printf("Error in dwarf_next_cu_header\n"); exit(1); } if(res == DW_DLV_NO_ENTRY) { /* Done. */ return; } /* The CU will have a single sibling, a cu_die. */ res = dwarf_siblingof(dbg,no_die,&cu_die,&error); if(res == DW_DLV_ERROR) { printf("Error in dwarf_siblingof on CU die \n"); exit(1); } if(res == DW_DLV_NO_ENTRY) { /* Impossible case. */ printf("no entry! in dwarf_siblingof on CU die \n"); exit(1); } get_die_and_siblings(dbg,cu_die,0,&sf); dwarf_dealloc(dbg,cu_die,DW_DLA_DIE); resetsrcfiles(dbg,&sf); } } static void get_die_and_siblings(Dwarf_Debug dbg, Dwarf_Die in_die,int in_level, struct srcfilesdata *sf) { int res = DW_DLV_ERROR; Dwarf_Die cur_die=in_die; Dwarf_Die child = 0; Dwarf_Error error; print_die_data(dbg,in_die,in_level,sf); for(;;) { Dwarf_Die sib_die = 0; res = dwarf_child(cur_die,&child,&error); if(res == DW_DLV_ERROR) { printf("Error in dwarf_child , level %d \n",in_level); exit(1); } if(res == DW_DLV_OK) { get_die_and_siblings(dbg,child,in_level+1,sf); } /* res == DW_DLV_NO_ENTRY */ res = dwarf_siblingof(dbg,cur_die,&sib_die,&error); if(res == DW_DLV_ERROR) { printf("Error in dwarf_siblingof , level %d \n",in_level); exit(1); } if(res == DW_DLV_NO_ENTRY) { /* Done at this level. */ break; } /* res == DW_DLV_OK */ if(cur_die != in_die) { dwarf_dealloc(dbg,cur_die,DW_DLA_DIE); } cur_die = sib_die; print_die_data(dbg,cur_die,in_level,sf); } return; } static void get_addr(Dwarf_Attribute attr,Dwarf_Addr *val) { Dwarf_Error error = 0; int res; Dwarf_Addr uval = 0; res = dwarf_formaddr(attr,&uval,&error); if(res == DW_DLV_OK) { *val = uval; return; } return; } static void get_number(Dwarf_Attribute attr,Dwarf_Unsigned *val) { Dwarf_Error error = 0; int res; Dwarf_Signed sval = 0; Dwarf_Unsigned uval = 0; res = dwarf_formudata(attr,&uval,&error); if(res == DW_DLV_OK) { *val = uval; return; } res = dwarf_formsdata(attr,&sval,&error); if(res == DW_DLV_OK) { *val = sval; return; } return; } static void print_subprog(Dwarf_Debug dbg,Dwarf_Die die, int level, struct srcfilesdata *sf) { int res; Dwarf_Error error = 0; Dwarf_Attribute *attrbuf = 0; Dwarf_Addr lowpc = 0; Dwarf_Addr highpc = 0; Dwarf_Signed attrcount = 0; Dwarf_Unsigned i; Dwarf_Unsigned filenum = 0; Dwarf_Unsigned linenum = 0; char *filename = 0; res = dwarf_attrlist(die,&attrbuf,&attrcount,&error); if(res != DW_DLV_OK) { return; } for(i = 0; i < attrcount ; ++i) { Dwarf_Half aform; res = dwarf_whatattr(attrbuf[i],&aform,&error); if(res == DW_DLV_OK) { if(aform == DW_AT_decl_file) { get_number(attrbuf[i],&filenum); if((filenum > 0) && (sf->srcfilescount > (filenum-1))) { filename = sf->srcfiles[filenum-1]; } } if(aform == DW_AT_decl_line) { get_number(attrbuf[i],&linenum); } if(aform == DW_AT_low_pc) { get_addr(attrbuf[i],&lowpc); } if(aform == DW_AT_high_pc) { get_addr(attrbuf[i],&highpc); } } dwarf_dealloc(dbg,attrbuf[i],DW_DLA_ATTR); } if(filenum || linenum) { printf("<%3d> file: %" DW_PR_DUu " %s line %" DW_PR_DUu "\n",level,filenum,filename?filename:"",linenum); } if(lowpc) { printf("<%3d> low_pc : 0x%" DW_PR_DUx "\n", level, (Dwarf_Unsigned)lowpc); } if(highpc) { printf("<%3d> high_pc: 0x%" DW_PR_DUx "\n", level, (Dwarf_Unsigned)highpc); } dwarf_dealloc(dbg,attrbuf,DW_DLA_LIST); } static void print_comp_dir(Dwarf_Debug dbg,Dwarf_Die die,int level, struct srcfilesdata *sf) { int res; Dwarf_Error error = 0; Dwarf_Attribute *attrbuf = 0; Dwarf_Signed attrcount = 0; Dwarf_Unsigned i; res = dwarf_attrlist(die,&attrbuf,&attrcount,&error); if(res != DW_DLV_OK) { return; } sf->srcfilesres = dwarf_srcfiles(die,&sf->srcfiles,&sf->srcfilescount, &error); for(i = 0; i < attrcount ; ++i) { Dwarf_Half aform; res = dwarf_whatattr(attrbuf[i],&aform,&error); if(res == DW_DLV_OK) { if(aform == DW_AT_comp_dir) { char *name = 0; res = dwarf_formstring(attrbuf[i],&name,&error); if(res == DW_DLV_OK) { printf( "<%3d> compilation directory : \"%s\"\n", level,name); } } if(aform == DW_AT_stmt_list) { /* Offset of stmt list for this CU in .debug_line */ } } dwarf_dealloc(dbg,attrbuf[i],DW_DLA_ATTR); } dwarf_dealloc(dbg,attrbuf,DW_DLA_LIST); } static void resetsrcfiles(Dwarf_Debug dbg,struct srcfilesdata *sf) { Dwarf_Signed sri = 0; for (sri = 0; sri < sf->srcfilescount; ++sri) { dwarf_dealloc(dbg, sf->srcfiles[sri], DW_DLA_STRING); } dwarf_dealloc(dbg, sf->srcfiles, DW_DLA_LIST); sf->srcfilesres = DW_DLV_ERROR; sf->srcfiles = 0; sf->srcfilescount = 0; } static void print_die_data(Dwarf_Debug dbg, Dwarf_Die print_me,int level, struct srcfilesdata *sf) { char *name = 0; Dwarf_Error error = 0; Dwarf_Half tag = 0; const char *tagname = 0; int localname = 0; int res = dwarf_diename(print_me,&name,&error); if(res == DW_DLV_ERROR) { printf("Error in dwarf_diename , level %d \n",level); exit(1); } if(res == DW_DLV_NO_ENTRY) { name = ""; localname = 1; } res = dwarf_tag(print_me,&tag,&error); if(res != DW_DLV_OK) { printf("Error in dwarf_tag , level %d \n",level); exit(1); } res = dwarf_get_TAG_name(tag,&tagname); if(res != DW_DLV_OK) { printf("Error in dwarf_get_TAG_name , level %d \n",level); exit(1); } if(namesoptionon) { if( tag == DW_TAG_subprogram) { printf( "<%3d> subprogram : \"%s\"\n",level,name); print_subprog(dbg,print_me,level,sf); } else if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit || tag == DW_TAG_type_unit) { resetsrcfiles(dbg,sf); printf( "<%3d> source file : \"%s\"\n",level,name); print_comp_dir(dbg,print_me,level,sf); } } else { printf("<%d> tag: %d %s name: \"%s\"\n",level,tag,tagname,name); } if(!localname) { dwarf_dealloc(dbg,name,DW_DLA_STRING); } } dwarf-20120410/dwarfexample/ChangeLog0000640000175000017500000000036511741100175016220 0ustar daveadavea2011-06-04 DavidAnderson * frame1.c, simplereader.c: Altered indentation to multiples of 4 spaces, no tabs. No substantive change. 2011-01-13 DavidAnderson * New year starts. dwarf-20120410/dwarfexample/NEWS0000640000175000017500000000040711741100175015142 0ustar daveadaveaJuly 21, 2009 Roni Simonian noticed a call to print_die_data(dbg,cur_die,in_level); was missing so not all DIEs would print. Good Catch! July 8, 2009 Created a sample libdwarf consumer. Using BSD license so anyone can use it. And a trivial Makefile. dwarf-20120410/dwarfgen/0000750000175000017500000000000011741100175013557 5ustar daveadaveadwarf-20120410/dwarfgen/createirepformfrombinary.cc0000640000175000017500000002362011741100175021172 0ustar daveadavea/* Copyright (C) 2010-2011 David Anderson. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. */ // createirepfrombinary.cc // Reads an object and inserts its dwarf data into // an object intended to hold all the dwarf data. #include "config.h" #include #include // for exit #include #include #include #include #include // For memset etc #include //open #include //open #include "elf.h" #include "gelf.h" #include "strtabdata.h" #include "dwarf.h" #include "libdwarf.h" #include "irepresentation.h" #include "createirepfrombinary.h" using std::string; using std::cout; using std::cerr; using std::endl; using std::vector; using std::list; // THis should instantiated only locally, not with 'new'. // It should not bt copied. class IRFormInterface { public: IRFormInterface(Dwarf_Debug dbg, Dwarf_Attribute attr,IRCUdata &cudata,IRAttr & irattr): dbg_(dbg),attr_(attr),cudata_(cudata),irattr_(irattr) {}; // Do not free anything we did not create here. ~IRFormInterface() {}; Dwarf_Debug dbg_; Dwarf_Attribute attr_; IRCUdata &cudata_; IRAttr &irattr_; private: // Do not instantiate. IRFormInterface(); IRFormInterface& operator= (const IRFormInterface &ir); }; IRForm *formFactory(Dwarf_Debug dbg, Dwarf_Attribute attr,IRCUdata &cudata,IRAttr & irattr) { Dwarf_Error err = 0; IRFormInterface interface(dbg,attr,cudata,irattr); enum Dwarf_Form_Class cl = irattr.getFormClass(); switch(cl) { case DW_FORM_CLASS_UNKNOWN: break; case DW_FORM_CLASS_ADDRESS: { IRFormAddress *f = new IRFormAddress(&interface); // FIXME: do we need to do anything about the symbol here? return f; } break; case DW_FORM_CLASS_BLOCK: { IRFormBlock *f = new IRFormBlock(&interface); //FIXME return f; } break; case DW_FORM_CLASS_CONSTANT: { IRFormConstant *f = new IRFormConstant(&interface); //FIXME return f; } break; case DW_FORM_CLASS_EXPRLOC: { IRFormExprloc *f = new IRFormExprloc(&interface); //FIXME return f; } break; case DW_FORM_CLASS_FLAG: { IRFormFlag *f = new IRFormFlag(&interface); //FIXME return f; } break; case DW_FORM_CLASS_LINEPTR: { IRFormLinePtr *f = new IRFormLinePtr(&interface); //FIXME return f; } break; case DW_FORM_CLASS_LOCLISTPTR: { IRFormLoclistPtr *f = new IRFormLoclistPtr(&interface); //FIXME return f; } break; case DW_FORM_CLASS_MACPTR: { IRFormMacPtr *f = new IRFormMacPtr(&interface); //FIXME return f; } break; case DW_FORM_CLASS_RANGELISTPTR: { IRFormRangelistPtr *f = new IRFormRangelistPtr(&interface); //FIXME return f; } break; case DW_FORM_CLASS_REFERENCE: { IRFormReference *f = new IRFormReference(&interface); //FIXME return f; } break; case DW_FORM_CLASS_STRING: { IRFormString *f = new IRFormString(&interface); return f; } break; case DW_FORM_CLASS_FRAMEPTR: /* SGI/IRIX extension. */ { IRFormFramePtr *f = new IRFormFramePtr(&interface); //FIXME return f; } break; default: break; } return new IRFormUnknown(); } IRFormAddress::IRFormAddress(IRFormInterface * interface) { Dwarf_Addr val = 0; Dwarf_Error error = 0; int res = dwarf_formaddr(interface->attr_,&val, &error); if(res != DW_DLV_OK) { cerr << "Unable to read flag value. Impossible error.\n" << endl; exit(1); } // FIXME do we need to do anything about the symbol here? address_ = val; } IRFormBlock::IRFormBlock(IRFormInterface * interface) { Dwarf_Block *blockptr = 0; Dwarf_Error error = 0; int res = dwarf_formblock(interface->attr_,&blockptr, &error); if(res != DW_DLV_OK) { cerr << "Unable to read flag value. Impossible error.\n" << endl; exit(1); } insertBlock(blockptr); dwarf_dealloc(interface->dbg_,blockptr,DW_DLA_BLOCK); } IRFormConstant::IRFormConstant(IRFormInterface * interface) { enum Signedness oursign = SIGN_NOT_SET; Dwarf_Unsigned uval = 0; Dwarf_Signed sval = 0; Dwarf_Error error = 0; int ress = dwarf_formsdata(interface->attr_, &sval,&error); int resu = dwarf_formudata(interface->attr_, &uval,&error); if(resu == DW_DLV_OK ) { if(ress == DW_DLV_OK) { oursign = SIGN_UNKNOWN; } else { oursign = UNSIGNED; sval = static_cast(uval); } } else { if(ress == DW_DLV_OK) { oursign = SIGNED; uval = static_cast(sval); } else { cerr << "Unable to read constant value. Impossible error.\n" << endl; exit(1); } } setValues(sval, uval, oursign); } IRFormExprloc::IRFormExprloc(IRFormInterface * interface) { Dwarf_Unsigned len = 0; Dwarf_Ptr data = 0; Dwarf_Error error = 0; int res = dwarf_formexprloc(interface->attr_,&len, &data, &error); if(res != DW_DLV_OK) { cerr << "Unable to read flag value. Impossible error.\n" << endl; exit(1); } insertBlock(len,data); } IRFormFlag::IRFormFlag(IRFormInterface * interface) { Dwarf_Bool flagval = 0; Dwarf_Error error = 0; int res = dwarf_formflag(interface->attr_,&flagval, &error); if(res != DW_DLV_OK) { cerr << "Unable to read flag value. Impossible error.\n" << endl; exit(1); } } // We are simply assuming (here) that the value is a global offset // to some section or other. // Calling code ensures that is true. // static Dwarf_Unsigned get_section_offset(IRFormInterface * interface) { Dwarf_Unsigned uval = 0; Dwarf_Signed sval = 0; Dwarf_Error error = 0; Dwarf_Off sectionoffset = 0; int resu = 0; // The following allows more sorts of value than // we really want to allow here, but that is // harmless, we believe. int resgf = dwarf_global_formref(interface->attr_, §ionoffset, &error); if(resgf == DW_DLV_OK ) { return sectionoffset; } resu = dwarf_formudata(interface->attr_, &uval,&error); if(resu != DW_DLV_OK ) { int ress = dwarf_formsdata(interface->attr_, &sval,&error); if(ress == DW_DLV_OK) { uval = static_cast(sval); } else { cerr << "Unable to read constant offset value. Impossible error.\n" << endl; exit(1); } } return uval; } IRFormLoclistPtr::IRFormLoclistPtr(IRFormInterface * interface) { Dwarf_Unsigned uval = get_section_offset(interface); setOffset(uval); } IRFormLinePtr::IRFormLinePtr(IRFormInterface * interface) { Dwarf_Unsigned uval = get_section_offset(interface); setOffset(uval); } IRFormMacPtr::IRFormMacPtr(IRFormInterface * interface) { Dwarf_Unsigned uval = get_section_offset(interface); setOffset(uval); } IRFormRangelistPtr::IRFormRangelistPtr(IRFormInterface * interface) { Dwarf_Unsigned uval = get_section_offset(interface); setOffset(uval); } IRFormFramePtr::IRFormFramePtr(IRFormInterface * interface) { Dwarf_Unsigned uval = get_section_offset(interface); setOffset(uval); } // This is a .debug_info to .debug_info (or .debug_types to .debug_types) // reference. IRFormReference::IRFormReference(IRFormInterface * interface) { Dwarf_Off val = 0; Dwarf_Error error = 0; Dwarf_Half form = interface->irattr_.getFinalForm(); if(form == DW_FORM_ref_sig8) { Dwarf_Sig8 val8; int res = dwarf_formsig8(interface->attr_,&val8, &error); if(res != DW_DLV_OK) { cerr << "Unable to read sig8 reference. Impossible error.\n" << endl; exit(1); } setSignature(&val8); return; } if(form == DW_FORM_ref_addr) { int res = dwarf_global_formref(interface->attr_,&val, &error); if(res != DW_DLV_OK) { cerr << "Unable to read reference. Impossible error.\n" << endl; exit(1); } setOffset(val); return; } // Otherwise it is (if a correct FORM for a .debug_info reference) // a local CU offset, and we record it as such.. int res = dwarf_formref(interface->attr_,&val, &error); if(res != DW_DLV_OK) { cerr << "Unable to read reference. Impossible error.\n" << endl; exit(1); } setCUOffset(val); } // Global static data used to initialized a sig8 reliably. static Dwarf_Sig8 zero_sig8; // Initialization helper function. void IRFormReference::initSig8() { typeSig8_ = zero_sig8; } IRFormString::IRFormString(IRFormInterface * interface) { char *str = 0; Dwarf_Error error = 0; int res = dwarf_formstring(interface->attr_,&str, &error); if(res != DW_DLV_OK) { cerr << "Unable to read string. Impossible error.\n" << endl; exit(1); } setString(str); } dwarf-20120410/dwarfgen/dwarfgen.10000640000175000017500000000035711741100175015444 0ustar daveadavea.TH DWARFGEN .SH NAME dwarfgen \- Generate example DWARF data. .SH SYNOPSIS .B dwarfgen .SH DESCRIPTION The .B dwarfgen command creates DWARF sections as requested by specific options. The command is under development as of January 2010. dwarf-20120410/dwarfgen/install.sh0000750000175000017500000000421211741100175015563 0ustar daveadavea#!/bin/sh # # install - install a program, script, or datafile # This comes from X11R5; it is not part of GNU. # # $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $ # # This script is compatible with the BSD install script, but was written # from scratch. # # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" instcmd="$mvprog" chmodcmd="" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; *) if [ x"$src" = x ] then src=$1 else dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` fi # Make a temp file name in the proper directory. dstdir=`dirname $dst` dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp # and set any options; do chmod last to preserve setuid bits if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi # Now rename the file to the real destination. $doit $rmcmd $dst $doit $mvcmd $dsttmp $dst exit 0 dwarf-20120410/dwarfgen/configure0000750000175000017500000046047111741100175015502 0ustar daveadavea#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.68. # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software # Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME= PACKAGE_TARNAME= PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= PACKAGE_URL= ac_unique_file="dwarfgen.cc" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='LTLIBOBJS LIBOBJS AR RANLIB INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM EGREP GREP CPP ac_ct_CXX CXXFLAGS CXX OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CXX CXXFLAGS CCC CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures this package to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF _ACEOF fi if test -n "$ac_init_help"; then cat <<\_ACEOF Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CXX C++ compiler command CXXFLAGS C++ compiler flags CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF configure generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers config.h" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h ;; #( no) ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) as_fn_error $? "unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac if test $ac_cv_c_compiler_gnu = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5 $as_echo_n "checking whether $CC needs -traditional... " >&6; } if ${ac_cv_prog_gcc_traditional+:} false; then : $as_echo_n "(cached) " >&6 else ac_pattern="Autoconf.*'x'" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include Autoconf TIOCGETP _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "$ac_pattern" >/dev/null 2>&1; then : ac_cv_prog_gcc_traditional=yes else ac_cv_prog_gcc_traditional=no fi rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include Autoconf TCGETA _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "$ac_pattern" >/dev/null 2>&1; then : ac_cv_prog_gcc_traditional=yes fi rm -f conftest* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_gcc_traditional" >&5 $as_echo "$ac_cv_prog_gcc_traditional" >&6; } if test $ac_cv_prog_gcc_traditional = yes; then CC="$CC -traditional" fi fi ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AR="${ac_tool_prefix}ar" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_AR"; then ac_ct_AR=$AR # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_AR="ar" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_AR" = x; then AR="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi else AR="$ac_cv_prog_AR" fi for ac_header in elf.h getopt.h libelf.h sgidefs.h sys/types.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { __uint32_t p; p = 27; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define HAVE___UINT32_T_IN_SGIDEFS_H 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { __uint64_t p; p = 27; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define HAVE___UINT64_T_IN_SGIDEFS_H 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { __uint64_t p; p = 27; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define HAVE___UINT64_T_IN_SGIDEFS_H 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { __uint32_t p; p = 27; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define HAVE___UINT32_T_IN_SGIDEFS_H 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { intptr_t p; p = 27; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define HAVE_INTPTR_T 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { __uint64_t p; p = 27; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define HAVE___UINT64_T_IN_SGIDEFS_H 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { __uint64_t p; p = 27; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define HAVE___UINT64_T_IN_SGIDEFS_H 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by $as_me, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ config.status configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi dwarf-20120410/dwarfgen/irepattrtodbg.cc0000640000175000017500000001463311741100175016750 0ustar daveadavea/* Copyright (C) 2010-2011 David Anderson. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. */ // irepattrtodbg.cc #include "config.h" #include #include // for exit #include #include // For BldName #include // iomanp for setw etc #include #include #include #include // For memset etc #include //open #include //open #include "general.h" #include "elf.h" #include "gelf.h" #include "strtabdata.h" #include "dwarf.h" #include "libdwarf.h" #include "irepresentation.h" #include "ireptodbg.h" #include "irepattrtodbg.h" #ifdef HAVE_INTPTR_T #include typedef intptr_t myintfromp; // intptr_t is from C99. #else // We want an integer that is big enough for a pointer so the // pointer return value from the libdwarf producer can be // tested for -1. Ugly overloading of integer and pointer in libdwarf. // We just hope it will compile for you. typedef long myintfromp; #endif using std::string; using std::cout; using std::cerr; using std::endl; using std::vector; using std::list; static Dwarf_Error error; static unsigned fakeaddrnum; // We are not going to 'validate' the FORM for this Attribute. // or this Die. We just assume that what we are handed is // what we are to produce. We do test the attribute // at times, partly to ensure we use as many of the dwarf_add_AT* // functions as possible. // Correctness/appropriateness must be evaluated elsewhere. void AddAttrToDie(Dwarf_P_Debug dbg, IRepresentation & Irep, Dwarf_P_Die outdie,IRDie & irdie,IRAttr &irattr) { int attrnum = irattr.getAttrNum(); enum Dwarf_Form_Class formclass = irattr.getFormClass(); // IRForm is an abstract base class. IRForm *form = irattr.getFormData(); switch(formclass) { case DW_FORM_CLASS_UNKNOWN: cerr << "ERROR Impossible DW_FORM_CLASS_UNKNOWN, attrnum " <(form); if (!f) { cerr << "ERROR Impossible DW_FORM_CLASS_ADDRESS cast fails, attrnum " <getAddress(); string symname = BldName("addrsym",fakeaddrnum++); Dwarf_Addr pcval = addr; ElfSymbols& es = Irep.getElfSymbols(); ElfSymIndex esi = es.addElfSymbol(pcval,symname); Dwarf_Unsigned sym_index = esi.getSymIndex(); // FIXME: we should allow for DW_FORM_indirect here. // Relocation later will fix value. Dwarf_P_Attribute a = dwarf_add_AT_targ_address(dbg, outdie,attrnum,0,sym_index,&error); if( reinterpret_cast(a) == DW_DLV_BADADDR) { cerr << "ERROR dwarf_add_AT_targ_address fails, attrnum " <(form); if (!f) { cerr << "ERROR Impossible DW_FORM_CLASS_FLAG cast fails, attrnum " <getFlagVal(),&error); if( reinterpret_cast(a) == DW_DLV_BADADDR) { cerr << "ERROR dwarf_add_AT_flag fails, attrnum " <(form); if (!f) { cerr << "ERROR Impossible DW_FORM_CLASS_STRING cast fails, attrnum " <(f->getString().c_str()); switch(attrnum) { case DW_AT_name: a = dwarf_add_AT_name(outdie,mystr,&error); break; case DW_AT_producer: a = dwarf_add_AT_producer(outdie,mystr,&error); break; case DW_AT_comp_dir: a = dwarf_add_AT_comp_dir(outdie,mystr,&error); break; default: a = dwarf_add_AT_string(dbg,outdie,attrnum,mystr, &error); break; } if( reinterpret_cast(a) == DW_DLV_BADADDR) { cerr << "ERROR dwarf_add_AT_string fails, attrnum " <(formclass) < blockdata_; Dwarf_Small fromloclist_; Dwarf_Unsigned sectionoffset_; void insertBlock(Dwarf_Block *bl) { char *d = static_cast(bl->bl_data); Dwarf_Unsigned len = bl->bl_len; blockdata_.clear(); blockdata_.insert(blockdata_.end(),d+0,d+len); fromloclist_ = bl->bl_from_loclist; sectionoffset_ = bl->bl_section_offset; }; }; class IRFormConstant : public IRForm { public: IRFormConstant(): directform_(0), indirectform_(0), formclass_(DW_FORM_CLASS_CONSTANT), signedness_(SIGN_NOT_SET), uval_(0), sval_(0) {} IRFormConstant(IRFormInterface *); ~IRFormConstant() {}; IRFormConstant & operator=(const IRFormConstant &r) { if(this == &r) return *this; directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; signedness_ = r.signedness_; uval_ = r.uval_; sval_ = r.sval_; }; IRFormConstant(const IRFormConstant &r) { directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; signedness_ = r.signedness_; uval_ = r.uval_; sval_ = r.sval_; } virtual IRFormConstant * clone() const { return new IRFormConstant(*this); } enum Dwarf_Form_Class getFormClass() const { return formclass_; }; private: Dwarf_Half directform_; // In most cases directform == indirect form. // Otherwise, directform == DW_FORM_indirect. Dwarf_Half indirectform_; enum Dwarf_Form_Class formclass_; // Starts at SIGN_NOT_SET. // SIGN_UNKNOWN means it was a DW_FORM_data* of some // kind so we do not really know. enum Signedness {SIGN_NOT_SET,SIGN_UNKNOWN,UNSIGNED, SIGNED }; enum Signedness signedness_; // Both uval_ and sval_ are always set to the same bits. Dwarf_Unsigned uval_; Dwarf_Signed sval_; void setValues(Dwarf_Signed sval, Dwarf_Unsigned uval, enum Signedness s) { signedness_ = s; uval_ = uval; sval_ = sval; } }; class IRFormExprloc : public IRForm { public: IRFormExprloc(): directform_(0), indirectform_(0), formclass_(DW_FORM_CLASS_EXPRLOC) {}; IRFormExprloc(IRFormInterface *); ~IRFormExprloc() {}; IRFormExprloc & operator=(const IRFormExprloc &r) { if(this == &r) return *this; directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; exprlocdata_ = r.exprlocdata_; }; IRFormExprloc(const IRFormExprloc &r) { directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; exprlocdata_ = r.exprlocdata_; } virtual IRFormExprloc * clone() const { return new IRFormExprloc(*this); } enum Dwarf_Form_Class getFormClass() const { return formclass_; }; private: Dwarf_Half directform_; // In most cases directform == indirect form. // Otherwise, directform == DW_FORM_indirect. Dwarf_Half indirectform_; enum Dwarf_Form_Class formclass_; std::vector exprlocdata_; void insertBlock(Dwarf_Unsigned len, Dwarf_Ptr data) { char *d = static_cast(data); exprlocdata_.clear(); exprlocdata_.insert(exprlocdata_.end(),d+0,d+len); }; }; class IRFormFlag : public IRForm { public: IRFormFlag(): directform_(0), indirectform_(0), formclass_(DW_FORM_CLASS_FLAG), flagval_(0) {}; IRFormFlag(IRFormInterface*); ~IRFormFlag() {}; IRFormFlag & operator=(const IRFormFlag &r) { if(this == &r) return *this; directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; flagval_ = r.flagval_; }; IRFormFlag(const IRFormFlag &r) { directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; flagval_ = r.flagval_; } virtual IRFormFlag * clone() const { return new IRFormFlag(*this); } enum Dwarf_Form_Class getFormClass() const { return formclass_; }; Dwarf_Bool getFlagVal() { return flagval_; } private: Dwarf_Half directform_; // In most cases directform == indirect form. // Otherwise, directform == DW_FORM_indirect. Dwarf_Half indirectform_; enum Dwarf_Form_Class formclass_; Dwarf_Bool flagval_; }; class IRFormLinePtr : public IRForm { public: IRFormLinePtr(): directform_(0), indirectform_(0), formclass_(DW_FORM_CLASS_LINEPTR), debug_line_offset_(0) {}; IRFormLinePtr(IRFormInterface *); ~IRFormLinePtr() {}; IRFormLinePtr & operator=(const IRFormLinePtr &r) { if(this == &r) return *this; directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; debug_line_offset_ = r.debug_line_offset_; }; IRFormLinePtr(const IRFormLinePtr &r) { directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; debug_line_offset_ = r.debug_line_offset_; } virtual IRFormLinePtr * clone() const { return new IRFormLinePtr(*this); } enum Dwarf_Form_Class getFormClass() const { return formclass_; }; private: Dwarf_Half directform_; // In most cases directform == indirect form. // Otherwise, directform == DW_FORM_indirect. Dwarf_Half indirectform_; enum Dwarf_Form_Class formclass_; Dwarf_Off debug_line_offset_; void setOffset(Dwarf_Unsigned uval) { debug_line_offset_ = uval; }; }; class IRFormLoclistPtr : public IRForm { public: IRFormLoclistPtr(): directform_(0), indirectform_(0), formclass_(DW_FORM_CLASS_LOCLISTPTR), loclist_offset_(0) {}; IRFormLoclistPtr(IRFormInterface *); ~IRFormLoclistPtr() {}; IRFormLoclistPtr & operator=(const IRFormLoclistPtr &r) { if(this == &r) return *this; directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; loclist_offset_ = r.loclist_offset_; }; IRFormLoclistPtr(const IRFormLoclistPtr &r) { directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; loclist_offset_ = r.loclist_offset_; } virtual IRFormLoclistPtr * clone() const { return new IRFormLoclistPtr(*this); } enum Dwarf_Form_Class getFormClass() const { return formclass_; }; private: Dwarf_Half directform_; // In most cases directform == indirect form. // Otherwise, directform == DW_FORM_indirect. Dwarf_Half indirectform_; enum Dwarf_Form_Class formclass_; Dwarf_Off loclist_offset_; void setOffset(Dwarf_Unsigned uval) { loclist_offset_ = uval; }; }; class IRFormMacPtr : public IRForm { public: IRFormMacPtr(): directform_(0), indirectform_(0), formclass_(DW_FORM_CLASS_MACPTR), macro_offset_(0) {}; IRFormMacPtr(IRFormInterface *); ~IRFormMacPtr() {}; IRFormMacPtr & operator=(const IRFormMacPtr &r) { if(this == &r) return *this; directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; macro_offset_ = r.macro_offset_; }; IRFormMacPtr(const IRFormMacPtr &r) { directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; macro_offset_ = r.macro_offset_; } virtual IRFormMacPtr * clone() const { return new IRFormMacPtr(*this); } enum Dwarf_Form_Class getFormClass() const { return formclass_; }; private: Dwarf_Half directform_; // In most cases directform == indirect form. // Otherwise, directform == DW_FORM_indirect. Dwarf_Half indirectform_; enum Dwarf_Form_Class formclass_; Dwarf_Off macro_offset_; void setOffset(Dwarf_Unsigned uval) { macro_offset_ = uval; }; }; class IRFormRangelistPtr : public IRForm { public: IRFormRangelistPtr(): directform_(0), indirectform_(0), formclass_(DW_FORM_CLASS_RANGELISTPTR), rangelist_offset_(0) {}; IRFormRangelistPtr(IRFormInterface *); ~IRFormRangelistPtr() {}; IRFormRangelistPtr & operator=(const IRFormRangelistPtr &r) { if(this == &r) return *this; directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; rangelist_offset_ = r.rangelist_offset_; }; IRFormRangelistPtr(const IRFormRangelistPtr &r) { directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; rangelist_offset_ = r.rangelist_offset_; } virtual IRFormRangelistPtr * clone() const { return new IRFormRangelistPtr(*this); } enum Dwarf_Form_Class getFormClass() const { return formclass_; }; private: Dwarf_Half directform_; // In most cases directform == indirect form. // Otherwise, directform == DW_FORM_indirect. Dwarf_Half indirectform_; enum Dwarf_Form_Class formclass_; Dwarf_Off rangelist_offset_; void setOffset(Dwarf_Unsigned uval) { rangelist_offset_ = uval; }; }; class IRFormFramePtr : public IRForm { public: IRFormFramePtr(): directform_(0), indirectform_(0), formclass_(DW_FORM_CLASS_FRAMEPTR), frame_offset_(0) {}; IRFormFramePtr(IRFormInterface *); ~IRFormFramePtr() {}; IRFormFramePtr & operator=(const IRFormFramePtr &r) { if(this == &r) return *this; directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; frame_offset_ = r.frame_offset_; }; IRFormFramePtr(const IRFormFramePtr &r) { directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; frame_offset_ = r.frame_offset_; } virtual IRFormFramePtr * clone() const { return new IRFormFramePtr(*this); } enum Dwarf_Form_Class getFormClass() const { return formclass_; }; private: Dwarf_Half directform_; // In most cases directform == indirect form. // Otherwise, directform == DW_FORM_indirect. Dwarf_Half indirectform_; enum Dwarf_Form_Class formclass_; Dwarf_Off frame_offset_; void setOffset(Dwarf_Unsigned uval) { frame_offset_ = uval; }; }; class IRFormReference : public IRForm { public: IRFormReference(): directform_(0), indirectform_(0), formclass_(DW_FORM_CLASS_REFERENCE), reftype_(RT_NONE), globalOffset_(0),cuRelativeOffset_(0) {initSig8();}; IRFormReference(IRFormInterface *); ~IRFormReference() {}; IRFormReference & operator=(const IRFormReference &r) { if(this == &r) return *this; directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; reftype_ = r.reftype_; globalOffset_ = r.globalOffset_; cuRelativeOffset_ = r.cuRelativeOffset_; typeSig8_ = r.typeSig8_; }; IRFormReference(const IRFormReference &r) { directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; reftype_ = r.reftype_; globalOffset_ = r.globalOffset_; cuRelativeOffset_ = r.cuRelativeOffset_; typeSig8_ = r.typeSig8_; } virtual IRFormReference * clone() const { return new IRFormReference(*this); } void setOffset(Dwarf_Off off) { globalOffset_ = off; reftype_ = RT_GLOBAL;}; void setCUOffset(Dwarf_Off off) { cuRelativeOffset_= off; reftype_ = RT_CUREL;}; void setSignature(Dwarf_Sig8 * sig) { typeSig8_ = *sig; reftype_ = RT_SIG;}; enum Dwarf_Form_Class getFormClass() const { return formclass_; }; private: void initSig8(); Dwarf_Half directform_; // In most cases directform == indirect form. // Otherwise, directform == DW_FORM_indirect. Dwarf_Half indirectform_; enum Dwarf_Form_Class formclass_; enum RefType { RT_NONE,RT_GLOBAL, RT_CUREL,RT_SIG }; enum RefType reftype_; Dwarf_Off globalOffset_; Dwarf_Off cuRelativeOffset_; Dwarf_Sig8 typeSig8_; }; class IRFormString: public IRForm { public: IRFormString(): directform_(0), indirectform_(0), formclass_(DW_FORM_CLASS_STRING), strpoffset_(0) {}; ~IRFormString() {}; IRFormString(IRFormInterface *); IRFormString(const IRFormString &r) { directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; formdata_= r.formdata_; strpoffset_= r.strpoffset_; } virtual IRFormString * clone() const { return new IRFormString(*this); } IRFormString & operator=(const IRFormString &r) { if(this == &r) return *this; directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; formdata_ = r.formdata_; strpoffset_ = r.strpoffset_; }; void setString(const char *s) {formdata_ = s; }; const std::string & getString() const {return formdata_; }; enum Dwarf_Form_Class getFormClass() const { return formclass_; }; private: Dwarf_Half directform_; // In most cases directform == indirect form. // Otherwise, directform == DW_FORM_indirect. Dwarf_Half indirectform_; enum Dwarf_Form_Class formclass_; std::string formdata_; Dwarf_Unsigned strpoffset_; }; // Factory Method. IRForm *formFactory(Dwarf_Debug dbg, Dwarf_Attribute attr, IRCUdata &cudata,IRAttr & irattr); dwarf-20120410/dwarfgen/irepattrtodbg.h0000640000175000017500000000152411741100175016605 0ustar daveadavea#ifndef IREPATTRTODBG_H #define IREPATTRTODBG_H /* Copyright (C) 2010-2011 David Anderson. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. */ // irepattrtodbg.h void AddAttrToDie(Dwarf_P_Debug dbg, IRepresentation & Irep, Dwarf_P_Die outdie,IRDie & irdie,IRAttr &irattr); #endif /* IREPATTRTODBG_H */ dwarf-20120410/dwarfgen/irepdie.h0000640000175000017500000001561611741100175015363 0ustar daveadavea/* Copyright (C) 2010-2011 David Anderson. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. */ // // irepdie.h // // class IRCUdata; class IRAttr { public: IRAttr():attr_(0),directform_(0),indirectform_(0), formclass_(DW_FORM_CLASS_UNKNOWN),formdata_(0) { }; IRAttr(Dwarf_Half attr,Dwarf_Half dirform, Dwarf_Half indirform): attr_(attr),directform_(dirform),indirectform_(indirform), formclass_(DW_FORM_CLASS_UNKNOWN),formdata_(0) { }; IRAttr(const IRAttr &r) { attr_ = r.attr_; directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; if(r.formdata_) { formdata_ = r.formdata_->clone(); } else { formdata_ = 0; } }; ~IRAttr() { delete formdata_; }; IRAttr & operator=( const IRAttr &r) { if(this == &r) { return *this; } attr_ = r.attr_; directform_ = r.directform_; indirectform_ = r.indirectform_; formclass_ = r.formclass_; if(r.formdata_) { formdata_ = r.formdata_->clone(); } else { formdata_ = 0; } return *this; } void setBaseData(Dwarf_Half attr, Dwarf_Half dirform, Dwarf_Half indirform){ attr_ = attr; directform_ = dirform; indirectform_ = indirform; }; void setFormClass(enum Dwarf_Form_Class cl) { formclass_ = cl; }; enum Dwarf_Form_Class getFormClass() const {return formclass_; }; void setFormData(IRForm *f) { formdata_ = f; }; Dwarf_Half getFinalForm() const { return indirectform_; }; Dwarf_Half getDirectForm() const { return directform_; }; Dwarf_Half getAttrNum() const { return attr_; }; IRForm * getFormData() { return formdata_;}; private: Dwarf_Half attr_; Dwarf_Half directform_; // In most cases directform == indirect form. // Otherwise, directform == DW_FORM_indirect. Dwarf_Half indirectform_; enum Dwarf_Form_Class formclass_; IRForm *formdata_; }; class IRDie { public: IRDie():tag_(0),globalOffset_(0), cuRelativeOffset_(0) {}; ~IRDie() {}; void addChild(const IRDie & newdie ) { children_.push_back(newdie); }; std::string getName() { std::list::iterator it = attrs_.begin(); for( ; it != attrs_.end() ; ++it) { if (it->getAttrNum() == DW_AT_name) { IRForm *f = it->getFormData(); const IRFormString * isv = dynamic_cast(f); if(isv) { return isv->getString(); } } } return ""; }; std::list & getAttributes() {return attrs_; }; std::list & getChildren() {return children_; }; bool hasNewestChild(IRDie **lastch) { size_t N = children_.size(); if(N < 1) { return false; } *lastch = &children_.back(); return true; }; // lastChild will throw if no child exists. IRDie &lastChild() { return children_.back(); }; void setBaseData(Dwarf_Half tag,Dwarf_Unsigned goff, Dwarf_Unsigned cuoff) { tag_ = tag; globalOffset_=goff; cuRelativeOffset_ = cuoff; }; Dwarf_Unsigned getGlobalOffset() const { return globalOffset_;}; unsigned getTag() {return tag_; } private: std::list children_; std::list attrs_; unsigned tag_; Dwarf_Unsigned globalOffset_; Dwarf_Unsigned cuRelativeOffset_; }; class IRCUdata { public: IRCUdata(): cu_header_length_(0), abbrev_offset_(0), next_cu_header_offset_(0), version_stamp_(0), address_size_(0), length_size_(0), extension_size_(0), has_macrodata_(false), macrodata_offset_(0), has_linedata_(false), linedata_offset_(0), cudie_offset_(0) {}; IRCUdata(Dwarf_Unsigned len,Dwarf_Half version, Dwarf_Unsigned abbrev_offset, Dwarf_Half addr_size, Dwarf_Half length_size, Dwarf_Half extension_size, Dwarf_Unsigned next_cu_header): cu_header_length_(len), abbrev_offset_(abbrev_offset), next_cu_header_offset_(addr_size), version_stamp_(version), address_size_(addr_size), length_size_(length_size), extension_size_(extension_size), has_macrodata_(false), macrodata_offset_(0), has_linedata_(false), linedata_offset_(0), cudie_offset_(0) {}; ~IRCUdata() { }; bool hasMacroData(Dwarf_Unsigned *offset_out,Dwarf_Unsigned *cudie_off) { *offset_out = macrodata_offset_; *cudie_off = cudie_offset_; return has_macrodata_; } bool hasLineData(Dwarf_Unsigned *offset_out,Dwarf_Unsigned *cudie_off) { *offset_out = linedata_offset_; *cudie_off = cudie_offset_; return has_linedata_; } void setMacroData(Dwarf_Unsigned offset,Dwarf_Unsigned cudieoff) { has_macrodata_ = true; macrodata_offset_ = offset; cudie_offset_ = cudieoff; }; void setLineData(Dwarf_Unsigned offset,Dwarf_Unsigned cudieoff) { has_linedata_ = true; linedata_offset_ = offset; cudie_offset_ = cudieoff; }; IRDie & baseDie() { return cudie_; }; Dwarf_Half getVersionStamp() { return version_stamp_; }; Dwarf_Half getOffsetSize() { return length_size_; }; IRCULineData & getCULines() { return cu_lines_; }; std::string getCUName() { return cudie_.getName(); } private: Dwarf_Unsigned cu_header_length_; Dwarf_Unsigned abbrev_offset_; Dwarf_Unsigned next_cu_header_offset_; Dwarf_Half version_stamp_; Dwarf_Half address_size_; Dwarf_Half length_size_; Dwarf_Half extension_size_; bool has_macrodata_; Dwarf_Unsigned macrodata_offset_; bool has_linedata_; Dwarf_Unsigned linedata_offset_; Dwarf_Unsigned cudie_offset_; IRCULineData cu_lines_; // If true, is 32bit dwarf,else 64bit. Gives the size of a reference. bool dwarf32bit_; IRDie cudie_; }; class IRDInfo { public: IRDInfo() {}; ~IRDInfo() {}; IRCUdata &lastCU() { return cudata_.back(); } std::list& getCUData() {return cudata_; }; private: std::list cudata_; }; dwarf-20120410/dwarfgen/README0000640000175000017500000000136311741100175014443 0ustar daveadavea David Anderson, September 20, 2010 The dwarfgen application is intended as both a vehicle for testing dwarf-generation by libdwarf and as an example of how one uses libdwarf to generate DWARF. In addition, it should be useful as a test vehicle for evaluating future changes to the DWARF standard. It is necessary as a test-vehicle so that the libdwarf producer code can be updated to allow more recent features of DWARF to be supported while trying to guarantee current producer code users are correctly supported. By default dwarfgen produces a fake a.out. By that we mean that no relocation sections are written. Instead, relocations are processed directly by dwarfgen. Perhaps at some point a more a.out-like output will be optionally supported. dwarf-20120410/dwarfgen/createirepfrombinary.cc0000640000175000017500000004550011741100175020307 0ustar daveadavea/* Copyright (C) 2010-2011 David Anderson. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. */ // createirepfrombinary.cc // Reads an object and inserts its dwarf data into // an object intended to hold all the dwarf data. #include "config.h" #include #include // for exit #include #include #include #include #include // For memset etc #include //open #include //open #include "elf.h" #include "gelf.h" #include "strtabdata.h" #include "dwarf.h" #include "libdwarf.h" #include "irepresentation.h" #include "createirepfrombinary.h" #include "general.h" // For IToHex() using std::string; using std::cout; using std::cerr; using std::endl; using std::vector; using std::list; static void readFrameDataFromBinary(Dwarf_Debug dbg, IRepresentation & irep); static void readMacroDataFromBinary(Dwarf_Debug dbg, IRepresentation & irep); static void readCUDataFromBinary(Dwarf_Debug dbg, IRepresentation & irep); class DbgInAutoCloser { public: DbgInAutoCloser(Dwarf_Debug dbg,int fd): dbg_(dbg),fd_(fd) {}; ~DbgInAutoCloser() { Dwarf_Error err = 0; dwarf_finish(dbg_,&err); close(fd_); }; private: Dwarf_Debug dbg_; int fd_; }; void createIrepFromBinary(const std::string &infile, IRepresentation & irep) { Dwarf_Debug dbg = 0; Dwarf_Error err; int fd = open(infile.c_str(),O_RDONLY, 0); if(fd < 0 ) { cerr << "Unable to open " << infile << " for reading." << endl; exit(1); } // All reader error handling is via the err argument. int res = dwarf_init(fd,DW_DLC_READ, 0, 0, &dbg, &err); if(res != DW_DLV_OK) { close(fd); cerr << "Error init-ing " << infile << " for reading." << endl; exit(1); } DbgInAutoCloser closer(dbg,fd); readFrameDataFromBinary(dbg,irep); readCUDataFromBinary(dbg,irep); readMacroDataFromBinary(dbg,irep); return; } static void readFrameDataFromBinary(Dwarf_Debug dbg, IRepresentation & irep) { Dwarf_Error err = 0; Dwarf_Cie * cie_data = 0; Dwarf_Signed cie_count = 0; Dwarf_Fde * fde_data = 0; Dwarf_Signed fde_count = 0; int res = dwarf_get_fde_list(dbg, &cie_data, &cie_count, &fde_data, &fde_count, &err); if(res == DW_DLV_NO_ENTRY) { // No frame data. return; } if(res == DW_DLV_ERROR) { cerr << "Error reading frame data " << endl; exit(1); } for(Dwarf_Signed i =0; i < cie_count; ++i) { Dwarf_Unsigned bytes_in_cie = 0; Dwarf_Small version = 0; char * augmentation = 0; Dwarf_Unsigned code_alignment_factor = 0; Dwarf_Signed data_alignment_factor = 0; Dwarf_Half return_address_register_rule = 0; Dwarf_Ptr initial_instructions = 0; Dwarf_Unsigned initial_instructions_length = 0; res = dwarf_get_cie_info(cie_data[i], &bytes_in_cie, &version,&augmentation, &code_alignment_factor, &data_alignment_factor,&return_address_register_rule, &initial_instructions,&initial_instructions_length, &err); if(res != DW_DLV_OK) { cerr << "Error reading frame data cie index " << i << endl; exit(1); } // Index in cie_data must match index in ciedata_, here // correct by construction. IRCie cie(bytes_in_cie,version,augmentation,code_alignment_factor, data_alignment_factor,return_address_register_rule, initial_instructions,initial_instructions_length); irep.framedata().insert_cie(cie); } for(Dwarf_Signed i =0; i < fde_count; ++i) { Dwarf_Addr low_pc = 0; Dwarf_Unsigned func_length = 0; Dwarf_Ptr fde_bytes = 0; Dwarf_Unsigned fde_byte_length = 0; Dwarf_Off cie_offset = 0; Dwarf_Signed cie_index = 0; Dwarf_Off fde_offset = 0; res = dwarf_get_fde_range(fde_data[i], &low_pc, &func_length,&fde_bytes, &fde_byte_length, &cie_offset,&cie_index, &fde_offset, &err); if(res != DW_DLV_OK) { cerr << "Error reading frame data fde index " << i << endl; exit(1); } IRFde fde(low_pc,func_length,fde_bytes,fde_byte_length, cie_offset, cie_index,fde_offset); Dwarf_Ptr instr_in = 0; Dwarf_Unsigned instr_len = 0; res = dwarf_get_fde_instr_bytes(fde_data[i], &instr_in, &instr_len, &err); if(res != DW_DLV_OK) { cerr << "Error reading frame data fde instructions " << i << endl; exit(1); } fde.get_fde_instrs_into_ir(instr_in,instr_len); irep.framedata().insert_fde(fde); } dwarf_fde_cie_list_dealloc(dbg,cie_data,cie_count, fde_data,fde_count); } static void readCUMacroDataFromBinary(Dwarf_Debug dbg, IRepresentation & irep, Dwarf_Unsigned macrodataoffset,IRCUdata &cu) { // Arbitrary, but way too high to be real! // Probably should be lower. Dwarf_Unsigned maxcount = 1000000000; Dwarf_Error error; Dwarf_Signed mcount=0; Dwarf_Macro_Details *md = 0; int res = dwarf_get_macro_details(dbg,macrodataoffset, maxcount, &mcount, &md, &error); if(res == DW_DLV_OK) { IRMacro ¯odata = irep.macrodata(); vector mvec = macrodata.getMacroVec(); mvec.reserve(mcount); Dwarf_Unsigned dieoffset = cu.baseDie().getGlobalOffset(); Dwarf_Macro_Details *mdp = md; for(int i = 0; i < mcount; ++i, mdp++ ) { IRMacroRecord i(dieoffset,mdp->dmd_offset, mdp->dmd_type, mdp->dmd_lineno, mdp->dmd_fileindex, mdp->dmd_macro?mdp->dmd_macro:""); mvec.push_back(i); } } dwarf_dealloc(dbg, md, DW_DLA_STRING); } void get_basic_attr_data_one_attr(Dwarf_Debug dbg, Dwarf_Attribute attr,IRCUdata &cudata,IRAttr & irattr) { Dwarf_Error error; Dwarf_Half attrnum = 0; Dwarf_Half dirform = 0; Dwarf_Half indirform = 0; int res = dwarf_whatattr(attr,&attrnum,&error); if(res != DW_DLV_OK) { cerr << "Unable to get attr number " << endl; exit(1); } res = dwarf_whatform(attr,&dirform,&error); if(res != DW_DLV_OK) { cerr << "Unable to get attr form " << endl; exit(1); } res = dwarf_whatform_direct(attr,&indirform,&error); if(res != DW_DLV_OK) { cerr << "Unable to get attr direct form " << endl; exit(1); } irattr.setBaseData(attrnum,dirform,indirform); enum Dwarf_Form_Class cl = dwarf_get_form_class( cudata.getVersionStamp(), attrnum, cudata.getOffsetSize(), dirform); irattr.setFormClass(cl); if (cl == DW_FORM_CLASS_UNKNOWN) { cerr << "Unable to figure out form class. ver " << cudata.getVersionStamp() << " attrnum " << attrnum << " offsetsize " << cudata.getOffsetSize() << " formnum " << dirform << endl; return; } irattr.setFormData(formFactory(dbg,attr,cudata,irattr)); } void get_basic_die_data(Dwarf_Debug dbg,Dwarf_Die indie,IRDie &irdie) { Dwarf_Half tagval = 0; Dwarf_Error error = 0; int res = dwarf_tag(indie,&tagval,&error); if(res != DW_DLV_OK) { cerr << "Unable to get die tag "<< endl; exit(1); } Dwarf_Off goff = 0; res = dwarf_dieoffset(indie,&goff,&error); if(res != DW_DLV_OK) { cerr << "Unable to get die offset "<< endl; exit(1); } Dwarf_Off localoff = 0; res = dwarf_die_CU_offset(indie,&localoff,&error); if(res != DW_DLV_OK) { cerr << "Unable to get cu die offset "<< endl; exit(1); } irdie.setBaseData(tagval,goff,localoff); } static void get_attrs_of_die(Dwarf_Die in_die,IRDie &irdie, IRCUdata &data, IRepresentation &irep, Dwarf_Debug dbg) { Dwarf_Error error = 0; Dwarf_Attribute *atlist = 0; Dwarf_Signed atcnt = 0; std::list &attrlist = irdie.getAttributes(); int res = dwarf_attrlist(in_die, &atlist,&atcnt,&error); if(res == DW_DLV_NO_ENTRY) { return; } if(res == DW_DLV_ERROR) { cerr << "dwarf_attrlist failed " << endl; exit(1); } for (Dwarf_Signed i = 0; i < atcnt; ++i) { Dwarf_Attribute attr = atlist[i]; IRAttr irattr; get_basic_attr_data_one_attr(dbg,attr,data,irattr); attrlist.push_back(irattr); } dwarf_dealloc(dbg,atlist, DW_DLA_LIST); } // Invariant: IRDie and IRCUdata is in the irep tree, // not local record references to local scopes. static void get_children_of_die(Dwarf_Die in_die,IRDie&irdie, IRCUdata &ircudata, IRepresentation &irep, Dwarf_Debug dbg) { Dwarf_Die curchilddie = 0; Dwarf_Error error = 0; int res = dwarf_child(in_die,&curchilddie,&error); if(res == DW_DLV_NO_ENTRY) { return; } if(res == DW_DLV_ERROR) { cerr << "dwarf_child failed " << endl; exit(1); } //std::list & childlist = irdie.getChildren(); int childcount = 0; for(;;) { IRDie child; get_basic_die_data(dbg,curchilddie,child); get_attrs_of_die(curchilddie,child,ircudata,irep,dbg); irdie.addChild(child); IRDie &lastchild = irdie.lastChild(); get_children_of_die(curchilddie,lastchild,ircudata,irep,dbg); ++childcount; Dwarf_Die tchild = 0; res = dwarf_siblingof(dbg,curchilddie,&tchild,&error); if(res == DW_DLV_NO_ENTRY) { break; } if(res == DW_DLV_ERROR) { cerr << "dwarf_siblingof failed " << endl; exit(1); } dwarf_dealloc(dbg,curchilddie,DW_DLA_DIE); curchilddie = tchild; } dwarf_dealloc(dbg,curchilddie,DW_DLA_DIE); } static void get_linedata_of_cu_die(Dwarf_Die in_die,IRDie&irdie, IRCUdata &ircudata, IRepresentation &irep, Dwarf_Debug dbg) { Dwarf_Error error = 0; char **srcfiles = 0; Dwarf_Signed srccount = 0; IRCULineData&culinesdata = ircudata.getCULines(); int res = dwarf_srcfiles(in_die,&srcfiles, &srccount,&error); if(res == DW_DLV_ERROR) { cerr << "dwarf_srcfiles failed " << endl; exit(1); } else if (res == DW_DLV_NO_ENTRY) { // No data. return; } std::vector &srcs = culinesdata.get_cu_srcfiles(); for (Dwarf_Signed i = 0; i < srccount; ++i) { IRCUSrcfile S(srcfiles[i]); srcs.push_back(S); /* use srcfiles[i] */ dwarf_dealloc(dbg, srcfiles[i], DW_DLA_STRING); } dwarf_dealloc(dbg, srcfiles, DW_DLA_LIST); Dwarf_Line * linebuf = 0; Dwarf_Signed linecnt = 0; int res2 = dwarf_srclines(in_die,&linebuf,&linecnt, &error); if(res == DW_DLV_ERROR) { cerr << "dwarf_srclines failed " << endl; exit(1); } else if (res == DW_DLV_NO_ENTRY) { // No data. cerr << "dwarf_srclines failed NO_ENTRY, crazy " "since srcfiles worked" << endl; exit(1); } std::vector &lines = culinesdata.get_cu_lines(); for(Dwarf_Signed j = 0; j < linecnt ; ++j ) { Dwarf_Line li = linebuf[j]; int lres; Dwarf_Addr address = 0; lres = dwarf_lineaddr(li,&address,&error); if (lres != DW_DLV_OK) { cerr << "dwarf_lineaddr failed. " << endl; exit(1); } Dwarf_Bool is_addr_set = 0; lres = dwarf_line_is_addr_set(li,&is_addr_set,&error); if (lres != DW_DLV_OK) { cerr << "dwarf_line_is_addr_set failed. " << endl; exit(1); } Dwarf_Unsigned fileno = 0; lres = dwarf_line_srcfileno(li,&fileno,&error); if (lres != DW_DLV_OK) { cerr << "dwarf_srcfileno failed. " << endl; exit(1); } Dwarf_Unsigned lineno = 0; lres = dwarf_lineno(li,&lineno,&error); if (lres != DW_DLV_OK) { cerr << "dwarf_lineno failed. " << endl; exit(1); } Dwarf_Unsigned lineoff = 0; lres = dwarf_lineoff_b(li,&lineoff,&error); if (lres != DW_DLV_OK) { cerr << "dwarf_lineoff failed. " << endl; exit(1); } char *linesrctmp = 0; lres = dwarf_linesrc(li,&linesrctmp,&error); if (lres != DW_DLV_OK) { cerr << "dwarf_linesrc failed. " << endl; exit(1); } // libdwarf is trying to generate a full path, // the string here is that generated data, not // simply the 'file' path represented by the // file number (fileno). std::string linesrc(linesrctmp); Dwarf_Bool is_stmt = 0; lres = dwarf_linebeginstatement(li,&is_stmt,&error); if (lres != DW_DLV_OK) { cerr << "dwarf_linebeginstatement failed. " << endl; exit(1); } Dwarf_Bool basic_block = 0; lres = dwarf_lineblock(li,&basic_block,&error); if (lres != DW_DLV_OK) { cerr << "dwarf_lineblock failed. " << endl; exit(1); } Dwarf_Bool end_sequence = 0; lres = dwarf_lineendsequence(li,&end_sequence,&error); if (lres != DW_DLV_OK) { cerr << "dwarf_lineendsequence failed. " << endl; exit(1); } Dwarf_Bool prologue_end = 0; Dwarf_Bool epilogue_begin = 0; Dwarf_Unsigned isa = 0; Dwarf_Unsigned discriminator = 0; lres = dwarf_prologue_end_etc(li,&prologue_end, &epilogue_begin,&isa,&discriminator,&error); if (lres != DW_DLV_OK) { cerr << "dwarf_prologue_end_etc failed. " << endl; exit(1); } IRCULine L(address, is_addr_set, fileno, lineno, lineoff, linesrc, is_stmt, basic_block, end_sequence, prologue_end,epilogue_begin, isa,discriminator); lines.push_back(L); } dwarf_srclines_dealloc(dbg, linebuf, linecnt); } static bool getToplevelOffsetAttr(Dwarf_Die cu_die,Dwarf_Half attrnumber, Dwarf_Unsigned &offset_out) { Dwarf_Error error = 0; Dwarf_Off offset = 0; Dwarf_Attribute attr = 0; int res = dwarf_attr(cu_die,attrnumber,&attr, &error); bool foundit = false; Dwarf_Off sectoff = 0; if(res == DW_DLV_OK) { Dwarf_Signed sval = 0; Dwarf_Unsigned uval = 0; res = dwarf_global_formref(attr,&offset,&error); if(res == DW_DLV_OK) { foundit = true; offset_out = offset; } } return foundit; } // We record the .debug_info info for each CU found // To start with we restrict attention to very few DIEs and // attributes, but intend to get all eventually. static void readCUDataFromBinary(Dwarf_Debug dbg, IRepresentation & irep) { Dwarf_Error error; int cu_number = 0; std::list &culist = irep.infodata().getCUData(); for(;;++cu_number) { Dwarf_Unsigned cu_header_length = 0; Dwarf_Half version_stamp = 0; Dwarf_Unsigned abbrev_offset = 0; Dwarf_Half address_size = 0; Dwarf_Unsigned next_cu_header = 0; Dwarf_Half offset_size = 0; Dwarf_Half extension_size = 0; Dwarf_Die no_die = 0; Dwarf_Die cu_die = 0; int res = DW_DLV_ERROR; res = dwarf_next_cu_header_b(dbg,&cu_header_length, &version_stamp, &abbrev_offset, &address_size, &offset_size, &extension_size, &next_cu_header, &error); if(res == DW_DLV_ERROR) { cerr <<"Error in dwarf_next_cu_header"<< endl; exit(1); } if(res == DW_DLV_NO_ENTRY) { /* Done. */ return; } IRCUdata cudata(cu_header_length,version_stamp, abbrev_offset,address_size, offset_size, extension_size,next_cu_header); // The CU will have a single sibling (well, it is // not exactly a sibling, but close enough), a cu_die. res = dwarf_siblingof(dbg,no_die,&cu_die,&error); if(res == DW_DLV_ERROR) { cerr <<"Error in dwarf_siblingof on CU die "<< endl; exit(1); } if(res == DW_DLV_NO_ENTRY) { /* Impossible case. */ cerr <<"no Entry! in dwarf_siblingof on CU die "<< endl; exit(1); } Dwarf_Off macrooffset = 0; bool foundmsect = getToplevelOffsetAttr(cu_die,DW_AT_macro_info, macrooffset); Dwarf_Off linesoffset = 0; bool foundlines = getToplevelOffsetAttr(cu_die,DW_AT_stmt_list, linesoffset); Dwarf_Off dieoff = 0; res = dwarf_dieoffset(cu_die,&dieoff,&error); if(res != DW_DLV_OK) { cerr << "Unable to get cu die offset for macro infomation "<< endl; exit(1); } if(foundmsect) { cudata.setMacroData(macrooffset,dieoff); } if(foundlines) { cudata.setLineData(linesoffset,dieoff); } culist.push_back(cudata); IRCUdata & treecu = irep.infodata().lastCU(); IRDie &cuirdie = treecu.baseDie(); get_basic_die_data(dbg,cu_die,cuirdie); get_attrs_of_die(cu_die,cuirdie,treecu,irep,dbg); get_children_of_die(cu_die,cuirdie,treecu,irep,dbg); get_linedata_of_cu_die(cu_die,cuirdie,treecu,irep,dbg); dwarf_dealloc(dbg,cu_die,DW_DLA_DIE); } // If we want pointers from child to parent now is the time // we can construct them. } // We read thru the CU headers and the CU die to find // the macro info for each CU (if any). // We record the CU macro info for each CU found (using // the value of the DW_AT_macro_info attribute, if any). static void readMacroDataFromBinary(Dwarf_Debug dbg, IRepresentation & irep) { list &cudata = irep.infodata().getCUData(); list::iterator it = cudata.begin(); int ct = 0; for( ; it != cudata.end(); ++it,++ct) { Dwarf_Unsigned macrooffset = 0; Dwarf_Unsigned cudieoffset = 0; bool foundmsect = it->hasMacroData(¯ooffset,&cudieoffset); if(foundmsect) { readCUMacroDataFromBinary(dbg, irep, macrooffset,*it); } } } dwarf-20120410/dwarfgen/ChangeLog0000640000175000017500000000033111741100175015327 0ustar daveadavea2011-04-10 DavidAnderson * config.h.in: Add HAVE_INTPTR_T * configure.in: Test for intptr_t * configure: Regenerated * irepattrtodbg.cc: Add typedef and test for INTPTR_T dwarf-20120410/dwarfgen/ireptodbg.h0000640000175000017500000000136611741100175015716 0ustar daveadavea/* Copyright (C) 2010-2011 David Anderson. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. */ // ireptodbg.h void transform_irep_to_dbg(Dwarf_P_Debug dbg, IRepresentation & Irep, int cu_of_input_we_output); dwarf-20120410/dwarfgen/ireptodbg.cc0000640000175000017500000003045511741100175016055 0ustar daveadavea/* Copyright (C) 2010-2011 David Anderson. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. */ // ireptodbg.cc #include "config.h" #include #include // for exit #include #include #include #include #include #include // For memset etc #include //open #include //open #include "elf.h" #include "gelf.h" #include "strtabdata.h" #include "dwarf.h" #include "libdwarf.h" #include "irepresentation.h" #include "ireptodbg.h" #include "irepattrtodbg.h" #include "general.h" using std::string; using std::cout; using std::cerr; using std::endl; using std::vector; using std::map; using std::list; static Dwarf_Error error; typedef std::map pathToUnsignedType; static Dwarf_P_Die HandleOneDieAndChildren(Dwarf_P_Debug dbg, IRepresentation & Irep, IRDie &inDie, unsigned level) { list& children = inDie.getChildren(); // We create our target DIE first so we can link // children to it, but add no content yet. Dwarf_P_Die ourdie = dwarf_new_die(dbg,inDie.getTag(),NULL,NULL, NULL,NULL,&error); if (reinterpret_cast(ourdie) == DW_DLV_BADADDR) { cerr << "Die creation failure. "<< endl; exit(1); } Dwarf_P_Die lastch = 0; for ( list::iterator it = children.begin(); it != children.end(); it++) { IRDie & ch = *it; Dwarf_P_Die chp = HandleOneDieAndChildren(dbg,Irep,ch,level+1); Dwarf_P_Die res = 0; if(lastch) { // Link to right of earlier sibling. res = dwarf_die_link(chp,NULL,NULL,lastch,NULL,&error); } else { // Link as first child. res = dwarf_die_link(chp,ourdie,NULL,NULL, NULL,&error); } // Bad cast here, FIXME if (reinterpret_cast(res) == DW_DLV_BADADDR) { cerr << "Die link failure. "<< endl; exit(1); } lastch = chp; } list& attrs = inDie.getAttributes(); // Now we add attributes (content), if any, to the 'ourdie'. for (list::iterator it = attrs.begin(); it != attrs.end(); it++) { IRAttr & attr = *it; AddAttrToDie(dbg,Irep,ourdie,inDie,attr); } return ourdie; } static void HandleLineData(Dwarf_P_Debug dbg,IRepresentation & Irep, IRCUdata&cu) { Dwarf_Error error = 0; // We refer to files by fileno, this builds an index. pathToUnsignedType pathmap; IRCULineData& ld = cu.getCULines(); std::vector & cu_lines = ld.get_cu_lines(); //std::vector &cu_srcfiles = ld.get_cu_srcfiles(); if(cu_lines.empty()) { // No lines data to emit, do nothing. return; } // To start with, we are doing a trivial generation here. // To be refined 'soon'. FIXME // Initially we don't worry about dwarf_add_directory_decl(). bool firstline = true; bool addrsetincu = false; for(unsigned k = 0; k < cu_lines.size(); ++k) { IRCULine &li = cu_lines[k]; const std::string&path = li.getpath(); unsigned pathindex = 0; pathToUnsignedType::const_iterator it = pathmap.find(path); if(it == pathmap.end()) { Dwarf_Error error = 0; Dwarf_Unsigned idx = dwarf_add_file_decl( dbg,const_cast(path.c_str()), 0,0,0,&error); if(idx == DW_DLV_NOCOUNT) { cerr << "Error from dwarf_add_file_decl() on " << path << endl; exit(1); } pathindex = idx; pathmap[path] = pathindex; } else { pathindex = it->second; } Dwarf_Addr a = li.getaddr(); bool addrsetinline = li.getaddrset(); bool endsequence = li.getendsequence(); if(firstline || !addrsetincu) { // We fake an elf sym index here. Dwarf_Unsigned elfsymidx = 0; if(firstline && !addrsetinline) { cerr << "Error building line, first entry not addr set" << endl; exit(1); } Dwarf_Unsigned res = dwarf_lne_set_address(dbg, a,elfsymidx,&error); if(res == DW_DLV_NOCOUNT) { cerr << "Error building line, dwarf_lne_set_address" << endl; exit(1); } addrsetincu = true; firstline = false; } else if( endsequence) { Dwarf_Unsigned esres = dwarf_lne_end_sequence(dbg, a,&error); if(esres == DW_DLV_NOCOUNT) { cerr << "Error building line, dwarf_lne_end_sequence" << endl; exit(1); } addrsetincu = false; continue; } Dwarf_Signed linecol = li.getlinecol(); // It's really the code address or (when in a proper compiler) // a section or function offset. // libdwarf subtracts the code_offset from the address passed // this way or from dwarf_lne_set_address() and writes a small // offset in a DW_LNS_advance_pc instruction. Dwarf_Addr code_offset = a; Dwarf_Unsigned lineno = li.getlineno(); Dwarf_Bool isstmt = li.getisstmt()?1:0; Dwarf_Bool isblock = li.getisblock()?1:0; Dwarf_Bool isepiloguebegin = li.getepiloguebegin()?1:0; Dwarf_Bool isprologueend = li.getprologueend()?1:0; Dwarf_Unsigned isa = li.getisa(); Dwarf_Unsigned discriminator = li.getdiscriminator(); Dwarf_Unsigned lires = dwarf_add_line_entry_b(dbg, pathindex, code_offset, lineno, linecol, isstmt, isblock, isepiloguebegin, isprologueend, isa, discriminator, &error); if(lires == DW_DLV_NOCOUNT) { cerr << "Error building line, dwarf_add_line_entry" << endl; exit(1); } } if(addrsetincu) { cerr << "CU Lines did not end in an end_sequence!" << endl; } } // This emits the DIEs for a single CU and possibly line data // associated with the CU. // The DIEs form a graph (which can be created and linked together // in any order) and which is emitted in tree preorder as // defined by the DWARF spec. // static void emitOneCU( Dwarf_P_Debug dbg,IRepresentation & Irep, IRCUdata&cu, int cu_of_input_we_output) { // We descend the the tree, creating DIEs and linking // them in as we return back up the tree of recursing // on IRDie children. Dwarf_Error error; IRDie & basedie = cu.baseDie(); Dwarf_P_Die cudie = HandleOneDieAndChildren(dbg,Irep,basedie,0); // Add base die to debug, this is the CU die. // This is not a good design as DWARF3/4 have // requirements of multiple CUs in a single creation, // which cannot be handled yet. Dwarf_Unsigned res = dwarf_add_die_to_debug(dbg,cudie,&error); if(res != DW_DLV_OK) { cerr << "Unable to add_die_to_debug " << endl; exit(1); } HandleLineData(dbg,Irep,cu); } // .debug_info creation. // Also creates .debug_line static void transform_debug_info(Dwarf_P_Debug dbg, IRepresentation & irep,int cu_of_input_we_output) { int cu_number = 0; std::list &culist = irep.infodata().getCUData(); // For now, just one CU we write (as spoken by Yoda). for ( list::iterator it = culist.begin(); it != culist.end(); it++,cu_number++) { if(cu_number == cu_of_input_we_output) { IRCUdata & primecu = *it; emitOneCU(dbg,irep,primecu,cu_of_input_we_output); break; } } } static void transform_cie_fde(Dwarf_P_Debug dbg, IRepresentation & Irep,int cu_of_input_we_output) { Dwarf_Error err = 0; std::vector &cie_vec = Irep.framedata().get_cie_vec(); std::vector &fde_vec = Irep.framedata().get_fde_vec(); for(size_t i = 0; i < cie_vec.size(); ++i) { IRCie &ciein = cie_vec[i]; Dwarf_Unsigned version = 0; string aug; Dwarf_Unsigned code_align = 0; Dwarf_Signed data_align = 0; Dwarf_Half ret_addr_reg = -1; void * bytes = 0; Dwarf_Unsigned bytes_len; ciein.get_basic_cie_data(&version, &aug, &code_align, &data_align, &ret_addr_reg); ciein.get_init_instructions(&bytes_len,&bytes); // version implied: FIXME, need to let user code set output // frame version. char *str = const_cast(aug.c_str()); Dwarf_Signed out_cie_index = dwarf_add_frame_cie(dbg, str, code_align, data_align, ret_addr_reg, bytes,bytes_len, &err); if(out_cie_index == DW_DLV_NOCOUNT) { cerr << "Error creating cie from input cie " << i << endl; exit(1); } vector fdeindex; // This inner loop is C*F so a bit slow. for(size_t j = 0; j < fde_vec.size(); ++j) { IRFde &fdein = fde_vec[j]; Dwarf_Unsigned code_len = 0; Dwarf_Addr code_virt_addr = 0; Dwarf_Signed cie_input_index = 0; fdein.get_fde_base_data(&code_virt_addr, &code_len, &cie_input_index); if(cie_input_index != i) { // Wrong cie, ignore this fde right now. continue; } Dwarf_P_Fde fdeout = dwarf_new_fde(dbg,&err); if(reinterpret_cast(fdeout) == DW_DLV_BADADDR) { cerr << "Error creating new fde " << j << endl; exit(1); } Dwarf_Unsigned ilen = 0; void *instrs = 0; fdein.get_fde_instructions(&ilen, &instrs); int res = dwarf_insert_fde_inst_bytes(dbg, fdeout, ilen, instrs,&err); if(res != DW_DLV_OK) { cerr << "Error inserting frame instr block " << j << endl; exit(1); } Dwarf_P_Die irix_die = 0; Dwarf_Signed irix_table_offset = 0; Dwarf_Unsigned irix_excep_sym = 0; Dwarf_Unsigned code_virt_addr_symidx = Irep.getBaseTextSymbol(); Dwarf_Unsigned fde_index = dwarf_add_frame_info( dbg, fdeout,irix_die, out_cie_index, code_virt_addr, code_len,code_virt_addr_symidx, irix_table_offset,irix_excep_sym, &err); if(fde_index == DW_DLV_BADADDR) { cerr << "Error creating new fde " << j << endl; exit(1); } } } } static void transform_macro_info(Dwarf_P_Debug dbg, IRepresentation & Irep,int cu_of_input_we_output) { IRMacro ¯odata = Irep.macrodata(); std::vector ¯ov = macrodata.getMacroVec(); for(size_t m = 0; m < macrov.size() ; m++ ) { // FIXME: we need to coordinate with generated // CUs . cout << "FIXME: macros not really output yet " << m << " " << macrov.size() << endl; } Dwarf_Unsigned reloc_count = 0; int drd_version = 0; int res = dwarf_get_relocation_info_count(dbg,&reloc_count, &drd_version,&error); if( res != DW_DLV_OK) { cerr << "Error getting relocation info count." << endl; exit(1); } for( Dwarf_Unsigned ct = 0; ct < reloc_count ; ++ct) { } } void transform_irep_to_dbg(Dwarf_P_Debug dbg, IRepresentation & Irep,int cu_of_input_we_output) { transform_debug_info(dbg,Irep,cu_of_input_we_output); transform_cie_fde(dbg,Irep,cu_of_input_we_output); transform_macro_info(dbg,Irep,cu_of_input_we_output); } dwarf-20120410/dwarfgen/configure.in0000640000175000017500000000311511741100175016071 0ustar daveadaveadnl This is input to autoconf, producing a configure script. AC_INIT(dwarfgen.cc) AC_CONFIG_HEADER(config.h) AC_PROG_CC AC_PROG_CXX AC_C_BIGENDIAN AC_GCC_TRADITIONAL AC_PROG_INSTALL AC_CHECK_TOOL(RANLIB, ranlib, :) AC_CHECK_TOOL(AR, ar) AC_CHECK_HEADERS(elf.h getopt.h libelf.h sgidefs.h sys/types.h) dnl Attempt to determine if it is really IRIX/SGI or 'other'. AC_TRY_COMPILE([#include ],[ __uint32_t p; p = 27;] , AC_DEFINE(HAVE___UINT32_T_IN_SGIDEFS_H,1, [Define 1 if __uint32_t is in sgidefs.h.])) AC_TRY_COMPILE([#include ],[ __uint64_t p; p = 27;] , AC_DEFINE(HAVE___UINT64_T_IN_SGIDEFS_H,1, [Define 1 if __uint64_t is in sgidefs.h.])) AC_TRY_COMPILE([#include ],[ __uint64_t p; p = 27;] , AC_DEFINE(HAVE___UINT64_T_IN_SGIDEFS_H,1, [Define 1 if is in sgidefs.h.])) dnl the existence of sgidefs.h does not prove it's truly SGI, nor dnl prove that __uint32_t or __uint64_t is defined therein. AC_TRY_COMPILE([#include ],[ __uint32_t p; p = 27;] , AC_DEFINE(HAVE___UINT32_T_IN_SGIDEFS_H,1, [Define 1 if __uint32_t is in sgidefs.h.])) AC_TRY_COMPILE([#include ],[intptr_t p; p = 27;] , AC_DEFINE(HAVE_INTPTR_T,1, [Define 1 if intptr_t defined in C99 stdint.h])) AC_TRY_COMPILE([#include ],[ __uint64_t p; p = 27;] , AC_DEFINE(HAVE___UINT64_T_IN_SGIDEFS_H,1, [Define 1 if __uint64_t is in sgidefs.h.])) AC_TRY_COMPILE([#include ],[ __uint64_t p; p = 27;] , AC_DEFINE(HAVE___UINT64_T_IN_SGIDEFS_H,1, [Define 1 if is in sgidefs.h.])) AC_OUTPUT(Makefile) dwarf-20120410/dwarfgen/general.h0000640000175000017500000000267411741100175015357 0ustar daveadavea/* Copyright (C) 2010-2011 David Anderson. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. */ // general.h // The following needed in code using this. //#include //#include // iomanip for setw etc #include #include template std::string IToHex(T v,unsigned l=0) { if(v == 0) { // For a zero value, ostringstream does not insert 0x. // So we do zeroes here. std::string out = "0x0"; if(l > 3) { out.append(l-3,'0'); } return out; } std::ostringstream s; s.setf(std::ios::hex,std::ios::basefield); s.setf(std::ios::showbase); if (l > 0) { s << std::setw(l); } s << v ; return s.str(); }; template std::string BldName(const std::string & prefix, T v) { std::ostringstream s; s << prefix; s << v; return s.str(); } dwarf-20120410/dwarfgen/config.h.in0000640000175000017500000000440211741100175015603 0ustar daveadavea/* config.h.in. Generated from configure.in by autoheader. */ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* Define to 1 if you have the header file. */ #undef HAVE_ELF_H /* Define to 1 if you have the header file. */ #undef HAVE_GETOPT_H /* Define 1 if intptr_t defined in C99 stdint.h */ #undef HAVE_INTPTR_T /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_LIBELF_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the header file. */ #undef HAVE_SGIDEFS_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define 1 if __uint32_t is in sgidefs.h. */ #undef HAVE___UINT32_T_IN_SGIDEFS_H /* Define 1 if is in sgidefs.h. */ #undef HAVE___UINT64_T_IN_SGIDEFS_H /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif #endif dwarf-20120410/dwarfgen/COPYING0000640000175000017500000000210511741100175014611 0ustar daveadaveaFiles here are copyrighted by David Anderson (and possibly others, see the copyright notices in individual files) by the GPL version 2. A typical notice is: Copyright (C) 2010 David Anderson. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. See GPL.txt in this directory for an original copy of the GPL version 2. (GPL.txt contains an obsolete address for the Free Software Foundation, 51 Franklin Street is the correct address.) David Anderson is at libdwarf-list -at- earthlink =dot= net 280 Bella Vista Drive Hillsborough, California 94010 USA. dwarf-20120410/dwarfgen/GPL.txt0000640000175000017500000004310311741100175014744 0ustar daveadavea GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. dwarf-20120410/dwarfgen/irepline.h0000640000175000017500000000613711741100175015547 0ustar daveadavea#ifndef IREPLINE_H #define IREPLINE_H /* Copyright (C) 2011 David Anderson. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. */ // // irepline.h // class IRCULine { public: IRCULine(Dwarf_Addr addr,Dwarf_Bool isset, Dwarf_Unsigned fileno, Dwarf_Unsigned lineno, Dwarf_Unsigned linecol, const std::string & linename, Dwarf_Bool is_stmt, Dwarf_Bool bb, Dwarf_Bool endseq, Dwarf_Bool prol_end, Dwarf_Bool epil_beg, Dwarf_Unsigned isa, Dwarf_Unsigned discrim): address_(addr), isaddrset_(isset), srcfileno_(fileno), lineno_(lineno), linecol_(linecol), linesrc_(linename), is_stmt_(is_stmt), basic_block_(bb), end_sequence_(endseq), prologue_end_(prol_end), epilogue_begin_(epil_beg), isa_(isa), discriminator_(discrim) {}; const std::string &getpath() { return linesrc_; }; Dwarf_Addr getaddr() { return address_;}; bool getaddrset() { return isaddrset_;}; bool getendsequence() { return end_sequence_; }; Dwarf_Unsigned getlineno() { return lineno_; }; Dwarf_Unsigned getlinecol() { return linecol_; }; bool getisstmt() { return is_stmt_; }; bool getisblock() { return basic_block_; }; bool getepiloguebegin() { return epilogue_begin_; }; bool getprologueend() { return prologue_end_; }; Dwarf_Unsigned getisa() { return isa_; }; Dwarf_Unsigned getdiscriminator() { return discriminator_; }; ~IRCULine() {}; private: // Names taken from the DWARF4 std. document, sec 6.2.2. Dwarf_Addr address_; bool isaddrset_; Dwarf_Unsigned srcfileno_; Dwarf_Unsigned lineno_; Dwarf_Signed linecol_; // aka lineoff std::string linesrc_; // Name for the file, constructed by libdwarf. bool is_stmt_; bool basic_block_; bool end_sequence_; bool prologue_end_; bool epilogue_begin_; int isa_; int discriminator_; }; class IRCUSrcfile { public: IRCUSrcfile(std::string file): cusrcfile_(file) {}; ~IRCUSrcfile() {}; std::string &getfilepath() {return cusrcfile_;}; private: std::string cusrcfile_; }; class IRCULineData { public: IRCULineData() {}; ~IRCULineData() {}; std::vector &get_cu_lines() { return culinedata_; }; std::vector &get_cu_srcfiles() { return cusrcfiledata_; }; private: std::vector cusrcfiledata_; std::vector culinedata_; }; #endif // IREPLINE_H dwarf-20120410/dwarfgen/dwarfgen.cc0000750000175000017500000005033711741100175015676 0ustar daveadavea/* Copyright (C) 2010-2011 David Anderson. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. */ // dwarfgen.cc // // Using some information source, create a tree of dwarf // information (speaking of a DIE tree). // Turn the die tree into dwarfdata using libdwarf producer // and write the resulting data in an object file. // It is a bit inconsistent in error handling just to // demonstrate the various possibilities using the producer // library. // // dwarfgen [-t def|obj|txt] [-o outpath] [-c cunum] path // where -t means what sort of input to read // def means predefined (no input is read, the output // is based on some canned setups built into dwarfgen). // 'path' is ignored in this case. This is the default. // // obj means 'path' is required, it is the object file to // read (the dwarf sections are duplicated in the output file) // // txt means 'path' is required, path must contain plain text // (in a form rather like output by dwarfdump) // that defines the dwarf that is to be output. // // where -o means specify the pathname of the output object. If not // supplied testout.o is used as the default output path. // where -c supplies a CU number of the obj input to output // because the dwarf producer wants just one CU. // Default is -1 which won't match anything. #include "config.h" #include #include // for exit #include #include #include #include #include #include #include // For memset etc #include //open #include //open #include "general.h" #include "elf.h" #include "gelf.h" #include "strtabdata.h" #include "dwarf.h" #include "libdwarf.h" #include "irepresentation.h" #include "ireptodbg.h" #include "createirepfrombinary.h" using std::string; using std::cout; using std::cerr; using std::endl; using std::vector; static void write_object_file(Dwarf_P_Debug dbg, IRepresentation &irep); static void write_text_section(Elf * elf); static void write_generated_dbg(Dwarf_P_Debug dbg,Elf * elf, IRepresentation &irep); static string outfile("testout.o"); static string infile; static enum WhichInputSource { OptNone, OptReadText,OptReadBin,OptPredefined} whichinput(OptPredefined); // This is a global so thet CallbackFunc can get to it // If we used the dwarf_producer_init_c() user_data pointer // creatively we would not need a global. static IRepresentation Irep; static Elf * elf = 0; static Elf32_Ehdr * ehp = 0; static strtabdata secstrtab; // loff_t is signed for some reason (strange) but we make offsets unsigned. #define LOFFTODWUNS(x) ( (Dwarf_Unsigned)(x)) class SectionFromDwarf { public: std::string name_; Dwarf_Unsigned section_name_itself_; ElfSymIndex section_name_symidx_; int size_; Dwarf_Unsigned type_; Dwarf_Unsigned flags_; Dwarf_Unsigned link_; Dwarf_Unsigned info_; private: ElfSectIndex elf_sect_index_; Dwarf_Unsigned lengthWrittenToElf_; public: Dwarf_Unsigned getNextOffset() { return lengthWrittenToElf_; } void setNextOffset(Dwarf_Unsigned v) { lengthWrittenToElf_ = v; } unsigned getSectionNameSymidx() { return section_name_symidx_.getSymIndex(); }; SectionFromDwarf():section_name_itself_(0), section_name_symidx_(0), size_(0),type_(0),flags_(0), link_(0), info_(0), elf_sect_index_(0), lengthWrittenToElf_(0) {} ; ~SectionFromDwarf() {}; void setSectIndex(ElfSectIndex v) { elf_sect_index_ = v;} ElfSectIndex getSectIndex() const { return elf_sect_index_;} SectionFromDwarf(const std::string&name, int size,Dwarf_Unsigned type,Dwarf_Unsigned flags, Dwarf_Unsigned link, Dwarf_Unsigned info): name_(name), size_(size),type_(type),flags_(flags), link_(link), info_(info), elf_sect_index_(0), lengthWrittenToElf_(0) { // Now create section name string section. section_name_itself_ = secstrtab.addString(name.c_str()); ElfSymbols& es = Irep.getElfSymbols(); // Now creat a symbol for the section name. // (which has its own string table) section_name_symidx_ = es.addElfSymbol(0,name); } ; }; vector dwsectab; static ElfSectIndex create_dw_elf(SectionFromDwarf &ds); static SectionFromDwarf & FindMySection(const ElfSectIndex & elf_section_index) { for(unsigned i =0; i < dwsectab.size(); ++i) { if(elf_section_index.getSectIndex() != dwsectab[i].getSectIndex().getSectIndex()) { continue; } return dwsectab[i]; } cerr << "Unable to find my dw sec data for elf section " << elf_section_index.getSectIndex() << endl; exit(1); } static unsigned createnamestr(unsigned strtabstroff) { Elf_Scn * strscn =elf_newscn(elf); if(!strscn) { cerr << "Unable to elf_newscn() on " << outfile << endl; exit(1); } Elf_Data* shstr =elf_newdata(strscn); if(!shstr) { cerr << "Unable to elf_newdata() on " << outfile << endl; exit(1); } shstr->d_buf = secstrtab.exposedata(); shstr->d_type = ELF_T_BYTE; shstr->d_size = secstrtab.exposelen(); shstr->d_off = 0; shstr->d_align = 1; shstr->d_version = EV_CURRENT; Elf32_Shdr * strshdr = elf32_getshdr(strscn); if(!strshdr) { cerr << "Unable to elf_getshdr() on " << outfile << endl; exit(1); } strshdr->sh_name = strtabstroff; strshdr->sh_type= SHT_STRTAB; strshdr->sh_flags = SHF_STRINGS; strshdr->sh_addr = 0; strshdr->sh_offset = 0; strshdr->sh_size = 0; strshdr->sh_link = 0; strshdr->sh_info = 0; strshdr->sh_addralign = 1; strshdr->sh_entsize = 0; return elf_ndxscn(strscn); } // This functional interface is defined by libdwarf. int CallbackFunc( char* name, int size, Dwarf_Unsigned type, Dwarf_Unsigned flags, Dwarf_Unsigned link, Dwarf_Unsigned info, Dwarf_Unsigned* sect_name_symbol_index, void * user_data, int* error) { // Create an elf section. // If the data is relocations, we suppress the generation // of a section when we intend to do the relocations // ourself (quite normal for dwarfgen but would // be really surprising for a normal compiler // back end using the producer code). // The section name appears both in the section strings .shstrtab and // in the elf symtab .symtab and its strings .strtab. if (0 == strncmp(name,".rel",4)) { // It is relocation, create no section! return 0; } SectionFromDwarf ds(name,size,type,flags,link,info) ; *sect_name_symbol_index = ds.getSectionNameSymidx(); ElfSectIndex createdsec = create_dw_elf(ds); // Do all the data creation before pushing (copying) ds onto dwsectab! dwsectab.push_back(ds); return createdsec.getSectIndex(); } static ElfSectIndex create_dw_elf(SectionFromDwarf &ds) { Elf_Scn * scn =elf_newscn(elf); if(!scn) { cerr << "Unable to elf_newscn() on " << ds.name_ << endl; exit(1); } Elf32_Shdr * shdr = elf32_getshdr(scn); if(!shdr) { cerr << "Unable to elf_getshdr() on " << ds.name_ << endl; exit(1); } shdr->sh_name = ds.section_name_itself_; shdr->sh_type = ds.type_; shdr->sh_flags = ds.flags_; shdr->sh_addr = 0; shdr->sh_offset = 0; shdr->sh_size = ds.size_; shdr->sh_link = ds.link_; shdr->sh_info = ds.info_; shdr->sh_addralign = 1; shdr->sh_entsize = 0; ElfSectIndex si(elf_ndxscn(scn)); ds.setSectIndex(si); return si; } // Default error handler of libdwarf producer code. void ErrorHandler(Dwarf_Error err,Dwarf_Ptr errarg) { // FIXME do better error handling cerr <<"Giving up, encountered an error" << endl; exit(1); } static void setinput(enum WhichInputSource *src, const string &type, bool *pathreq) { if(type == "txt") { *src = OptReadText; *pathreq = true; return; } else if (type == "obj") { *src = OptReadBin; *pathreq = true; return; } else if (type == "def") { *src = OptPredefined; *pathreq = false; return; } cout << "Giving up, only txt obj or def accepted after -t" << endl; exit(1); } int main(int argc, char **argv) { int opt; bool pathrequired(false); long cu_of_input_we_output = -1; while((opt=getopt(argc,argv,"o:t:c:")) != -1) { switch(opt) { case 'c': // At present we can only create a single // cu in the output of the libdwarf producer. cu_of_input_we_output = atoi(optarg); break; case 't': setinput(&whichinput,optarg,&pathrequired); break; case 'o': outfile = optarg; break; case '?': cerr << "Invalid quest? option input " << endl; exit(1); default: cerr << "Invalid option input " << endl; exit(1); } } if ( (optind >= argc) && pathrequired) { cerr << "Expected argument after options! Giving up." << endl; exit(EXIT_FAILURE); } if(pathrequired) { infile = argv[optind]; } if(whichinput == OptReadBin) { createIrepFromBinary(infile,Irep); } else if (whichinput == OptReadText) { cerr << "text read not supported yet" << endl; exit(EXIT_FAILURE); } else if (whichinput == OptPredefined) { cerr << "predefined not supported yet" << endl; exit(EXIT_FAILURE); } else { cerr << "Impossible: unknown input style." << endl; exit(EXIT_FAILURE); } // Example will return error value thru 'err' pointer // and return DW_DLV_BADADDR if there is an error. int ptrsize = DW_DLC_SIZE_32; Dwarf_Ptr errarg = 0; Dwarf_Error err = 0; // We use DW_DLC_SYMBOLIC_RELOCATIONS so we can // read the relocations and do our own relocating. // See calls of dwarf_get_relocation_info(). Dwarf_P_Debug dbg = dwarf_producer_init_c( DW_DLC_WRITE|ptrsize|DW_DLC_SYMBOLIC_RELOCATIONS, CallbackFunc, 0, errarg, 0, /* we are not using user_data, so pass in 0 */ &err); if(dbg == reinterpret_cast(DW_DLV_BADADDR)) { cerr << "Failed init_b" << endl; exit(EXIT_FAILURE); } transform_irep_to_dbg(dbg,Irep,cu_of_input_we_output); write_object_file(dbg,Irep); // Example calls ErrorHandler if there is an error // (which does not return, see above) // so no need to test for error. dwarf_producer_finish( dbg, 0); return 0; } static void write_object_file(Dwarf_P_Debug dbg, IRepresentation &irep) { int mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; int fd = open(outfile.c_str(),O_WRONLY|O_CREAT|O_TRUNC, mode); if(fd < 0 ) { cerr << "Unable to open " << outfile << " for writing." << endl; exit(1); } if(elf_version(EV_CURRENT) == EV_NONE) { cerr << "Bad elf_version" << endl; exit(1); } Elf_Cmd cmd = ELF_C_WRITE; elf = elf_begin(fd,cmd,0); if(!elf) { cerr << "Unable to elf_begin() on " << outfile << endl; exit(1); } ehp = elf32_newehdr(elf); if(!ehp) { cerr << "Unable to elf_newehdr() on " << outfile << endl; exit(1); } ehp->e_ident[EI_MAG0] = ELFMAG0; ehp->e_ident[EI_MAG1] = ELFMAG1; ehp->e_ident[EI_MAG2] = ELFMAG2; ehp->e_ident[EI_MAG3] = ELFMAG3; ehp->e_ident[EI_CLASS] = ELFCLASS32; ehp->e_ident[EI_DATA] = ELFDATA2LSB; ehp->e_ident[EI_VERSION] = EV_CURRENT; ehp->e_machine = EM_386; ehp->e_type = ET_EXEC; ehp->e_version = EV_CURRENT; unsigned strtabstroff = secstrtab.addString(".shstrtab"); // an object section with fake .text data (just as an example). write_text_section(elf); write_generated_dbg(dbg,elf,Irep); // Now create section name string section. unsigned shstrindex = createnamestr(strtabstroff); ehp->e_shstrndx = shstrindex; off_t ures = elf_update(elf,cmd); if(ures == (off_t)(-1LL)) { cerr << "Unable to elf_update() on " << outfile << endl; int eer = elf_errno(); cerr << "Error is " << eer << " " << elf_errmsg(eer) << endl; exit(1); } cout << " output image size in bytes " << ures << endl; elf_end(elf); close(fd); } // an object section with fake .text data (just as an example). static void write_text_section(Elf * elf) { unsigned osecnameoff = secstrtab.addString(".text"); Elf_Scn * scn1 =elf_newscn(elf); if(!scn1) { cerr << "Unable to elf_newscn() on " << outfile << endl; exit(1); } Elf_Data* ed1 =elf_newdata(scn1); if(!ed1) { cerr << "Unable to elf_newdata() on " << outfile << endl; exit(1); } const char *d = "data in section"; ed1->d_buf = (void *)d; ed1->d_type = ELF_T_BYTE; ed1->d_size = strlen(d) +1; ed1->d_off = 0; ed1->d_align = 4; ed1->d_version = EV_CURRENT; Elf32_Shdr * shdr1 = elf32_getshdr(scn1); if(!shdr1) { cerr << "Unable to elf_getshdr() on " << outfile << endl; exit(1); } shdr1->sh_name = osecnameoff; shdr1->sh_type= SHT_PROGBITS; shdr1->sh_flags = 0; shdr1->sh_addr = 0; shdr1->sh_offset = 0; shdr1->sh_size = 0; shdr1->sh_link = 0; shdr1->sh_info = 0; shdr1->sh_addralign = 1; shdr1->sh_entsize = 0; } static void InsertDataIntoElf(Dwarf_Signed d,Dwarf_P_Debug dbg,Elf *elf) { Dwarf_Signed elf_section_index = 0; Dwarf_Unsigned length = 0; Dwarf_Ptr bytes = dwarf_get_section_bytes(dbg,d, &elf_section_index,&length,0); Elf_Scn *scn = elf_getscn(elf,elf_section_index); if(!scn) { cerr << "Unable to elf_getscn on disk transform # " << d << endl; exit(1); } ElfSectIndex si(elf_section_index); SectionFromDwarf & sfd = FindMySection(si); Elf_Data* ed =elf_newdata(scn); if(!ed) { cerr << "elf_newdata died on transformed index " << d << endl; exit(1); } ed->d_buf = bytes; ed->d_type = ELF_T_BYTE; ed->d_size = length; ed->d_off = sfd.getNextOffset(); sfd.setNextOffset(ed->d_off + length); ed->d_align = 1; ed->d_version = EV_CURRENT; cout << "Inserted " << length << " bytes into elf section index " << elf_section_index << endl; } #if 0 static string printable_rel_type(unsigned char reltype) { enum Dwarf_Rel_Type t = (enum Dwarf_Rel_Type)reltype; switch(t) { case dwarf_drt_none: return "dwarf_drt_none"; case dwarf_drt_data_reloc: return "dwarf_drt_data_reloc"; case dwarf_drt_segment_rel: return "dwarf_drt_segment_rel"; case dwarf_drt_first_of_length_pair: return "dwarf_drt_first_of_length_pair"; case dwarf_drt_second_of_length_pair: return "dwarf_drt_second_of_length_pair"; default: break; } return "drt-unknown (impossible case)"; } #endif static Dwarf_Unsigned FindSymbolValue(ElfSymIndex symi,IRepresentation &irep) { ElfSymbols & syms = irep.getElfSymbols(); ElfSymbol & es = syms.getElfSymbol(symi); Dwarf_Unsigned symv = es.getSymbolValue(); return symv; } static void bitreplace(char *buf, Dwarf_Unsigned newval, size_t newvalsize,int length) { if(length == 4) { uint32_t my4 = newval; uint32_t * p = reinterpret_cast(buf ); uint32_t oldval = *p; *p = oldval + my4; } else if (length == 8) { uint64_t my8 = newval; uint64_t * p = reinterpret_cast(buf ); uint64_t oldval = *p; *p = oldval + my8; } else { cerr << " Relocation is length " << length << " which we do not yet handle." << endl; exit(1); } } // This remembers nothing, so is dreadfully slow. static char * findelfbuf(Elf *elf,Elf_Scn *scn,Dwarf_Unsigned offset, unsigned length) { Elf_Data * edbase = 0; Elf_Data * ed = elf_getdata(scn,edbase); unsigned bct = 0; for (;ed; ed = elf_getdata(scn,ed)) { bct++; if(offset >= LOFFTODWUNS(ed->d_off + ed->d_size) ) { continue; } if(offset < LOFFTODWUNS(ed->d_off)) { cerr << " Relocation at offset " << offset << " cannot be accomplished, no buffer. " << endl; exit(1); } Dwarf_Unsigned localoff = offset - ed->d_off; if((localoff + length) > ed->d_size) { cerr << " Relocation at offset " << offset << " cannot be accomplished, size mismatch. " << endl; exit(1); } char *lclptr = reinterpret_cast(ed->d_buf) + localoff; return lclptr; } cerr << " Relocation at offset " << offset << " cannot be accomplished, past end of buffers" << endl; return 0; } static void write_generated_dbg(Dwarf_P_Debug dbg,Elf * elf,IRepresentation &irep) { Dwarf_Error err = 0; Dwarf_Signed sectioncount = dwarf_transform_to_disk_form(dbg,0); Dwarf_Signed d = 0; for(d = 0; d < sectioncount ; ++d) { InsertDataIntoElf(d,dbg,elf); } // Since we are emitting in final form sometimes, we may // do relocation processing here or we may // instead emit relocation records into the object file. // The following is for DW_DLC_SYMBOLIC_RELOCATIONS. Dwarf_Unsigned reloc_sections_count = 0; int drd_version = 0; int res = dwarf_get_relocation_info_count(dbg,&reloc_sections_count, &drd_version,&err); if( res != DW_DLV_OK) { cerr << "Error getting relocation info count." << endl; exit(1); } cout << "Relocations sections count= " << reloc_sections_count << " relversion=" << drd_version << endl; for( Dwarf_Unsigned ct = 0; ct < reloc_sections_count ; ++ct) { // elf_section_index is the elf index of the relocations // themselves. Dwarf_Signed elf_section_index = 0; // elf_section_index_link is the elf index of the section // the relocations apply to. Dwarf_Signed elf_section_index_link = 0; // relocation_buffer_count is the number of relocations // of this section. Dwarf_Unsigned relocation_buffer_count = 0; Dwarf_Relocation_Data reld; res = dwarf_get_relocation_info(dbg,&elf_section_index, &elf_section_index_link, &relocation_buffer_count, &reld,&err); if (res != DW_DLV_OK) { cerr << "Error getting relocation record " << ct << "." << endl; exit(1); } ElfSectIndex si(elf_section_index_link); cout << "Relocs for sec " << ct << " elf-sec=" << elf_section_index << " link=" << elf_section_index_link << " bufct=" << relocation_buffer_count << endl; Elf_Scn *scn = elf_getscn(elf,si.getSectIndex()); if(!scn) { cerr << "Unable to elf_getscn # " << si.getSectIndex() << endl; exit(1); } for (Dwarf_Unsigned r = 0; r < relocation_buffer_count; ++r) { Dwarf_Relocation_Data rec = reld+r; ElfSymIndex symi(rec->drd_symbol_index); Dwarf_Unsigned newval = FindSymbolValue(symi,irep); char *buf_to_update = findelfbuf(elf,scn, rec->drd_offset,rec->drd_length); if(buf_to_update) { bitreplace(buf_to_update, newval,sizeof(newval), rec->drd_length); } } } } dwarf-20120410/dwarfgen/irepframe.h0000640000175000017500000001241711741100175015710 0ustar daveadavea/* Copyright (C) 2010-2011 David Anderson. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. */ // // irepframe.h // class IRCie { public: IRCie(): cie_byte_length_(0), version_(0), code_alignment_factor_(1), data_alignment_factor_(1), return_address_register_rule_(0) {}; IRCie(Dwarf_Unsigned length, Dwarf_Unsigned version, const std::string &augmentation, Dwarf_Unsigned code_align, Dwarf_Signed data_align, Dwarf_Half return_reg_rule, const void * init_instrs, Dwarf_Unsigned instrs_len): cie_byte_length_(length), version_(version), augmentation_(augmentation), code_alignment_factor_(code_align), data_alignment_factor_(data_align), return_address_register_rule_(return_reg_rule) { const Dwarf_Small *x = reinterpret_cast(init_instrs); for(Dwarf_Unsigned i = 0; i < instrs_len; ++i) { initial_instructions_.push_back(x[i]); } } void insert_fde_index(unsigned i) { fde_index_.push_back(i); }; ~IRCie() {}; void get_basic_cie_data(Dwarf_Unsigned * version, std::string * aug, Dwarf_Unsigned * code_align, Dwarf_Signed * data_align, Dwarf_Half * ret_addr_reg) { *version = version_; *aug = augmentation_; *code_align = code_alignment_factor_; *data_align = data_alignment_factor_; *ret_addr_reg = return_address_register_rule_; } void get_init_instructions(Dwarf_Unsigned *len, void **bytes) { *len = initial_instructions_.size(); *bytes = reinterpret_cast(&initial_instructions_[0]); }; private: // Byte length 0 if not known yet. Dwarf_Unsigned cie_byte_length_; Dwarf_Unsigned version_; std::string augmentation_; Dwarf_Unsigned code_alignment_factor_; Dwarf_Signed data_alignment_factor_; Dwarf_Half return_address_register_rule_; std::vector initial_instructions_; // fde_index is the array of indexes into fdedata_ // that are fdes used by this cie. std::vector fde_index_; }; class IRFde { public: IRFde(): low_pc_(0), func_length_(0), cie_offset_(0), cie_index_(-1), fde_offset_(0) {}; IRFde(Dwarf_Addr low_pc,Dwarf_Unsigned func_length, Dwarf_Ptr fde_bytes, Dwarf_Unsigned fde_length, Dwarf_Off cie_offset,Dwarf_Signed cie_index, Dwarf_Off fde_offset): low_pc_(low_pc), func_length_(func_length), cie_offset_(cie_offset), cie_index_(cie_index), fde_offset_(fde_offset) { const Dwarf_Small *x = reinterpret_cast(fde_bytes); for(Dwarf_Unsigned i = 0; i < fde_length; ++i) { fde_bytes_.push_back(x[i]); } }; ~IRFde() {}; Dwarf_Signed cie_index() { return cie_index_; }; void get_fde_base_data(Dwarf_Addr *lowpc, Dwarf_Unsigned * funclen, Dwarf_Signed *cie_index_input) { *lowpc = low_pc_; *funclen = func_length_; *cie_index_input = cie_index_; }; void get_fde_instrs_into_ir(Dwarf_Ptr ip,Dwarf_Unsigned len ) { const Dwarf_Small *x = reinterpret_cast(ip); for(Dwarf_Unsigned i = 0; i < len; ++i) { fde_instrs_.push_back(x[i]); } }; void get_fde_instructions(Dwarf_Unsigned *len, void **bytes) { *len = fde_instrs_.size(); *bytes = reinterpret_cast(&fde_instrs_[0]); }; void fde_instrs () { }; private: Dwarf_Addr low_pc_; Dwarf_Unsigned func_length_; // fde_bytes_ may be empty if content bytes not yet created. std::vector fde_bytes_; std::vector fde_instrs_; // cie_offset may be 0 if not known yet. Dwarf_Off cie_offset_; // cie_index is the index in ciedata_ of // the applicable CIE. Begins with index 0. Dwarf_Signed cie_index_; // fde_offset may be 0 if not yet known. Dwarf_Off fde_offset_; }; class IRFrame { public: IRFrame() {}; ~IRFrame() {}; void insert_cie(IRCie &cie) { ciedata_.push_back(cie); } void insert_fde(IRFde &fdedata) { fdedata_.push_back(fdedata); unsigned findex = fdedata_.size() -1; Dwarf_Signed cindex = fdedata.cie_index(); if( cindex != -1) { IRCie & mycie = ciedata_[cindex]; mycie.insert_fde_index(findex); } } std::vector &get_cie_vec() { return ciedata_; }; std::vector &get_fde_vec() { return fdedata_; }; private: std::vector ciedata_; std::vector fdedata_; }; dwarf-20120410/dwarfgen/irepresentation.h0000640000175000017500000001012111741100175017137 0ustar daveadavea/* Copyright (C) 2010-2011 David Anderson. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. */ // // irepresentation.h // The internal (to dwarfgen) representation of debug information. // All the various components (info, frame, etc) // will be stored here in an internal-to-dwarfgen form. // // #include "irepform.h" #include "irepline.h" #include "irepdie.h" #include "irepmacro.h" #include "irepframe.h" #include "strtabdata.h" // The elf symbols are used to tie relocations to values. // We do relocations ourselves in dwarfgen so the data is not needed // once the dwarf .debug_* sections created in elf. // We don't write the symbols out as an elf section. // The position in the vector of symbols is the 'elf symbol index' // we create. // Symbol 0 is 'no symbol'. // Symbol 1 is .text class ElfSymbol { public: ElfSymbol():symbolValue_(0), nameIndex_(0) {}; ElfSymbol(Dwarf_Unsigned val, const std::string&name, strtabdata&stab): symbolValue_(val),name_(name) { nameIndex_ = stab.addString(name); }; ~ElfSymbol() {}; Dwarf_Unsigned getSymbolValue() const { return symbolValue_;} private: Dwarf_Unsigned symbolValue_; std::string name_; // The offset in the string table. unsigned nameIndex_; }; class ElfSectIndex { public: ElfSectIndex():elfsect_(0) {}; ~ElfSectIndex() {}; ElfSectIndex(unsigned v):elfsect_(v) {}; unsigned getSectIndex() const { return elfsect_; } void setSectIndex(unsigned v) { elfsect_ = v; } private: unsigned elfsect_; }; class ElfSymIndex { public: ElfSymIndex():elfsym_(0) {}; ~ElfSymIndex() {}; ElfSymIndex(unsigned v):elfsym_(v) {}; unsigned getSymIndex() const { return elfsym_; } void setSymIndex(unsigned v) { elfsym_ = v; } private: unsigned elfsym_; }; class ElfSymbols { public: ElfSymbols() { // The initial symbol is 'no symbol'. std::string emptyname(""); elfSymbols_.push_back(ElfSymbol(0,emptyname,symstrtab_)); // We arbitrarily make this symbol .text now, though // not needed yet. std::string textname(".text"); elfSymbols_.push_back(ElfSymbol(0,textname,symstrtab_)); baseTextAddressSymbol_.setSymIndex(elfSymbols_.size()-1); } ~ElfSymbols() {}; ElfSymIndex getBaseTextSymbol() const {return baseTextAddressSymbol_;}; ElfSymIndex addElfSymbol(Dwarf_Unsigned val, const std::string&name) { elfSymbols_.push_back(ElfSymbol(val,name,symstrtab_)); ElfSymIndex indx(elfSymbols_.size()-1); return indx; }; ElfSymbol & getElfSymbol(ElfSymIndex symi) { size_t i = symi.getSymIndex(); if (i >= elfSymbols_.size()) { std::cerr << "Error, sym index " << i << " to big for symtab size " << elfSymbols_.size() << std::endl; exit(1); } return elfSymbols_[i]; } private: std::vector elfSymbols_; strtabdata symstrtab_; ElfSymIndex baseTextAddressSymbol_; }; class IRepresentation { public: IRepresentation() {}; ~IRepresentation(){}; IRFrame &framedata() { return framedata_; }; IRMacro ¯odata() { return macrodata_; }; IRDInfo &infodata() { return debuginfodata_; }; ElfSymbols &getElfSymbols() { return elfSymbols_;}; unsigned getBaseTextSymbol() { return elfSymbols_.getBaseTextSymbol().getSymIndex();}; private: // The Elf symbols data to use for relocations ElfSymbols elfSymbols_; IRFrame framedata_; IRMacro macrodata_; // Line data is inside IRDInfo. IRDInfo debuginfodata_; }; dwarf-20120410/dwarfgen/strtabdata.h0000750000175000017500000000422211741100175016064 0ustar daveadavea#ifndef STRTABDATA_H #define STRTABDATA_H /* Copyright (C) 2010-2011 David Anderson. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. */ // strtabdata.h // Creates a string table in a way consistent with // elf string tables. The zero index is a null byte always. class strtabdata { public: strtabdata(): data_(new char[1000]), datalen_(1000), nexttouse_(0) { data_[0] = 0; nexttouse_ = 1;}; ~strtabdata() { delete[]data_; }; unsigned addString(const std::string & newstr) { // The 1 is for the terminating null byte. unsigned nsz = newstr.size() +1; unsigned needed = nexttouse_ + nsz; if (needed >= datalen_) { unsigned baseincr = nsz; unsigned altincr = datalen_*2; if(altincr> baseincr) { baseincr = altincr; } unsigned newsize = datalen_ + baseincr; char *newdata = new char [newsize]; memcpy(newdata, data_, nexttouse_); delete [] data_; data_ = newdata; datalen_ = newsize; } memcpy(data_ + nexttouse_, newstr.c_str(),nsz); unsigned newstrindex = nexttouse_; nexttouse_ += nsz; return newstrindex; }; void *exposedata() {return (void *)data_;}; unsigned exposelen() const {return nexttouse_;}; private: char * data_; // datalen_ is the size in bytes pointed to by data_ . unsigned datalen_; // nexttouse_ is the index of the next (unused) byte in // data_ , so it is also the amount of space in data_ that // is in use. unsigned nexttouse_; }; #endif /* STRTABDATA_H */ dwarf-20120410/dwarfgen/irepmacro.h0000640000175000017500000000255511741100175015721 0ustar daveadavea/* Copyright (C) 2010-2011 David Anderson. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. */ // // irepmacro.h // class IRMacroRecord { public: IRMacroRecord() {}; ~IRMacroRecord() {}; IRMacroRecord(Dwarf_Off cuDieOffset,Dwarf_Off offset,Dwarf_Small type, Dwarf_Signed lineno, Dwarf_Signed lineindex, const std::string ¯o):cuDieOffset_(cuDieOffset), offset_(offset), type_(type),lineno_(lineno),lineindex_(lineindex), macro_(macro) {}; private: Dwarf_Off cuDieOffset_; Dwarf_Off offset_; Dwarf_Small type_; Dwarf_Signed lineno_; Dwarf_Signed lineindex_; std::string macro_; }; class IRMacro { public: IRMacro() {}; ~IRMacro() {}; std::vector &getMacroVec() { return macrorec_; }; private: std::vector macrorec_; }; dwarf-20120410/dwarfgen/createirepfrombinary.h0000640000175000017500000000135211741100175020146 0ustar daveadavea/* Copyright (C) 2010-2011 David Anderson. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. */ // createirepfrombinary.h void createIrepFromBinary(const std::string &infile, IRepresentation & irep); dwarf-20120410/dwarfgen/Makefile.in0000640000175000017500000000343611741100175015633 0ustar daveadavea# # Makefile.in uses very simple make rules. # There are no restrictions on copying this file. # # Standard Makefile.in stuff: srcdir = @srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = $(exec_prefix)/bin libdir = $(exec_prefix)/lib mandir = $(exec_prefix)/share/man man1dir = $(mandir)/man1 INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ DATAROOT = @datarootdir@ SHELL = /bin/sh CXX = @CXX@ AR = @AR@ #ARFLAGS = @ARFLAGS@ RM = rm RANLIB = @RANLIB@ DEFS = @DEFS@ LIBS = @LIBS@ -L ../libdwarf -ldwarf -lelf INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libdwarf CXXFLAGS = @CXXFLAGS@ $(INCLUDES) LDFLAGS = @LDFLAGS@ $(LIBS) DIRINC = $(srcdir)/../libdwarf INSTALL = cp binprefix = DGOBJECTS = \ createirepformfrombinary.o \ createirepfrombinary.o \ dwarfgen.o \ irepattrtodbg.o \ ireptodbg.o HEADERS = \ createirepfrombinary.h\ general.h \ irepattrtodbg.h \ irepdie.h \ irepframe.h \ irepform.h \ irepmacro.h \ irepresentation.h \ ireptodbg.h \ strtabdata.h all: dwarfgen default: $(TARGETS) dwarfgen: $(HEADERS) $(DGOBJECTS) $(CXX) $(CXXFLAGS) -o $@ $(DGOBJECTS) $(LDFLAGS) test: install: all $(INSTALL) $(srcdir)/dwarfgen.conf $(libdir)/dwarfgen.conf $(INSTALL) $(srcdir)/dwarfgen.1 $(man1dir)/dwarfgen.1 $(INSTALL) dwarfgen $(bindir)/dwarfgen clean: -rm -f *.o dwarfgen uninstall: -rm -f $(libdir)/dwarfgen.conf -rm -f $(man1dir)/dwarfgen.1 -rm -f $(bindir)/dwarfgen distclean: clean -rm -f config.log config.h config.cache config.status rm -rf autom4te.cache rm -f Makefile shar: @echo "shar not set up." dist: @echo "dist not set up." dwarf-20120410/BLDLIBDWARF0000750000175000017500000000052311741100175013424 0ustar daveadavea#!/bin/sh # bldone () { t=$1 cd $t # The following distclean will fail on a clean directory # Ignore the failure make distclean ./configure if [ $? != 0 ] then echo build failed exit fi make if [ $? != 0 ] then echo build failed exit fi cd .. } bldone libdwarf bldone dwarfdump bldone dwarfdump2 dwarf-20120410/dwarfdump/0000750000175000017500000000000011741100175013753 5ustar daveadaveadwarf-20120410/dwarfdump/print_abbrevs.c0000640000175000017500000002543111741100175016765 0ustar daveadavea/* Copyright (C) 2000-2006 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright 2007-2010 Sun Microsystems, Inc. All rights reserved. Portions Copyright 2009-2011 SN Systems Ltd. All rights reserved. Portions Copyright 2008-2011 David Anderson. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/print_sections.c,v 1.69 2006/04/17 00:09:56 davea Exp $ */ /* The address of the Free Software Foundation is Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. SGI has moved from the Crittenden Lane address. */ #include "globals.h" #include "naming.h" #include "dwconf.h" #include "esb.h" #include "print_sections.h" /* The following relevent for one specific Linker. */ #define SNLINKER_MAX_ATTRIB_COUNT 16 /* Print data in .debug_abbrev This is inherently unsafe as it assumes there are no byte sequences in .debug_abbrev other than legal abbrev sequences. But the Dwarf spec does not promise that. The spec only promises that any bytes at an offset referred to from .debug_info are legal sequences. */ extern void print_abbrevs(Dwarf_Debug dbg) { Dwarf_Abbrev ab; Dwarf_Unsigned offset = 0; Dwarf_Unsigned length = 0; Dwarf_Unsigned abbrev_entry_count = 0; /* Maximum defined tag is 0xffff, DW_TAG_hi_user. */ Dwarf_Half tag = 0; Dwarf_Half attr = 0; Dwarf_Signed form = 0; Dwarf_Off off = 0; Dwarf_Unsigned i = 0; const char * child_name = 0; Dwarf_Unsigned abbrev_num = 1; Dwarf_Signed child_flag = 0; int abres = 0; int tres = 0; int acres = 0; Dwarf_Unsigned abbrev_code = 0; current_section_id = DEBUG_ABBREV; if (do_print_dwarf) { printf("\n.debug_abbrev\n"); } while ((abres = dwarf_get_abbrev(dbg, offset, &ab, &length, &abbrev_entry_count, &err)) == DW_DLV_OK) { if (abbrev_entry_count == 0) { /* Simple innocuous zero : null abbrev entry */ if (dense) { printf("<%" DW_PR_DUu "><0x%" DW_PR_XZEROS DW_PR_DUx "><%" DW_PR_DSd "><%s>\n", abbrev_num, offset, (Dwarf_Signed) /* abbrev_code */ 0, "null .debug_abbrev entry"); } else { printf("<%5" DW_PR_DUu "><0x%" DW_PR_XZEROS DW_PR_DUx "> %-20s\n", abbrev_num, offset, (Dwarf_Signed) /* abbrev_code */ 0, "null .debug_abbrev entry"); } offset += length; ++abbrev_num; dwarf_dealloc(dbg, ab, DW_DLA_ABBREV); continue; } tres = dwarf_get_abbrev_tag(ab, &tag, &err); if (tres != DW_DLV_OK) { dwarf_dealloc(dbg, ab, DW_DLA_ABBREV); print_error(dbg, "dwarf_get_abbrev_tag", tres, err); } tres = dwarf_get_abbrev_code(ab, &abbrev_code, &err); if (tres != DW_DLV_OK) { dwarf_dealloc(dbg, ab, DW_DLA_ABBREV); print_error(dbg, "dwarf_get_abbrev_code", tres, err); } if (dense) { printf("<%" DW_PR_DUu "><0x%" DW_PR_XZEROS DW_PR_DUx "><%" DW_PR_DSd "><%s>", abbrev_num, offset, abbrev_code, get_TAG_name(tag,dwarf_names_print_on_error)); } else { printf("<%5" DW_PR_DUu "><0x%" DW_PR_XZEROS DW_PR_DUx "> %-20s", abbrev_num, offset, abbrev_code, get_TAG_name(tag,dwarf_names_print_on_error)); } /* Process specific TAGs specially. */ tag_specific_checks_setup(tag,0); ++abbrev_num; acres = dwarf_get_abbrev_children_flag(ab, &child_flag, &err); if (acres == DW_DLV_ERROR) { dwarf_dealloc(dbg, ab, DW_DLA_ABBREV); print_error(dbg, "dwarf_get_abbrev_children_flag", acres, err); } if (acres == DW_DLV_NO_ENTRY) { child_flag = 0; } child_name = get_children_name(child_flag, dwarf_names_print_on_error); if (dense) printf(" %s", child_name); else printf(" %s\n", child_name); /* Abbrev just contains the format of a die, which debug_info then points to with the real data. So here we just print the given format. */ for (i = 0; i < abbrev_entry_count; i++) { int aeres = 0; aeres = dwarf_get_abbrev_entry(ab, i, &attr, &form, &off, &err); if (aeres == DW_DLV_ERROR) { dwarf_dealloc(dbg, ab, DW_DLA_ABBREV); print_error(dbg, "dwarf_get_abbrev_entry", aeres, err); } if (aeres == DW_DLV_NO_ENTRY) { attr = -1LL; form = -1LL; } if (dense) { printf(" <%ld>%s<%s>", (unsigned long) off, get_AT_name(attr,dwarf_names_print_on_error), get_FORM_name((Dwarf_Half) form, dwarf_names_print_on_error)); } else { printf(" <0x%08lx> %-28s%s\n", (unsigned long) off, get_AT_name(attr, dwarf_names_print_on_error), get_FORM_name((Dwarf_Half) form, dwarf_names_print_on_error)); } } dwarf_dealloc(dbg, ab, DW_DLA_ABBREV); offset += length; if (dense) { printf("\n"); } } if (abres == DW_DLV_ERROR) { print_error(dbg, "dwarf_get_abbrev", abres, err); } } /* Number of abbreviations for current CU */ static Dwarf_Unsigned CU_abbrev_count = 0; /* Abbreviations array info for checking abbrev tags. The [zero] entry is not used. We never shrink the array, but it never grows beyond the largest abbreviation count of all the CUs. */ static Dwarf_Signed *abbrev_array = NULL; /* Size of the array, the same as the abbrev tag count of the CU with the most of them. */ static Dwarf_Unsigned abbrev_array_size = 0; #define ABBREV_ARRAY_INITIAL_SIZE 64 /* Calculate the number of abbreviations for the current CU and set up a basic abbreviations array info, storing the number of attributes per abbreviation. */ void get_abbrev_array_info(Dwarf_Debug dbg, Dwarf_Unsigned offset_in) { Dwarf_Unsigned offset = offset_in; if (check_abbreviations) { Dwarf_Abbrev ab; Dwarf_Unsigned length = 0; Dwarf_Unsigned abbrev_entry_count = 0; Dwarf_Unsigned abbrev_code; int abres = DW_DLV_OK; Dwarf_Error err; Dwarf_Bool bMore = TRUE; CU_abbrev_count = 0; if (abbrev_array == NULL) { /* Allocate initial abbreviation array info */ abbrev_array = (Dwarf_Signed *) calloc(ABBREV_ARRAY_INITIAL_SIZE+1,sizeof(Dwarf_Signed)); abbrev_array_size = ABBREV_ARRAY_INITIAL_SIZE; } else { /* Clear out values from previous CU */ memset((void *)abbrev_array,0, (abbrev_array_size+1) * sizeof(Dwarf_Signed)); } while (bMore && (abres = dwarf_get_abbrev(dbg, offset, &ab, &length, &abbrev_entry_count, &err)) == DW_DLV_OK) { dwarf_get_abbrev_code(ab,&abbrev_code,&err); if (abbrev_code == 0) { /* End of abbreviation table for this CU */ ++offset; /* Skip abbreviation code */ bMore = FALSE; } else { /* Valid abbreviation code */ if (abbrev_code > 0) { if (abbrev_code > abbrev_array_size) { /* Resize abbreviation array */ abbrev_array_size *= 2; abbrev_array = (Dwarf_Signed *) realloc(abbrev_array, (abbrev_array_size+1) * sizeof(Dwarf_Signed)); } abbrev_array[abbrev_code] = abbrev_entry_count; ++CU_abbrev_count; offset += length; } else { /* Invalid abbreviation code */ print_error(dbg, "get_abbrev_array_info", abres, err); } } dwarf_dealloc(dbg, ab, DW_DLA_ABBREV); } } } /* Validate an abbreviation for the current CU. */ void validate_abbrev_code(Dwarf_Debug dbg,Dwarf_Unsigned abbrev_code) { char buf[128]; DWARF_CHECK_COUNT(abbreviations_result,1); if (abbrev_code < 0 || (abbrev_code && abbrev_code > CU_abbrev_count)) { snprintf(buf, sizeof(buf), "Abbrev code %" DW_PR_DUu " outside valid range of [0-%" DW_PR_DUu "]", abbrev_code,CU_abbrev_count); DWARF_CHECK_ERROR2(abbreviations_result,buf, "Invalid abbreviation code."); } else { Dwarf_Signed abbrev_entry_count = abbrev_array[abbrev_code]; if (abbrev_entry_count < 0 || abbrev_entry_count > SNLINKER_MAX_ATTRIB_COUNT) { snprintf(buf, sizeof(buf), "Abbrev code %" DW_PR_DUu ", with %" DW_PR_DUu " attributes: " "outside valid range.", abbrev_code, abbrev_entry_count); DWARF_CHECK_ERROR2(abbreviations_result,buf, "Invalid number of attributes."); } } } dwarf-20120410/dwarfdump/tag_attr.list0000640000175000017500000003752311741100175016470 0ustar daveadavea/* Copyright (C) 2000-2010 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright (C) 2009-2011 David Anderson. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2.1 of the GNU Lesser General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/tag_attr.list,v 1.7 2005/12/01 17:34:59 davea Exp $ */ #include /* list for semantic check of tag-attr relation. 0xffffffff is a "punctuation." The final line of this file must be 0xffffffff. The next line after each 0xffffffff (except the final line) is a tag. The lines after this line before the next 0xffffffff are the attributes that can be given to the tag." For example, 0xffffffff DW_TAG_access_declaration DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_accessibility DW_AT_name DW_AT_sibling 0xffffffff means "only DW_AT_decl_column, DW_AT_decl_file, DW_AT_decl_line, DW_AT_accessibility, DW_AT_name and DW_AT_sibling can be given to DW_TAG_access_declaration." This file is applied to the preprocessor, thus any C comment and preprocessor control line is available. */ 0xffffffff DW_TAG_access_declaration DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_accessibility DW_AT_name DW_AT_sibling 0xffffffff DW_TAG_array_type DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_abstract_origin DW_AT_accessibility DW_AT_allocated DW_AT_associated DW_AT_bit_stride DW_AT_byte_size DW_AT_bit_size /* Allowed in DWARF4 */ DW_AT_data_location DW_AT_declaration DW_AT_description DW_AT_name DW_AT_ordering DW_AT_sibling DW_AT_specification DW_AT_start_scope DW_AT_type DW_AT_visibility 0xffffffff DW_TAG_base_type DW_AT_allocated DW_AT_associated DW_AT_binary_scale DW_AT_bit_offset DW_AT_bit_size DW_AT_byte_size DW_AT_bit_size /* Allowed in DWARF4 */ DW_AT_data_bit_offset DW_AT_data_location DW_AT_decimal_scale DW_AT_decimal_sign DW_AT_description DW_AT_digit_count DW_AT_encoding DW_AT_endianity DW_AT_name DW_AT_name DW_AT_picture_string DW_AT_sibling DW_AT_small 0xffffffff DW_TAG_catch_block DW_AT_abstract_origin DW_AT_high_pc DW_AT_low_pc DW_AT_ranges DW_AT_segment DW_AT_sibling 0xffffffff DW_TAG_class_type DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_abstract_origin DW_AT_accessibility DW_AT_allocated DW_AT_associated DW_AT_byte_size DW_AT_bit_size /* Allowed in DWARF4 */ DW_AT_data_location DW_AT_declaration DW_AT_description DW_AT_name DW_AT_sibling DW_AT_signature DW_AT_specification DW_AT_start_scope DW_AT_visibility 0xffffffff DW_TAG_common_block DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_declaration DW_AT_location DW_AT_name DW_AT_segment DW_AT_sibling DW_AT_visibility 0xffffffff DW_TAG_common_inclusion DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_common_reference DW_AT_declaration DW_AT_sibling DW_AT_visibility 0xffffffff DW_TAG_compile_unit DW_AT_base_types DW_AT_comp_dir DW_AT_identifier_case DW_AT_high_pc DW_AT_language DW_AT_low_pc DW_AT_macro_info DW_AT_main_subprogram DW_AT_name DW_AT_producer DW_AT_ranges DW_AT_segment DW_AT_sibling DW_AT_stmt_list DW_AT_use_UTF8 DW_AT_entry_pc 0xffffffff DW_TAG_condition DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_name DW_AT_sibling 0xffffffff DW_TAG_const_type DW_AT_allocated DW_AT_associated DW_AT_data_location DW_AT_name DW_AT_sibling DW_AT_type 0xffffffff DW_TAG_constant DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_accessibility DW_AT_const_value DW_AT_declaration DW_AT_description DW_AT_endianity DW_AT_external DW_AT_linkage_name DW_AT_name DW_AT_sibling DW_AT_start_scope DW_AT_type DW_AT_visibility 0xffffffff DW_TAG_dwarf_procedure DW_AT_location 0xffffffff DW_TAG_entry_point DW_AT_address_class DW_AT_description DW_AT_linkage_name DW_AT_low_pc DW_AT_name DW_AT_return_addr DW_AT_segment DW_AT_sibling DW_AT_static_link DW_AT_type 0xffffffff DW_TAG_enumeration_type DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_abstract_origin DW_AT_accessibility DW_AT_allocated DW_AT_associated DW_AT_bit_stride DW_AT_byte_size DW_AT_bit_size /* Allowed in DWARF4 */ DW_AT_byte_stride DW_AT_data_location DW_AT_declaration DW_AT_description DW_AT_enum_class DW_AT_name DW_AT_sibling DW_AT_signature DW_AT_specification DW_AT_start_scope DW_AT_type DW_AT_visibility 0xffffffff DW_TAG_enumerator DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_const_value DW_AT_description DW_AT_name DW_AT_sibling 0xffffffff DW_TAG_file_type DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_abstract_origin DW_AT_allocated DW_AT_associated DW_AT_byte_size DW_AT_bit_size /* Allowed in DWARF4 */ DW_AT_data_location DW_AT_description DW_AT_name DW_AT_sibling DW_AT_start_scope DW_AT_type DW_AT_visibility 0xffffffff DW_TAG_formal_parameter DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_abstract_origin DW_AT_artificial DW_AT_const_value DW_AT_default_value DW_AT_description DW_AT_endianity DW_AT_is_optional DW_AT_location DW_AT_name DW_AT_segment DW_AT_sibling DW_AT_type DW_AT_variable_parameter 0xffffffff DW_TAG_friend DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_abstract_origin DW_AT_friend DW_AT_sibling 0xffffffff DW_TAG_imported_declaration DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_accessibility DW_AT_description DW_AT_import DW_AT_name DW_AT_sibling DW_AT_start_scope 0xffffffff DW_TAG_imported_module DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_import DW_AT_sibling DW_AT_start_scope 0xffffffff DW_TAG_imported_unit DW_AT_import 0xffffffff DW_TAG_inheritance DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_accessibility DW_AT_data_member_location DW_AT_sibling DW_AT_type DW_AT_virtuality 0xffffffff DW_TAG_inlined_subroutine DW_AT_abstract_origin DW_AT_call_column DW_AT_call_file DW_AT_call_line DW_AT_const_expr DW_AT_entry_pc DW_AT_high_pc DW_AT_low_pc DW_AT_ranges DW_AT_return_addr DW_AT_segment DW_AT_sibling DW_AT_start_scope DW_AT_trampoline 0xffffffff DW_TAG_interface_type DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_accessibility DW_AT_description DW_AT_name DW_AT_sibling DW_AT_start_scope 0xffffffff DW_TAG_label DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_abstract_origin DW_AT_description DW_AT_low_pc DW_AT_name DW_AT_segment DW_AT_start_scope DW_AT_sibling 0xffffffff DW_TAG_lexical_block DW_AT_abstract_origin DW_AT_description DW_AT_high_pc DW_AT_low_pc DW_AT_name DW_AT_ranges DW_AT_segment DW_AT_sibling 0xffffffff DW_TAG_member DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_accessibility DW_AT_bit_offset DW_AT_bit_size DW_AT_byte_size DW_AT_bit_size /* Allowed in DWARF4 */ DW_AT_data_bit_offset DW_AT_data_member_location DW_AT_declaration DW_AT_description DW_AT_mutable DW_AT_name DW_AT_sibling DW_AT_type DW_AT_visibility DW_AT_artificial 0xffffffff DW_TAG_module DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_accessibility DW_AT_declaration DW_AT_description DW_AT_entry_pc DW_AT_high_pc DW_AT_low_pc DW_AT_name DW_AT_priority DW_AT_segment DW_AT_sibling DW_AT_specification DW_AT_visibility 0xffffffff DW_TAG_namelist DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_accessibility DW_AT_abstract_origin DW_AT_declaration DW_AT_name DW_AT_sibling DW_AT_visibility 0xffffffff DW_TAG_namelist_item DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_namelist_item DW_AT_sibling 0xffffffff DW_TAG_namespace DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_description DW_AT_extension DW_AT_name DW_AT_sibling DW_AT_start_scope 0xffffffff DW_TAG_packed_type DW_AT_allocated DW_AT_associated DW_AT_data_location DW_AT_name DW_AT_sibling DW_AT_type 0xffffffff DW_TAG_partial_unit DW_AT_base_types DW_AT_comp_dir DW_AT_description DW_AT_identifier_case DW_AT_high_pc DW_AT_language DW_AT_low_pc DW_AT_macro_info DW_AT_main_subprogram DW_AT_name DW_AT_producer DW_AT_ranges DW_AT_segment DW_AT_sibling DW_AT_stmt_list DW_AT_use_UTF8 0xffffffff DW_TAG_pointer_type DW_AT_address_class DW_AT_allocated DW_AT_associated DW_AT_data_location DW_AT_name DW_AT_sibling DW_AT_specification DW_AT_type /* Comment from 1993: "Though DWARF spec doesn't refer to DW_AT_byte_size, it may well be given to DW_TAG_pointer_type." Comment 31 January 2009: Discussed in the dwarf-workgroup mailing list Jan 5 2009, that DW_AT_byte_size is allowed. */ DW_AT_byte_size DW_AT_bit_size /* Allowed in DWARF4 (if DW_AT_byte_size allowed) */ 0xffffffff DW_TAG_ptr_to_member_type DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_abstract_origin DW_AT_address_class DW_AT_allocated DW_AT_associated DW_AT_containing_type DW_AT_data_location DW_AT_declaration DW_AT_description DW_AT_name DW_AT_sibling DW_AT_type DW_AT_use_location DW_AT_visibility 0xffffffff DW_TAG_rvalue_reference_type DW_AT_address_class DW_AT_allocated DW_AT_associated DW_AT_data_location DW_AT_name DW_AT_sibling DW_AT_type 0xffffffff DW_TAG_reference_type DW_AT_address_class DW_AT_allocated DW_AT_associated DW_AT_data_location DW_AT_name DW_AT_sibling DW_AT_type /* Comment from 1993: "Though DWARF spec doesn't refer to DW_AT_byte_size, it may well be given to DW_TAG_pointer_type." Comment 31 January 2009: Discussed in the dwarf-workgroup mailing list Jan 5 2009, that DW_AT_byte_size is allowed. */ DW_AT_byte_size DW_AT_bit_size /* Allowed in DWARF4 */ 0xffffffff DW_TAG_template_alias DW_AT_abstract_origin DW_AT_accessibility DW_AT_allocated DW_AT_associated DW_AT_data_location DW_AT_declaration DW_AT_description DW_AT_name DW_AT_sibling DW_AT_signature DW_AT_start_scope DW_AT_type DW_AT_visibility 0xffffffff DW_TAG_restrict_type DW_AT_allocated DW_AT_associated DW_AT_data_location DW_AT_name DW_AT_sibling DW_AT_type 0xffffffff DW_TAG_set_type DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_abstract_origin DW_AT_accessibility DW_AT_allocated DW_AT_associated DW_AT_byte_size DW_AT_bit_size /* Allowed in DWARF4 */ DW_AT_data_location DW_AT_declaration DW_AT_description DW_AT_name DW_AT_start_scope DW_AT_sibling DW_AT_type DW_AT_visibility 0xffffffff DW_TAG_shared_type DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_count DW_AT_name DW_AT_sibling DW_AT_type 0xffffffff DW_TAG_string_type DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_abstract_origin DW_AT_accessibility DW_AT_allocated DW_AT_associated DW_AT_byte_size DW_AT_bit_size /* Allowed in DWARF4 */ DW_AT_data_location DW_AT_declaration DW_AT_description DW_AT_name DW_AT_segment DW_AT_sibling DW_AT_start_scope DW_AT_string_length DW_AT_visibility 0xffffffff DW_TAG_structure_type DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_abstract_origin DW_AT_accessibility DW_AT_allocated DW_AT_associated DW_AT_byte_size DW_AT_bit_size /* Allowed in DWARF4 */ DW_AT_containing_type DW_AT_data_location DW_AT_declaration DW_AT_description DW_AT_name DW_AT_sibling DW_AT_signature DW_AT_specification DW_AT_start_scope DW_AT_visibility 0xffffffff DW_TAG_subprogram DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_abstract_origin DW_AT_accessibility DW_AT_address_class DW_AT_artificial DW_AT_calling_convention DW_AT_containing_type DW_AT_declaration DW_AT_description DW_AT_elemental DW_AT_entry_pc DW_AT_explicit DW_AT_external DW_AT_frame_base DW_AT_high_pc DW_AT_inline DW_AT_linkage_name DW_AT_low_pc DW_AT_main_subprogram DW_AT_name DW_AT_object_pointer DW_AT_prototyped DW_AT_pure DW_AT_ranges DW_AT_recursive DW_AT_return_addr DW_AT_segment DW_AT_sibling DW_AT_specification DW_AT_start_scope DW_AT_static_link DW_AT_trampoline DW_AT_type DW_AT_visibility DW_AT_virtuality DW_AT_vtable_elem_location 0xffffffff DW_TAG_subrange_type DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_abstract_origin DW_AT_accessibility DW_AT_allocated DW_AT_associated DW_AT_bit_stride DW_AT_byte_size DW_AT_bit_size /* Allowed in DWARF4 */ DW_AT_byte_stride DW_AT_count DW_AT_data_location DW_AT_declaration DW_AT_description DW_AT_lower_bound DW_AT_name DW_AT_sibling DW_AT_threads_scaled DW_AT_type DW_AT_upper_bound DW_AT_visibility 0xffffffff DW_TAG_subroutine_type DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_abstract_origin DW_AT_accessibility DW_AT_address_class DW_AT_allocated DW_AT_associated DW_AT_data_location DW_AT_declaration DW_AT_description DW_AT_name DW_AT_prototyped DW_AT_sibling DW_AT_start_scope DW_AT_type DW_AT_visibility 0xffffffff DW_TAG_template_type_parameter DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_description DW_AT_name DW_AT_sibling DW_AT_type 0xffffffff DW_TAG_template_value_parameter DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_const_value DW_AT_description DW_AT_name DW_AT_sibling DW_AT_type 0xffffffff DW_TAG_thrown_type DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_allocated DW_AT_associated DW_AT_data_location DW_AT_sibling DW_AT_type 0xffffffff DW_TAG_try_block DW_AT_abstract_origin DW_AT_high_pc DW_AT_low_pc DW_AT_ranges DW_AT_segment DW_AT_sibling 0xffffffff DW_TAG_typedef DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_abstract_origin DW_AT_accessibility DW_AT_allocated DW_AT_associated DW_AT_data_location DW_AT_declaration DW_AT_description DW_AT_name DW_AT_sibling DW_AT_start_scope DW_AT_type DW_AT_visibility 0xffffffff DW_TAG_union_type DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_abstract_origin DW_AT_accessibility DW_AT_allocated DW_AT_associated DW_AT_byte_size DW_AT_bit_size /* Allowed in DWARF4 */ DW_AT_data_location DW_AT_declaration DW_AT_description DW_AT_name DW_AT_sibling DW_AT_signature DW_AT_specification DW_AT_start_scope DW_AT_visibility 0xffffffff DW_TAG_unspecified_parameters DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_abstract_origin DW_AT_artificial DW_AT_sibling 0xffffffff DW_TAG_unspecified_type DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_description DW_AT_sibling 0xffffffff DW_TAG_variable DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_abstract_origin DW_AT_accessibility DW_AT_byte_size DW_AT_bit_size /* Allowed in DWARF4 */ DW_AT_const_expr DW_AT_const_value DW_AT_declaration DW_AT_description DW_AT_endianity DW_AT_external DW_AT_linkage_name DW_AT_location DW_AT_name DW_AT_segment DW_AT_sibling DW_AT_specification DW_AT_start_scope DW_AT_type DW_AT_visibility DW_AT_artificial 0xffffffff DW_TAG_variant DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_accessibility DW_AT_abstract_origin DW_AT_declaration DW_AT_discr_list DW_AT_discr_value DW_AT_sibling 0xffffffff DW_TAG_variant_part DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_accessibility DW_AT_abstract_origin DW_AT_declaration DW_AT_discr DW_AT_sibling DW_AT_type 0xffffffff DW_TAG_volatile_type DW_AT_allocated DW_AT_associated DW_AT_data_location DW_AT_name DW_AT_sibling DW_AT_type 0xffffffff DW_TAG_with_stmt DW_AT_accessibility DW_AT_address_class DW_AT_declaration DW_AT_high_pc DW_AT_location DW_AT_low_pc DW_AT_ranges DW_AT_segment DW_AT_sibling DW_AT_type DW_AT_visibility 0xffffffff DW_TAG_type_unit DW_AT_language 0xffffffff dwarf-20120410/dwarfdump/print_die.c0000640000175000017500000037127311741100175016112 0ustar daveadavea/* Copyright (C) 2000-2006 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright 2007-2010 Sun Microsystems, Inc. All rights reserved. Portions Copyright 2009-2011 SN Systems Ltd. All rights reserved. Portions Copyright 2007-2011 David Anderson. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $ Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/print_die.c,v 1.51 2006/04/01 16:20:21 davea Exp $ */ /* The address of the Free Software Foundation is Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. SGI has moved from the Crittenden Lane address. */ #include "globals.h" #include "naming.h" #include "esb.h" /* For flexible string buffer. */ #include "makename.h" /* Non-duplicating string table. */ #include "print_frames.h" /* for get_string_from_locs() . */ #include "tag_common.h" /* Traverse a DIE and attributes to check self references */ static boolean traverse_one_die(Dwarf_Debug dbg, Dwarf_Attribute attrib, Dwarf_Die die, char **srcfiles, Dwarf_Signed cnt, int die_indent_level); static boolean traverse_attribute(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Half attr, Dwarf_Attribute attr_in, boolean print_information, char **srcfiles, Dwarf_Signed cnt, int die_indent_level); static void print_die_and_children_internal(Dwarf_Debug dbg, Dwarf_Die in_die_in, Dwarf_Bool is_info, char **srcfiles, Dwarf_Signed cnt); static int print_one_die_section(Dwarf_Debug dbg,Dwarf_Bool is_info); /* Is this a PU has been invalidated by the SN Systems linker? */ #define IsInvalidCode(low,high) ((low == elf_max_address) || (low == 0 && high == 0)) static int get_form_values(Dwarf_Attribute attrib, Dwarf_Half * theform, Dwarf_Half * directform); static void show_form_itself(int show_form,int verbose, int theform, int directform, struct esb_s * str_out); static void print_exprloc_content(Dwarf_Debug dbg,Dwarf_Die die, Dwarf_Attribute attrib, int showhextoo, struct esb_s *esbp); static boolean print_attribute(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Half attr, Dwarf_Attribute actual_addr, boolean print_information, int die_indent_level, char **srcfiles, Dwarf_Signed cnt); static void get_location_list(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Attribute attr, struct esb_s *esbp); static int legal_tag_attr_combination(Dwarf_Half tag, Dwarf_Half attr); static int legal_tag_tree_combination(Dwarf_Half parent_tag, Dwarf_Half child_tag); static int _dwarf_print_one_expr_op(Dwarf_Debug dbg,Dwarf_Loc* expr, int index, struct esb_s *string_out); static int formxdata_print_value(Dwarf_Debug dbg,Dwarf_Attribute attrib, struct esb_s *esbp, Dwarf_Error * err, Dwarf_Bool hex_format); /* esb_base is static so gets initialized to zeros. It is not thread-safe or safe for multiple open producer instances for but that does not matter here in dwarfdump. The memory used by esb_base and esb_extra is never freed. */ static struct esb_s esb_base; static struct esb_s esb_extra; static int dwarf_names_print_on_error = 1; static int die_stack_indent_level = 0; static boolean local_symbols_already_began = FALSE; typedef const char *(*encoding_type_func) (unsigned,int doprintingonerr); Dwarf_Off fde_offset_for_cu_low = DW_DLV_BADOFFSET; Dwarf_Off fde_offset_for_cu_high = DW_DLV_BADOFFSET; /* Indicators to record a pair [low,high], these are used in printing DIEs to accumulate the high and low pc across attributes and to record the pair as soon as both are known. Probably would be better to use variables as arguments to print_attribute(). */ static Dwarf_Addr lowAddr = 0; static Dwarf_Addr highAddr = 0; static Dwarf_Bool bSawLow = FALSE; static Dwarf_Bool bSawHigh = FALSE; /* The following too is related to high and low pc attributes of a function. It's misnamed, it really means 'yes, we have high and low pc' if it is TRUE. Defaulting to TRUE seems bogus. */ static Dwarf_Bool in_valid_code = TRUE; struct operation_descr_s { int op_code; int op_count; const char * op_1type; }; struct operation_descr_s opdesc[]= { {DW_OP_addr,1,"addr" }, {DW_OP_deref,0 }, {DW_OP_const1u,1,"1u" }, {DW_OP_const1s,1,"1s" }, {DW_OP_const2u,1,"2u" }, {DW_OP_const2s,1,"2s" }, {DW_OP_const4u,1,"4u" }, {DW_OP_const4s,1,"4s" }, {DW_OP_const8u,1,"8u" }, {DW_OP_const8s,1,"8s" }, {DW_OP_constu,1,"uleb" }, {DW_OP_consts,1,"sleb" }, {DW_OP_dup,0,""}, {DW_OP_drop,0,""}, {DW_OP_over,0,""}, {DW_OP_pick,1,"1u"}, {DW_OP_swap,0,""}, {DW_OP_rot,0,""}, {DW_OP_xderef,0,""}, {DW_OP_abs,0,""}, {DW_OP_and,0,""}, {DW_OP_div,0,""}, {DW_OP_minus,0,""}, {DW_OP_mod,0,""}, {DW_OP_mul,0,""}, {DW_OP_neg,0,""}, {DW_OP_not,0,""}, {DW_OP_or,0,""}, {DW_OP_plus,0,""}, {DW_OP_plus_uconst,1,"uleb"}, {DW_OP_shl,0,""}, {DW_OP_shr,0,""}, {DW_OP_shra,0,""}, {DW_OP_xor,0,""}, {DW_OP_skip,1,"2s"}, {DW_OP_bra,1,"2s"}, {DW_OP_eq,0,""}, {DW_OP_ge,0,""}, {DW_OP_gt,0,""}, {DW_OP_le,0,""}, {DW_OP_lt,0,""}, {DW_OP_ne,0,""}, /* lit0 thru reg31 handled specially, no operands */ /* breg0 thru breg31 handled specially, 1 operand */ {DW_OP_regx,1,"uleb"}, {DW_OP_fbreg,1,"sleb"}, {DW_OP_bregx,2,"uleb"}, {DW_OP_piece,1,"uleb"}, {DW_OP_deref_size,1,"1u"}, {DW_OP_xderef_size,1,"1u"}, {DW_OP_nop,0,""}, {DW_OP_push_object_address,0,""}, {DW_OP_call2,1,"2u"}, {DW_OP_call4,1,"4u"}, {DW_OP_call_ref,1,"off"}, {DW_OP_form_tls_address,0,""}, {DW_OP_call_frame_cfa,0,""}, {DW_OP_bit_piece,2,"uleb"}, {DW_OP_implicit_value,2,"uleb"}, {DW_OP_stack_value,0,""}, {DW_OP_GNU_uninit,0,""}, {DW_OP_GNU_encoded_addr,1,"addr"}, {DW_OP_GNU_implicit_pointer,1,"addr" }, {DW_OP_GNU_entry_value,1,"val" }, /* terminator */ {0,0,""} }; struct die_stack_data_s { Dwarf_Die die_; boolean already_printed_; }; struct die_stack_data_s empty_stack_entry; #define DIE_STACK_SIZE 800 static struct die_stack_data_s die_stack[DIE_STACK_SIZE]; #define SET_DIE_STACK_ENTRY(i,x) { die_stack[i].die_ = x; \ die_stack[die_stack_indent_level].already_printed_ = FALSE; } #define EMPTY_DIE_STACK_ENTRY(i) { die_stack[i] = empty_stack_entry; } static int print_as_info_or_cu() { return (info_flag || cu_name_flag); } /* process each compilation unit in .debug_info */ void print_infos(Dwarf_Debug dbg,Dwarf_Bool is_info) { int nres = 0; if(is_info) { nres = print_one_die_section(dbg,TRUE); if (nres == DW_DLV_ERROR) { char * errmsg = dwarf_errmsg(err); Dwarf_Unsigned myerr = dwarf_errno(err); fprintf(stderr, "%s ERROR: %s: %s (%lu)\n", program_name, "attempting to print .debug_info", errmsg, (unsigned long) myerr); fprintf(stderr, "attempting to continue.\n"); } return; } nres = print_one_die_section(dbg,FALSE); if (nres == DW_DLV_ERROR) { char * errmsg = dwarf_errmsg(err); Dwarf_Unsigned myerr = dwarf_errno(err); fprintf(stderr, "%s ERROR: %s: %s (%lu)\n", program_name, "attempting to print .debug_types", errmsg, (unsigned long) myerr); fprintf(stderr, "attempting to continue.\n"); } } static void print_std_cu_hdr(Dwarf_Unsigned cu_header_length, Dwarf_Unsigned abbrev_offset, Dwarf_Half version_stamp, Dwarf_Half address_size) { if(dense) { printf(" %s<0x%" DW_PR_XZEROS DW_PR_DUx ">", "cu_header_length", cu_header_length); printf(" %s<0x%04x>", "version_stamp", version_stamp); printf(" %s<0x%" DW_PR_XZEROS DW_PR_DUx ">", "abbrev_offset", abbrev_offset); printf(" %s<0x%02x>", "address_size", address_size); } else { printf(" %-16s = 0x%" DW_PR_XZEROS DW_PR_DUx " %" DW_PR_DUu "\n", "cu_header_length", cu_header_length, cu_header_length); printf(" %-16s = 0x%04x %u\n", "version_stamp", version_stamp,version_stamp); printf(" %-16s = 0x%" DW_PR_XZEROS DW_PR_DUx " %" DW_PR_DUu "\n", "abbrev_offset", abbrev_offset, abbrev_offset); printf(" %-16s = 0x%02x %u\n", "address_size", address_size,address_size); } } static void print_std_cu_signature(Dwarf_Sig8 *signature,Dwarf_Unsigned typeoffset) { if(dense) { struct esb_s sig8str; esb_constructor(&sig8str); format_sig8_string(signature,&sig8str); printf(" %s<%s>", "signature",esb_get_string(&sig8str)); printf(" %s<0x%" DW_PR_XZEROS DW_PR_DUx ">", "typeoffset", typeoffset); esb_destructor(&sig8str); } else { struct esb_s sig8str; esb_constructor(&sig8str); format_sig8_string(signature,&sig8str); printf(" %-16s = %s\n", "signature",esb_get_string(&sig8str)); printf(" %-16s = 0x%" DW_PR_XZEROS DW_PR_DUx " %" DW_PR_DUu "\n", "typeoffset", typeoffset,typeoffset); esb_destructor(&sig8str); } } static int print_one_die_section(Dwarf_Debug dbg,Dwarf_Bool is_info) { Dwarf_Unsigned cu_header_length = 0; Dwarf_Unsigned abbrev_offset = 0; Dwarf_Half version_stamp = 0; Dwarf_Half address_size = 0; Dwarf_Half extension_size = 0; Dwarf_Half length_size = 0; Dwarf_Sig8 signature; Dwarf_Unsigned typeoffset = 0; Dwarf_Unsigned next_cu_offset = 0; unsigned loop_count = 0; int nres = DW_DLV_OK; int cu_count = 0; char * cu_short_name = NULL; char * cu_long_name = NULL; char * producer_name = NULL; current_section_id = DEBUG_INFO; if (print_as_info_or_cu() && do_print_dwarf) { if(is_info) { printf("\n.debug_info\n"); } } /* Loop until it fails. */ for(;;++loop_count) { int sres = DW_DLV_OK; Dwarf_Die cu_die = 0; nres = dwarf_next_cu_header_c(dbg, is_info, &cu_header_length, &version_stamp, &abbrev_offset, &address_size, &length_size,&extension_size, &signature, &typeoffset, &next_cu_offset, &err); if (nres == DW_DLV_NO_ENTRY) { return nres; } if( loop_count == 0 &&!is_info && print_as_info_or_cu() && do_print_dwarf) { printf("\n.debug_types\n"); } if (nres != DW_DLV_OK) { return nres; } if(cu_count >= break_after_n_units) { printf("Break at %d\n",cu_count); break; } /* Regardless of any options used, get basic information about the current CU: producer, name */ sres = dwarf_siblingof_b(dbg, NULL,is_info, &cu_die, &err); if (sres != DW_DLV_OK) { print_error(dbg, "siblingof cu header", sres, err); } /* Get the CU offset for easy error reporting */ dwarf_die_offsets(cu_die,&DIE_overall_offset,&DIE_offset,&err); if (cu_name_flag) { if(should_skip_this_cu(dbg,cu_die,err)) { dwarf_dealloc(dbg, cu_die, DW_DLA_DIE); cu_die = 0; ++cu_count; cu_offset = next_cu_offset; continue; } } /* Get producer name for this CU and update compiler list */ get_producer_name(dbg,cu_die,err,&producer_name); update_compiler_target(producer_name); /* Once the compiler table has been updated, see if we need to generate the list of CU compiled by all the producers contained in the elf file */ if (producer_children_flag) { get_cu_name(dbg,cu_die,err,&cu_short_name,&cu_long_name); /* Add CU name to current compiler entry */ add_cu_name_compiler_target(cu_long_name); } /* If the current compiler is not requested by the user, then move to the next CU */ if (!checking_this_compiler()) { dwarf_dealloc(dbg, cu_die, DW_DLA_DIE); ++cu_count; cu_offset = next_cu_offset; cu_die = 0; continue; } /* We have not seen the compile unit yet, reset these error-reporting globals. */ seen_CU = FALSE; need_CU_name = TRUE; need_CU_base_address = TRUE; need_CU_high_address = TRUE; seen_PU_base_address = FALSE; seen_PU_high_address = FALSE; /* Release the 'cu_die' created by the call to 'dwarf_siblingof' at the top of the main loop. */ dwarf_dealloc(dbg, cu_die, DW_DLA_DIE); cu_die = 0; /* For debugging, stale die should be NULL. */ if (info_flag && do_print_dwarf) { if(verbose) { if (dense) { printf("<%s>", "cu_header"); } else { printf("\nCU_HEADER:\n"); } print_std_cu_hdr(cu_header_length,abbrev_offset, version_stamp,address_size); if(!is_info) { print_std_cu_signature(&signature,typeoffset); } if(dense) { printf("\n"); } } else { if(!is_info) { if(dense) { printf("<%s>", "cu_header"); } else { printf("\nCU_HEADER:\n"); } print_std_cu_signature(&signature,typeoffset); if(dense) { printf("\n"); } } } } /* Get abbreviation info for this CU */ get_abbrev_array_info(dbg,abbrev_offset); /* process a single compilation unit in .debug_info. */ sres = dwarf_siblingof_b(dbg, NULL,is_info, &cu_die, &err); if (sres == DW_DLV_OK) { if (print_as_info_or_cu() || search_is_on) { Dwarf_Signed cnt = 0; char **srcfiles = 0; int srcf = dwarf_srcfiles(cu_die, &srcfiles, &cnt, &err); if (srcf != DW_DLV_OK) { srcfiles = 0; cnt = 0; } /* Get the CU offset for easy error reporting */ dwarf_die_offsets(cu_die,&DIE_CU_overall_offset, &DIE_CU_offset,&err); print_die_and_children(dbg, cu_die,is_info, srcfiles, cnt); if (srcf == DW_DLV_OK) { int si = 0; for (si = 0; si < cnt; ++si) { dwarf_dealloc(dbg, srcfiles[si], DW_DLA_STRING); } dwarf_dealloc(dbg, srcfiles, DW_DLA_LIST); } } /* Dump Ranges Information */ if (dump_ranges_info) { PrintBucketGroup(pRangesInfo,TRUE); } /* Traverse the line section if in check mode */ if (line_flag || check_decl_file) { print_line_numbers_this_cu(dbg, cu_die); } dwarf_dealloc(dbg, cu_die, DW_DLA_DIE); cu_die = 0; } else if (sres == DW_DLV_NO_ENTRY) { /* Do nothing I guess. */ } else { print_error(dbg, "Regetting cu_die", sres, err); } ++cu_count; cu_offset = next_cu_offset; } return nres; } static void print_a_die_stack(Dwarf_Debug dbg,char **srcfiles,Dwarf_Signed cnt,int lev) { boolean print_information = TRUE; boolean ignore_die_stack = FALSE; print_one_die(dbg,die_stack[lev].die_,print_information,lev,srcfiles,cnt, ignore_die_stack); } extern void print_die_and_children(Dwarf_Debug dbg, Dwarf_Die in_die_in, Dwarf_Bool is_info, char **srcfiles, Dwarf_Signed cnt) { print_die_and_children_internal(dbg, in_die_in,is_info,srcfiles,cnt); } static void print_die_stack(Dwarf_Debug dbg,char **srcfiles,Dwarf_Signed cnt) { int lev = 0; boolean print_information = TRUE; boolean ignore_die_stack = FALSE; for(lev = 0; lev <= die_stack_indent_level; ++lev) { print_one_die(dbg,die_stack[lev].die_,print_information, lev,srcfiles,cnt, ignore_die_stack); } } /* recursively follow the die tree */ static void print_die_and_children_internal(Dwarf_Debug dbg, Dwarf_Die in_die_in, Dwarf_Bool is_info, char **srcfiles, Dwarf_Signed cnt) { Dwarf_Die child = 0; Dwarf_Die sibling = 0; Dwarf_Error err = 0; int tres = 0; int cdres = 0; Dwarf_Die in_die = in_die_in; for (;;) { SET_DIE_STACK_ENTRY(die_stack_indent_level,in_die); /* Get the CU offset for easy error reporting */ dwarf_die_offsets(in_die,&DIE_overall_offset,&DIE_offset,&err); if (check_tag_tree) { DWARF_CHECK_COUNT(tag_tree_result,1); if (die_stack_indent_level == 0) { Dwarf_Half tag = 0; tres = dwarf_tag(in_die, &tag, &err); if (tres != DW_DLV_OK) { DWARF_CHECK_ERROR(tag_tree_result, "Tag-tree root is not DW_TAG_compile_unit"); } else if (tag == DW_TAG_compile_unit) { /* OK */ } else { DWARF_CHECK_ERROR(tag_tree_result, "tag-tree root is not DW_TAG_compile_unit"); } } else { Dwarf_Half tag_parent = 0; Dwarf_Half tag_child = 0; int pres = 0; int cres = 0; const char *ctagname = ""; const char *ptagname = ""; pres = dwarf_tag(die_stack[die_stack_indent_level - 1].die_, &tag_parent, &err); cres = dwarf_tag(in_die, &tag_child, &err); if (pres != DW_DLV_OK) tag_parent = 0; if (cres != DW_DLV_OK) tag_child = 0; /* Check for specific compiler */ if (checking_this_compiler()) { /* Process specific TAGs. */ tag_specific_checks_setup(tag_child,die_stack_indent_level); if (cres != DW_DLV_OK || pres != DW_DLV_OK) { if (cres == DW_DLV_OK) { ctagname = get_TAG_name(tag_child, dwarf_names_print_on_error); } if (pres == DW_DLV_OK) { ptagname = get_TAG_name(tag_parent, dwarf_names_print_on_error); } DWARF_CHECK_ERROR3(tag_tree_result,ptagname, ctagname, "Tag-tree relation is not standard.."); } else if (legal_tag_tree_combination(tag_parent, tag_child)) { /* OK */ } else { DWARF_CHECK_ERROR3(tag_tree_result, get_TAG_name(tag_parent, dwarf_names_print_on_error), get_TAG_name(tag_child, dwarf_names_print_on_error), "tag-tree relation is not standard."); } } } } if (record_dwarf_error && check_verbose_mode) { record_dwarf_error = FALSE; } /* Here do pre-descent processing of the die. */ { boolean retry_print_on_match = FALSE; boolean ignore_die_stack = FALSE; retry_print_on_match = print_one_die(dbg, in_die, print_as_info_or_cu(), die_stack_indent_level, srcfiles, cnt,ignore_die_stack); if(!print_as_info_or_cu() && retry_print_on_match) { if (display_parent_tree) { print_die_stack(dbg,srcfiles,cnt); } else { if (display_children_tree) { print_a_die_stack(dbg,srcfiles,cnt,die_stack_indent_level); } } if (display_children_tree) { stop_indent_level = die_stack_indent_level; info_flag = TRUE; } } } cdres = dwarf_child(in_die, &child, &err); /* Check for specific compiler */ if (check_abbreviations && checking_this_compiler()) { Dwarf_Half ab_has_child; Dwarf_Bool bError = FALSE; Dwarf_Half tag = 0; tres = dwarf_die_abbrev_children_flag(in_die,&ab_has_child); if (tres == DW_DLV_OK) { DWARF_CHECK_COUNT(abbreviations_result,1); tres = dwarf_tag(in_die, &tag, &err); if (tres == DW_DLV_OK) { switch (tag) { case DW_TAG_array_type: case DW_TAG_class_type: case DW_TAG_compile_unit: case DW_TAG_enumeration_type: case DW_TAG_lexical_block: case DW_TAG_namespace: case DW_TAG_structure_type: case DW_TAG_subprogram: case DW_TAG_subroutine_type: case DW_TAG_union_type: case DW_TAG_entry_point: case DW_TAG_inlined_subroutine: break; default: bError = (cdres == DW_DLV_OK && !ab_has_child) || (cdres == DW_DLV_NO_ENTRY && ab_has_child); if (bError) { DWARF_CHECK_ERROR(abbreviations_result, "check 'dw_children' flag combination."); } break; } } } } /* child first: we are doing depth-first walk */ if (cdres == DW_DLV_OK) { die_stack_indent_level++; SET_DIE_STACK_ENTRY(die_stack_indent_level,0); if(die_stack_indent_level >= DIE_STACK_SIZE ) { print_error(dbg, "compiled in DIE_STACK_SIZE limit exceeded", DW_DLV_OK,err); } print_die_and_children_internal(dbg, child,is_info, srcfiles, cnt); EMPTY_DIE_STACK_ENTRY(die_stack_indent_level); die_stack_indent_level--; if (die_stack_indent_level == 0) local_symbols_already_began = FALSE; dwarf_dealloc(dbg, child, DW_DLA_DIE); child = 0; } else if (cdres == DW_DLV_ERROR) { print_error(dbg, "dwarf_child", cdres, err); } /* Stop the display of all children */ if (display_children_tree && info_flag && stop_indent_level == die_stack_indent_level) { info_flag = FALSE; } cdres = dwarf_siblingof_b(dbg, in_die,is_info, &sibling, &err); if (cdres == DW_DLV_OK) { /* print_die_and_children(dbg, sibling, srcfiles, cnt); We loop around to actually print this, rather than recursing. Recursing is horribly wasteful of stack space. */ } else if (cdres == DW_DLV_ERROR) { print_error(dbg, "dwarf_siblingof", cdres, err); } /* If we have a sibling, verify that its offset is next to the last processed DIE; An incorrect sibling chain is a nasty bug. */ if (cdres == DW_DLV_OK && sibling && check_di_gaps && checking_this_compiler()) { Dwarf_Off glb_off; DWARF_CHECK_COUNT(di_gaps_result,1); if (dwarf_validate_die_sibling(sibling,&glb_off) == DW_DLV_ERROR) { static char msg[128]; Dwarf_Off sib_off; dwarf_dieoffset(sibling,&sib_off,&err); sprintf(msg, "GSIB = 0x%" DW_PR_XZEROS DW_PR_DUx " GOFF = 0x%" DW_PR_XZEROS DW_PR_DUx " Gap = %" DW_PR_DUu " bytes", sib_off,glb_off,sib_off-glb_off); DWARF_CHECK_ERROR2(di_gaps_result, "Incorrect sibling chain",msg); } } /* Here do any post-descent (ie post-dwarf_child) processing of the in_die. */ EMPTY_DIE_STACK_ENTRY(die_stack_indent_level); if (in_die != in_die_in) { /* Dealloc our in_die, but not the argument die, it belongs to our caller. Whether the siblingof call worked or not. */ dwarf_dealloc(dbg, in_die, DW_DLA_DIE); in_die = 0; } if (cdres == DW_DLV_OK) { /* Set to process the sibling, loop again. */ in_die = sibling; } else { /* We are done, no more siblings at this level. */ break; } } /* end for loop on siblings */ return; } /* Print one die on error and verbose or non check mode */ #define PRINTING_DIES (do_print_dwarf || (record_dwarf_error && check_verbose_mode)) /* If print_information is FALSE, check the TAG and if it is a CU die print the information anyway. */ boolean print_one_die(Dwarf_Debug dbg, Dwarf_Die die, boolean print_information, int die_indent_level, char **srcfiles, Dwarf_Signed cnt, boolean ignore_die_stack) { Dwarf_Signed i = 0; Dwarf_Off offset = 0; Dwarf_Off overall_offset = 0; const char * tagname = 0; Dwarf_Half tag = 0; Dwarf_Signed atcnt = 0; Dwarf_Attribute *atlist = 0; int tres = 0; int ores = 0; int atres = 0; int abbrev_code = dwarf_die_abbrev_code(die); boolean attribute_matched = FALSE; /* Print using indentation < 1><0x000854ff GOFF=0x00546047> DW_TAG_pointer_type -> 34 < 1><0x000854ff> DW_TAG_pointer_type -> 18 DW_TAG_pointer_type -> 2 */ /* Attribute indent. */ int nColumn = show_global_offsets ? 34 : 18; if (check_abbreviations && checking_this_compiler()) { validate_abbrev_code(dbg,abbrev_code); } if(!ignore_die_stack && die_stack[die_indent_level].already_printed_) { /* FALSE seems like a safe return. */ return FALSE; } /* Reset indentation column if no offsets */ if (!display_offsets) { nColumn = 2; } tres = dwarf_tag(die, &tag, &err); if (tres != DW_DLV_OK) { print_error(dbg, "accessing tag of die!", tres, err); } tagname = get_TAG_name(tag,dwarf_names_print_on_error); tag_specific_checks_setup(tag,die_indent_level); ores = dwarf_dieoffset(die, &overall_offset, &err); if (ores != DW_DLV_OK) { print_error(dbg, "dwarf_dieoffset", ores, err); } ores = dwarf_die_CU_offset(die, &offset, &err); if (ores != DW_DLV_OK) { print_error(dbg, "dwarf_die_CU_offset", ores, err); } if (dump_visited_info && check_self_references) { printf("<%2d><0x%" DW_PR_XZEROS DW_PR_DUx " GOFF=0x%" DW_PR_XZEROS DW_PR_DUx "> ", die_indent_level, (Dwarf_Unsigned)offset, (Dwarf_Unsigned)overall_offset); printf("%*s%s\n",die_indent_level * 2 + 2," ",tagname); } /* Print the die */ if (PRINTING_DIES && print_information) { if (!ignore_die_stack) { die_stack[die_indent_level].already_printed_ = TRUE; } if (die_indent_level == 0) { if (dense) { printf("\n"); } else { printf("\nCOMPILE_UNIT
:\n", (Dwarf_Unsigned)(overall_offset - offset)); } } else if (local_symbols_already_began == FALSE && die_indent_level == 1 && !dense) { printf("\nLOCAL_SYMBOLS:\n"); local_symbols_already_began = TRUE; } /* Print just the Tags and Attributes */ if (!display_offsets) { /* Print using indentation */ printf("%*s%s\n",die_stack_indent_level * 2 + 2," ",tagname); } else { if (dense) { if (show_global_offsets) { if (die_indent_level == 0) { printf("<%d><0x%" DW_PR_DUx "+0x%" DW_PR_DUx " GOFF=0x%" DW_PR_DUx ">", die_indent_level, (Dwarf_Unsigned)(overall_offset - offset), (Dwarf_Unsigned)offset, (Dwarf_Unsigned)overall_offset); } else { printf("<%d><0x%" DW_PR_DUx " GOFF=0x%" DW_PR_DUx ">", die_indent_level, (Dwarf_Unsigned)offset, (Dwarf_Unsigned)overall_offset); } } else { if (die_indent_level == 0) { printf("<%d><0x%" DW_PR_DUx "+0x%" DW_PR_DUx ">", die_indent_level, (Dwarf_Unsigned)(overall_offset - offset), (Dwarf_Unsigned)offset); } else { printf("<%d><0x%" DW_PR_DUx ">", die_indent_level, (Dwarf_Unsigned)offset); } } printf("<%s>",tagname); if(verbose) { printf(" ",abbrev_code); } } else { if (show_global_offsets) { printf("<%2d><0x%" DW_PR_XZEROS DW_PR_DUx " GOFF=0x%" DW_PR_XZEROS DW_PR_DUx ">", die_indent_level, (Dwarf_Unsigned)offset, (Dwarf_Unsigned)overall_offset); } else { printf("<%2d><0x%" DW_PR_XZEROS DW_PR_DUx ">", die_indent_level, (Dwarf_Unsigned)offset); } /* Print using indentation */ printf("%*s%s",die_indent_level * 2 + 2," ",tagname); if(verbose) { printf(" ",abbrev_code); } fputs("\n",stdout); } } } atres = dwarf_attrlist(die, &atlist, &atcnt, &err); if (atres == DW_DLV_ERROR) { print_error(dbg, "dwarf_attrlist", atres, err); } else if (atres == DW_DLV_NO_ENTRY) { /* indicates there are no attrs. It is not an error. */ atcnt = 0; } /* Reset any loose references to low or high PC */ bSawLow = FALSE; bSawHigh = FALSE; /* Get the CU offset for easy error reporting */ dwarf_die_offsets(die,&DIE_CU_overall_offset,&DIE_CU_offset,&err); for (i = 0; i < atcnt; i++) { Dwarf_Half attr; int ares; ares = dwarf_whatattr(atlist[i], &attr, &err); if (ares == DW_DLV_OK) { /* Print using indentation */ if (!dense && PRINTING_DIES && print_information) { printf("%*s",die_indent_level * 2 + 2 + nColumn," "); } { boolean attr_match = print_attribute(dbg, die, attr, atlist[i], print_information, die_indent_level, srcfiles, cnt); if(print_information == FALSE && attr_match) { attribute_matched = TRUE; } } if (record_dwarf_error && check_verbose_mode) { record_dwarf_error = FALSE; } } else { print_error(dbg, "dwarf_whatattr entry missing", ares, err); } } for (i = 0; i < atcnt; i++) { dwarf_dealloc(dbg, atlist[i], DW_DLA_ATTR); } if (atres == DW_DLV_OK) { dwarf_dealloc(dbg, atlist, DW_DLA_LIST); } if (PRINTING_DIES && dense && print_information) { printf("\n"); } return attribute_matched; } /* Encodings have undefined signedness. Accept either signedness. The values are integer-like (they are defined in the DWARF specification), so the form the compiler uses (as long as it is a constant value) is a non-issue. The numbers need not be small (in spite of the function name), but the result should be an integer. If string_out is non-NULL, construct a string output, either an error message or the name of the encoding. The function pointer passed in is to code generated by a script at dwarfdump build time. The code for the val_as_string function is generated from dwarf.h. See /dwarf_names.c The known_signed bool is set true(nonzero) or false (zero) and *both* uval_out and sval_out are set to the value, though of course uval_out cannot represent a signed value properly and sval_out cannot represent all unsigned values properly. If string_out is non-NULL then attr_name and val_as_string must also be non-NULL. */ static int get_small_encoding_integer_and_name(Dwarf_Debug dbg, Dwarf_Attribute attrib, Dwarf_Unsigned * uval_out, char *attr_name, const char ** string_out, encoding_type_func val_as_string, Dwarf_Error * err, int show_form) { Dwarf_Unsigned uval = 0; char buf[100]; /* The strings are small. */ int vres = dwarf_formudata(attrib, &uval, err); if (vres != DW_DLV_OK) { Dwarf_Signed sval = 0; vres = dwarf_formsdata(attrib, &sval, err); if (vres != DW_DLV_OK) { vres = dwarf_global_formref(attrib,&uval,err); if (vres != DW_DLV_OK) { if (string_out != 0) { snprintf(buf, sizeof(buf), "%s has a bad form.", attr_name); *string_out = makename(buf); } return vres; } *uval_out = uval; } else { uval = (Dwarf_Unsigned) sval; *uval_out = uval; } } else { *uval_out = uval; } if (string_out) { Dwarf_Half theform = 0; Dwarf_Half directform = 0; get_form_values(attrib,&theform,&directform); esb_empty_string(&esb_base); esb_append(&esb_base, val_as_string((Dwarf_Half) uval, dwarf_names_print_on_error)); show_form_itself(show_form, verbose, theform, directform,&esb_base); *string_out = makename(esb_get_string(&esb_base)); } return DW_DLV_OK; } /* We need a 32-bit signed number here, but there's no portable way of getting that. So use __uint32_t instead. It's supplied in a reliable way by the autoconf infrastructure. */ static void get_FLAG_BLOCK_string(Dwarf_Debug dbg, Dwarf_Attribute attrib, struct esb_s*esbp) { int fres = 0; Dwarf_Block *tempb = 0; __uint32_t * array = 0; Dwarf_Unsigned array_len = 0; __uint32_t * array_ptr; Dwarf_Unsigned array_remain = 0; char linebuf[100]; /* first get compressed block data */ fres = dwarf_formblock (attrib,&tempb, &err); if (fres != DW_DLV_OK) { print_error(dbg,"DW_FORM_blockn cannot get block\n",fres,err); return; } /* uncompress block into int array */ array = dwarf_uncompress_integer_block(dbg, 1, /* 'true' (meaning signed ints)*/ 32, /* bits per unit */ tempb->bl_data, tempb->bl_len, &array_len, /* len of out array */ &err); if (array == (void*) DW_DLV_BADOFFSET) { print_error(dbg,"DW_AT_SUN_func_offsets cannot uncompress data\n",0,err); return; } if (array_len == 0) { print_error(dbg,"DW_AT_SUN_func_offsets has no data\n",0,err); return; } /* fill in string buffer */ array_remain = array_len; array_ptr = array; while (array_remain > 8) { /* Print a full line */ /* If you touch this string, update the magic number 8 in the += and -= below! */ snprintf(linebuf, sizeof(linebuf), "\n 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x", array_ptr[0], array_ptr[1], array_ptr[2], array_ptr[3], array_ptr[4], array_ptr[5], array_ptr[6], array_ptr[7]); array_ptr += 8; array_remain -= 8; esb_append(&esb_base, linebuf); } /* now do the last line */ if (array_remain > 0) { esb_append(&esb_base, "\n "); while (array_remain > 0) { snprintf(linebuf, sizeof(linebuf), " 0x%08x", *array_ptr); array_remain--; array_ptr++; esb_append(&esb_base, linebuf); } } /* free array buffer */ dwarf_dealloc_uncompressed_block(dbg, array); } static const char * get_rangelist_type_descr(Dwarf_Ranges *r) { switch(r->dwr_type) { case DW_RANGES_ENTRY: return "range entry"; case DW_RANGES_ADDRESS_SELECTION: return "addr selection"; case DW_RANGES_END: return "range end"; } /* Impossible. */ return "Unknown"; } void print_ranges_list_to_extra(Dwarf_Debug dbg, Dwarf_Unsigned off, Dwarf_Ranges *rangeset, Dwarf_Signed rangecount, Dwarf_Unsigned bytecount, struct esb_s *stringbuf) { char tmp[200]; Dwarf_Signed i; if(dense) { snprintf(tmp,sizeof(tmp), "< ranges: %" DW_PR_DSd " ranges at .debug_ranges offset %" DW_PR_DUu " (0x%" DW_PR_XZEROS DW_PR_DUx ") " "(%" DW_PR_DUu " bytes)>", rangecount, off, off, bytecount); esb_append(stringbuf,tmp); } else { snprintf(tmp,sizeof(tmp), "\t\tranges: %" DW_PR_DSd " at .debug_ranges offset %" DW_PR_DUu " (0x%" DW_PR_XZEROS DW_PR_DUx ") " "(%" DW_PR_DUu " bytes)\n", rangecount, off, off, bytecount); esb_append(stringbuf,tmp); } for(i = 0; i < rangecount; ++i) { Dwarf_Ranges * r = rangeset +i; const char *type = get_rangelist_type_descr(r); if(dense) { snprintf(tmp,sizeof(tmp), "<[%2" DW_PR_DSd "] %s 0x%" DW_PR_XZEROS DW_PR_DUx " 0x%" DW_PR_XZEROS DW_PR_DUx ">", (Dwarf_Signed)i, type, (Dwarf_Unsigned)r->dwr_addr1, (Dwarf_Unsigned)r->dwr_addr2); } else { snprintf(tmp,sizeof(tmp), "\t\t\t[%2" DW_PR_DSd "] %-14s 0x%" DW_PR_XZEROS DW_PR_DUx " 0x%" DW_PR_XZEROS DW_PR_DUx "\n", (Dwarf_Signed)i, type, (Dwarf_Unsigned)r->dwr_addr1, (Dwarf_Unsigned)r->dwr_addr2); } esb_append(stringbuf,tmp); } } static boolean is_location_form(int form) { if(form == DW_FORM_block1 || form == DW_FORM_block2 || form == DW_FORM_block4 || form == DW_FORM_block || form == DW_FORM_data4 || form == DW_FORM_data8 || form == DW_FORM_sec_offset) { return TRUE; } return FALSE; } static void show_attr_form_error(Dwarf_Debug dbg,unsigned attr,unsigned form,struct esb_s *out) { const char *n = 0; int res; char buf[30]; esb_append(out,"ERROR: Attribute "); snprintf(buf,sizeof(buf),"%u",attr); esb_append(out,buf); esb_append(out," ("); res = dwarf_get_AT_name(attr,&n); if(res != DW_DLV_OK) { n = "UknownAttribute"; } esb_append(out,n); esb_append(out,") "); esb_append(out," has form "); snprintf(buf,sizeof(buf),"%u",form); esb_append(out,buf); esb_append(out," ("); res = dwarf_get_FORM_name(form,&n); if(res != DW_DLV_OK) { n = "UknownForm"; } esb_append(out,n); esb_append(out,"), a form which is not appropriate"); print_error_and_continue(dbg,esb_get_string(out), DW_DLV_OK,err); } /* Traverse an attribute and following any reference in order to detect self references to DIES (loop). */ static boolean traverse_attribute(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Half attr, Dwarf_Attribute attr_in, boolean print_information, char **srcfiles, Dwarf_Signed cnt, int die_indent_level) { Dwarf_Attribute attrib = 0; const char * atname = 0; const char * valname = 0; int tres = 0; Dwarf_Half tag = 0; boolean circular_reference = FALSE; Dwarf_Bool is_info = TRUE; is_info = dwarf_get_die_infotypes_flag(die); atname = get_AT_name(attr,dwarf_names_print_on_error); /* The following gets the real attribute, even in the face of an incorrect doubling, or worse, of attributes. */ attrib = attr_in; /* Do not get attr via dwarf_attr: if there are (erroneously) multiple of an attr in a DIE, dwarf_attr will not get the second, erroneous one and dwarfdump will print the first one multiple times. Oops. */ tres = dwarf_tag(die, &tag, &err); if (tres == DW_DLV_ERROR) { tag = 0; } else if (tres == DW_DLV_NO_ENTRY) { tag = 0; } else { /* ok */ } switch (attr) { case DW_AT_specification: case DW_AT_abstract_origin: case DW_AT_type: { int res = 0; Dwarf_Off die_off = 0; Dwarf_Off ref_off = 0; Dwarf_Die ref_die = 0; ++die_indent_level; esb_empty_string(&esb_base); get_attr_value(dbg, tag, die, attrib, srcfiles, cnt, &esb_base, show_form_used,verbose); valname = esb_get_string(&esb_base); /* Get the global offset for reference */ res = dwarf_global_formref(attrib, &ref_off, &err); if (res != DW_DLV_OK) { int errno = dwarf_errno(err); if (errno == DW_DLE_REF_SIG8_NOT_HANDLED ) { // No need to stop, ref_sig8 refers out of // the current section. break; } else { print_error(dbg, "dwarf_global_formref fails in traversal", res, err); } } res = dwarf_dieoffset(die, &die_off, &err); if (res != DW_DLV_OK) { int errno = dwarf_errno(err); if (errno == DW_DLE_REF_SIG8_NOT_HANDLED ) { // No need to stop, ref_sig8 refers out of // the current section. break; } else { print_error(dbg, "dwarf_dieoffset fails in traversal", res, err); } } /* Follow reference chain, looking for self references */ res = dwarf_offdie_b(dbg,ref_off,is_info,&ref_die,&err); if (res == DW_DLV_OK) { ++die_indent_level; /* Dump visited information */ if (dump_visited_info) { Dwarf_Off off = 0; dwarf_die_CU_offset(die, &off, &err); /* Check above call return status? FIXME */ printf("<%2d><0x%" DW_PR_XZEROS DW_PR_DUx " GOFF=0x%" DW_PR_XZEROS DW_PR_DUx "> ", die_indent_level, (Dwarf_Unsigned)off, (Dwarf_Unsigned)die_off); printf("%*s%s -> %s\n",die_indent_level * 2 + 2, " ",atname,valname); } circular_reference = traverse_one_die(dbg,attrib,ref_die, srcfiles,cnt,die_indent_level); DeleteKeyInBucketGroup(pVisitedInfo,ref_off); dwarf_dealloc(dbg,ref_die,DW_DLA_DIE); --die_indent_level; ref_die = 0; } } break; } /* End switch. */ return circular_reference; } /* Traverse one DIE in order to detect self references to DIES. */ static boolean traverse_one_die(Dwarf_Debug dbg, Dwarf_Attribute attrib, Dwarf_Die die, char **srcfiles, Dwarf_Signed cnt, int die_indent_level) { Dwarf_Half tag = 0; Dwarf_Off overall_offset = 0; Dwarf_Signed atcnt = 0; int res = 0; boolean circular_reference = FALSE; boolean print_information = FALSE; res = dwarf_tag(die, &tag, &err); if (res != DW_DLV_OK) { print_error(dbg, "accessing tag of die!", res, err); } res = dwarf_dieoffset(die, &overall_offset, &err); if (res != DW_DLV_OK) { print_error(dbg, "dwarf_dieoffset", res, err); } /* Print visited information */ if (dump_visited_info) { Dwarf_Off offset = 0; const char * tagname = 0; res = dwarf_die_CU_offset(die, &offset, &err); if (res != DW_DLV_OK) { print_error(dbg, "dwarf_die_CU_offsetC", res, err); } tagname = get_TAG_name(tag,dwarf_names_print_on_error); printf("<%2d><0x%" DW_PR_XZEROS DW_PR_DUx " GOFF=0x%" DW_PR_XZEROS DW_PR_DUx "> ", die_indent_level, (Dwarf_Unsigned)offset, (Dwarf_Unsigned)overall_offset); printf("%*s%s\n",die_indent_level * 2 + 2," ",tagname); } DWARF_CHECK_COUNT(self_references_result,1); if (FindKeyInBucketGroup(pVisitedInfo,overall_offset)) { char * valname = NULL; Dwarf_Half attr = 0; const char *atname = NULL; esb_empty_string(&esb_base); get_attr_value(dbg, tag, die, attrib, srcfiles, cnt, &esb_base, show_form_used,verbose); valname = esb_get_string(&esb_base); dwarf_whatattr(attrib, &attr, &err); atname = get_AT_name(attr,dwarf_names_print_on_error); /* We have a self reference */ DWARF_CHECK_ERROR3(self_references_result, "Invalid self reference to DIE: ",atname,valname); circular_reference = TRUE; } else { Dwarf_Signed i = 0; Dwarf_Attribute *atlist = 0; /* Add current DIE */ AddEntryIntoBucketGroup(pVisitedInfo,overall_offset, 0,0,0,NULL,FALSE); res = dwarf_attrlist(die, &atlist, &atcnt, &err); if (res == DW_DLV_ERROR) { print_error(dbg, "dwarf_attrlist", res, err); } else if (res == DW_DLV_NO_ENTRY) { /* indicates there are no attrs. It is not an error. */ atcnt = 0; } for (i = 0; i < atcnt; i++) { Dwarf_Half attr; int ares; ares = dwarf_whatattr(atlist[i], &attr, &err); if (ares == DW_DLV_OK) { circular_reference = traverse_attribute(dbg, die, attr, atlist[i], print_information, srcfiles, cnt, die_indent_level); } else { print_error(dbg, "dwarf_whatattr entry missing", ares, err); } } for (i = 0; i < atcnt; i++) { dwarf_dealloc(dbg, atlist[i], DW_DLA_ATTR); } if (res == DW_DLV_OK) { dwarf_dealloc(dbg, atlist, DW_DLA_LIST); } /* Delete current DIE */ DeleteKeyInBucketGroup(pVisitedInfo,overall_offset); } return circular_reference; } /* Extracted this from print_attribute() to get tolerable indents. In other words to make it readable. It uses global data fields excessively, but so does print_attribute(). The majority of the code here is checking for compiler errors. */ static void print_range_attribute(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Half attr, Dwarf_Attribute attr_in, Dwarf_Half theform, int dwarf_names_print_on_error, boolean print_information, int *append_extra_string) { Dwarf_Error err = 0; Dwarf_Unsigned original_off = 0; int fres = 0; fres = dwarf_global_formref(attr_in, &original_off, &err); if( fres == DW_DLV_OK) { Dwarf_Ranges *rangeset = 0; Dwarf_Signed rangecount = 0; Dwarf_Unsigned bytecount = 0; int rres = dwarf_get_ranges_a(dbg,original_off, die, &rangeset, &rangecount,&bytecount,&err); if(rres == DW_DLV_OK) { /* Ignore ranges inside a stripped function */ if (check_ranges && in_valid_code && checking_this_compiler()) { Dwarf_Unsigned off = original_off; Dwarf_Signed index = 0; Dwarf_Addr base_address = CU_base_address; Dwarf_Addr lopc = 0; Dwarf_Addr hipc = 0; Dwarf_Bool bError = FALSE; /* Ignore last entry, is the end-of-list */ for (index = 0; index < rangecount - 1; index++) { Dwarf_Ranges *r = rangeset + index; if (r->dwr_addr1 == elf_max_address) { /* (0xffffffff,addr), use specific address (current PU address) */ base_address = r->dwr_addr2; } else { /* (offset,offset), update using CU address */ lopc = r->dwr_addr1 + base_address; hipc = r->dwr_addr2 + base_address; DWARF_CHECK_COUNT(ranges_result,1); /* Check the low_pc and high_pc are within a valid range in the .text section */ if (IsValidInBucketGroup(pRangesInfo,lopc) && IsValidInBucketGroup(pRangesInfo,hipc)) { /* Valid values; do nothing */ } else { /* At this point may be we are dealing with a linkonce symbol */ if (IsValidInLinkonce(pLinkonceInfo, PU_name,lopc,hipc)) { /* Valid values; do nothing */ } else { bError = TRUE; DWARF_CHECK_ERROR(ranges_result, ".debug_ranges: Address outside a " "valid .text range"); if (check_verbose_mode) { printf( "Offset = 0x%" DW_PR_XZEROS DW_PR_DUx ", Base = 0x%" DW_PR_XZEROS DW_PR_DUx ", " "Low = 0x%" DW_PR_XZEROS DW_PR_DUx " (0x%" DW_PR_XZEROS DW_PR_DUx "), High = 0x%" DW_PR_XZEROS DW_PR_DUx " (0x%" DW_PR_XZEROS DW_PR_DUx ")\n", off,base_address,lopc, r->dwr_addr1,hipc, r->dwr_addr2); } } } } /* Each entry holds 2 addresses (offsets) */ off += elf_address_size * 2; } if (bError && check_verbose_mode) { printf("\n"); } } if(print_information) { *append_extra_string = 1; esb_empty_string(&esb_extra); print_ranges_list_to_extra(dbg,original_off, rangeset,rangecount,bytecount, &esb_extra); } dwarf_ranges_dealloc(dbg,rangeset,rangecount); } else if (rres == DW_DLV_ERROR) { if (do_print_dwarf) { printf("\ndwarf_get_ranges() " "cannot find DW_AT_ranges at offset 0x%" DW_PR_XZEROS DW_PR_DUx " (0x%" DW_PR_XZEROS DW_PR_DUx ").", original_off, original_off); } else { DWARF_CHECK_COUNT(ranges_result,1); DWARF_CHECK_ERROR2(ranges_result, get_AT_name(attr, dwarf_names_print_on_error), " cannot find DW_AT_ranges at offset"); } } else { /* NO ENTRY */ if (do_print_dwarf) { printf("\ndwarf_get_ranges() " "finds no DW_AT_ranges at offset 0x%" DW_PR_XZEROS DW_PR_DUx " (0x%" DW_PR_XZEROS DW_PR_DUx ").", original_off, original_off); } else { DWARF_CHECK_COUNT(ranges_result,1); DWARF_CHECK_ERROR2(ranges_result, get_AT_name(attr, dwarf_names_print_on_error), " fails to find DW_AT_ranges at offset"); } } } else { if (do_print_dwarf) { struct esb_s local; char tmp[100]; snprintf(tmp,sizeof(tmp)," attr 0x%x form 0x%x ", (unsigned)attr,(unsigned)theform); esb_constructor(&local); esb_append(&local, " fails to find DW_AT_ranges offset"); esb_append(&local,tmp); printf(" %s ",esb_get_string(&local)); esb_destructor(&local); } else { DWARF_CHECK_COUNT(ranges_result,1); DWARF_CHECK_ERROR2(ranges_result, get_AT_name(attr, dwarf_names_print_on_error), " fails to find DW_AT_ranges offset"); } } } /* A DW_AT_name in a CU DIE will likely have dots and be entirely sensible. So lets not call things a possible error when they are not. Some assemblers allow '.' in an identifier too. We should check for that, but we don't yet. We should check the compiler before checking for 'altabi.' too (FIXME). This is a heuristic, not all that reliable. Return 0 if it is a vaguely standard identifier. Else return 1, meaning 'it might be a file name or have '.' in it quite sensibly.' If we don't do the TAG check we might report "t.c" as a questionable DW_AT_name. Which would be silly. */ static int dot_ok_in_identifier(int tag,Dwarf_Die die, const char *val) { if (strncmp(val,"altabi.",7)) { /* Ignore the names of the form 'altabi.name', which apply to one specific compiler. */ return 1; } if(tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit || tag == DW_TAG_imported_unit || tag == DW_TAG_type_unit) { return 1; } return 0; } static void trim_quotes(const char *val,struct esb_s *es) { if(val[0] == '"') { size_t l = strlen(val); if(l > 2 && val[l-1] == '"') { esb_appendn(es,val+1,l-2); return; } } esb_append(es,val); } static int have_a_search_match(const char *valname,const char *atname) { /* valname may have had quotes inserted, but search_match_text will not. So we need to use a new copy, not valname here. */ struct esb_s esb_match; char *s2; esb_constructor(&esb_match); trim_quotes(valname,&esb_match); s2 = esb_get_string(&esb_match); if (search_match_text ) { if(!strcmp(s2,search_match_text) || !strcmp(atname,search_match_text)) { esb_destructor(&esb_match); return TRUE; } } if (search_any_text) { if(is_strstrnocase(s2,search_any_text) || is_strstrnocase(atname,search_any_text)) { esb_destructor(&esb_match); return TRUE; } } #ifdef HAVE_REGEX if (search_regex_text) { if(!regexec(&search_re,s2,0,NULL,0) || !regexec(&search_re,atname,0,NULL,0)) { esb_destructor(&esb_match); return TRUE; } } #endif esb_destructor(&esb_match); return FALSE; } static boolean print_attribute(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Half attr, Dwarf_Attribute attr_in, boolean print_information, int die_indent_level, char **srcfiles, Dwarf_Signed cnt) { Dwarf_Attribute attrib = 0; Dwarf_Unsigned uval = 0; const char * atname = 0; const char * valname = 0; int tres = 0; Dwarf_Half tag = 0; int append_extra_string = 0; boolean found_search_attr = FALSE; boolean bTextFound = FALSE; Dwarf_Bool is_info = FALSE; is_info = dwarf_get_die_infotypes_flag(die); esb_empty_string(&esb_extra); atname = get_AT_name(attr,dwarf_names_print_on_error); /* The following gets the real attribute, even in the face of an incorrect doubling, or worse, of attributes. */ attrib = attr_in; /* Do not get attr via dwarf_attr: if there are (erroneously) multiple of an attr in a DIE, dwarf_attr will not get the second, erroneous one and dwarfdump will print the first one multiple times. Oops. */ tres = dwarf_tag(die, &tag, &err); if (tres == DW_DLV_ERROR) { tag = 0; } else if (tres == DW_DLV_NO_ENTRY) { tag = 0; } else { /* ok */ } if (check_attr_tag && checking_this_compiler()) { const char *tagname = ""; DWARF_CHECK_COUNT(attr_tag_result,1); if (tres == DW_DLV_ERROR) { DWARF_CHECK_ERROR3(attr_tag_result,tagname, get_AT_name(attr,dwarf_names_print_on_error), "check the tag-attr combination, dwarf_tag failed."); } else if (tres == DW_DLV_NO_ENTRY) { DWARF_CHECK_ERROR3(attr_tag_result,tagname, get_AT_name(attr,dwarf_names_print_on_error), "check the tag-attr combination, dwarf_tag NO ENTRY?."); } else if (legal_tag_attr_combination(tag, attr)) { /* OK */ } else { tagname = get_TAG_name(tag,dwarf_names_print_on_error); tag_specific_checks_setup(tag,die_stack_indent_level); DWARF_CHECK_ERROR3(attr_tag_result,tagname, get_AT_name(attr,dwarf_names_print_on_error), "check the tag-attr combination"); } } switch (attr) { case DW_AT_language: get_small_encoding_integer_and_name(dbg, attrib, &uval, "DW_AT_language", &valname, get_LANG_name, &err, show_form_used); break; case DW_AT_accessibility: get_small_encoding_integer_and_name(dbg, attrib, &uval, "DW_AT_accessibility", &valname, get_ACCESS_name, &err, show_form_used); break; case DW_AT_visibility: get_small_encoding_integer_and_name(dbg, attrib, &uval, "DW_AT_visibility", &valname, get_VIS_name, &err, show_form_used); break; case DW_AT_virtuality: get_small_encoding_integer_and_name(dbg, attrib, &uval, "DW_AT_virtuality", &valname, get_VIRTUALITY_name, &err, show_form_used); break; case DW_AT_identifier_case: get_small_encoding_integer_and_name(dbg, attrib, &uval, "DW_AT_identifier", &valname, get_ID_name, &err, show_form_used); break; case DW_AT_inline: get_small_encoding_integer_and_name(dbg, attrib, &uval, "DW_AT_inline", &valname, get_INL_name, &err, show_form_used); break; case DW_AT_encoding: get_small_encoding_integer_and_name(dbg, attrib, &uval, "DW_AT_encoding", &valname, get_ATE_name, &err, show_form_used); break; case DW_AT_ordering: get_small_encoding_integer_and_name(dbg, attrib, &uval, "DW_AT_ordering", &valname, get_ORD_name, &err, show_form_used); break; case DW_AT_calling_convention: get_small_encoding_integer_and_name(dbg, attrib, &uval, "DW_AT_calling_convention", &valname, get_CC_name, &err, show_form_used); break; case DW_AT_discr_list: /* DWARF3 */ get_small_encoding_integer_and_name(dbg, attrib, &uval, "DW_AT_discr_list", &valname, get_DSC_name, &err, show_form_used); break; case DW_AT_data_member_location: { /* Value is a constant or a location description or location list. If a constant, it could be signed or unsigned. Telling whether a constant or a reference is nontrivial since DW_FORM_data{4,8} could be either in DWARF{2,3} */ enum Dwarf_Form_Class fc = DW_FORM_CLASS_UNKNOWN; Dwarf_Half theform = 0; Dwarf_Half directform = 0; Dwarf_Half version = 0; Dwarf_Half offset_size = 0; int wres = 0; get_form_values(attrib,&theform,&directform); wres = dwarf_get_version_of_die(die , &version,&offset_size); if(wres != DW_DLV_OK) { print_error(dbg,"Cannot get DIE context version number",wres,err); break; } fc = dwarf_get_form_class(version,attr,offset_size,theform); if(fc == DW_FORM_CLASS_CONSTANT) { esb_empty_string(&esb_base); wres = formxdata_print_value(dbg,attrib,&esb_base, &err, FALSE); show_form_itself(show_form_used,verbose, theform, directform,&esb_base); valname = esb_get_string(&esb_base); if(wres == DW_DLV_OK){ /* String appended already. */ break; } else if (wres == DW_DLV_NO_ENTRY) { print_error(dbg,"Cannot get DW_AT_data_member_location, how can it be NO_ENTRY? ",wres,err); break; } else { print_error(dbg,"Cannot get DW_AT_data_member_location ",wres,err); break; } } /* FALL THRU, this is a a location description, or a reference to one, or a mistake. */ } /* FALL THRU to location description */ case DW_AT_location: case DW_AT_vtable_elem_location: case DW_AT_string_length: case DW_AT_return_addr: case DW_AT_use_location: case DW_AT_static_link: case DW_AT_frame_base: { /* The value is a location description or location list. */ Dwarf_Half theform = 0; Dwarf_Half directform = 0; get_form_values(attrib,&theform,&directform); esb_empty_string(&esb_base); if(is_location_form(theform)) { get_location_list(dbg, die, attrib, &esb_base); show_form_itself(show_form_used,verbose, theform, directform,&esb_base); } else if (theform == DW_FORM_exprloc) { int showhextoo = 1; print_exprloc_content(dbg,die,attrib,showhextoo,&esb_base); } else { show_attr_form_error(dbg,attr,theform,&esb_base); } valname = esb_get_string(&esb_base); } break; case DW_AT_SUN_func_offsets: { /* value is a location description or location list */ Dwarf_Half theform = 0; Dwarf_Half directform = 0; get_form_values(attrib,&theform,&directform); esb_empty_string(&esb_base); get_FLAG_BLOCK_string(dbg, attrib,&esb_base); show_form_itself(show_form_used,verbose, theform, directform,&esb_base); valname = esb_get_string(&esb_base); } break; case DW_AT_SUN_cf_kind: { Dwarf_Half kind = 0; Dwarf_Unsigned tempud = 0; Dwarf_Error err = 0; int wres = 0; Dwarf_Half theform = 0; Dwarf_Half directform = 0; get_form_values(attrib,&theform,&directform); wres = dwarf_formudata (attrib,&tempud, &err); esb_empty_string(&esb_base); if(wres == DW_DLV_OK) { kind = tempud; esb_append(&esb_base, get_ATCF_name(kind,dwarf_names_print_on_error)); } else if (wres == DW_DLV_NO_ENTRY) { esb_append(&esb_base, "?"); } else { print_error(dbg,"Cannot get formudata....",wres,err); esb_append(&esb_base, "??"); } show_form_itself(show_form_used,verbose, theform, directform,&esb_base); valname = esb_get_string(&esb_base); } break; case DW_AT_upper_bound: { Dwarf_Half theform; int rv; rv = dwarf_whatform(attrib,&theform,&err); /* depending on the form and the attribute, process the form */ if(rv == DW_DLV_ERROR) { print_error(dbg, "dwarf_whatform Cannot find attr form", rv, err); } else if (rv == DW_DLV_NO_ENTRY) { break; } esb_empty_string(&esb_base); switch (theform) { case DW_FORM_block1: { Dwarf_Half theform = 0; Dwarf_Half directform = 0; get_form_values(attrib,&theform,&directform); get_location_list(dbg, die, attrib, &esb_base); show_form_itself(show_form_used,verbose, theform, directform,&esb_base); valname = esb_get_string(&esb_base); } break; default: get_attr_value(dbg, tag, die, attrib, srcfiles, cnt, &esb_base, show_form_used,verbose); valname = esb_get_string(&esb_base); break; } break; } case DW_AT_low_pc: case DW_AT_high_pc: { Dwarf_Half theform; int rv; rv = dwarf_whatform(attrib,&theform,&err); /* Depending on the form and the attribute, process the form. */ if(rv == DW_DLV_ERROR) { print_error(dbg, "dwarf_whatform cannot Find attr form", rv, err); } else if (rv == DW_DLV_NO_ENTRY) { break; } esb_empty_string(&esb_base); if( theform != DW_FORM_addr) { /* New in DWARF4: other forms are not an address but are instead offset from pc. One could test for DWARF4 here before adding this string, but that seems unnecessary as this could not happen with DWARF3 or earlier. A normal consumer would have to add this value to DW_AT_low_pc to get a true pc. */ esb_append(&esb_base,""); } get_attr_value(dbg, tag, die, attrib, srcfiles, cnt, &esb_base,show_form_used,verbose); valname = esb_get_string(&esb_base); /* Update base and high addresses for CU */ if (seen_CU && (need_CU_base_address || need_CU_high_address)) { /* Update base address for CU */ if (need_CU_base_address && attr == DW_AT_low_pc) { dwarf_formaddr(attrib, &CU_base_address, &err); need_CU_base_address = FALSE; } /* Update high address for CU */ if (need_CU_high_address && attr == DW_AT_high_pc) { dwarf_formaddr(attrib, &CU_high_address, &err); need_CU_high_address = FALSE; } } /* Record the low and high addresses as we have them */ if ((check_decl_file || check_ranges || check_locations) && theform == DW_FORM_addr) { Dwarf_Addr addr = 0; dwarf_formaddr(attrib, &addr, &err); if (attr == DW_AT_low_pc) { lowAddr = addr; bSawLow = TRUE; /* Record the base address of the last seen PU to be used when checking line information */ if (seen_PU && !seen_PU_base_address) { seen_PU_base_address = TRUE; PU_base_address = addr; } } else { highAddr = addr; bSawHigh = TRUE; /* Record the high address of the last seen PU to be used when checking line information */ if (seen_PU && !seen_PU_high_address) { seen_PU_high_address = TRUE; PU_high_address = addr; } } /* We have now both low_pc and high_pc values */ if (bSawLow && bSawHigh) { /* We need to decide if this PU is valid, as the SN Linker marks a stripped function by setting lowpc to -1; also for discarded comdat, both lowpc and highpc are zero */ if (need_PU_valid_code) { need_PU_valid_code = FALSE; /* To ignore a PU as invalid code, only consider the lowpc and highpc values associated with the DW_TAG_subprogram; other instances of lowpc and highpc, must be ignore (lexical blocks) */ in_valid_code = TRUE; if (IsInvalidCode(lowAddr,highAddr) && tag == DW_TAG_subprogram) { in_valid_code = FALSE; } } /* We have a low_pc/high_pc pair; check if they are valid */ if (in_valid_code) { DWARF_CHECK_COUNT(ranges_result,1); if (lowAddr != elf_max_address && lowAddr > highAddr) { DWARF_CHECK_ERROR(ranges_result, ".debug_info: Incorrect values " "for low_pc/high_pc"); if (check_verbose_mode) { printf("Low = 0x%" DW_PR_XZEROS DW_PR_DUx ", High = 0x%" DW_PR_XZEROS DW_PR_DUx "\n", lowAddr,highAddr); } } if (check_decl_file || check_ranges || check_locations) { AddEntryIntoBucketGroup(pRangesInfo,0,lowAddr, lowAddr,highAddr,NULL,FALSE); } } bSawLow = FALSE; bSawHigh = FALSE; } } } break; case DW_AT_ranges: { Dwarf_Half theform = 0; int rv; rv = dwarf_whatform(attrib,&theform,&err); if(rv == DW_DLV_ERROR) { print_error(dbg, "dwarf_whatform cannot find Attr Form", rv, err); } else if (rv == DW_DLV_NO_ENTRY) { break; } esb_empty_string(&esb_base); get_attr_value(dbg, tag,die, attrib, srcfiles, cnt, &esb_base, show_form_used,verbose); print_range_attribute(dbg, die, attr,attr_in, theform, dwarf_names_print_on_error,print_information, &append_extra_string); valname = esb_get_string(&esb_base); } break; case DW_AT_MIPS_linkage_name: esb_empty_string(&esb_base); get_attr_value(dbg, tag, die, attrib, srcfiles, cnt, &esb_base, show_form_used,verbose); valname = esb_get_string(&esb_base); if (check_locations || check_ranges) { int local_show_form = 0; int local_verbose = 0; struct esb_s lesb; const char *name = 0; esb_constructor(&lesb); get_attr_value(dbg, tag, die, attrib, srcfiles, cnt, &lesb, local_show_form,local_verbose); /* Look for specific name forms, attempting to notice and report 'odd' identifiers. */ name = esb_get_string(&lesb); safe_strcpy(PU_name,sizeof(PU_name),name,strlen(name)); } break; case DW_AT_name: case DW_AT_GNU_template_name: esb_empty_string(&esb_base); get_attr_value(dbg, tag, die, attrib, srcfiles, cnt, &esb_base, show_form_used,verbose); valname = esb_get_string(&esb_base); if (check_names && checking_this_compiler()) { int local_show_form = FALSE; int local_verbose = 0; struct esb_s lesb; const char *name = 0; esb_constructor(&lesb); get_attr_value(dbg, tag, die, attrib, srcfiles, cnt, &lesb, local_show_form,local_verbose); /* Look for specific name forms, attempting to notice and report 'odd' identifiers. */ name = esb_get_string(&lesb); DWARF_CHECK_COUNT(names_result,1); if (!strcmp("\"(null)\"",name)) { DWARF_CHECK_ERROR(names_result, "string attribute is \"(null)\"."); } else { if (!dot_ok_in_identifier(tag,die,name) && !need_CU_name && strchr(name,'.')) { /* This is a suggestion there 'might' be a surprising name, not a guarantee of an error. */ DWARF_CHECK_ERROR(names_result, "string attribute is invalid."); } } esb_destructor(&lesb); } /* If we are in checking mode and we do not have a PU name */ if ((check_locations || check_ranges) && seen_PU && !PU_name[0]) { int local_show_form = FALSE; int local_verbose = 0; const char *name = 0; struct esb_s lesb; esb_constructor(&lesb); get_attr_value(dbg, tag, die, attrib, srcfiles, cnt, &lesb, local_show_form,local_verbose); name = esb_get_string(&lesb); safe_strcpy(PU_name,sizeof(PU_name),name,strlen(name)); esb_destructor(&lesb); } /* If we are processing the compile unit, record the name */ if (seen_CU && need_CU_name) { /* Lets not get the form name included. */ struct esb_s lesb; int local_show_form_used = FALSE; int local_verbose = 0; char *localname = 0; esb_constructor(&lesb); get_attr_value(dbg, tag, die, attrib, srcfiles, cnt, &lesb, local_show_form_used,local_verbose); localname = esb_get_string(&lesb); safe_strcpy(CU_name,sizeof(CU_name),localname,strlen(localname)); need_CU_name = FALSE; esb_destructor(&lesb); } break; case DW_AT_producer: esb_empty_string(&esb_base); get_attr_value(dbg, tag, die, attrib, srcfiles, cnt, &esb_base, show_form_used,verbose); valname = esb_get_string(&esb_base); /* If we are in checking mode, identify the compiler */ if (do_check_dwarf || search_is_on) { /* Do not use show-form here! We just want the producer name, not the form name. */ int show_form_local = FALSE; int local_verbose = 0; struct esb_s local_e; esb_constructor(&local_e); get_attr_value(dbg, tag, die, attrib, srcfiles, cnt, &local_e, show_form_local,local_verbose); /* Check if this compiler version is a target */ update_compiler_target(esb_get_string(&local_e)); esb_destructor(&local_e); } break; /* When dealing with linkonce symbols, the low_pc and high_pc are associated with a specific symbol; SNC always generate a name in the for of DW_AT_MIPS_linkage_name; GCC does not; instead it generates DW_AT_abstract_origin or DW_AT_specification; in that case we have to traverse this attribute in order to get the name for the linkonce */ case DW_AT_specification: case DW_AT_abstract_origin: case DW_AT_type: esb_empty_string(&esb_base); get_attr_value(dbg, tag, die, attrib, srcfiles, cnt, &esb_base, show_form_used,verbose); valname = esb_get_string(&esb_base); if (check_forward_decl || check_self_references) { Dwarf_Off die_off = 0; Dwarf_Off ref_off = 0; int res = 0; int suppress_check = 0; /* Get the global offset for reference */ res = dwarf_global_formref(attrib, &ref_off, &err); if (res != DW_DLV_OK) { int myerr = dwarf_errno(err); if(myerr == DW_DLE_REF_SIG8_NOT_HANDLED) { /* DW_DLE_REF_SIG8_NOT_HANDLED */ /* No offset available, it makes little sense to delve into this sort of reference unless we think a graph of self-refs *across* type-units is possible. Hmm. FIXME? */ suppress_check = 1 ; dwarf_dealloc(dbg,err,DW_DLA_ERROR); err = 0; } else { print_error(dbg, "dwarf_die_CU_offsetD", res, err); } } res = dwarf_dieoffset(die, &die_off, &err); if (res != DW_DLV_OK) { print_error(dbg, "ref formwith no ref?!", res, err); } if (!suppress_check && check_self_references) { Dwarf_Die ref_die = 0; ResetBucketGroup(pVisitedInfo); AddEntryIntoBucketGroup(pVisitedInfo,die_off,0,0,0,NULL,FALSE); /* Follow reference chain, looking for self references */ res = dwarf_offdie_b(dbg,ref_off,is_info,&ref_die,&err); if (res == DW_DLV_OK) { ++die_indent_level; struct esb_s copy_base; if (dump_visited_info) { Dwarf_Off off; dwarf_die_CU_offset(die, &off, &err); printf("<%2d><0x%" DW_PR_XZEROS DW_PR_DUx " GOFF=0x%" DW_PR_XZEROS DW_PR_DUx "> ", die_indent_level, (Dwarf_Unsigned)off, (Dwarf_Unsigned)die_off); printf("%*s%s -> %s\n",die_indent_level * 2 + 2, " ",atname,valname); } /* Because esb_base is global, lets not let the traversal trash what we have here. */ esb_constructor(©_base); esb_append(©_base,esb_get_string(&esb_base)); esb_empty_string(&esb_base); traverse_one_die(dbg,attrib,ref_die,srcfiles,cnt,die_indent_level); esb_empty_string(&esb_base); esb_append(&esb_base,esb_get_string(©_base)); esb_destructor(©_base); dwarf_dealloc(dbg,ref_die,DW_DLA_DIE); ref_die = 0; --die_indent_level; } DeleteKeyInBucketGroup(pVisitedInfo,die_off); } if (!suppress_check && check_forward_decl) { if (attr == DW_AT_specification) { /* Check the DW_AT_specification does not make forward references to DIEs. DWARF4 specifications, section 2.13.2, but really they are legal, this test is probably wrong. */ DWARF_CHECK_COUNT(forward_decl_result,1); if (ref_off > die_off) { DWARF_CHECK_ERROR2(forward_decl_result, "Invalid forward reference to DIE: ",valname); } } } } /* If we are in checking mode and we do not have a PU name */ if ((check_locations || check_ranges) && seen_PU && !PU_name[0]) { if (tag == DW_TAG_subprogram) { /* This gets the DW_AT_name if this DIE has one. */ Dwarf_Addr low_pc = 0; static char proc_name[BUFSIZ]; proc_name[0] = 0; get_proc_name(dbg,die,low_pc,proc_name,BUFSIZ,/*pcMap=*/0); if (proc_name[0]) { safe_strcpy(PU_name,sizeof(PU_name),proc_name, strlen(proc_name)); } } } break; default: esb_empty_string(&esb_base); get_attr_value(dbg, tag,die, attrib, srcfiles, cnt, &esb_base, show_form_used,verbose); valname = esb_get_string(&esb_base); break; } if (!print_information) { if(have_a_search_match(valname,atname) ) { if (search_wide_format) { found_search_attr = TRUE; } else { PRINT_CU_INFO(); bTextFound = TRUE; } } } if ((PRINTING_DIES && print_information) || bTextFound) { /* Print just the Tags and Attributes */ if (!display_offsets) { printf("%-28s\n",atname); } else { if (dense) { printf(" %s<%s>", atname, valname); if(append_extra_string) { char *v = esb_get_string(&esb_extra); printf("%s", v); } } else { printf("%-28s%s\n", atname, valname); if( append_extra_string) { char *v = esb_get_string(&esb_extra); printf("%s", v); } } } /* Due to redirection of stderr */ fflush(stdout); bTextFound = FALSE; } return found_search_attr; } int dwarfdump_print_one_locdesc(Dwarf_Debug dbg, Dwarf_Locdesc * llbuf, int skip_locdesc_header, struct esb_s *string_out) { Dwarf_Locdesc *locd = 0; Dwarf_Half no_of_ops = 0; int i = 0; char small_buf[100]; if (!skip_locdesc_header && (verbose || llbuf->ld_from_loclist)) { snprintf(small_buf, sizeof(small_buf), "", (Dwarf_Unsigned) llbuf->ld_lopc); esb_append(string_out, small_buf); snprintf(small_buf, sizeof(small_buf), "", (Dwarf_Unsigned) llbuf->ld_hipc); esb_append(string_out, small_buf); if (display_offsets && verbose) { snprintf(small_buf, sizeof(small_buf), "", llbuf->ld_from_loclist ? ".debug_loc" : ".debug_info", llbuf->ld_section_offset); esb_append(string_out, small_buf); } } locd = llbuf; no_of_ops = llbuf->ld_cents; for (i = 0; i < no_of_ops; i++) { Dwarf_Loc * op = &locd->ld_s[i]; int res = _dwarf_print_one_expr_op(dbg,op,i,string_out); if(res == DW_DLV_ERROR) { return res; } } return DW_DLV_OK; } static int op_has_no_operands(int op) { unsigned i = 0; if(op >= DW_OP_lit0 && op <= DW_OP_reg31) { return TRUE; } for( ; ; ++i) { struct operation_descr_s *odp = opdesc+i; if(odp->op_code == 0) { break; } if(odp->op_code != op) { continue; } if (odp->op_count == 0) { return TRUE; } return FALSE; } return FALSE; } int _dwarf_print_one_expr_op(Dwarf_Debug dbg,Dwarf_Loc* expr,int index, struct esb_s *string_out) { /* local_space_needed is intended to be 'more than big enough' for a short group of loclist entries. */ char small_buf[100]; Dwarf_Small op; Dwarf_Unsigned opd1; Dwarf_Unsigned opd2; const char * op_name; if (index > 0) { esb_append(string_out, " "); } op = expr->lr_atom; /* We have valid operands whose values are bigger than the DW_OP_nop = 0x96; for example: DW_OP_GNU_push_tls_address = 0xe0 Also, the function 'get_OP_name' handles this case, generating a name 'Unknown OP value'. */ if (op > DW_OP_hi_user) { print_error(dbg, "dwarf_op unexpected value!", DW_DLV_OK, err); return DW_DLV_ERROR; } op_name = get_OP_name(op,dwarf_names_print_on_error); esb_append(string_out, op_name); opd1 = expr->lr_number; if(op_has_no_operands(op)) { /* Nothing to add. */ } else if (op >= DW_OP_breg0 && op <= DW_OP_breg31) { snprintf(small_buf, sizeof(small_buf), "%+" DW_PR_DSd , (Dwarf_Signed) opd1); esb_append(string_out, small_buf); } else { switch (op) { case DW_OP_addr: snprintf(small_buf, sizeof(small_buf), " 0x%" DW_PR_XZEROS DW_PR_DUx , opd1); esb_append(string_out, small_buf); break; case DW_OP_const1s: case DW_OP_const2s: case DW_OP_const4s: case DW_OP_const8s: case DW_OP_consts: case DW_OP_skip: case DW_OP_bra: case DW_OP_fbreg: snprintf(small_buf, sizeof(small_buf), " %" DW_PR_DSd, (Dwarf_Signed) opd1); esb_append(string_out, small_buf); break; case DW_OP_const1u: case DW_OP_const2u: case DW_OP_const4u: case DW_OP_const8u: case DW_OP_constu: case DW_OP_pick: case DW_OP_plus_uconst: case DW_OP_regx: case DW_OP_piece: case DW_OP_deref_size: case DW_OP_xderef_size: snprintf(small_buf, sizeof(small_buf), " %" DW_PR_DUu , opd1); esb_append(string_out, small_buf); break; case DW_OP_bregx: snprintf(small_buf, sizeof(small_buf), "0x%08" DW_PR_DUx , opd1); esb_append(string_out, small_buf); opd2 = expr->lr_number2; snprintf(small_buf, sizeof(small_buf), "+%" DW_PR_DSd , (Dwarf_Signed) opd2); esb_append(string_out, small_buf); break; case DW_OP_call2: snprintf(small_buf, sizeof(small_buf), " 0x%" DW_PR_XZEROS DW_PR_DUx , opd1); esb_append(string_out, small_buf); break; case DW_OP_call4: snprintf(small_buf, sizeof(small_buf), " 0x%" DW_PR_XZEROS DW_PR_DUx , opd1); esb_append(string_out, small_buf); break; case DW_OP_call_ref: snprintf(small_buf, sizeof(small_buf), " 0x%" DW_PR_XZEROS DW_PR_DUx , opd1); esb_append(string_out, small_buf); break; case DW_OP_bit_piece: snprintf(small_buf, sizeof(small_buf), " 0x%" DW_PR_XZEROS DW_PR_DUx , opd1); esb_append(string_out, small_buf); opd2 = expr->lr_number2; snprintf(small_buf, sizeof(small_buf), " offset 0x%" DW_PR_DUx , (Dwarf_Signed) opd2); esb_append(string_out, small_buf); break; case DW_OP_implicit_value: { #define IMPLICIT_VALUE_PRINT_MAX 12 unsigned int print_len = 0; snprintf(small_buf, sizeof(small_buf), " 0x%" DW_PR_XZEROS DW_PR_DUx , opd1); esb_append(string_out, small_buf); /* The other operand is a block of opd1 bytes. */ /* FIXME */ print_len = opd1; if(print_len > IMPLICIT_VALUE_PRINT_MAX) { print_len = IMPLICIT_VALUE_PRINT_MAX; } #undef IMPLICIT_VALUE_PRINT_MAX if(print_len > 0) { const unsigned char *bp = 0; unsigned int i = 0; opd2 = expr->lr_number2; /* This is a really ugly cast, a way to implement DW_OP_implicit value in this libdwarf context. */ bp = (const unsigned char *) opd2; esb_append(string_out," contents 0x"); for( ; i < print_len; ++i,++bp) { /* Do not use DW_PR_DUx here, the value *bp is a const unsigned char. */ snprintf(small_buf, sizeof(small_buf), "%02x", *bp); esb_append(string_out,small_buf); } } } break; /* We do not know what the operands, if any, are. */ case DW_OP_HP_unknown: case DW_OP_HP_is_value: case DW_OP_HP_fltconst4: case DW_OP_HP_fltconst8: case DW_OP_HP_mod_range: case DW_OP_HP_unmod_range: case DW_OP_HP_tls: case DW_OP_INTEL_bit_piece: break; case DW_OP_stack_value: /* DWARF4 */ break; case DW_OP_GNU_uninit: /* DW_OP_APPLE_uninit */ /* No operands. */ break; case DW_OP_GNU_encoded_addr: snprintf(small_buf, sizeof(small_buf), " 0x%" DW_PR_XZEROS DW_PR_DUx , opd1); esb_append(string_out, small_buf); break; case DW_OP_GNU_implicit_pointer: snprintf(small_buf, sizeof(small_buf), " 0x%" DW_PR_XZEROS DW_PR_DUx , opd1); esb_append(string_out, small_buf); break; case DW_OP_GNU_entry_value: snprintf(small_buf, sizeof(small_buf), " 0x%" DW_PR_XZEROS DW_PR_DUx , opd1); esb_append(string_out, small_buf); break; default: { snprintf(small_buf, sizeof(small_buf), " dwarf_op unknown 0x%x", (unsigned)op); esb_append(string_out,small_buf); } break; } } return DW_DLV_OK; } /* Fill buffer with location lists Buffer esbp expands as needed. */ /*ARGSUSED*/ static void get_location_list(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Attribute attr, struct esb_s *esbp) { Dwarf_Locdesc *llbuf = 0; Dwarf_Locdesc **llbufarray = 0; Dwarf_Signed no_of_elements; Dwarf_Error err; int i; int lres = 0; int llent = 0; int skip_locdesc_header = 0; /* Base address used to update entries in .debug_loc */ Dwarf_Addr base_address = CU_base_address; Dwarf_Addr lopc = 0; Dwarf_Addr hipc = 0; Dwarf_Bool bError = FALSE; if (use_old_dwarf_loclist) { lres = dwarf_loclist(attr, &llbuf, &no_of_elements, &err); if (lres == DW_DLV_ERROR) { print_error(dbg, "dwarf_loclist", lres, err); } else if (lres == DW_DLV_NO_ENTRY) { return; } dwarfdump_print_one_locdesc(dbg, llbuf,skip_locdesc_header,esbp); dwarf_dealloc(dbg, llbuf->ld_s, DW_DLA_LOC_BLOCK); dwarf_dealloc(dbg, llbuf, DW_DLA_LOCDESC); return; } lres = dwarf_loclist_n(attr, &llbufarray, &no_of_elements, &err); if (lres == DW_DLV_ERROR) { print_error(dbg, "dwarf_loclist", lres, err); } else if (lres == DW_DLV_NO_ENTRY) { return; } for (llent = 0; llent < no_of_elements; ++llent) { char small_buf[100]; Dwarf_Off offset = 0; llbuf = llbufarray[llent]; /* If we have a location list refering to the .debug_loc Check for specific compiler we are validating. */ if (check_locations && in_valid_code && llbuf->ld_from_loclist && checking_this_compiler()) { /* To calculate the offset, we use: sizeof(Dwarf_Half) -> number of expression list 2 * address_size -> low_pc and high_pc */ offset = llbuf->ld_section_offset - llbuf->ld_cents * sizeof(Dwarf_Half) - 2 * elf_address_size; if (llbuf->ld_lopc == elf_max_address) { /* (0xffffffff,addr), use specific address (current PU address) */ base_address = llbuf->ld_hipc; } else { /* (offset,offset), update using CU address */ lopc = llbuf->ld_lopc + base_address; hipc = llbuf->ld_hipc + base_address; DWARF_CHECK_COUNT(locations_result,1); /* Check the low_pc and high_pc are within a valid range in the .text section */ if (IsValidInBucketGroup(pRangesInfo,lopc) && IsValidInBucketGroup(pRangesInfo,hipc)) { /* Valid values; do nothing */ } else { /* At this point may be we are dealing with a linkonce symbol */ if (IsValidInLinkonce(pLinkonceInfo,PU_name, lopc,hipc)) { /* Valid values; do nothing */ } else { bError = TRUE; DWARF_CHECK_ERROR(locations_result, ".debug_loc: Address outside a " "valid .text range"); if (check_verbose_mode) { printf( "Offset = 0x%" DW_PR_XZEROS DW_PR_DUx ", Base = 0x%" DW_PR_XZEROS DW_PR_DUx ", " "Low = 0x%" DW_PR_XZEROS DW_PR_DUx " (0x%" DW_PR_XZEROS DW_PR_DUx "), High = 0x%" DW_PR_XZEROS DW_PR_DUx " (0x%" DW_PR_XZEROS DW_PR_DUx ")\n", offset,base_address,lopc, llbuf->ld_lopc, hipc, llbuf->ld_hipc); } } } } } if (!dense && llbuf->ld_from_loclist) { if (llent == 0) { snprintf(small_buf, sizeof(small_buf), "", (long) no_of_elements); esb_append(esbp, small_buf); } esb_append(esbp, "\n\t\t\t"); snprintf(small_buf, sizeof(small_buf), "[%2d]", llent); esb_append(esbp, small_buf); } lres = dwarfdump_print_one_locdesc(dbg, llbuf, skip_locdesc_header, esbp); if (lres == DW_DLV_ERROR) { return; } else { /* DW_DLV_OK so we add follow-on at end, else is DW_DLV_NO_ENTRY (which is impossible, treat like DW_DLV_OK). */ } } if (bError && check_verbose_mode) { printf("\n"); } for (i = 0; i < no_of_elements; ++i) { dwarf_dealloc(dbg, llbufarray[i]->ld_s, DW_DLA_LOC_BLOCK); dwarf_dealloc(dbg, llbufarray[i], DW_DLA_LOCDESC); } dwarf_dealloc(dbg, llbufarray, DW_DLA_LIST); } static void formx_unsigned(Dwarf_Unsigned u, struct esb_s *esbp, Dwarf_Bool hex_format) { char small_buf[40]; if (hex_format) { snprintf(small_buf, sizeof(small_buf),"0x%" DW_PR_XZEROS DW_PR_DUx , u); } else { snprintf(small_buf, sizeof(small_buf), "%" DW_PR_DUu , u); } esb_append(esbp, small_buf); } static void formx_signed(Dwarf_Signed u, struct esb_s *esbp) { char small_buf[40]; snprintf(small_buf, sizeof(small_buf), "%" DW_PR_DSd , u); esb_append(esbp, small_buf); } /* We think this is an integer. Figure out how to print it. In case the signedness is ambiguous (such as on DW_FORM_data1 (ie, unknown signedness) print two ways. */ static int formxdata_print_value(Dwarf_Debug dbg,Dwarf_Attribute attrib, struct esb_s *esbp, Dwarf_Error * err, Dwarf_Bool hex_format) { Dwarf_Signed tempsd = 0; Dwarf_Unsigned tempud = 0; int sres = 0; int ures = 0; Dwarf_Error serr = 0; ures = dwarf_formudata(attrib, &tempud, err); sres = dwarf_formsdata(attrib, &tempsd, &serr); if(ures == DW_DLV_OK) { if(sres == DW_DLV_OK) { if(tempud == tempsd && tempsd >= 0) { /* Data is the same value and not negative, so makes no difference which we print. */ formx_unsigned(tempud,esbp,hex_format); } else { formx_unsigned(tempud,esbp,hex_format); esb_append(esbp,"(as signed = "); formx_signed(tempsd,esbp); esb_append(esbp,")"); } } else if (sres == DW_DLV_NO_ENTRY) { formx_unsigned(tempud,esbp,hex_format); } else /* DW_DLV_ERROR */{ formx_unsigned(tempud,esbp,hex_format); } goto cleanup; } else { /* ures == DW_DLV_ERROR or DW_DLV_NO_ENTRY*/ if(sres == DW_DLV_OK) { formx_signed(tempsd,esbp); } else { /* Neither worked. */ } } /* Clean up any unused Dwarf_Error data. DW_DLV_NO_ENTRY cannot really happen, so a complete cleanup for that is not necessary. */ cleanup: if(sres == DW_DLV_OK || ures == DW_DLV_OK) { if(sres == DW_DLV_ERROR) { dwarf_dealloc(dbg,serr,DW_DLA_ERROR); } if(ures == DW_DLV_ERROR) { dwarf_dealloc(dbg,*err,DW_DLA_ERROR); *err = 0; } return DW_DLV_OK; } if(sres == DW_DLV_ERROR || ures == DW_DLV_ERROR) { if(sres == DW_DLV_ERROR && ures == DW_DLV_ERROR) { dwarf_dealloc(dbg,serr,DW_DLA_ERROR); return DW_DLV_ERROR; } if(sres == DW_DLV_ERROR) { *err = serr; } return DW_DLV_ERROR; } /* Both are DW_DLV_NO_ENTRY which is crazy, impossible. */ return DW_DLV_NO_ENTRY; } static char * get_form_number_as_string(int form, char *buf, unsigned bufsize) { snprintf(buf,bufsize," %d",form); return buf; } static void print_exprloc_content(Dwarf_Debug dbg,Dwarf_Die die, Dwarf_Attribute attrib, int showhextoo, struct esb_s *esbp) { Dwarf_Ptr x = 0; Dwarf_Unsigned tempud = 0; char small_buf[80]; Dwarf_Error err = 0; int wres = 0; wres = dwarf_formexprloc(attrib,&tempud,&x,&err); if(wres == DW_DLV_NO_ENTRY) { /* Show nothing? Impossible. */ } else if(wres == DW_DLV_ERROR) { print_error(dbg, "Cannot get a DW_FORM_exprbloc....", wres, err); } else { Dwarf_Half address_size = 0; int ares = 0; unsigned u = 0; snprintf(small_buf, sizeof(small_buf), "len 0x%04" DW_PR_DUx ": ",tempud); esb_append(esbp, small_buf); if(showhextoo) { for (u = 0; u < tempud; u++) { snprintf(small_buf, sizeof(small_buf), "%02x", *(u + (unsigned char *) x)); esb_append(esbp, small_buf); } esb_append(esbp,": "); } address_size = 0; ares = dwarf_get_die_address_size(die,&address_size,&err); if(wres == DW_DLV_NO_ENTRY) { print_error(dbg,"Cannot get die address size for exprloc", ares,err); } else if(wres == DW_DLV_ERROR) { print_error(dbg,"Cannot Get die address size for exprloc", ares,err); } else { get_string_from_locs(dbg,x,tempud,address_size, esbp); } } } /* Fill buffer with attribute value. We pass in tag so we can try to do the right thing with broken compiler DW_TAG_enumerator We append to esbp's buffer. */ void get_attr_value(Dwarf_Debug dbg, Dwarf_Half tag, Dwarf_Die die, Dwarf_Attribute attrib, char **srcfiles, Dwarf_Signed cnt, struct esb_s *esbp, int show_form, int local_verbose) { Dwarf_Half theform = 0; char * temps = 0; Dwarf_Block *tempb = 0; Dwarf_Signed tempsd = 0; Dwarf_Unsigned tempud = 0; int i = 0; Dwarf_Half attr = 0; Dwarf_Off off = 0; Dwarf_Off goff = 0; /* Global offset */ Dwarf_Die die_for_check = 0; Dwarf_Half tag_for_check = 0; Dwarf_Bool tempbool = 0; Dwarf_Addr addr = 0; int fres = 0; int bres = 0; int wres = 0; int dres = 0; Dwarf_Half direct_form = 0; char small_buf[COMPILE_UNIT_NAME_LEN]; /* Size to hold a filename */ Dwarf_Bool is_info = TRUE; is_info = dwarf_get_die_infotypes_flag(die); /* Dwarf_whatform gets the real form, DW_FORM_indir is never returned: instead the real form following DW_FORM_indir is returned. */ fres = dwarf_whatform(attrib, &theform, &err); /* Depending on the form and the attribute, process the form. */ if (fres == DW_DLV_ERROR) { print_error(dbg, "dwarf_whatform cannot Find Attr Form", fres, err); } else if (fres == DW_DLV_NO_ENTRY) { return; } /* dwarf_whatform_direct gets the 'direct' form, so if the form is DW_FORM_indir that is what is returned. */ dwarf_whatform_direct(attrib, &direct_form, &err); /* Ignore errors in dwarf_whatform_direct() */ switch (theform) { case DW_FORM_addr: bres = dwarf_formaddr(attrib, &addr, &err); if (bres == DW_DLV_OK) { snprintf(small_buf, sizeof(small_buf), "0x%" DW_PR_XZEROS DW_PR_DUx , (Dwarf_Unsigned) addr); esb_append(esbp, small_buf); } else { print_error(dbg, "addr formwith no addr?!", bres, err); } break; case DW_FORM_ref_addr: /* DW_FORM_ref_addr is not accessed thru formref: ** it is an address (global section offset) in ** the .debug_info section. */ bres = dwarf_global_formref(attrib, &off, &err); if (bres == DW_DLV_OK) { snprintf(small_buf, sizeof(small_buf), "", (Dwarf_Unsigned) off); esb_append(esbp, small_buf); } else { print_error(dbg, "DW_FORM_ref_addr form with no reference?!", bres, err); } wres = dwarf_whatattr(attrib, &attr, &err); if (wres == DW_DLV_ERROR) { } else if (wres == DW_DLV_NO_ENTRY) { } else { if (attr == DW_AT_sibling) { /* The value had better be inside the current CU else there is a nasty error here, as a sibling has to be in the same CU, it seems. */ Dwarf_Off cuoff = 0; Dwarf_Off culen = 0; int res = dwarf_die_CU_offset_range(die,&cuoff, &culen,&err); DWARF_CHECK_COUNT(tag_tree_result,1); if(res != DW_DLV_OK) { } else { Dwarf_Off cuend = cuoff+culen; if(off < cuoff || off >= cuend) { DWARF_CHECK_ERROR(tag_tree_result, "DW_AT_sibling DW_FORM_ref_addr offset points " "outside of current CU"); } } } } break; case DW_FORM_ref1: case DW_FORM_ref2: case DW_FORM_ref4: case DW_FORM_ref8: case DW_FORM_ref_udata: bres = dwarf_formref(attrib, &off, &err); if (bres != DW_DLV_OK) { /* Report incorrect offset */ snprintf(small_buf,sizeof(small_buf), "%s, offset=<0x%" DW_PR_XZEROS DW_PR_DUx ">","reference form with no valid local ref?!",off); print_error(dbg, small_buf, bres, err); } /* Convert the local offset into a relative section offset */ if (show_global_offsets) { bres = dwarf_convert_to_global_offset(attrib, off, &goff, &err); if (bres != DW_DLV_OK) { /* Report incorrect offset */ snprintf(small_buf,sizeof(small_buf), "%s, global die offset=<0x%" DW_PR_XZEROS DW_PR_DUx ">","invalid offset",goff); print_error(dbg, small_buf, bres, err); } } /* Do references inside <> to distinguish them ** from constants. In dense form this results in <<>>. Ugly for dense form, but better than ambiguous. davea 9/94 */ if (show_global_offsets) { snprintf(small_buf, sizeof(small_buf), "<0x%" DW_PR_XZEROS DW_PR_DUx " GOFF=0x%" DW_PR_XZEROS DW_PR_DUx ">", (Dwarf_Unsigned)off, goff); } else { snprintf(small_buf, sizeof(small_buf), "<0x%" DW_PR_XZEROS DW_PR_DUx ">", off); } esb_append(esbp, small_buf); if (check_type_offset) { attr = 0; wres = dwarf_whatattr(attrib, &attr, &err); if (wres == DW_DLV_ERROR) { } else if (wres == DW_DLV_NO_ENTRY) { } if (attr == DW_AT_type) { dres = dwarf_offdie_b(dbg, cu_offset + off, is_info, &die_for_check, &err); DWARF_CHECK_COUNT(type_offset_result,1); if (dres != DW_DLV_OK) { snprintf(small_buf,sizeof(small_buf), "DW_AT_type offset does not point to a DIE for global offset 0x%" DW_PR_DUx " cu off 0x%" DW_PR_DUx " local offset 0x%" DW_PR_DUx, cu_offset + off,cu_offset,off); DWARF_CHECK_ERROR(type_offset_result,small_buf); } else { int tres2 = dwarf_tag(die_for_check, &tag_for_check, &err); if (tres2 == DW_DLV_OK) { switch (tag_for_check) { case DW_TAG_array_type: case DW_TAG_class_type: case DW_TAG_enumeration_type: case DW_TAG_pointer_type: case DW_TAG_reference_type: case DW_TAG_string_type: case DW_TAG_structure_type: case DW_TAG_subroutine_type: case DW_TAG_typedef: case DW_TAG_union_type: case DW_TAG_ptr_to_member_type: case DW_TAG_set_type: case DW_TAG_subrange_type: case DW_TAG_base_type: case DW_TAG_const_type: case DW_TAG_file_type: case DW_TAG_packed_type: case DW_TAG_thrown_type: case DW_TAG_volatile_type: case DW_TAG_template_type_parameter: case DW_TAG_template_value_parameter: case DW_TAG_unspecified_type: /* OK */ break; default: { snprintf(small_buf,sizeof(small_buf), "DW_AT_type offset does not point to Type info we got tag 0x%x %s", tag_for_check, get_TAG_name(tag_for_check, dwarf_names_print_on_error)); DWARF_CHECK_ERROR(type_offset_result,small_buf); } break; } dwarf_dealloc(dbg, die_for_check, DW_DLA_DIE); die_for_check = 0; } else { DWARF_CHECK_ERROR(type_offset_result, "DW_AT_type offset does not exist"); } } } } break; case DW_FORM_block: case DW_FORM_block1: case DW_FORM_block2: case DW_FORM_block4: fres = dwarf_formblock(attrib, &tempb, &err); if (fres == DW_DLV_OK) { for (i = 0; i < tempb->bl_len; i++) { snprintf(small_buf, sizeof(small_buf), "%02x", *(i + (unsigned char *) tempb->bl_data)); esb_append(esbp, small_buf); } dwarf_dealloc(dbg, tempb, DW_DLA_BLOCK); tempb = 0; } else { print_error(dbg, "DW_FORM_blockn cannot get block\n", fres, err); } break; case DW_FORM_data1: case DW_FORM_data2: case DW_FORM_data4: case DW_FORM_data8: fres = dwarf_whatattr(attrib, &attr, &err); if (fres == DW_DLV_ERROR) { print_error(dbg, "FORM_datan cannot get attr", fres, err); } else if (fres == DW_DLV_NO_ENTRY) { print_error(dbg, "FORM_datan cannot get attr", fres, err); } else { switch (attr) { case DW_AT_ordering: case DW_AT_byte_size: case DW_AT_bit_offset: case DW_AT_bit_size: case DW_AT_inline: case DW_AT_language: case DW_AT_visibility: case DW_AT_virtuality: case DW_AT_accessibility: case DW_AT_address_class: case DW_AT_calling_convention: case DW_AT_discr_list: /* DWARF3 */ case DW_AT_encoding: case DW_AT_identifier_case: case DW_AT_MIPS_loop_unroll_factor: case DW_AT_MIPS_software_pipeline_depth: case DW_AT_decl_column: case DW_AT_decl_file: case DW_AT_decl_line: case DW_AT_call_column: case DW_AT_call_file: case DW_AT_call_line: case DW_AT_start_scope: case DW_AT_byte_stride: case DW_AT_bit_stride: case DW_AT_count: case DW_AT_stmt_list: case DW_AT_MIPS_fde: { int show_form_here = 0; wres = get_small_encoding_integer_and_name(dbg, attrib, &tempud, /* attrname */ (char *) NULL, /* err_string */ (const char **) NULL, (encoding_type_func) 0, &err,show_form_here); if (wres == DW_DLV_OK) { snprintf(small_buf, sizeof(small_buf), "0x%08" DW_PR_DUx , tempud); esb_append(esbp, small_buf); if (attr == DW_AT_decl_file || attr == DW_AT_call_file) { if (srcfiles && tempud > 0 && tempud <= cnt) { /* added by user request */ /* srcfiles is indexed starting at 0, but DW_AT_decl_file defines that 0 means no file, so tempud 1 means the 0th entry in srcfiles, thus tempud-1 is the correct index into srcfiles. */ char *fname = srcfiles[tempud - 1]; esb_append(esbp, " "); esb_append(esbp, fname); } /* Validate integrity of files referenced in .debug_line */ if(check_decl_file) { DWARF_CHECK_COUNT(decl_file_result,1); /* Zero is always a legal index, it means no source name provided. */ if(tempud != 0 && tempud > cnt) { if(!srcfiles) { snprintf(small_buf,sizeof(small_buf), "There is a file number=%" DW_PR_DUu " but no source files " " are known.",tempud); } else { snprintf(small_buf, sizeof(small_buf), "Does not point to valid file info " " filenum=%" DW_PR_DUu " filecount=%" DW_PR_DUu ".", tempud,cnt); } DWARF_CHECK_ERROR2(decl_file_result, get_AT_name(attr, dwarf_names_print_on_error), small_buf); } } } } else { print_error(dbg, "Cannot get encoding attribute ..", wres, err); } } break; case DW_AT_const_value: /* Do not use hexadecimal format */ wres = formxdata_print_value(dbg,attrib,esbp, &err, FALSE); if(wres == DW_DLV_OK){ /* String appended already. */ } else if (wres == DW_DLV_NO_ENTRY) { /* nothing? */ } else { print_error(dbg,"Cannot get DW_AT_const_value ",wres,err); } break; case DW_AT_upper_bound: case DW_AT_lower_bound: default: /* Do not use hexadecimal format except for DW_AT_ranges. */ wres = formxdata_print_value(dbg,attrib,esbp, &err, (DW_AT_ranges == attr)); if (wres == DW_DLV_OK) { /* String appended already. */ } else if (wres == DW_DLV_NO_ENTRY) { /* nothing? */ } else { print_error(dbg, "Cannot get form data..", wres, err); } break; } } if (cu_name_flag) { if (attr == DW_AT_MIPS_fde) { if (fde_offset_for_cu_low == DW_DLV_BADOFFSET) { fde_offset_for_cu_low = fde_offset_for_cu_high = tempud; } else if (tempud < fde_offset_for_cu_low) { fde_offset_for_cu_low = tempud; } else if (tempud > fde_offset_for_cu_high) { fde_offset_for_cu_high = tempud; } } } break; case DW_FORM_sdata: wres = dwarf_formsdata(attrib, &tempsd, &err); if (wres == DW_DLV_OK) { snprintf(small_buf, sizeof(small_buf), "0x%" DW_PR_XZEROS DW_PR_DUx , tempsd); esb_append(esbp, small_buf); } else if (wres == DW_DLV_NO_ENTRY) { /* nothing? */ } else { print_error(dbg, "Cannot get formsdata..", wres, err); } break; case DW_FORM_udata: wres = dwarf_formudata(attrib, &tempud, &err); if (wres == DW_DLV_OK) { snprintf(small_buf, sizeof(small_buf), "0x%" DW_PR_XZEROS DW_PR_DUx , tempud); esb_append(esbp, small_buf); } else if (wres == DW_DLV_NO_ENTRY) { /* nothing? */ } else { print_error(dbg, "Cannot get formudata....", wres, err); } break; case DW_FORM_string: case DW_FORM_strp: wres = dwarf_formstring(attrib, &temps, &err); if (wres == DW_DLV_OK) { /* Print as quoted string for clarity. */ esb_append(esbp, "\""); esb_append(esbp, temps); esb_append(esbp, "\""); } else if (wres == DW_DLV_NO_ENTRY) { /* nothing? */ } else { print_error(dbg, "Cannot get a formstr (or a formstrp)....", wres, err); } break; case DW_FORM_flag: wres = dwarf_formflag(attrib, &tempbool, &err); if (wres == DW_DLV_OK) { if (tempbool) { snprintf(small_buf, sizeof(small_buf), "yes(%d)", tempbool); esb_append(esbp, small_buf); } else { snprintf(small_buf, sizeof(small_buf), "no"); esb_append(esbp, small_buf); } } else if (wres == DW_DLV_NO_ENTRY) { /* nothing? */ } else { print_error(dbg, "Cannot get formflag/p....", wres, err); } break; case DW_FORM_indirect: /* We should not ever get here, since the true form was determined and direct_form has the DW_FORM_indirect if it is used here in this attr. */ esb_append(esbp, get_FORM_name(theform, dwarf_names_print_on_error)); break; case DW_FORM_exprloc: { /* DWARF4 */ int showhextoo = 1; print_exprloc_content(dbg,die,attrib,showhextoo,esbp); } break; case DW_FORM_sec_offset: { /* DWARF4 */ string emptyattrname = 0; int show_form_here = 0; wres = get_small_encoding_integer_and_name(dbg, attrib, &tempud, emptyattrname, /* err_string */ NULL, (encoding_type_func) 0, &err,show_form_here); if(wres == DW_DLV_NO_ENTRY) { /* Show nothing? */ } else if(wres == DW_DLV_ERROR) { print_error(dbg, "Cannot get a DW_FORM_sec_offset....", wres, err); } else { snprintf(small_buf, sizeof(small_buf), "0x%" DW_PR_XZEROS DW_PR_DUx, tempud); esb_append(esbp,small_buf); } } break; case DW_FORM_flag_present: /* DWARF4 */ esb_append(esbp,"yes(1)"); break; case DW_FORM_ref_sig8: { /* DWARF4 */ Dwarf_Sig8 sig8data; wres = dwarf_formsig8(attrib,&sig8data,&err); if(wres != DW_DLV_OK) { /* Show nothing? */ print_error(dbg, "Cannot get a DW_FORM_ref_sig8 ....", wres, err); } else { struct esb_s sig8str; esb_constructor(&sig8str); format_sig8_string(&sig8data,&sig8str); esb_append(esbp,esb_get_string(&sig8str)); esb_destructor(&sig8str); } } break; default: print_error(dbg, "dwarf_whatform unexpected value", DW_DLV_OK, err); } show_form_itself(show_form,local_verbose,theform, direct_form,esbp); } void format_sig8_string(Dwarf_Sig8*data, struct esb_s *out) { unsigned i = 0; char small_buf[40]; esb_append(out,"0x"); for( ; i < sizeof(data->signature); ++i) { if (i == 4) { esb_append(out," 0x"); } snprintf(small_buf,sizeof(small_buf), "%02x", (unsigned char)(data->signature[i])); esb_append(out,small_buf); } } /* A cleanup so that when using a memory checker we don't show irrelevant leftovers. */ void clean_up_die_esb() { esb_destructor(&esb_base); } static int get_form_values(Dwarf_Attribute attrib, Dwarf_Half * theform, Dwarf_Half * directform) { Dwarf_Error err = 0; int res = dwarf_whatform(attrib, theform, &err); dwarf_whatform_direct(attrib, directform, &err); return res; } static void show_form_itself(int local_show_form, int local_verbose, int theform, int directform, struct esb_s *esbp) { char small_buf[100]; if (local_show_form && directform && directform == DW_FORM_indirect) { char *form_indir = " (used DW_FORM_indirect"; char *form_indir2 = ") "; esb_append(esbp, form_indir); if(local_verbose) { esb_append(esbp, get_form_number_as_string(DW_FORM_indirect, small_buf,sizeof(small_buf))); } esb_append(esbp, form_indir2); } if(local_show_form) { esb_append(esbp,"
"); } } #include "tmp-ta-table.c" #include "tmp-ta-ext-table.c" static int legal_tag_attr_combination(Dwarf_Half tag, Dwarf_Half attr) { if(tag <= 0) { return FALSE; } if(tag < ATTR_TREE_ROW_COUNT) { int index = attr / BITS_PER_WORD; if ( index < ATTR_TREE_COLUMN_COUNT) { unsigned bitflag = 1 << (attr % BITS_PER_WORD); int known = ((tag_attr_combination_table[tag][index] & bitflag) > 0 ? TRUE : FALSE); if(known) { return TRUE; } } } /* DW_AT_MIPS_fde used to return TRUE as that was convenient for SGI/MIPS users. */ if(!suppress_check_extensions_tables) { int r = 0; for ( ; r < ATTR_TREE_EXT_ROW_COUNT; ++r ) { int c = 1; if(tag != tag_attr_combination_ext_table[r][0]) { continue; } for( ; c < ATTR_TREE_EXT_COLUMN_COUNT ; ++c) { if (tag_attr_combination_ext_table[r][c] == attr) { return TRUE; } } } } return (FALSE); } #include "tmp-tt-table.c" #include "tmp-tt-ext-table.c" /* Look only at valid table entries The check here must match the building-logic in tag_tree.c And must match the tags defined in dwarf.h The tag_tree_combination_table is a table of bit flags. */ static int legal_tag_tree_combination(Dwarf_Half tag_parent, Dwarf_Half tag_child) { if(tag_parent <= 0) { return FALSE; } if ( tag_parent < TAG_TREE_ROW_COUNT) { int index = tag_child / BITS_PER_WORD; if ( index < TAG_TREE_COLUMN_COUNT) { unsigned bitflag = 1 << (tag_child % BITS_PER_WORD); int known = ((tag_tree_combination_table[tag_parent] [index] & bitflag) > 0 ? TRUE : FALSE); if(known) { return TRUE; } } } if(!suppress_check_extensions_tables) { int r = 0; for ( ; r < TAG_TREE_EXT_ROW_COUNT; ++r ) { int c = 1; if(tag_parent != tag_tree_combination_ext_table[r][0]) { continue; } for( ; c < TAG_TREE_EXT_COLUMN_COUNT ; ++c) { if (tag_tree_combination_ext_table[r][c] == tag_child) { return TRUE; } } } } return (FALSE); } dwarf-20120410/dwarfdump/print_types.c0000640000175000017500000001153311741100175016503 0ustar daveadavea/* Copyright (C) 2000-2006 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright 2007-2010 Sun Microsystems, Inc. All rights reserved. Portions Copyright 2009-2010 SN Systems Ltd. All rights reserved. Portions Copyright 2008-2011 David Anderson. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/print_sections.c,v 1.69 2006/04/17 00:09:56 davea Exp $ */ /* The address of the Free Software Foundation is Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. SGI has moved from the Crittenden Lane address. */ #include "globals.h" #include "naming.h" #include "dwconf.h" #include "esb.h" #include "print_sections.h" #include "print_frames.h" /* get all the data in .debug_types */ extern void print_types(Dwarf_Debug dbg, enum type_type_e type_type) { Dwarf_Type *typebuf = NULL; Dwarf_Signed count = 0; Dwarf_Signed i = 0; char *name = NULL; int gtres = 0; char *section_name = NULL; char *offset_err_name = NULL; char *section_open_name = NULL; char *print_name_prefix = NULL; int (*get_types) (Dwarf_Debug, Dwarf_Type **, Dwarf_Signed *, Dwarf_Error *) = 0; int (*get_offset) (Dwarf_Type, char **, Dwarf_Off *, Dwarf_Off *, Dwarf_Error *) = NULL; int (*get_cu_offset) (Dwarf_Type, Dwarf_Off *, Dwarf_Error *) = NULL; void (*dealloctype) (Dwarf_Debug, Dwarf_Type *, Dwarf_Signed) = NULL; /* Do nothing if in check mode */ if (!do_print_dwarf) { return; } if (type_type == DWARF_PUBTYPES) { section_name = ".debug_pubtypes"; offset_err_name = "dwarf_pubtype_name_offsets"; section_open_name = "dwarf_get_pubtypes"; print_name_prefix = "pubtype"; get_types = dwarf_get_pubtypes; get_offset = dwarf_pubtype_name_offsets; get_cu_offset = dwarf_pubtype_cu_offset; dealloctype = dwarf_pubtypes_dealloc; } else { /* SGI_TYPENAME */ section_name = ".debug_typenames"; offset_err_name = "dwarf_type_name_offsets"; section_open_name = "dwarf_get_types"; print_name_prefix = "type"; get_types = dwarf_get_types; get_offset = dwarf_type_name_offsets; get_cu_offset = dwarf_type_cu_offset; dealloctype = dwarf_types_dealloc; } gtres = get_types(dbg, &typebuf, &count, &err); if (gtres == DW_DLV_ERROR) { print_error(dbg, section_open_name, gtres, err); } else if (gtres == DW_DLV_NO_ENTRY) { /* no types */ } else { Dwarf_Unsigned maxoff = get_info_max_offset(dbg); /* Before July 2005, the section name was printed unconditionally, now only prints if non-empty section really exists. */ printf("\n%s\n", section_name); for (i = 0; i < count; i++) { int tnres = 0; int cures3 = 0; Dwarf_Off die_off = 0; Dwarf_Off cu_off = 0; Dwarf_Off global_cu_off = 0; tnres = get_offset(typebuf[i], &name, &die_off, &cu_off, &err); deal_with_name_offset_err(dbg, offset_err_name, name, die_off, tnres, err); cures3 = get_cu_offset(typebuf[i], &global_cu_off, &err); if (cures3 != DW_DLV_OK) { print_error(dbg, "dwarf_var_cu_offset", cures3, err); } print_pubname_style_entry(dbg, print_name_prefix, name, die_off, cu_off, global_cu_off, maxoff); /* print associated die too? */ } dealloctype(dbg, typebuf, count); } } /* print_types() */ dwarf-20120410/dwarfdump/dwconf.h0000640000175000017500000001061511741100175015410 0ustar daveadavea/* Copyright (C) 2006 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright 2011 David Anderson. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/dwconf.h,v 1.2 2006/04/18 04:29:39 davea Exp $ */ /* declarations helping configure the frame reader. */ struct dwconf_s { char *cf_config_file_path; char *cf_abi_name; /* 2 for old, 3 for frame interface 3. 2 means use the old mips-abi-oriented frame interface. 3 means use the new DWARF3-capable and configureable-abi interface. Now, anyone who revises dwarf.h and libdwarf.h to match their abi-of-interest will still be able to use cf_interface_number 2 as before. But most folks don't update those header files and instead of making *them* configurable we make dwarfdump (and libdwarf) configurable sufficiently to print frame information sensibly. */ int cf_interface_number; /* The number of table rules , aka columns. For MIPS/IRIX is 66. */ unsigned long cf_table_entry_count; /* Array of cf_table_entry_count reg names. Names not filled in from dwarfdump.conf have NULL (0) pointer value. cf_named_regs_table_size must match size of cf_regs array. Set cf_regs_malloced 1 if table was malloced. Set 0 if static. */ char **cf_regs; unsigned long cf_named_regs_table_size; int cf_regs_malloced; /* The 'default initial value' when intializing a table. for MIPS is DW_FRAME_SAME_VAL(1035). For other ISA/ABIs may be DW_FRAME_UNDEFINED_VAL(1034). */ int cf_initial_rule_value; int cf_same_val; int cf_undefined_val; /* The number of the cfa 'register'. For cf_interface_number 2 of MIPS this is 0. For other architectures (and anytime using cf_interface_number 3) this should be outside the table, a special value such as 1436, not a table column at all). */ int cf_cfa_reg; /* If non-zero it is the number of bytes in an address for the frame data. Normally it will be zero because there are usually other sources for the correct address size. However, with DWARF2 frame data there is no explicit address size in the frame data and the object file might not have other .debug_ sections to work with. If zero, no address size was supplied, and that is normal and the already-set (or defaulted) address size is to be used. Only an exceptional frame configure will specify address size here. This won't work at all if the object needing this setting has different address size in different CUs. */ int cf_address_size; }; /* Returns DW_DLV_OK if works. DW_DLV_ERROR if cannot do what is asked. */ int find_conf_file_and_read_config(const char *named_file, const char *named_abi, char **defaults, struct dwconf_s *conf_out); void init_conf_file_data(struct dwconf_s *config_file_data); void init_mips_conf_file_data(struct dwconf_s *config_file_data); void print_reg_from_config_data(Dwarf_Signed reg, struct dwconf_s *config_data); void init_generic_config_1200_regs(struct dwconf_s *conf); dwarf-20120410/dwarfdump/ChangeLog20090000640000175000017500000003530011741100175016042 0ustar daveadavea2009-12-30 DavidAnderson * configure: Regenerated with autoconf 2.64. * config.guess, config.sub: Delete these, best not to have them. 2009-11-24 DavidAnderson * tag_common.h: Updated 'standard tag table row' and tag table column maximums now the DWARF4 entries are in the .list files. Removed dos 'CR' characters at line ends. * tag_tree.list, tag_attr.list: Added various DWARF4 entries and added DW_TAG_enumeration_type under DW_TAG_union_type. 2009-11-17 DavidAnderson * dwarfdump.1: Document the -u option more fully. * print_die.c: Check for both info_flag and cu_name_flag to decide when to print DIEs. 2009-10-12 DavidAnderson * dwarfdump.c: Updated dwarfdump version string to today. 2009-09-30 DavidAnderson * dwarfdump.c: Added globals for aranges checking and to print the resulting error count. * print_aranges.c: Added checking that all 3 ways of computing a cu_die_offset from an arange get the same offset (checked with -r -ka). * print_frames.c: DW_CFA_cfa_offset_extended_sf corrected to DW_CFA_offset_extended_sf. 2009-09-01 DavidAnderson * tag_tree.list: We add DW_TAG_class_type as a valid child of a DW_TAG_union_type. 2009-08-05 DavidAnderson * gennames.c: Change include from getopt.h to unistd.h so the code is more universally compilable. 2009-07-24: David Anderson * tag_attr.c: Remove duplicate include of naming.h. 2009-06-23: David Anderson * strstrnocase.c: Corrected typo in TEST code and added a new test. 2009-06-22: David Anderson * Makefile.in: switched to personally written string comparison, strstrnocase.c. * stristr.c: deleted. * strstrnocase.c: New code, written by me so no license issues. * print_die.c: Call is_strstrnocase(), the new function. * dwarfdump.1: More fully document -S. * globals.h: Create extern for is_strstrnocase(). 2009-06-18: David Anderson * configure: Regenerated. * Makefile.in: Add stristr.o * stristr.c: public domain source added to dwarfdump * print_die.c: Add code and arguments to support -S. * print_lines.c: print_one_die argument list changed, added the require argument.. * dwarfdump.c: Added the -S option. * configure.in: Add test to set HAVE_REGEX for the -S option. * dwarfdump.1: Document the -S options. * config.h.in: Set the default HAVE_REGEX * globals.h: Add -S globals, change the print_one_die() prototype to support -S. * print_aranges.c: Alter the print_one_die calls added to support -S. 2009-06-06: David Anderson * naming.c,naming.h: New files that implement the ellipsis functionality of dwarfdump and defer to libdwarf to get the names of the TAGs, attributes, FORMs, etc. * gennames.c: This file has moved to libdwarf, no longer present in dwarfdump. * esb.h, esb.c: Change certain char* arguments to const char* to avoid compiler warnings. * print_static_vars.c,print_static_funcs.c, print_sections.c,print_strings.c, print_locs.c, print_lines.c, print_pubnames.c,print_ranges.c, print_macros.c,print_types.c,tag_common.c, print_weaknames.c, print_aranges.c: Include changed from dwarf_names.h to naming.h * tag_common.h: Removed the tag_name array, libdwarf provides the TAG, ATTR, etc name strings now. * dwarfdump.c: Updated DWARFDUMP_VERSION string. * tag_tree.c,tag_attr.c: Include changed from dwarf_names.h to naming.h. simplified long complicated lines, remove dbg argument to get_TAG_name. * print_die.c,print_abbrevs.c: Include changed from dwarf_names.h to naming.h. Calls to get_TAG_name (etc) no longer have a dbg argument. * Makefile.in: We no longer build generated file names.c, we build naming.c (hand coded, not generated). 2009-05-07: David Anderson * dwarfdump.cc: updated DWARF_VERSION string. * Makefile.in: dwarf_names* are now generated by C, so 'clean' now cleans them out. 2009-05-04: David Anderson * common.h, common.c: Extracted simple utility routines into their own files. * dwarf_names.awk, at_list.awk: deleted. gennames.c replaces these. * tag_common.c, tag_common.h: Removed the simple utility routines from these files to simplify dependencies. * tag_attr.c, tag_tree.c: Include new common.h. * print_frames.c: Adding address_size argument to call. * print_frames.h: Adding new address_size argument to get_string_from_locs() declaration. * print_locs.c: Gets and uses CU-specific address_size. * print_ranges.c: Adding commentary. * print_die.c: adding DIE argument to ensure correct address size used for the CU in question. * Makefile.in: Now handles common.* and gennames.c changes. * gennames.c: New code emitting string 'get name' source. Replaces awk source. 2009-04-04: David Anderson * Makefile.in: clean up 'clean' and 'distclean' so that distributed files are not cleaned out by 'clean' and all generated files (even those shipped in distribution) are cleaned out by distclean. * dwarfdump.c: Now calls the new libdwarf function dwarf_set_frame_cfa_value() and other such functions to specify all the values libdwarf needs. * dwarfdump.conf: Sets the cfa_reg: value to a new higher value (1436) to avoid conflict with largest known register count. * dwconf.h: Corrected commentary on DW_FRAME_CFA_COL3. * dwconf.c: Now uses DW_FRAME_CFA_COL3 as default for interface 3, rather than a directly typed number. Sets undefined-value and same-value pseudo-register numbers. 2009-04-03: David Anderson * dwarfdump.1: Amplified -R and -x abi= documentation. * dwarfdump.conf: Added generic500 generic100 abis. 2009-03-29: David Anderson * print_die.c: Moved print_infos() to here. * dwarfdump.c: Moved print_infos() out of here. * globals.h: Declarations changed to allow moving print_infos(). * dwarf_names.awk: Eliminate a pointless space before a newline in the generated code. * print_locs.c: Add -v section offset output to loclist printing of the debug_loc section so the entries can be matched to loclist printing initiated from .debug_info. 2009-03-24: David Anderson * README: Would be nice if all could use dwarfdump2, not this C dwarfdump. * dwconf.c: Initialize new frame regs configure data and parse it in the .conf file. Fixed old formatting mistakes. * dwconf.h: Add new fields to frame regs configure struct. Make -R be 1200 regs so that -R covers all the currently popular ABIs. * print_die.c, print_lines.c, print_frames.c: Change %# to 0x% so that zero prints with leading 0x consistently. * dwarfdump.c: -R is now 1200 registers. So config function changed and usage message needed update. * dwarfdump.1: Change -R to 1200 and document -C. * dwarfdump.conf: Add same_val_reg: and undefined_val_reg: initial values where needed or interesting. * print_macros.c: Fix old formatting mistake. 2009-03-23: David Anderson * print_sections.h: New file for print_*.c sources. * dwarfdump.1: Added -C documentation. * Makefile.in: updated 'mandir' so it works with current configure (so now make install properly installs the man page). * print_sections.c: Moved get_fde_proc_name() and related code to print_frames.c, where it is referenced. * dwarfdump.c: No longer turn on info_flag with -f or -F. Moved the Usage strings into a string table and loop through to print them. * globals.h: Removed get_fde_proc_name() declaration. * print_frames.c: Added get_fde_proc_name() here and removed the 'inlined:' from the abstract origin name. 2009-03-20: David Anderson * print_static_vars.c, print_static_funcs.c, print_strings.c, print_locs.c, print_pubnames.c, print_lines.c, print_ranges.c, print_abbrevs.c, print_macros.c, print_types.c, print_weaknames.c, print_aranges.c: Moved the print_* functions from print_sections.c into individual sourcefiles. * Makefile.in: Now lists the new sourcefiles. * print_sections.c: Deleted code moved to individual sourcefiles. Added code to try to find the name from a DW_AT_abstract_origin DIE when a subprogram DIE itself has no DW_AT_name; * dwarfdump.c: Remove unused local variables. Use DWARFDUMP_VERSION #define to set version string. * tag_tree.c: Fix && || problem with parentheses. * tag_attr.c: Fix && || problem with parentheses. * print_frames.c: Moved the 'print_frames' function itself from print_sections.c to here. 2009-03-17: David Anderson * globals.h: Created predicate function should_skip_this_cu() predicate function. Eliminating code duplication. * print_frames.c: Fix a hex value output to have a leading 0x as all hex values should (when printed). * print_sections.c: Call should_skip_this_cu(), which replaces duplicate code. Fix the arange print: now the hex value has a leading 0x as all hex values should. get_proc_name() had local variable funcnamefound initialized incorrectly, now is set to 0 as it should be. get_nested_proc_name() now initializes string buffers. get_fde_proc_name() now initializes its string buffer. Surprisingly things worked adequately before in spite of the errors. * dwarfdump.c: Call should_skip_this_cu(). Implementation of that new function is in this source file. 2009-03-16: David Anderson * print_frames.c:DW_CFA_restore output had a spurious newline. Removed 2 pointless blank lines an initialized 2 local variables. * print_sections.c: Removed a pointless redeclaration of a function in libdwarf.h. check_info_offset_sanity() was missing a return statement in one place, which could lead to spurious extra (and silly) error text. 2009-03-09: David Anderson * print_die.c: Make a comment easier to understand. 2009-02-28: David Anderson * Makefile.in: add tmp-*.tmp to the 'clean' rule. 2009-02-17: David Anderson * print_sections.c,print_die.c,tag_common.c,print_frames.c: C99 in-line declarations and // comments are not intended here, this removes a few that were introduced accidentally. 2009-02-16: David Anderson * Makefile.in: Removed some use of awk and simplified some shell scripting here. renamed temp files, no longer named with underbars, they uniformly start with 'tmp-'. * print_sections.c: Added the new argument required by the updated dwarf_names.c functions argument lists. * tag_tree_ext.list: List 'common extensions' of tag->tag relationships. * tag_attr_ext.list: List 'common extensions' of tag->attr relationships. * print_die.c: New 'common extension' tables used for checking tag->tag and tag->attr relationships unless turned off with -C. * dwarf_names.awk: Removed tabs so generated names.c not so spread out. Added argument to the generated functions so tag_tree.c, tag_attr.c can use these generated functions nicely. * dwarfdump.c: Adding -C option, which exposes some 'common extensions' of dwarf uses as DWARF CHECK (-ka) warnings. By default these extensions not reported as warnings. * tag_tree.c: Now generates base and extensions tables. Code in common with tag_attr.c is in tag_common* files. * tag_attr.c: Now generates base and extensions tables. Code in common with tag_tree.c is in tag_common* files. * tag_common.c, tag_common.h: New files with the common data extracted from tag_tree.c and tag_attr.c * globals.h: global flag added for -C. 2009-02-14: David Anderson * configure.in: Define --enable-nonstandardprintf * config.h.in: new #undef HAVE_NONSTANDARD_PRINTF_64_FORMAT * configure: Regenerated. * config.guess, config.sub: Latest version from GNU. * Makefile.in: Referenced configure variable to avoid irritating message at configure time. * README: document --enable-nonstandardprintf * print_sections.c, print_die.c, print_reloc.c, dwarfdump.c, dwconf.c, print_frames.c: Use libdwarf.h DW_PR_ printf macros for for better portability. 2009-02-13: David Anderson * print_sections.c: Ensure we are checking line table header correctness whichever line-table-print code is being used. Allow ARM line header table (which has a bug) to be used. * dwarfdump.c: Print lines_result total with checking on. * globals.h: Add lines_result global to count line botches. 2009-02-11: David Anderson * print_sections.c, print_die.c: DWARF_CHECK_ERROR* macros now get the count struct passed in. * tag_tree.c, tag_attr.c: Add a comment in the output identifying the output as generated code and with the generation date/time inserted. * globals.h: Accept the struct in DWARF_CHECK_ERROR* macros so we can update the error count in the macro. 2009-01-31: David Anderson * Makefile.in: Remove compilation of _tag_attr_table.c and _tag_tree_table.c as those are #included in print_die.c, not separately compiled. * print_frames.c: A formerly-static function now called from another file, so declare it here. * print_sections.c: Improve the printing of the .debug_loc section. * print_die.c: A couple of errors were missing their error count increment. * tag_attr.list tag_tree.list: Some normal relationships were left out of the tables: fixed now. dwarf-20120410/dwarfdump/install.sh0000750000175000017500000000421211741100175015757 0ustar daveadavea#!/bin/sh # # install - install a program, script, or datafile # This comes from X11R5; it is not part of GNU. # # $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $ # # This script is compatible with the BSD install script, but was written # from scratch. # # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" instcmd="$mvprog" chmodcmd="" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; *) if [ x"$src" = x ] then src=$1 else dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` fi # Make a temp file name in the proper directory. dstdir=`dirname $dst` dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp # and set any options; do chmod last to preserve setuid bits if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi # Now rename the file to the real destination. $doit $rmcmd $dst $doit $mvcmd $dsttmp $dst exit 0 dwarf-20120410/dwarfdump/configure0000750000175000017500000044066111741100175015675 0ustar daveadavea#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.68. # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software # Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME= PACKAGE_TARNAME= PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= PACKAGE_URL= ac_unique_file="dwarfdump.c" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='LTLIBOBJS LIBOBJS AR RANLIB INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM EGREP GREP CPP OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_nonstandardprintf ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures this package to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF _ACEOF fi if test -n "$ac_init_help"; then cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-nonstandardprintf Use a special printf format for 64bit (default is NO) Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF configure generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers config.h" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" if test $ac_cv_c_compiler_gnu = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5 $as_echo_n "checking whether $CC needs -traditional... " >&6; } if ${ac_cv_prog_gcc_traditional+:} false; then : $as_echo_n "(cached) " >&6 else ac_pattern="Autoconf.*'x'" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include Autoconf TIOCGETP _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "$ac_pattern" >/dev/null 2>&1; then : ac_cv_prog_gcc_traditional=yes else ac_cv_prog_gcc_traditional=no fi rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include Autoconf TCGETA _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "$ac_pattern" >/dev/null 2>&1; then : ac_cv_prog_gcc_traditional=yes fi rm -f conftest* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_gcc_traditional" >&5 $as_echo "$ac_cv_prog_gcc_traditional" >&6; } if test $ac_cv_prog_gcc_traditional = yes; then CC="$CC -traditional" fi fi ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AR="${ac_tool_prefix}ar" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_AR"; then ac_ct_AR=$AR # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_AR="ar" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_AR" = x; then AR="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi else AR="$ac_cv_prog_AR" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in elf.h getopt.h libelf.h libelf/libelf.h sgidefs.h sys/types.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for elf64_getehdr in -lelf" >&5 $as_echo_n "checking for elf64_getehdr in -lelf... " >&6; } if ${ac_cv_lib_elf_elf64_getehdr+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lelf $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char elf64_getehdr (); int main () { return elf64_getehdr (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_elf_elf64_getehdr=yes else ac_cv_lib_elf_elf64_getehdr=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_elf_elf64_getehdr" >&5 $as_echo "$ac_cv_lib_elf_elf64_getehdr" >&6; } if test "x$ac_cv_lib_elf_elf64_getehdr" = xyes; then : $as_echo "#define HAVE_ELF64_GETEHDR 1" >>confdefs.h fi if test "$ac_cv_header_elf_h" = yes; then $as_echo "#define LOCATION_OF_LIBELFHEADER " >>confdefs.h elif test "$ac_cv_header_libelf_h" = yes; then $as_echo "#define LOCATION_OF_LIBELFHEADER " >>confdefs.h elif test "$ac_cv_header_libelf_libelf_h" = yes; then $as_echo "#define LOCATION_OF_LIBELFHEADER " >>confdefs.h fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include "stdafx.h" int main () { int p; p = 27; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define HAVE_STDAFX_H 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include LOCATION_OF_LIBELFHEADER int main () { Elf64_Rel *p; int i; i = p->r_info; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define HAVE_ELF64_R_INFO 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { __uint32_t p; p = 3; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define HAVE___UINT32_T 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { __uint64_t p; p = 3; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define HAVE___UINT64_T 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { __uint32_t p; p = 3; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define HAVE___UINT32_T_IN_SYS_TYPES_H 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { int i; regex_t r; int cflags = REG_EXTENDED; const char *s = "abc"; i = regcomp(&r,s,cflags); regfree(&r); ; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define HAVE_REGEX 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include /* On Ubuntu 10.x, tsearch is in package libc6-dev. */ /* The tdestroy function is GNU, not POSIX. */ #define __USE_GNU 1 #include struct my_tentry { long mt_key; char * mt_name; }; struct my_tentry * make_my_tentry(long k,char *name) { return 0; } void mt_free_func(void *mt_data) { return; } int mt_compare_func(const void *l, const void *r) { return 0; } int main () { long i = 1; void *tree1 = 0; char *dbuf = 0; struct my_tentry *mt = 0; struct my_tentry *retval = 0; mt = make_my_tentry(i,dbuf); retval = tsearch(mt,&tree1, mt_compare_func ); tdestroy(tree1,mt_free_func); exit(0); ; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : $as_echo "#define HAVE_TSEARCH 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # Check whether --enable-nonstandardprintf was given. if test "${enable_nonstandardprintf+set}" = set; then : enableval=$enable_nonstandardprintf; $as_echo "#define HAVE_NONSTANDARD_PRINTF_64_FORMAT 1" >>confdefs.h fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int p; p = 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define HAVE_RAW_LIBELF_OK 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _GNU_SOURCE #include int main () { off64_t p; p = 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define HAVE_LIBELF_OFF64_OK 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by $as_me, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ config.status configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi dwarf-20120410/dwarfdump/DWARFDUMPCOPYRIGHT0000640000175000017500000000707711741100175016534 0ustar daveadavea ========The dwarfdump copyright======= The full text of the GPL version 2 is provided in the file GPL.txt. Nearly all the files in this directory have contained a GPL copyright, not an LGPL copyright, for years. The following is an example of that copyright as used in the dwarfdump source, and is what SGI always intended (in David Anderson's opinion) to have present in the DWARFDUMPCOPYRIGHT file. (tag_tree.list tag_attr.list acconfig.h have long been marked LGPL and therefore the LGPL copyright, not GPL, applies to those three files.) This GPL copyright text added here to DWARFDUMPCOPYRIGHT Dec 4, 2006 Copyright (C) 2000,2002,2004,2005 Silicon Graphics, Inc. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan The following was the entire content of this file before December 24 2006, Being the LGPL text this is in conflict with the individual source files and I (David Anderson) believe the source file copyright was intended for dwarfdump not the LGPL source directly following this note. However the 3 files tag_tree.list tag_attr.list acconfig.h have long been marked LGPL and the following copyright applies to those three. Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2.1 of the GNU Lesser General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan dwarf-20120410/dwarfdump/esb.c0000640000175000017500000001434011741100175014673 0ustar daveadavea/* Copyright (C) 2005 Silicon Graphics, Inc. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/esb.c,v 1.1 2005/08/04 05:09:37 davea Exp $ */ /* esb.c extensible string buffer. A simple means (vaguely like a C++ class) that enables safely saving strings of arbitrary length built up in small pieces. */ #include "globals.h" #include /* For va_start etc. */ #include "esb.h" #define INITIAL_ALLOC 1024 static size_t alloc_size = INITIAL_ALLOC; static void init_esb_string(struct esb_s *data, size_t min_len) { string d; if (data->esb_allocated_size > 0) { return; } if (min_len < alloc_size) { min_len = alloc_size; } d = malloc(min_len); if (!d) { fprintf(stderr, "dwarfdump is out of memory allocating %lu bytes\n", (unsigned long) min_len); exit(5); } data->esb_string = d; data->esb_allocated_size = min_len; data->esb_string[0] = 0; data->esb_used_bytes = 0; } /* Make more room. Leaving contents unchanged, effectively. */ static void allocate_more(struct esb_s *data, size_t len) { size_t new_size = data->esb_allocated_size + len; string newd = 0; if (new_size < alloc_size) new_size = alloc_size; newd = realloc(data->esb_string, new_size); if (!newd) { fprintf(stderr, "dwarfdump is out of memory re-allocating " "%lu bytes\n", (unsigned long) new_size); exit(5); } data->esb_string = newd; data->esb_allocated_size = new_size; } static void esb_appendn_internal(struct esb_s *data, const char * in_string, size_t len); void esb_appendn(struct esb_s *data, const char * in_string, size_t len) { size_t full_len = strlen(in_string); if (full_len < len) { fprintf(stderr, "dwarfdump internal error, bad string length " " %lu < %lu \n", (unsigned long) full_len, (unsigned long) len); len = full_len; } esb_appendn_internal(data, in_string, len); } /* The length is gotten from the in_string itself. */ void esb_append(struct esb_s *data, const char * in_string) { size_t len = strlen(in_string); esb_appendn_internal(data, in_string, len); } /* The 'len' is believed. Do not pass in strings < len bytes long. */ static void esb_appendn_internal(struct esb_s *data, const char * in_string, size_t len) { size_t remaining = 0; size_t needed = len + 1; if (data->esb_allocated_size == 0) { size_t maxlen = (len > alloc_size) ? len : alloc_size; init_esb_string(data, maxlen); } remaining = data->esb_allocated_size - data->esb_used_bytes; if (remaining < needed) { allocate_more(data, needed); } strncpy(&data->esb_string[data->esb_used_bytes], in_string, len); data->esb_used_bytes += len; /* Insist on explicit NUL terminator */ data->esb_string[data->esb_used_bytes] = 0; } /* Always returns an empty string or a non-empty string. Never 0. */ string esb_get_string(struct esb_s *data) { if (data->esb_allocated_size == 0) { init_esb_string(data, alloc_size); } return data->esb_string; } /* Sets esb_used_bytes to zero. The string is not freed and esb_allocated_size is unchanged. */ void esb_empty_string(struct esb_s *data) { if (data->esb_allocated_size == 0) { init_esb_string(data, alloc_size); } data->esb_used_bytes = 0; data->esb_string[0] = 0; } /* Return esb_used_bytes. */ size_t esb_string_len(struct esb_s *data) { return data->esb_used_bytes; } /* The following are for testing esb, not use by dwarfdump. */ /* *data is presumed to contain garbage, not values, and is properly initialized. */ void esb_constructor(struct esb_s *data) { memset(data, 0, sizeof(*data)); } /* The string is freed, contents of *data set to zeroes. */ void esb_destructor(struct esb_s *data) { if (data->esb_string) { free(data->esb_string); } esb_constructor(data); } /* To get all paths in the code tested, this sets the allocation/reallocation to the given value, which can be quite small but must not be zero. */ void esb_alloc_size(size_t size) { alloc_size = size; } size_t esb_get_allocated_size(struct esb_s *data) { return data->esb_allocated_size; } /* Append a formatted string */ void esb_append_printf(struct esb_s *data,const char *in_string, ...) { #if WIN32 #define NULL_DEVICE_FILE "NUL" #else #define NULL_DEVICE_FILE "/dev/null" #endif /* WIN32 */ static FILE *null_file = NULL; int needed_size = 0; int length = 0; va_list ap; va_start(ap,in_string); if (null_file == NULL) { null_file = fopen(NULL_DEVICE_FILE,"w"); } length = vfprintf(null_file,in_string,ap); /* Check if we require allocate more space */ needed_size = data->esb_used_bytes + length; if (needed_size > data->esb_allocated_size) { allocate_more(data,length); } vsprintf(&data->esb_string[data->esb_used_bytes],in_string,ap); data->esb_used_bytes += length; va_end(ap); } dwarf-20120410/dwarfdump/common.c0000640000175000017500000000511111741100175015406 0ustar daveadavea/* Copyright (C) 2008-2010 SN Systems. All Rights Reserved. Portions Copyright (C) 2008-2011 David Anderson. All Rights Reserved. Portions Copyright (C) 2011 SN Systems Ltd. . All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan */ /* These do little except on Windows */ #include "common.h" #include #define DWARFDUMP_VERSION " Tue Apr 10 11:43:32 PDT 2012 " /* The Linux/Unix version does not want a version string to print unless -V is on the command line. */ void print_version_details(const char * name,int alwaysprint) { #ifdef WIN32 # ifdef _DEBUG char *acType = "Debug"; # else char *acType = "Release"; # endif /* _DEBUG */ static char acVersion[32]; snprintf(acVersion,sizeof(acVersion), "[%s %s %s]",__DATE__,__TIME__,acType); printf("%s %s\n",name,acVersion); #else /* !WIN32 */ if(alwaysprint) { printf("%s\n",DWARFDUMP_VERSION); } #endif /* WIN32 */ } void print_args(int argc, char *argv[]) { #ifdef WIN32 int index = 1; printf("Arguments: "); for (index = 1; index < argc; ++index) { printf("%s ",argv[index]); } printf("\n"); #endif /* WIN32 */ } void print_usage_message(const char *program_name, const char **text) { unsigned i = 0; #ifndef WIN32 fprintf(stderr,"Usage: %s \n", program_name); #endif for (i = 0; *text[i]; ++i) { fprintf(stderr,"%s\n", text[i]); } } dwarf-20120410/dwarfdump/print_sections.c0000640000175000017500000001307411741100175017170 0ustar daveadavea/* Copyright (C) 2000-2006 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright 2007-2010 Sun Microsystems, Inc. All rights reserved. Portions Copyright 2009-2010 SN Systems Ltd. All rights reserved. Portions Copyright 2008-2011 David Anderson. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/print_sections.c,v 1.69 2006/04/17 00:09:56 davea Exp $ */ /* The address of the Free Software Foundation is Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. SGI has moved from the Crittenden Lane address. */ #include "globals.h" #include "naming.h" #include "dwconf.h" #include "esb.h" #include "print_sections.h" #include "print_frames.h" /* Print line number information: filename new basic-block [line] [address] */ int dwarf_names_print_on_error = 1; /* referred in dwarfdump.c */ Dwarf_Die current_cu_die_for_print_frames; void deal_with_name_offset_err(Dwarf_Debug dbg, char *err_loc, char *name, Dwarf_Unsigned die_off, int nres, Dwarf_Error err) { if (nres == DW_DLV_ERROR) { Dwarf_Unsigned myerr = dwarf_errno(err); if (myerr == DW_DLE_OFFSET_BAD) { printf("Error: bad offset %s, %s %" DW_PR_DUu " (0x%08" DW_PR_DUx ")\n", err_loc, name, die_off, die_off); } print_error(dbg, err_loc, nres, err); } } /* The April 2005 dwarf_get_section_max_offsets() in libdwarf returns all max-offsets, but we only want one of those offsets. This function returns the one we want from that set, making functions needing this offset as readable as possible. (avoiding code duplication). */ Dwarf_Unsigned get_info_max_offset(Dwarf_Debug dbg) { Dwarf_Unsigned debug_info_size = 0; Dwarf_Unsigned debug_abbrev_size = 0; Dwarf_Unsigned debug_line_size = 0; Dwarf_Unsigned debug_loc_size = 0; Dwarf_Unsigned debug_aranges_size = 0; Dwarf_Unsigned debug_macinfo_size = 0; Dwarf_Unsigned debug_pubnames_size = 0; Dwarf_Unsigned debug_str_size = 0; Dwarf_Unsigned debug_frame_size = 0; Dwarf_Unsigned debug_ranges_size = 0; Dwarf_Unsigned debug_pubtypes_size = 0; dwarf_get_section_max_offsets(dbg, &debug_info_size, &debug_abbrev_size, &debug_line_size, &debug_loc_size, &debug_aranges_size, &debug_macinfo_size, &debug_pubnames_size, &debug_str_size, &debug_frame_size, &debug_ranges_size, &debug_pubtypes_size); return debug_info_size; } /* decode ULEB */ Dwarf_Unsigned local_dwarf_decode_u_leb128(unsigned char *leb128, unsigned int *leb128_length) { unsigned char byte = 0; Dwarf_Unsigned number = 0; unsigned int shift = 0; unsigned int byte_length = 1; byte = *leb128; for (;;) { number |= (byte & 0x7f) << shift; shift += 7; if ((byte & 0x80) == 0) { if (leb128_length != NULL) *leb128_length = byte_length; return (number); } byte_length++; byte = *(++leb128); } } #define BITSINBYTE 8 Dwarf_Signed local_dwarf_decode_s_leb128(unsigned char *leb128, unsigned int *leb128_length) { Dwarf_Signed number = 0; Dwarf_Bool sign = 0; Dwarf_Signed shift = 0; unsigned char byte = *leb128; Dwarf_Signed byte_length = 1; /* byte_length being the number of bytes of data absorbed so far in turning the leb into a Dwarf_Signed. */ for (;;) { sign = byte & 0x40; number |= ((Dwarf_Signed) ((byte & 0x7f))) << shift; shift += 7; if ((byte & 0x80) == 0) { break; } ++leb128; byte = *leb128; byte_length++; } if ((shift < sizeof(Dwarf_Signed) * BITSINBYTE) && sign) { number |= -((Dwarf_Signed) 1 << shift); } if (leb128_length != NULL) *leb128_length = byte_length; return (number); } /* Dumping a dwarf-expression as a byte stream. */ void dump_block(char *prefix, char *data, Dwarf_Signed len) { char *end_data = data + len; char *cur = data; int i = 0; printf("%s", prefix); for (; cur < end_data; ++cur, ++i) { if (i > 0 && i % 4 == 0) printf(" "); printf("%02x", 0xff & *cur); } } dwarf-20120410/dwarfdump/ChangeLog20100000640000175000017500000001245011741100175016033 0ustar daveadavea2010-09-30 DavidAnderson * dwarfdump.c: Now -a no longer implies -c because the -c option is not guaranteed to work by the DWARF spec, nor is -c really necessary. * README: More tweaks on the 'install' issue. 2010-09-29 DavidAnderson * README, Makefile.in: Amplified make install instructions. 2010-09-20 DavidAnderson * print_die.c: If a location form is wrong report an error but continue operating. * dwarfdump.c: Implement print_error_and_continue(). Fix mistakes in usage message. * globals.h: Declare print_error_and_continue(). 2010-04-04 DavidAnderson * dwarfdump.c: New version date. * configure: regenerated. * addrmap.c: Added a comment to mention that tdestroy is GNU only, POSIX does not mention a way to delete the tsearch tree. Hence the code does #define USE_GNU 1 to expose the tdestroy function prototype. 2010-04-03 DavidAnderson * print_frames.h: Added new arguments to a function to get better function names printing. * configure.in: Added test for tsearch functions so dwarfdump will still compile if they are not present. See HAVE_TSEARCH macro. * configure: regenerated. * Makefile.in: Now names object for addrmap.c * addrmap.c: New file to map pc address to function names so fde printing gets functions named properly (using tsearch). * addrmap.h: New file to map pc address to function names so fde printing gets functions named properly (using tsearch). * print_lines.c: Correct the calculation of the number of error checks. * dwarfdump.c: Added fdes error check print. * config.h.in: Now handles the HAVE_TSEARCH macro. * globals.h: Added declarations for the fde error check globals. * print_frames.c: Now uses addrmap.h functions to do a better job of printing function names in the frame output. 2010-03-31 DavidAnderson * dwarfdump.1: Added some text about 'harmless' errors. * dwarfdump.c: Change the size of the harmless error list to 50. Change harmless error reporting to be associated with -k flags. * dwconf.c: Initialize uninitialized fields to satisfy a compiler warning. * globals.h: Declarations added for 'harmless' error reporting. * print_die.c: Added commentary. * print_frames.cc: Change harmless error reporting to be associated with -k flags. * print_aranges.c: Now calls dwarf_get_arange_info_b() allowing proper printing of DWARF4 segment-sensitive aranges. Change harmless error reporting to be associated with -k flags. 2010-03-28 DavidAnderson * dwarf_globals.h: Added interface to print_any_harmless_errors(). * dwarfdump.c: Added print_any_harmless_errors() implementation and we call it just before closing libdwarf. * print_frames.c: Call print_any_harmless_errors after getting cie/fde list. * dwarfdump.conf: Add abi named 'arm' for Arm users. * print_die.c: Initialize a local string pointer to NULL at the point of definition. 2010-02-14 DavidAnderson * print_die.c: Add newer DW_OP operators, remove bogus test of DW_OP_nop as the highest valid operator. Add table of DW_OPs to simplify testing for zero-operand operators. Revise so that the FORM of all attributes print with -M. Move a local variable declaration to the front of a block to match C 1990 rules. String searches now also match on attribute name. * tag_attr.list: Updated copyright. * dwarfdump.c: Remove a switch FALL THROUGH in the 'g' case. * tag_tree_ext.list, tag_attr_ext.list: Added GNU template parameter tags, attributes. Updated copyright. * tag_tree.list: Added template parameter tags. Added entry for nested classes. Updated copyright. * tag_common.h: Increased STD_TAG_TABLE_COLUMNS and EXT_ATTR_TABLE_COLS. 2010-01-30 DavidAnderson * print_die.c: Changed the spelling of one 'DW_AT_type offset does not point to type info' error message so one can distinguish which check lead to the message. 2010-01-26 DavidAnderson * dwarfdump.1, dwconf.c, dwconf.h, dwarfdump.conf: The default frame values in frame output are now generic registers like r0 to r99 instead of MIPS register names. For the MIPS register names use '-x abi=mips'. * print_frames.c: Added commentary. 2010-01-17 DavidAnderson * print_die.c: The special case DW_AT_SUN_func_offsets now prints identically in dwarfdump and dwarfdump2. 2010-01-03 DavidAnderson * tag_common.c, common.h, common.c: Remove line terminator characters. Update copyright year. * All other files: Update copyright year. dwarf-20120410/dwarfdump/print_reloc.h0000640000175000017500000003774511741100175016465 0ustar daveadavea/* Copyright (C) 2000,2004,2005 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright (C) 2007-2011 David Anderson. All Rights Reserved. Portions Copyright (C) 2011 SN Systems Ltd. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/print_reloc.c,v 1.11 2005/08/04 05:09:37 davea Exp $ */ /* The address of the Free Software Foundation is Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. SGI has moved from the Crittenden Lane address. */ /* PowerPC relocations defined by the ABIs */ #define R_PPC_NONE 0 #define R_PPC_ADDR32 1 /* 32bit absolute address */ #define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */ #define R_PPC_ADDR16 3 /* 16bit absolute address */ #define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */ #define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */ #define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */ #define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */ #define R_PPC_ADDR14_BRTAKEN 8 #define R_PPC_ADDR14_BRNTAKEN 9 #define R_PPC_REL24 10 /* PC relative 26 bit */ #define R_PPC_REL14 11 /* PC relative 16 bit */ #define R_PPC_REL14_BRTAKEN 12 #define R_PPC_REL14_BRNTAKEN 13 #define R_PPC_GOT16 14 #define R_PPC_GOT16_LO 15 #define R_PPC_GOT16_HI 16 #define R_PPC_GOT16_HA 17 #define R_PPC_PLTREL24 18 #define R_PPC_COPY 19 #define R_PPC_GLOB_DAT 20 #define R_PPC_JMP_SLOT 21 #define R_PPC_RELATIVE 22 #define R_PPC_LOCAL24PC 23 #define R_PPC_UADDR32 24 #define R_PPC_UADDR16 25 #define R_PPC_REL32 26 #define R_PPC_PLT32 27 #define R_PPC_PLTREL32 28 #define R_PPC_PLT16_LO 29 #define R_PPC_PLT16_HI 30 #define R_PPC_PLT16_HA 31 #define R_PPC_SDAREL16 32 #define R_PPC_SECTOFF 33 #define R_PPC_SECTOFF_LO 34 #define R_PPC_SECTOFF_HI 35 #define R_PPC_SECTOFF_HA 36 /* Unused types */ #define R_PPC_37 37 #define R_PPC_38 38 #define R_PPC_39 39 #define R_PPC_40 40 #define R_PPC_41 41 #define R_PPC_42 42 #define R_PPC_43 43 #define R_PPC_44 44 #define R_PPC_45 45 #define R_PPC_46 46 #define R_PPC_47 47 #define R_PPC_48 48 #define R_PPC_49 49 #define R_PPC_50 50 #define R_PPC_51 51 #define R_PPC_52 52 #define R_PPC_53 53 #define R_PPC_54 54 #define R_PPC_55 55 /* Unused types */ #define R_PPC_56 56 #define R_PPC_57 57 #define R_PPC_58 58 #define R_PPC_59 59 #define R_PPC_60 60 #define R_PPC_61 61 #define R_PPC_62 62 #define R_PPC_63 63 #define R_PPC_64 64 #define R_PPC_65 65 #define R_PPC_66 66 /* PowerPC relocations defined for the TLS access ABI. */ #define R_PPC_TLS 67 /* none (sym+add)@tls */ #define R_PPC_DTPMOD32 68 /* word32 (sym+add)@dtpmod */ #define R_PPC_TPREL16 69 /* half16* (sym+add)@tprel */ #define R_PPC_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */ #define R_PPC_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */ #define R_PPC_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */ #define R_PPC_TPREL32 73 /* word32 (sym+add)@tprel */ #define R_PPC_DTPREL16 74 /* half16* (sym+add)@dtprel */ #define R_PPC_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */ #define R_PPC_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */ #define R_PPC_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */ #define R_PPC_DTPREL32 78 /* word32 (sym+add)@dtprel */ #define R_PPC_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */ #define R_PPC_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */ #define R_PPC_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */ #define R_PPC_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */ #define R_PPC_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */ #define R_PPC_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */ #define R_PPC_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */ #define R_PPC_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */ #define R_PPC_GOT_TPREL16 87 /* half16* (sym+add)@got@tprel */ #define R_PPC_GOT_TPREL16_LO 88 /* half16 (sym+add)@got@tprel@l */ #define R_PPC_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */ #define R_PPC_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */ #define R_PPC_GOT_DTPREL16 91 /* half16* (sym+add)@got@dtprel */ #define R_PPC_GOT_DTPREL16_LO 92 /* half16* (sym+add)@got@dtprel@l */ #define R_PPC_GOT_DTPREL16_HI 93 /* half16* (sym+add)@got@dtprel@h */ #define R_PPC_GOT_DTPREL16_HA 94 /* half16* (sym+add)@got@dtprel@ha */ /* Keep this the last entry. */ #define R_PPC_NUM 95 /* PowerPC64 relocations defined by the ABIs */ #define R_PPC64_NONE R_PPC_NONE #define R_PPC64_ADDR32 R_PPC_ADDR32 /* 32bit absolute address. */ #define R_PPC64_ADDR24 R_PPC_ADDR24 /* 26bit address, word aligned. */ #define R_PPC64_ADDR16 R_PPC_ADDR16 /* 16bit absolute address. */ #define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO /* lower 16bits of abs. address. */ #define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI /* high 16bits of abs. address. */ #define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA /* adjusted high 16bits. */ #define R_PPC64_ADDR14 R_PPC_ADDR14 /* 16bit address, word aligned. */ #define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN #define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN #define R_PPC64_REL24 R_PPC_REL24 /* PC relative 26 bit, word aligned. */ #define R_PPC64_REL14 R_PPC_REL14 /* PC relative 16 bit. */ #define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN #define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN #define R_PPC64_GOT16 R_PPC_GOT16 #define R_PPC64_GOT16_LO R_PPC_GOT16_LO #define R_PPC64_GOT16_HI R_PPC_GOT16_HI #define R_PPC64_GOT16_HA R_PPC_GOT16_HA #define R_PPC64_COPY R_PPC_COPY #define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT #define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT #define R_PPC64_RELATIVE R_PPC_RELATIVE #define R_PPC64_UADDR32 R_PPC_UADDR32 #define R_PPC64_UADDR16 R_PPC_UADDR16 #define R_PPC64_REL32 R_PPC_REL32 #define R_PPC64_PLT32 R_PPC_PLT32 #define R_PPC64_PLTREL32 R_PPC_PLTREL32 #define R_PPC64_PLT16_LO R_PPC_PLT16_LO #define R_PPC64_PLT16_HI R_PPC_PLT16_HI #define R_PPC64_PLT16_HA R_PPC_PLT16_HA #define R_PPC64_SECTOFF R_PPC_SECTOFF #define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO #define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI #define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA #define R_PPC64_ADDR30 37 /* word30 (S + A - P) >> 2. */ #define R_PPC64_ADDR64 38 /* doubleword64 S + A. */ #define R_PPC64_ADDR16_HIGHER 39 /* half16 #higher(S + A). */ #define R_PPC64_ADDR16_HIGHERA 40 /* half16 #highera(S + A). */ #define R_PPC64_ADDR16_HIGHEST 41 /* half16 #highest(S + A). */ #define R_PPC64_ADDR16_HIGHESTA 42 /* half16 #highesta(S + A). */ #define R_PPC64_UADDR64 43 /* doubleword64 S + A. */ #define R_PPC64_REL64 44 /* doubleword64 S + A - P. */ #define R_PPC64_PLT64 45 /* doubleword64 L + A. */ #define R_PPC64_PLTREL64 46 /* doubleword64 L + A - P. */ #define R_PPC64_TOC16 47 /* half16* S + A - .TOC. */ #define R_PPC64_TOC16_LO 48 /* half16 #lo(S + A - .TOC.). */ #define R_PPC64_TOC16_HI 49 /* half16 #hi(S + A - .TOC.). */ #define R_PPC64_TOC16_HA 50 /* half16 #ha(S + A - .TOC.). */ #define R_PPC64_TOC 51 /* doubleword64 .TOC. */ #define R_PPC64_PLTGOT16 52 /* half16* M + A. */ #define R_PPC64_PLTGOT16_LO 53 /* half16 #lo(M + A). */ #define R_PPC64_PLTGOT16_HI 54 /* half16 #hi(M + A). */ #define R_PPC64_PLTGOT16_HA 55 /* half16 #ha(M + A). */ #define R_PPC64_ADDR16_DS 56 /* half16ds* (S + A) >> 2. */ #define R_PPC64_ADDR16_LO_DS 57 /* half16ds #lo(S + A) >> 2. */ #define R_PPC64_GOT16_DS 58 /* half16ds* (G + A) >> 2. */ #define R_PPC64_GOT16_LO_DS 59 /* half16ds #lo(G + A) >> 2. */ #define R_PPC64_PLT16_LO_DS 60 /* half16ds #lo(L + A) >> 2. */ #define R_PPC64_SECTOFF_DS 61 /* half16ds* (R + A) >> 2. */ #define R_PPC64_SECTOFF_LO_DS 62 /* half16ds #lo(R + A) >> 2. */ #define R_PPC64_TOC16_DS 63 /* half16ds* (S + A - .TOC.) >> 2. */ #define R_PPC64_TOC16_LO_DS 64 /* half16ds #lo(S + A - .TOC.) >> 2. */ #define R_PPC64_PLTGOT16_DS 65 /* half16ds* (M + A) >> 2. */ #define R_PPC64_PLTGOT16_LO_DS 66 /* half16ds #lo(M + A) >> 2. */ /* PowerPC64 relocations defined for the TLS access ABI. */ #define R_PPC64_TLS 67 /* none (sym+add)@tls */ #define R_PPC64_DTPMOD64 68 /* doubleword64 (sym+add)@dtpmod */ #define R_PPC64_TPREL16 69 /* half16* (sym+add)@tprel */ #define R_PPC64_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */ #define R_PPC64_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */ #define R_PPC64_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */ #define R_PPC64_TPREL64 73 /* doubleword64 (sym+add)@tprel */ #define R_PPC64_DTPREL16 74 /* half16* (sym+add)@dtprel */ #define R_PPC64_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */ #define R_PPC64_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */ #define R_PPC64_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */ #define R_PPC64_DTPREL64 78 /* doubleword64 (sym+add)@dtprel */ #define R_PPC64_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */ #define R_PPC64_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */ #define R_PPC64_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */ #define R_PPC64_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */ #define R_PPC64_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */ #define R_PPC64_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */ #define R_PPC64_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */ #define R_PPC64_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */ #define R_PPC64_GOT_TPREL16_DS 87 /* half16ds* (sym+add)@got@tprel */ #define R_PPC64_GOT_TPREL16_LO_DS 88 /* half16ds (sym+add)@got@tprel@l */ #define R_PPC64_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */ #define R_PPC64_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */ #define R_PPC64_GOT_DTPREL16_DS 91 /* half16ds* (sym+add)@got@dtprel */ #define R_PPC64_GOT_DTPREL16_LO_DS 92 /* half16ds (sym+add)@got@dtprel@l */ #define R_PPC64_GOT_DTPREL16_HI 93 /* half16 (sym+add)@got@dtprel@h */ #define R_PPC64_GOT_DTPREL16_HA 94 /* half16 (sym+add)@got@dtprel@ha */ #define R_PPC64_TPREL16_DS 95 /* half16ds* (sym+add)@tprel */ #define R_PPC64_TPREL16_LO_DS 96 /* half16ds (sym+add)@tprel@l */ #define R_PPC64_TPREL16_HIGHER 97 /* half16 (sym+add)@tprel@higher */ #define R_PPC64_TPREL16_HIGHERA 98 /* half16 (sym+add)@tprel@highera */ #define R_PPC64_TPREL16_HIGHEST 99 /* half16 (sym+add)@tprel@highest */ #define R_PPC64_TPREL16_HIGHESTA 100 /* half16 (sym+add)@tprel@highesta */ #define R_PPC64_DTPREL16_DS 101 /* half16ds* (sym+add)@dtprel */ #define R_PPC64_DTPREL16_LO_DS 102 /* half16ds (sym+add)@dtprel@l */ #define R_PPC64_DTPREL16_HIGHER 103 /* half16 (sym+add)@dtprel@higher */ #define R_PPC64_DTPREL16_HIGHERA 104 /* half16 (sym+add)@dtprel@highera */ #define R_PPC64_DTPREL16_HIGHEST 105 /* half16 (sym+add)@dtprel@highest */ #define R_PPC64_DTPREL16_HIGHESTA 106 /* half16 (sym+add)@dtprel@highesta */ /* Additional relocation types */ #define R_PPC64_TOC32 107 #define R_PPC64_DTPMOD32 108 #define R_PPC64_TPREL32 109 #define R_PPC64_DTPREL32 110 /* Keep this the last entry. */ #define R_PPC64_NUM 111 /* Relocation types for MIPS */ #define R_MIPS_NONE 0 #define R_MIPS_16 1 #define R_MIPS_32 2 #define R_MIPS_ADD 2 #define R_MIPS_REL 3 #define R_MIPS_REL32 3 #define R_MIPS_26 4 #define R_MIPS_HI16 5 #define R_MIPS_LO16 6 #define R_MIPS_GPREL 7 #define R_MIPS_GPREL16 7 #define R_MIPS_LITERAL 8 #define R_MIPS_GOT 9 #define R_MIPS_GOT16 9 #define R_MIPS_PC16 10 #define R_MIPS_CALL 11 #define R_MIPS_CALL16 11 #define R_MIPS_GPREL32 12 #define R_MIPS_SHIFT5 16 #define R_MIPS_SHIFT6 17 #define R_MIPS_64 18 #define R_MIPS_GOT_DISP 19 #define R_MIPS_GOT_PAGE 20 #define R_MIPS_GOT_OFST 21 #define R_MIPS_GOT_HI16 22 #define R_MIPS_GOT_LO16 23 #define R_MIPS_SUB 24 #define R_MIPS_INSERT_A 25 #define R_MIPS_INSERT_B 26 #define R_MIPS_DELETE 27 #define R_MIPS_HIGHER 28 #define R_MIPS_HIGHEST 29 #define R_MIPS_CALL_HI16 30 #define R_MIPS_CALL_LO16 31 #define R_MIPS_SCN_DISP 32 #define R_MIPS_REL16 33 #define R_MIPS_ADD_IMMEDIATE 34 dwarf-20120410/dwarfdump/tag_tree.c0000640000175000017500000002125411741100175015716 0ustar daveadavea/* Copyright (C) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright 2009-2010 SN Systems Ltd. All rights reserved. Portions Copyright 2009-2011 David Anderson. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/tag_tree.c,v 1.8 2005/12/01 17:34:59 davea Exp $ */ #include #include #include /* For exit() declaration etc. */ #include /* For errno declaration. */ #include /* For getopt. */ #include "globals.h" #include "libdwarf.h" #include "common.h" #include "tag_common.h" unsigned int tag_tree_combination_table[TAG_TABLE_ROW_MAXIMUM][TAG_TABLE_COLUMN_MAXIMUM]; string program_name; boolean ellipsis = FALSE; /* So we can use dwarf_names.c */ /* Expected input format 0xffffffff value of a tag value of a standard tag that may be a child ofthat tag ... 0xffffffff value of a tag value of a standard tag that may be a child ofthat tag ... 0xffffffff ... No commentary allowed, no symbols, just numbers. Blank lines are allowed and are dropped. */ static const char *usage[] = { "Usage: tag_tree_build ", "options:\t-t\tGenerate Tags table", " -i Input-file-path", " -o Output-table-path", " -e (Want Extended table (common extensions))", " -s (Want Standard table)", "" }; static char *input_name = 0; static char *output_name = 0; int extended_flag = FALSE; int standard_flag = FALSE; static void process_args(int argc, char *argv[]) { int c = 0; boolean usage_error = FALSE; program_name = argv[0]; while ((c = getopt(argc, argv, "i:o:es")) != EOF) { switch (c) { case 'i': input_name = strdup(optarg); break; case 'o': output_name = strdup(optarg); break; case 'e': extended_flag = TRUE; break; case 's': standard_flag = TRUE; break; default: usage_error = TRUE; break; } } if (usage_error || 1 == optind || optind != argc) { print_usage_message(argv[0],usage); exit(FAILED); } } int main(int argc, char **argv) { int i = 0; unsigned int num = 0; int input_eof = 0; int table_rows = 0; int table_columns = 0; int current_row = 0; FILE *fileInp = 0; FILE *fileOut = 0; print_version_details(argv[0],FALSE); process_args(argc,argv); print_args(argc,argv); if (!input_name ) { fprintf(stderr,"Input name required, not supplied.\n"); print_usage_message(argv[0],usage); exit(FAILED); } fileInp = fopen(input_name,"r"); if (!fileInp) { fprintf(stderr,"Invalid input filename, could not open '%s'\n", input_name); print_usage_message(argv[0],usage); exit(FAILED); } if (!output_name ) { fprintf(stderr,"Output name required, not supplied.\n"); print_usage_message(argv[0],usage); exit(FAILED); } fileOut = fopen(output_name,"w"); if (!fileOut) { fprintf(stderr,"Invalid output filename, could not open: '%s'\n", output_name); print_usage_message(argv[0],usage); exit(FAILED); } if ((standard_flag && extended_flag) || (!standard_flag && !extended_flag)) { fprintf(stderr,"Invalid table type\n"); fprintf(stderr,"Choose -e or -s .\n"); print_usage_message(argv[0],usage); exit(FAILED); } if(standard_flag) { table_rows = STD_TAG_TABLE_ROWS; table_columns = STD_TAG_TABLE_COLUMNS; } else { table_rows = EXT_TAG_TABLE_ROWS; table_columns = EXT_TAG_TABLE_COLS; } input_eof = read_value(&num,fileInp); /* 0xffffffff */ if (IS_EOF == input_eof) { bad_line_input("Empty input file"); } if (num != MAGIC_TOKEN_VALUE) { bad_line_input("Expected 0xffffffff"); } while (!feof(stdin)) { unsigned int tag = 0; int nTagLoc = 0; input_eof = read_value(&tag,fileInp); if (IS_EOF == input_eof) { /* Reached normal eof */ break; } if(standard_flag) { if (tag >= table_rows ) { bad_line_input("tag value exceeds standard table size"); } } else { if(current_row >= table_rows) { bad_line_input("too many extended table rows."); } tag_tree_combination_table[current_row][0] = tag; } input_eof = read_value(&num,fileInp); if (IS_EOF == input_eof) { bad_line_input("Not terminated correctly.."); } nTagLoc = 1; while (num != 0xffffffff) { if(standard_flag) { int idx = num / BITS_PER_WORD; int bit = num % BITS_PER_WORD; if (idx >= table_columns) { fprintf(stderr,"Want column %d, have only %d\n", idx,table_columns); bad_line_input("too many TAGs: table incomplete."); } tag_tree_combination_table[tag][idx] |= (1 << bit); } else { if(nTagLoc >= table_columns) { printf("Attempting to use colum %d, max is %d\n", nTagLoc,table_columns); bad_line_input("too many subTAGs, table incomplete."); } tag_tree_combination_table[current_row][nTagLoc] = num; nTagLoc++; } input_eof = read_value(&num,fileInp); if (IS_EOF == input_eof) { bad_line_input("Not terminated correctly."); } } ++current_row; /* for extended table */ } fprintf(fileOut,"/* Generated code, do not edit. */\n"); fprintf(fileOut,"/* Generated on %s %s */\n",__DATE__,__TIME__); fprintf(fileOut,"\n/* BEGIN FILE */\n\n"); if (standard_flag) { fprintf(fileOut,"#define TAG_TREE_COLUMN_COUNT %d\n\n",table_columns); fprintf(fileOut,"#define TAG_TREE_ROW_COUNT %d\n\n",table_rows); fprintf(fileOut, "static unsigned int tag_tree_combination_table" "[TAG_TREE_ROW_COUNT][TAG_TREE_COLUMN_COUNT] = {\n"); } else { fprintf(fileOut,"#define TAG_TREE_EXT_COLUMN_COUNT %d\n\n", table_columns); fprintf(fileOut,"#define TAG_TREE_EXT_ROW_COUNT %d\n\n",table_rows); fprintf(fileOut,"/* Common extensions */\n"); fprintf(fileOut, "static unsigned int tag_tree_combination_ext_table" "[TAG_TREE_EXT_ROW_COUNT][TAG_TREE_EXT_COLUMN_COUNT] = {\n"); } for (i = 0; i < table_rows; i++) { int j = 0; const char *name = 0; if (standard_flag) { dwarf_get_TAG_name(i,&name);; fprintf(fileOut,"/* %d %-37s*/\n",i, name); } else { int k = tag_tree_combination_table[i][0]; dwarf_get_TAG_name(i,&name);; fprintf(fileOut,"/* %u %-37s*/\n", k, name); } fprintf(fileOut," { "); for(j = 0; j < table_columns; ++j ) { fprintf(fileOut,"0x%08x,",tag_tree_combination_table[i][j]); } fprintf(fileOut,"},\n"); } fprintf(fileOut,"};\n"); fprintf(fileOut,"\n/* END FILE */\n"); fclose(fileInp); fclose(fileOut); return (0); } /* A fake so we can use dwarf_names.c */ void print_error (Dwarf_Debug dbg, string msg,int res, Dwarf_Error err) { } dwarf-20120410/dwarfdump/print_frames.h0000640000175000017500000000345011741100175016620 0ustar daveadavea/* Copyright (C) 2006 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright (C) 2009-2011 David Anderson. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/print_frames.h,v 1.2 2006/04/17 00:09:56 davea Exp $ */ int print_one_cie(Dwarf_Debug dbg, Dwarf_Cie cie, Dwarf_Unsigned cie_index, Dwarf_Half address_size, struct dwconf_s * config_data); void get_string_from_locs(Dwarf_Debug dbg, Dwarf_Ptr bytes_in, Dwarf_Unsigned block_len, Dwarf_Half addr_size, struct esb_s *out_string); dwarf-20120410/dwarfdump/print_sections.h0000640000175000017500000000355011741100175017173 0ustar daveadavea/* Copyright (C) 2006 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright (C) 2009-2011 David Anderson. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan */ extern int dwarf_names_print_on_error; void deal_with_name_offset_err(Dwarf_Debug dbg, char *err_loc, char *name, Dwarf_Unsigned die_off, int nres, Dwarf_Error err); Dwarf_Unsigned get_info_max_offset(Dwarf_Debug dbg); void print_pubname_style_entry(Dwarf_Debug dbg, char *line_title, char *name, Dwarf_Unsigned die_off, Dwarf_Unsigned cu_off, Dwarf_Unsigned global_cu_off, Dwarf_Unsigned maxoff); dwarf-20120410/dwarfdump/dwarfdump.10000640000175000017500000003600611741100175016034 0ustar daveadavea.TH DWARFDUMP .SH NAME dwarfdump \- dumps DWARF debug information of an ELF object .SH SYNOPSIS .B dwarfdump [options] \f2objectfilename\fP .SH DESCRIPTION The .B dwarfdump command prints or checks DWARF sections as requested by specific options. With no options (but with the required \f2objectfilename\fP ) all sections print (but some sections cannot be printed independently safely, so those are only printed at offsets where the .debug_info section refers to those sections). .PP As of June 2011 the printing options and the checking options are mutually exclusive (if checking options are selected the section details are not printed). When errors are encountered dwarfdump does attempt to print sufficient context so that one can understand exactly where the error is in the DWARF. This change makes checking really large object files much easier. .PP The format is intended to be human readable. If a script is to parse the output, the .B \-d option is useful. .PP Not all sections actually exist in any given object file. .PP The format may change from release to release, so it is unwise to depend too heavily on the format. .PP Frame information (.debug_frame and .eh_frame) is heavily dependent on the ABI/ISA of the object file. By default we use a generic set of register names handling up to 100 registers named r0-100. The '-R' option uses a built-in generic register name set handling up to 1200 registers named r0-r1199. The '-x abi=' description below shows how to name an abi and use that to guide the -f or -F processing. Unless the cpu for the object file being dumped has many registers, do not use -R or -x abi=generic as those can be needlessly slow dumping frame sections. Instead, use the correct abi (if it exists in dwarfdump.conf) or a generic such as -x abi=generic100 or -x abi=generic500. To get MIPS/IRIX register names names and call the old version 2 libdwarf frame interface use the option '-x abi=mips'. Without '-R' or '-x abi=' dwarfdump ignores the dwarfdump.conf file and uses compiled-in generic set of register names. If no '-x name=' is given, dwarfdump looks for "./dwarfdump.conf", "$HOME/.dwarfdump.conf", "/lib/dwarfdump.conf" and takes the first it finds. If one or more '-x name=' is given the last of these is used and all other such files are ignored. .PP Some -k (checking) options print so-called harmless errors. These are compiler errors that do not cause any known problem and are only detected inside libdwarf itself. These are difficult to properly report in dwarfdump and any error strings may not appear close to the time the error was encountered. .SH URI STYLE INPUT STRINGS .PP The and the options taking name strings look for URIs and translate the URI strings to characters by default (see -x, -c, -S, -u). So any single % character is treated as if the following two characters are hex digits representing the underlying true character. Various characters are meaningful to shells (such as bash or sh) and to getopt (such as the space character) If the URI translation does anything it prints the before and after of the URI translation on standard output, so inspection of the first lines of output will show if URI did anything. The actual options themselves are assumed to be non-URI. So in the option '-cS&T' the -c portion must be non-URI, but the & character might cause input issues so '-cS%26T' could be used instead. To actually input a single % character (in a name, for example), double it to %% on the command line. .PP Options -U (turning off URI interpretation) and -q (making finding URI sequences silent) give finer control of URI interpretation. PP As an example, to get a string'a b' make the string 'a%20b' (here the quote (') is for exposition not part of the string, though quote is certainly problematic in a name). Instead of escaping " quotes in the string, type %25, as in 'a "b' should be typed 'a%20%25b' Any characters can be typed in URI style, not just characters which are problematic to the shell or getopt. We strongly suggest you not type URI-style characters where such are not needed or use the % character itself in command line strings unless you must. .SH PRINTING OPTIONS .TP .B \-a Print each section as independently as possible. Sections that can safely be printed independently (like .debug_abbrev) have relevant info printed in the report (sometimes dependent on -v). .TP .B \-b Print the .debug_abbrev section. Because the DWARF specfications do not rule out garbage data areas in .debug_abbrev (if they are not referenced from .debug_info) any garbage bytes can result in this print failing. .TP .B \-c Print locations lists. .TP .B \-f Print the .debug_frame section. .TP .B \-F Print the .eh_frame section. .TP .B \-i Print the .debug_info section. .TP .B \-l Print the .debug_info section and the associated line section data. .TP .B \-m Print the .debug_macinfo section. .TP .B \-N Print .debug_ranges section. Because the DWARF specfications do not rule out garbage data areas in .debug_ranges (if they are not referenced from .debug_info) any garbage bytes can result in this print failing. .TP .B \-p Print the .debug_pubnames section. .TP .B \-r Print the .debug_aranges section. .TP .B \-s Print .debug_string section. .TP .B \-ta Print the IRIX only sections .debug_static_funcs and .debug_static_vars. .TP .B \-tf Print the IRIX only section .debug_static_funcs. .TP .B \-tv Print the IRIX only section .debug_static_vars. .TP .B \-w Print the IRIX-only .debug_weaknames section. .TP .B \-y Print the .debug_pubtypes section (and .debug_typenames, an SGI IRIX-only section). .PP Having dwarfdump print relocations may help establish whether dwarfdump understands any relocations that might exist. .TP .B \-o Print all relocation records as well as we can manage. .TP .B \-oi Print .rel*debug_info relocations. .TP .B \-ol Print .rel*debug_line relocation. .TP .B \-op Print .rel*debug_pubnames relocation. .TP .B \-oa Has no effect. .TP .B \-or Print .rel*debug_aranges relocations. .TP .B \-of Print .rel*debug_frame relocations. .TP .B \-oo Print .rel*debug_loc relocations. .TP .B \-oR Print .rel*debug_ranges relocations. .TP .B \-g Normally used only for testing libdwarf, this tells dwarfdump to print .debug_info and use an older dwarf_loclist() interface function (a function that cannot handle all current location lists). .TP .B \-V Print a dwarfdump date/version string and stop. .SH CHECKING OPTIONS .TP .B \-cg Restricts checking to compilers whose producer string starts with 'GNU' and turns off -cs . .TP .B \-cs Restricts checking to compilers whose producer string starts with 'SN' and turns off -cg . .TP .B \-cname Restricts checking to compilers whose producer string contains 'name' (not case sensitive). The 'name' is read as a URI string. .TP .B \ -ka : Turns on all checking options except -kxe (-kxe might be slow enough one mignt not want to use it routinely.) .TP .B \ -kb : Checks for certain abbreviations section errors when reading DIEs. .TP .B \-kc Checks for errors in constants in debug_info. .TP .B \-kd Turns on full reporting of error totals per producer. (the default shows less detail). .TP .B \-ke Turns on reading pubnames and checking for fde errors. .TP .B \-kf Turns on checking for FDE errors. .TP .B \-kF Turns on checking for line table errors. .TP .B \-kg Turns on checking for unused gaps in .debug_info (these gaps are not an error, just a waste of space). .TP .B \-ki Causes a summary of checking results per compiler (producer) to be printed at the end. .TP .B \-kl Turns on locations list checking. .TP .B \-km Turns on checking of ranges. .TP .B \-kM Turns on checking of aranges. .TP .B \-kr Turns on DIE tag-attr combinations checking. .TP .B \-kR Turns on reading DIEs and checking for forward declarations rom DW_AT_specification attributes. (which are not an error but can be a source of inefficiency for debuggers). .TP .B \-ks Turns on extra reporting for some DIE errors checking detects . .TP .B \-kS Turns on checking DIE references for circular references. .TP .B \-kt Turns on tag-tag combinations checking. .TP .B \-kx Turns on check_frames. .TP .B \-kxe Turns off basic check_frames and turns on extended frame checking. .TP .B \-ky Turns on type_offset, decl_file checking, .SH OPTION MODIFIERS .TP .B \-C Normally when checking for tag-tag or tag-attribute combinations both the standard combinations and some common extensions are allowed. With -C the extensions are taken out of the allowed class of combinations. .TP .B \-d When printing DIEs, put all the attributes for each DIE on the same (long) line as the TAG. This makes searching for DIE information (as with grep) much simpler as the entire DIE is on one line. .TP .B \-D Turns off the display of section offsets and attribute values in printed output. So the .debug_info output isjust TAGs and Attributes. For pubnames (and the like) it removes offsets from the output. For locations lists it removes offsets from the output, but that is useless since the attribute values don't show so neither does the location data. .TP .B \-e Turns on truncation of attribute and tag names. For example DW_TAG_foo becomes foo . Not compatible with checking, only useful for printing DIEs. .TP .B \-G When printing, add global offsets to the offsets printed. .TP .B \-H number When printing or checking .debug_info, this terminates the search after 'number' compilation units. When printing frame information this terminates the FDE reporting after 'number' FDEs and the CIE reporting (which occurs if one adds -v) after 'number' CIEs. Example '-H 1' .TP .B \-M When printing, this means one want to have the FORM show for each attribute. If a -v is also added (or more than one) then details of any form indirection are also shown. .TP .B \-n When printing frames, this turns off the search for function names. In a really large object the search can take more time than one wants to wait, so this avoids the search. .TP .B \-Q Suppresses section data printing (set automatically with a checking option). .TP .B \-R When printing frames for ABIs with lots of registers, this allows up to 1200 registers to be named (like R999) without choosing an ABI with, for example '-x abi=ppc' .TP .B \-v Increases the detail shown when printing. In some sections, using more -v options will increase the detail (one to three are useful) or may change the report to show, for example, the actual line-data-commands instead of the resultant line-table. .SH SELECTIVE ENTRY PRINTING .PP These -S options stand alone and basic print information about the compilation unit and DIE where the string(s) appear. At most one of each of the following is effective (so for example one can only have one 'match', but one can have a 'match', an 'any', and a 'regex'). Any -S causes the .debug_info section to be inspected. No checking options or printing options should be supplied with -S. .TP .B \-S match=string When printing DIEs for each tag value or attribute name that matches 'string' exactly print the compilation unit information and its section offset. Any CU with no match is not printed. The 'string' is read as a URI string. .TP .B \-S any=string When printing DIEs for each tag value or attribute name that contains 'string' somewhere in the tag or attribute (case insensitive) print the compilation unit information and its section offset. Any CU with no match is not printed. The 'string' is read as a URI string. .TP .B \-S regex=string When printing DIEs for each tag value or attribute name where the 'string' reqular expression matches print the compilation unit information and its section offset. Any CU with no match is not printed. The 'string' is read as a URI string. .PP The string cannot have spaces or other characters which are meaningful to getopt(3) and the shell will strip off quotes and other characters. So the string is assumed to be in URI style and is translated. In other words, to match 'a b' make the -S string 'a%20b' Instead of escaping " quotes in the string, type %25, as in 'a "b' should be typed 'a%20%25b' (the ' are for exposition here, not part of the strings). Any characters can be typed in URI style, not just characters which are problematic to the shell or getopt. .PP The -S any= and -S regex= options are only usable if the library functions required are found at configure time. .PP The -W option is a modifier to the -S option, and increases the amount of output -W prints. Now we show the -W in context with a -S option. .TP .B \-S match=string1 -W Prints the parent tree and the children tree for the DIEs that -S matches. .TP .B \-S match=string2 -Wp Prints the parent tree for the DIEs that -S matches. .TP .B \-S match=string3 -Wc Prints the parent tree for the DIEs that -S matches. .SH OTHER OPTIONS .TP .B \-# number This option controls internal debugging output, higher numbers mean more debug actions. See the source code. .TP .B \-x name=/p/a/t/h.conf The file path given is the name of a file assumed to be a dwarfdump.conf-like file. The file path is read as a URI string. .TP .B \-x abi=ppc Selects the abi (from a dwarfdump.conf file) to be used in printing frame information (here using ppc as an example). The abi is read as a URI string. .TP .B \-P When checking this adds the list of compilation-unit names seen for each producer-compiler to the printed checking results. .TP .B \-q When a URI is found and translated while reading the command line, be quiet about the URI translation. That is, don't print the original and translated option strings. .TP .B \-E Turns on printing object-internal header data for some systems (for Unix/Linux does nothing). .TP .B \-u cuname Turns on selective printing of DIEs (printing like -i). Only the DIEs for a compilation unit that match the name provided are printed. If the compilation unit is ./a/b/c.c the 'cuname' you provide should be c.c as the characters through the final path-separating / are ignored. If 'cuname' begins with a / then the entire name string of a compilation unit must match 'cuname'. The 'cuname' is read as a URI string. .TP .B \-U Turn off the URI interpretation of the command line strings entirely. Must be be on the command line before any URI strings encountered to be fully effective. .TP .B \-z No longer suported. .SH FILES dwarfdump dwarfdump.conf ./dwarfdump.conf $(HOME)/.dwarfdump.conf $(HOME)/dwarfdump.conf /lib/dwarfdump.conf .SH NOTES In some cases compilers use DW_FORM_data1 (for example) and in such cases the signedness of the value must be taken from context. Rather than attempt to determine the context, dwarfdump prints the value with both signednesses whenever there is ambiguity about the correct interpretation. For example, "DW_AT_const_value 176(as signed = -80)". For normal DWARF consumers that correctly and fully evaluate all attributes there is no ambiguity of signedness: the ambiguity for dwarfdump is due to dwarfdump evaluating DIEs in a simple order and not keeping track of much context. .SH BUGS Support for DWARF3 is being completed but may not be complete. dwarf-20120410/dwarfdump/esb.h0000640000175000017500000000615111741100175014701 0ustar daveadavea/* Copyright (C) 2005 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright 2011 David Anderson. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/esb.h,v 1.1 2005/08/04 05:09:37 davea Exp $ */ /* esb.h Extensible string buffer. A simple vaguely object oriented extensible string buffer. The struct could be opaque here, but it seems ok to expose the contents: simplifies debugging. */ struct esb_s { string esb_string; /* pointer to the data itself, or NULL. */ size_t esb_allocated_size; /* Size of allocated data or 0 */ size_t esb_used_bytes; /* Amount of space used or 0 */ }; /* string length taken from string itself. */ void esb_append(struct esb_s *data, const char * in_string); /* The 'len' is believed. Do not pass in strings < len bytes long. */ void esb_appendn(struct esb_s *data, const char * in_string, size_t len); /* Always returns an empty string or a non-empty string. Never 0. */ string esb_get_string(struct esb_s *data); /* Sets esb_used_bytes to zero. The string is not freed and esb_allocated_size is unchanged. */ void esb_empty_string(struct esb_s *data); /* Return esb_used_bytes. */ size_t esb_string_len(struct esb_s *data); /* The following are for testing esb, not use by dwarfdump. */ /* *data is presumed to contain garbage, not values, and is properly initialized. */ void esb_constructor(struct esb_s *data); /* The string is freed, contents of *data set to zeroes. */ void esb_destructor(struct esb_s *data); /* To get all paths in the code tested, this sets the allocation/reallocation to the given value, which can be quite small but must not be zero. */ void esb_alloc_size(size_t size); size_t esb_get_allocated_size(struct esb_s *data); /* Append a formatted string */ void esb_append_printf(struct esb_s *data,const char *in_string, ...); dwarf-20120410/dwarfdump/uri.h0000640000175000017500000000260511741100175014727 0ustar daveadavea/* Copyright 2011 David Anderson. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan */ void translate_to_uri(const char * filename, struct esb_s *out); void translate_from_uri(const char * input, struct esb_s *out); dwarf-20120410/dwarfdump/naming.h0000640000175000017500000000675511741100175015413 0ustar daveadavea /* Copyright (C) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright (C) 2007-2011 David Anderson. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan */ /* The address of the Free Software Foundation is Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. SGI has moved from the Crittenden Lane address. */ /* naming.h */ extern const char * get_TAG_name(unsigned int val_in,int printonerr); extern const char * get_children_name(unsigned int val_in,int printonerr); extern const char * get_FORM_name(unsigned int val_in,int printonerr); extern const char * get_AT_name(unsigned int val_in,int printonerr); extern const char * get_OP_name(unsigned int val_in,int printonerr); extern const char * get_ATE_name(unsigned int val_in,int printonerr); extern const char * get_DS_name(unsigned int val_in,int printonerr); extern const char * get_END_name(unsigned int val_in,int printonerr); extern const char * get_ATCF_name(unsigned int val_in,int printonerr); extern const char * get_ACCESS_name(unsigned int val_in,int printonerr); extern const char * get_VIS_name(unsigned int val_in,int printonerr); extern const char * get_VIRTUALITY_name(unsigned int val_in,int printonerr); extern const char * get_LANG_name(unsigned int val_in,int printonerr); extern const char * get_ID_name(unsigned int val_in,int printonerr); extern const char * get_CC_name(unsigned int val_in,int printonerr); extern const char * get_INL_name(unsigned int val_in,int printonerr); extern const char * get_ORD_name(unsigned int val_in,int printonerr); extern const char * get_DSC_name(unsigned int val_in,int printonerr); extern const char * get_LNS_name(unsigned int val_in,int printonerr); extern const char * get_LNE_name(unsigned int val_in,int printonerr); extern const char * get_MACINFO_name(unsigned int val_in,int printonerr); extern const char * get_CFA_name(unsigned int val_in,int printonerr); extern const char * get_EH_name(unsigned int val_in,int printonerr); extern const char * get_FRAME_name(unsigned int val_in,int printonerr); extern const char * get_CHILDREN_name(unsigned int val_in,int printonerr); extern const char * get_ADDR_name(unsigned int val_in,int printonerr); dwarf-20120410/dwarfdump/print_aranges.c0000640000175000017500000002473011741100175016762 0ustar daveadavea/* Copyright (C) 2000-2006 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright 2007-2010 Sun Microsystems, Inc. All rights reserved. Portions Copyright 2009-2011 SN Systems Ltd. All rights reserved. Portions Copyright 2008-2011 David Anderson. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/print_sections.c,v 1.69 2006/04/17 00:09:56 davea Exp $ */ /* The address of the Free Software Foundation is Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. SGI has moved from the Crittenden Lane address. */ #include "globals.h" #include "naming.h" #include "dwconf.h" #include "esb.h" #include "print_sections.h" static void do_checking(Dwarf_Debug dbg, Dwarf_Arange *arange_buf,Dwarf_Signed i, Dwarf_Off cu_die_offset,Dwarf_Bool first_cu, Dwarf_Off cu_die_offset_prev, Dwarf_Die cu_die ) { int dres = 0; Dwarf_Off cuhdroff = 0; Dwarf_Off cudieoff3 = 0; dres = dwarf_get_arange_cu_header_offset( arange_buf[i],&cuhdroff,&err); if(dres == DW_DLV_OK) { Dwarf_Off cudieoff2 = 0; /* Get the CU offset for easy error reporting */ if (first_cu || cu_die_offset != cu_die_offset_prev) { cu_die_offset_prev = cu_die_offset; dres = dwarf_die_offsets(cu_die,&DIE_overall_offset,&DIE_offset,&err); if (dres != DW_DLV_OK) { print_error(dbg, "dwarf_die_offsets", dres, err); } } dres = dwarf_get_cu_die_offset_given_cu_header_offset( dbg,cuhdroff,&cudieoff2,&err); if(dres == DW_DLV_OK) { /* Get the CU offset for easy error reporting */ dwarf_die_offsets(cu_die,&DIE_overall_offset,&DIE_offset,&err); DWARF_CHECK_COUNT(aranges_result,1); if(cudieoff2 != cu_die_offset) { printf("Error, cu_die offsets mismatch, 0x%" DW_PR_DUx " != 0x%" DW_PR_DUx " from arange data", cu_die_offset,cudieoff2); DWARF_CHECK_ERROR(aranges_result, " dwarf_get_cu_die_offset_given_cu..." " gets wrong offset"); } } else { print_error(dbg, "dwarf_get_cu_die_offset_given...", dres, err); } } else { print_error(dbg, "dwarf_get_arange_cu_header_offset", dres, err); } dres = dwarf_get_cu_die_offset(arange_buf[i],&cudieoff3, &err); if(dres == DW_DLV_OK) { DWARF_CHECK_COUNT(aranges_result,1); if(cudieoff3 != cu_die_offset) { printf( "Error, cu_die offsets (b) mismatch , 0x%" DW_PR_DUx " != 0x%" DW_PR_DUx " from arange data", cu_die_offset,cudieoff3); DWARF_CHECK_ERROR(aranges_result, " dwarf_get_cu_die_offset " " gets wrong offset"); } } else { print_error(dbg, "dwarf_get_cu_die_offset failed ", dres,err); } } /* get all the data in .debug_aranges */ extern void print_aranges(Dwarf_Debug dbg) { Dwarf_Signed count = 0; Dwarf_Signed i = 0; Dwarf_Arange *arange_buf = NULL; int ares = 0; int aires = 0; Dwarf_Off prev_off = 0; /* Holds previous CU offset */ Dwarf_Bool first_cu = TRUE; Dwarf_Off cu_die_offset_prev = 0; /* Reset the global state, so we can traverse the debug_info */ seen_CU = FALSE; need_CU_name = TRUE; need_CU_base_address = TRUE; need_CU_high_address = TRUE; current_section_id = DEBUG_ARANGES; if (do_print_dwarf) { printf("\n.debug_aranges\n"); } ares = dwarf_get_aranges(dbg, &arange_buf, &count, &err); if (ares == DW_DLV_ERROR) { print_error(dbg, "dwarf_get_aranges", ares, err); } else if (ares == DW_DLV_NO_ENTRY) { /* no arange is included */ } else { for (i = 0; i < count; i++) { Dwarf_Unsigned segment = 0; Dwarf_Unsigned segment_entry_size = 0; Dwarf_Addr start = 0; Dwarf_Unsigned length = 0; Dwarf_Off cu_die_offset = 0; Dwarf_Die cu_die = NULL; aires = dwarf_get_arange_info_b(arange_buf[i], &segment, &segment_entry_size, &start, &length, &cu_die_offset, &err); if (aires != DW_DLV_OK) { print_error(dbg, "dwarf_get_arange_info", aires, err); } else { int dres; char *producer_name = 0; /* Get basic locations for error reporting */ dres = dwarf_offdie(dbg, cu_die_offset, &cu_die, &err); if (dres != DW_DLV_OK) { print_error(dbg, "dwarf_offdie", dres, err); } if (cu_name_flag) { if(should_skip_this_cu(dbg,cu_die,err)) { continue; } } /* Get producer name for this CU and update compiler list */ get_producer_name(dbg,cu_die,err,&producer_name); update_compiler_target(producer_name); if (!checking_this_compiler()) { continue; } if (check_aranges) { do_checking(dbg,arange_buf,i,cu_die_offset,first_cu, cu_die_offset_prev,cu_die); } /* Get the offset of the cu header itself in the section, but not for end-entries. */ if(start || length) { Dwarf_Off off = 0; int cures3 = dwarf_get_arange_cu_header_offset( arange_buf[i], &off, &err); if (cures3 != DW_DLV_OK) { print_error(dbg, "dwarf_get_cu_hdr_offset", cures3, err); } /* Print the CU information if different. */ if (prev_off != off || first_cu) { first_cu = FALSE; prev_off = off; /* We are faking the indent level. We do not know what level it is, really. If do_check_dwarf we do not want to do the die print call as it will do check/print we may not have asked for. And if we did ask for debug_info checks this will do the checks a second time! So only call print_one_die if printing. */ if(do_print_dwarf){ /* There is no die if its a set-end entry */ print_one_die(dbg, cu_die, /* print_information= */ (boolean) TRUE, /* indent_level = */0, /* srcfiles= */ 0, /* cnt= */ 0, /* ignore_die_stack= */TRUE); } /* Reset the state, so we can traverse the debug_info */ seen_CU = FALSE; need_CU_name = TRUE; if (do_print_dwarf) { printf("\n"); } } if (do_print_dwarf) { /* Print current aranges record */ if(segment_entry_size) { printf( "\narange starts at seg,off 0x%" DW_PR_XZEROS DW_PR_DUx ",0x%" DW_PR_XZEROS DW_PR_DUx ", ", segment, (Dwarf_Unsigned)start); } else { printf("\narange starts at 0x%" DW_PR_XZEROS DW_PR_DUx ", ", (Dwarf_Unsigned)start); } printf("length of 0x%" DW_PR_XZEROS DW_PR_DUx ", cu_die_offset = 0x%" DW_PR_XZEROS DW_PR_DUx, length, (Dwarf_Unsigned)cu_die_offset); } if (verbose && do_print_dwarf) { printf(" cuhdr 0x%" DW_PR_XZEROS DW_PR_DUx "\n", (Dwarf_Unsigned)off); } dwarf_dealloc(dbg, cu_die, DW_DLA_DIE); cu_die = 0; } else { /* Must be a range end. We really do want to print this as there is a real record here, an 'arange end' record. */ if (do_print_dwarf) { printf("\narange end"); } }/* end start||length test */ } /* end aires DW_DLV_OK test */ /* print associated die too? */ dwarf_dealloc(dbg, arange_buf[i], DW_DLA_ARANGE); } dwarf_dealloc(dbg, arange_buf, DW_DLA_LIST); } } dwarf-20120410/dwarfdump/naming.c0000640000175000017500000001777211741100175015407 0ustar daveadavea/* Copyright (C) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright (C) 2007-2011 David Anderson. All Rights Reserved. Portions Copyright (C) 2010-2011 SN Systems Ltd. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan */ /* The address of the Free Software Foundation is Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. SGI has moved from the Crittenden Lane address. */ /* naming.c */ #include "globals.h" #include "dwarf.h" #include "libdwarf.h" #include "makename.h" static const char * skipunder(const char *v) { const char *cp = v; int undercount = 0; for( ; *cp ; ++cp) { if( *cp == '_') { ++undercount; if(undercount == 2) { return cp+1; } } } return ""; } static const char * ellipname(int res, int val_in, const char *v,const char *ty,int printonerr) { #ifndef TRIVIAL_NAMING if (check_dwarf_constants && checking_this_compiler()) { DWARF_CHECK_COUNT(dwarf_constants_result,1); } #endif if(res != DW_DLV_OK) { char buf[100]; char *n; snprintf(buf,sizeof(buf),"",ty,val_in); /* Capture any name error in DWARF constants */ #ifndef TRIVIAL_NAMING if(printonerr && check_dwarf_constants && checking_this_compiler()) { if (check_verbose_mode) { fprintf(stderr,"%s of %d (0x%x) is unknown to dwarfdump. " "Continuing. \n",ty,val_in,val_in ); } DWARF_ERROR_COUNT(dwarf_constants_result,1); DWARF_CHECK_ERROR_PRINT_CU(); } #else /* This is for the tree-generation, not dwarfdump itself. */ if(printonerr) { fprintf(stderr,"%s of %d (0x%x) is unknown to dwarfdump. " "Continuing. \n",ty,val_in,val_in ); } #endif n = makename(buf); return n; } if(ellipsis) { return skipunder(v); } return v; } const char * get_TAG_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_TAG_name(val_in,&v); return ellipname(res,val_in,v,"TAG",printonerr); } const char * get_children_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_children_name(val_in,&v); return ellipname(res,val_in,v,"children",printonerr); } const char * get_FORM_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_FORM_name(val_in,&v); return ellipname(res,val_in,v,"FORM",printonerr); } const char * get_AT_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_AT_name(val_in,&v); return ellipname(res,val_in,v,"AT",printonerr); } const char * get_OP_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_OP_name(val_in,&v); return ellipname(res,val_in,v,"OP",printonerr); } const char * get_ATE_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_ATE_name(val_in,&v); return ellipname(res,val_in,v,"ATE",printonerr); } const char * get_DS_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_DS_name(val_in,&v); return ellipname(res,val_in,v,"DS",printonerr); } const char * get_END_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_END_name(val_in,&v); return ellipname(res,val_in,v,"END",printonerr); } const char * get_ATCF_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_ATCF_name(val_in,&v); return ellipname(res,val_in,v,"ATCF",printonerr); } const char * get_ACCESS_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_ACCESS_name(val_in,&v); return ellipname(res,val_in,v,"ACCESS",printonerr); } const char * get_VIS_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_VIS_name(val_in,&v); return ellipname(res,val_in,v,"VIS",printonerr); } const char * get_VIRTUALITY_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_VIRTUALITY_name(val_in,&v); return ellipname(res,val_in,v,"VIRTUALITY",printonerr); } const char * get_LANG_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_LANG_name(val_in,&v); return ellipname(res,val_in,v,"LANG",printonerr); } const char * get_ID_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_ID_name(val_in,&v); return ellipname(res,val_in,v,"ID",printonerr); } const char * get_CC_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_CC_name(val_in,&v); return ellipname(res,val_in,v,"CC",printonerr); } const char * get_INL_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_INL_name(val_in,&v); return ellipname(res,val_in,v,"INL",printonerr); } const char * get_ORD_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_ORD_name(val_in,&v); return ellipname(res,val_in,v,"ORD",printonerr); } const char * get_DSC_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_DSC_name(val_in,&v); return ellipname(res,val_in,v,"DSC",printonerr); } const char * get_LNS_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_LNS_name(val_in,&v); return ellipname(res,val_in,v,"LNS",printonerr); } const char * get_LNE_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_LNE_name(val_in,&v); return ellipname(res,val_in,v,"LNE",printonerr); } const char * get_MACINFO_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_MACINFO_name(val_in,&v); return ellipname(res,val_in,v,"MACINFO",printonerr); } const char * get_CFA_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_CFA_name(val_in,&v); return ellipname(res,val_in,v,"CFA",printonerr); } const char * get_EH_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_EH_name(val_in,&v); return ellipname(res,val_in,v,"EH",printonerr); } const char * get_FRAME_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_FRAME_name(val_in,&v); return ellipname(res,val_in,v,"FRAME",printonerr); } const char * get_CHILDREN_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_CHILDREN_name(val_in,&v); return ellipname(res,val_in,v,"CHILDREN",printonerr); } const char * get_ADDR_name(unsigned int val_in,int printonerr) { const char *v = 0; int res = dwarf_get_ADDR_name(val_in,&v); return ellipname(res,val_in,v,"ADDR",printonerr); } dwarf-20120410/dwarfdump/tag_common.h0000640000175000017500000000733211741100175016255 0ustar daveadavea/* Copyright (C) 2000-2010 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright (C) 2009-2010 SN Systems Ltd. All Rights Reserved. Portions Copyright (C) 2009-2011 David Anderson. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/tag_common.h,v 1.8 2008/01/23 09:47:59 davea Exp $ */ #ifndef tag_common_INCLUDED #define tag_common_INCLUDED /* The following is the magic token used to distinguish real tags/attrs from group-delimiters. Blank lines have been eliminated by an awk script. */ #define MAGIC_TOKEN_VALUE 0xffffffff /* TAG_TREE.LIST Expected input format 0xffffffff value of a tag value of a standard tag that may be a child of that tag ... 0xffffffff value of a tag value of a standard tag that may be a child of that tag ... 0xffffffff ... No blank lines or commentary allowed, no symbols, just numbers. */ /* TAG_ATTR.LIST Expected input format 0xffffffff value of a tag value of a standard attribute that follows that tag ... 0xffffffff value of a tag value of a standard attribute that follows that tag ... 0xffffffff ... No blank lines or commentary allowed, no symbols, just numbers. */ /* We don't need really long lines: the input file is simple. */ #define MAX_LINE_SIZE 1000 /* 1 more than the highest number in the DW_TAG defines, this is for standard TAGs. Number of rows. */ #define STD_TAG_TABLE_ROWS 0x44 /* Enough entries to have a bit for each standard legal tag. */ #define STD_TAG_TABLE_COLUMNS 7 /* TAG tree common extension maximums. */ #define EXT_TAG_TABLE_ROWS 7 #define EXT_TAG_TABLE_COLS 7 /* The following 2 used in tag_tree.c only. */ #define TAG_TABLE_ROW_MAXIMUM STD_TAG_TABLE_ROWS #define TAG_TABLE_COLUMN_MAXIMUM EXT_TAG_TABLE_COLS /* Number of attributes columns per tag. The array is bit fields, BITS_PER_WORD fields per word. Dense and quick to inspect */ #define COUNT_ATTRIBUTE_STD 7 #define STD_ATTR_TABLE_ROWS STD_TAG_TABLE_ROWS #define STD_ATTR_TABLE_COLUMNS 7 /* tag/attr tree common extension maximums. */ #define EXT_ATTR_TABLE_ROWS 7 #define EXT_ATTR_TABLE_COLS 7 /* The following 2 used in tag_attr.c only. */ #define ATTR_TABLE_ROW_MAXIMUM STD_ATTR_TABLE_ROWS #define ATTR_TABLE_COLUMN_MAXIMUM EXT_ATTR_TABLE_COLS /* Bits per 'int' to mark legal attrs. */ #define BITS_PER_WORD 32 #define IS_EOF 1 #define NOT_EOF 0 extern void bad_line_input(char *msg); extern void trim_newline(char *line, int max); extern boolean is_blank_line(char *pLine); extern int read_value(unsigned int *outval,FILE *f); #endif /* tag_common_INCLUDED */ dwarf-20120410/dwarfdump/globals.h0000640000175000017500000003665011741100175015562 0ustar daveadavea/* Copyright (C) 2000,2004,2005 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright (C) 2007-2010 David Anderson. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/globals.h,v 1.25 2006/04/17 00:09:56 davea Exp $ */ #ifndef globals_INCLUDED #define globals_INCLUDED #include "config.h" #if (!defined(HAVE_RAW_LIBELF_OK) && defined(HAVE_LIBELF_OFF64_OK) ) /* At a certain point libelf.h requires _GNU_SOURCE. here we assume the criteria in configure determine that usefully. */ #define _GNU_SOURCE 1 #endif /* We want __uint32_t and __uint64_t and __int32_t __int64_t properly defined but not duplicated, since duplicate typedefs are not legal C. HAVE___UINT32_T HAVE___UINT64_T will be set by configure if our 4 types are predefined in compiler */ #if (!defined(HAVE___UINT32_T)) && defined(HAVE_SGIDEFS_H) #include /* sgidefs.h defines them */ #define HAVE___UINT32_T 1 #define HAVE___UINT64_T 1 #endif #if (!defined(HAVE___UINT32_T)) && defined(HAVE_SYS_TYPES_H) && defined(HAVE___UINT32_T_IN_SYS_TYPES_H) # include /* we assume __[u]int32_t and __[u]int64_t defined since __uint32_t defined in the sys/types.h in use */ #define HAVE___UINT32_T 1 #define HAVE___UINT64_T 1 #endif #ifndef HAVE___UINT32_T typedef int __int32_t; typedef unsigned __uint32_t; #define HAVE___UINT32_T 1 #endif #ifndef HAVE___UINT64_T typedef long long __int64_t; typedef unsigned long long __uint64_t; #define HAVE___UINT64_T 1 #endif #include #include #include /* Windows specific */ #ifdef HAVE_STDAFX_H #include "stdafx.h" #endif /* HAVE_STDAFX_H */ #ifdef HAVE_ELF_H #include #endif #ifdef HAVE_LIBELF_H #include #else #ifdef HAVE_LIBELF_LIBELF_H #include #endif #endif #include #include #ifdef HAVE_REGEX #include #endif typedef char * string; #include "checkutil.h" #ifndef BOOLEAN_TYPEDEFED #define BOOLEAN_TYPEDEFED typedef int boolean; #endif /* BOOLEAN_TYPEDEFED */ #ifndef FALSE #define FALSE 0 #endif #ifndef TRUE #define TRUE 1 #endif #ifndef FAILED #define FAILED 1 #endif /* size of attrib_buffer, defined in print_die.c */ #define ATTRIB_BUFSIZ 999 typedef struct { int checks; int errors; } Dwarf_Check_Result; extern boolean do_check_dwarf; extern boolean do_print_dwarf; extern boolean record_dwarf_error; /* A test has failed, this is normally set FALSE shortly after being set TRUE, it is a short-range hint we should print something we might not otherwise print (under the circumstances). */ /* Compilation Unit information for improved error messages. If the strings are too short we just truncate so fixed length here is fine. */ #define COMPILE_UNIT_NAME_LEN 512 extern char PU_name[COMPILE_UNIT_NAME_LEN]; /* PU Name */ extern char CU_name[COMPILE_UNIT_NAME_LEN]; /* CU Name */ extern char CU_producer[COMPILE_UNIT_NAME_LEN]; /* CU Producer Name */ extern boolean seen_PU; /* Detected a PU. */ extern boolean seen_CU; /* Detected a CU. */ extern boolean need_CU_name; /* Need CU name. */ extern boolean need_CU_base_address; /* Need CU Base address. */ extern boolean need_CU_high_address; /* Need CU High address. */ extern boolean need_PU_valid_code; /* Need PU valid code. */ extern boolean seen_PU_base_address; /* Detected a Base address for PU */ extern boolean seen_PU_high_address; /* Detected a High address for PU */ extern Dwarf_Addr PU_base_address; /* PU Base address */ extern Dwarf_Addr PU_high_address; /* PU High address */ extern Dwarf_Off DIE_offset; /* DIE offset in compile unit. */ extern Dwarf_Off DIE_overall_offset; /* DIE offset in .debug_info. */ /* Current CU information for better error reporting. */ extern Dwarf_Off DIE_CU_offset; /* CU DIE offset in compile unit */ extern Dwarf_Off DIE_CU_overall_offset; /* CU DIE offset in .debug_info */ extern int current_section_id; /* Section being process. */ extern Dwarf_Addr CU_base_address; /* CU Base address. */ extern Dwarf_Addr CU_high_address; /* CU High address. */ extern Dwarf_Addr elf_max_address; /* Largest representable address offset. */ extern Dwarf_Half elf_address_size; /* Target pointer size. */ /* Ranges and Location tables for better error checking: see dwarfdump.c comments for more information. */ extern Bucket_Group *pRangesInfo; extern Bucket_Group *pLinkonceInfo; extern Bucket_Group *pVisitedInfo; /* Display parent/children when in wide format. */ extern boolean display_parent_tree; extern boolean display_children_tree; extern int stop_indent_level; /* Print search results when in wide format. */ extern boolean search_wide_format; extern boolean search_is_on; const extern char *search_any_text; const extern char *search_match_text; const extern char *search_regex_text; #ifdef HAVE_REGEX extern regex_t search_re; #endif extern boolean is_strstrnocase(const char *data, const char *pattern); /* Options to enable debug tracing. */ #define MAX_TRACE_LEVEL 10 extern int nTrace[MAX_TRACE_LEVEL + 1]; #define DUMP_RANGES_INFO 1 /* Dump RangesInfo Table. */ #define DUMP_LOCATION_SECTION_INFO 2 /* Dump Location (.debug_loc) Info. */ #define DUMP_RANGES_SECTION_INFO 3 /* Dump Ranges (.debug_ranges) Info. */ #define DUMP_LINKONCE_INFO 4 /* Dump Linkonce Table. */ #define DUMP_VISITED_INFO 5 /* Dump Visited Info. */ #define dump_ranges_info nTrace[DUMP_RANGES_INFO] #define dump_location_section_info nTrace[DUMP_LOCATION_SECTION_INFO] #define dump_ranges_section_info nTrace[DUMP_RANGES_SECTION_INFO] #define dump_linkonce_info nTrace[DUMP_LINKONCE_INFO] #define dump_visited_info nTrace[DUMP_VISITED_INFO] /* Section IDs */ #define DEBUG_ABBREV 1 #define DEBUG_ARANGES 2 #define DEBUG_FRAME 3 #define DEBUG_INFO 4 #define DEBUG_LINE 5 #define DEBUG_LOC 6 #define DEBUG_MACINFO 7 #define DEBUG_PUBNAMES 8 #define DEBUG_RANGES 9 #define DEBUG_STATIC_VARS 10 #define DEBUG_STATIC_FUNC 11 #define DEBUG_STR 12 #define DEBUG_WEAKNAMES 13 #define DEBUG_TYPES 14 extern int verbose; extern boolean dense; extern boolean ellipsis; extern boolean use_mips_regnames; extern boolean show_global_offsets; extern boolean show_form_used; extern boolean display_offsets; extern boolean check_pubname_attr; extern boolean check_attr_tag; extern boolean check_tag_tree; extern boolean check_type_offset; extern boolean check_decl_file; extern boolean check_lines; extern boolean check_ranges; /* Ranges (aranges & ranges) check */ extern boolean check_fdes; extern boolean check_aranges; extern boolean check_harmless; extern boolean check_abbreviations; extern boolean check_dwarf_constants; extern boolean check_di_gaps; extern boolean check_forward_decl; extern boolean check_self_references; extern boolean suppress_nested_name_search; extern boolean suppress_check_extensions_tables; extern int break_after_n_units; extern boolean check_names; /* Check for invalid names */ extern boolean check_verbose_mode; /* During '-k' mode, display errors */ extern boolean check_frames; /* Frames check */ extern boolean check_frames_extended;/* Extensive frames check */ extern boolean check_locations; /* Location list check */ /* Check categories corresponding to the -k option */ typedef enum /* Dwarf_Check_Categories */ { abbrev_code_result, pubname_attr_result, reloc_offset_result, attr_tag_result, tag_tree_result, type_offset_result, decl_file_result, ranges_result, lines_result, aranges_result, /* Harmless errors are errors detected inside libdwarf but not reported via DW_DLE_ERROR returns because the errors won't really affect client code. The 'harmless' errors are reported and otherwise ignored. It is difficult to report the error when the error is noticed by libdwarf, the error is reported at a later time. The other errors dwarfdump reports are also generally harmless but are detected by dwarfdump so it's possble to report the error as soon as the error is discovered. */ harmless_result, fde_duplication, frames_result, locations_result, names_result, abbreviations_result, dwarf_constants_result, di_gaps_result, forward_decl_result, self_references_result, total_check_result, LAST_CATEGORY /* Must be last */ } Dwarf_Check_Categories; extern boolean info_flag; extern boolean line_flag; extern boolean use_old_dwarf_loclist; extern boolean producer_children_flag; /* List of CUs per compiler */ extern char cu_name[ ]; extern boolean cu_name_flag; extern Dwarf_Unsigned cu_offset; extern Dwarf_Off fde_offset_for_cu_low; extern Dwarf_Off fde_offset_for_cu_high; /* Process TAGs for checking mode and reset pRangesInfo table if appropriate. */ extern void tag_specific_checks_setup(Dwarf_Half val,int die_indent_level); extern char *program_name; extern Dwarf_Error err; extern void print_error_and_continue (Dwarf_Debug dbg, string msg,int res, Dwarf_Error err); extern void print_error (Dwarf_Debug dbg, string msg,int res, Dwarf_Error err); extern void print_line_numbers_this_cu (Dwarf_Debug dbg, Dwarf_Die in_die); struct dwconf_s; extern void print_frames (Dwarf_Debug dbg, int print_debug_frame, int print_eh_frame,struct dwconf_s *); extern void print_ranges (Dwarf_Debug dbg); extern void print_pubnames (Dwarf_Debug dbg); extern void print_macinfo (Dwarf_Debug dbg); extern void print_infos (Dwarf_Debug dbg,Dwarf_Bool is_info); extern void print_locs (Dwarf_Debug dbg); extern void print_abbrevs (Dwarf_Debug dbg); extern void print_strings (Dwarf_Debug dbg); extern void print_aranges (Dwarf_Debug dbg); extern void print_relocinfo (Dwarf_Debug dbg,unsigned reloc_map); extern void print_static_funcs(Dwarf_Debug dbg); extern void print_static_vars(Dwarf_Debug dbg); enum type_type_e {SGI_TYPENAME, DWARF_PUBTYPES} ; extern void print_types(Dwarf_Debug dbg,enum type_type_e type_type); extern void print_weaknames(Dwarf_Debug dbg); extern void print_exception_tables(Dwarf_Debug dbg); struct esb_s; extern void print_ranges_list_to_extra(Dwarf_Debug dbg, Dwarf_Unsigned off, Dwarf_Ranges *rangeset, Dwarf_Signed rangecount, Dwarf_Unsigned bytecount, struct esb_s *stringbuf); boolean should_skip_this_cu(Dwarf_Debug dbg, Dwarf_Die cu_die, Dwarf_Error err); /* Returns the DW_AT_name of the CU */ string old_get_cu_name(Dwarf_Debug dbg,Dwarf_Die cu_die,Dwarf_Error err); /* Returns the producer of the CU */ int get_cu_name(Dwarf_Debug dbg,Dwarf_Die cu_die, Dwarf_Error err,char **short_name,char **long_name); int get_producer_name(Dwarf_Debug dbg,Dwarf_Die cu_die, Dwarf_Error err,char **producer_name); /* Get number of abbreviations for a CU */ extern void get_abbrev_array_info(Dwarf_Debug dbg,Dwarf_Unsigned offset); /* Validate an abbreviation */ extern void validate_abbrev_code(Dwarf_Debug dbg,Dwarf_Unsigned abbrev_code); extern void print_die_and_children( Dwarf_Debug dbg, Dwarf_Die in_die, Dwarf_Bool is_info, char **srcfiles, Dwarf_Signed cnt); extern boolean print_one_die( Dwarf_Debug dbg, Dwarf_Die die, boolean print_information, int die_indent_level, char **srcfiles, Dwarf_Signed cnt, boolean ignore_die_stack); /* Check for specific compiler */ extern boolean checking_this_compiler(); extern void update_compiler_target(const char *producer_name); extern void add_cu_name_compiler_target(char *name); /* General error reporting routines. These were macros for a short time and when changed into functions they kept (for now) their capitalization. The capitalization will likely change. */ extern void PRINT_CU_INFO(); extern void DWARF_CHECK_COUNT(Dwarf_Check_Categories category, int inc); extern void DWARF_ERROR_COUNT(Dwarf_Check_Categories category, int inc); extern void DWARF_CHECK_ERROR_PRINT_CU(); extern void DWARF_CHECK_ERROR(Dwarf_Check_Categories category, const char *str); extern void DWARF_CHECK_ERROR2(Dwarf_Check_Categories category, const char *str1, const char *str2); extern void DWARF_CHECK_ERROR3(Dwarf_Check_Categories category, const char *str1, const char *str2, const char *strexpl); struct esb_s; extern Dwarf_Die current_cu_die_for_print_frames; /* This is an awful hack, making current_cu_die_for_print_frames public. But it enables cleaning up (doing all dealloc needed). */ extern void printreg(Dwarf_Signed reg,struct dwconf_s *config_data); extern void print_frame_inst_bytes(Dwarf_Debug dbg, Dwarf_Ptr cie_init_inst, Dwarf_Signed len, Dwarf_Signed data_alignment_factor, int code_alignment_factor, Dwarf_Half addr_size, struct dwconf_s *config_data); int get_proc_name(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Addr low_pc, char *proc_name_buf, int proc_name_buf_len, void **pcMap); void get_attr_value(Dwarf_Debug dbg, Dwarf_Half tag, Dwarf_Die die, Dwarf_Attribute attrib, char **srcfiles, Dwarf_Signed cnt, struct esb_s *esbp, int show_form,int local_verbose); extern Dwarf_Unsigned local_dwarf_decode_u_leb128(unsigned char *leb128, unsigned int *leb128_length); extern Dwarf_Signed local_dwarf_decode_s_leb128(unsigned char *leb128, unsigned int *leb128_length); extern void dump_block(char *prefix, char *data, Dwarf_Signed len); extern void format_sig8_string(Dwarf_Sig8 *data,struct esb_s *out); int dwarfdump_print_one_locdesc(Dwarf_Debug dbg, Dwarf_Locdesc * llbuf, int skip_locdesc_header, struct esb_s *string_out); void clean_up_die_esb(); void clean_up_syms_malloc_data(); void safe_strcpy(char *out, long outlen, const char *in, long inlen); void print_any_harmless_errors(Dwarf_Debug dbg); /* Definitions for printing relocations. */ #define DW_SECTION_REL_DEBUG_INFO 0 #define DW_SECTION_REL_DEBUG_LINE 1 #define DW_SECTION_REL_DEBUG_PUBNAMES 2 #define DW_SECTION_REL_DEBUG_ABBREV 3 #define DW_SECTION_REL_DEBUG_ARANGES 4 #define DW_SECTION_REL_DEBUG_FRAME 5 #define DW_SECTION_REL_DEBUG_LOC 6 #define DW_SECTION_REL_DEBUG_RANGES 7 #define DW_SECTION_REL_DEBUG_TYPES 8 #endif /* globals_INCLUDED */ dwarf-20120410/dwarfdump/makename.c0000640000175000017500000000366611741100175015711 0ustar daveadavea /* Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan makename.c $Revision: 1.4 $ $Date: 2005/11/08 21:48:42 $ This used to be elaborate stuff. Now it is trivial, as duplicating names is unimportant in dwarfdump (in general). And in fact, this is only called for attributes and tags etc whose true name is unknown. Not for any normal case. */ #include #include #include #include "makename.h" char * makename(const char *s) { char *newstr; if (!s) { return ""; } newstr = strdup(s); if (newstr == 0) { fprintf(stderr, "Out of memory mallocing %d bytes\n", (int) strlen(s)); exit(1); } return newstr; } dwarf-20120410/dwarfdump/README0000640000175000017500000000614311741100175014640 0ustar daveadaveaI would prefer you try using ../dwarfdump2, not this source. If you must use this for some reason, could you let me know why? Thanks. To build dwarfdump, first build libdwarf in the neighboring directory then type ./configure make Installation is a bit primitive. sudo make install may or may not work. Some or all of the following might be required on Unix or Linux or MacOS: sudo mkdir -p /usr/local/share/man/man1/ sudo mkdir -p /usr/local/lib sudo mkdir -p /usr/local/bin Then retry the 'sudo make install' and (if necessary) try sudo chmod a+x /usr/local/bin/dwarfdump sudo chmod a+r /usr/local/share/man/man1/dwarfdump.1 sudo chmod a+r /usr/local/lib/dwarfdump.conf You don't really need the dwarfdump.1 man page, but you might as well have it. If the man page is not visible with 'man dwarfdump' try 'man manpath' for hints. If you don't need others using dwarfdump on your computer, just cp dwarfdump $HOME/bin/dwarfdump (by convention many people put personal executables in $HOME/bin and fix up $PATH to refer there) which suffices as 'installation'. Also cp dwarfdump.conf $HOME To use dwarf or libdwarf, you may want to install dwarf.h and libdwarf.h somewhere convenient. You can just copy those two headers to /usr/local/include by hand (or anywhere, really, that you have permission to copy to) (you may need to use -I/usr/local/include on compile lines to reference them there, but see below on configure and make). Notice that dwarf_names.c and dwarf_names.h are supplied by the release though the Makefile can and may rebuild them. Some users find it difficult to get a reliable awk(1) program, so for them these prebuilt versions may be useful. If your headers or libelf/libdwarf are not in the expected places, use the make command line to add flags and include directories. For example ./configure PREINCS="-I /usr/local/include" POSTINCS="-I /home/x/include" make PREINCS content is inserted before CFLAGS as make(1) is running. POSTINCS content is added after the CFLAGS value. To set LDFLAGS, do so at configure time, for example: ./configure LDFLAGS="-L /some/dir" And/or use PRELIBS and/or POSTLIBS at 'make' time similar to the use of PREINCS and POSTINCS. If the libdwarf directory has both libdwarf.so and libdwarf.a, the libdwarf.so will be picked up and "./tag_tree_build: error while loading shared libraries: libdwarf.so: cannot open shared object file: No such file or directory" will probably result. Either: remove libdwarf.so and rebuild or set the environment variable LD_LIBRARY_PATH to the directory containing the .so or use LDFLAGS to set rpath (see just below). It is perhaps simpler to ensure that the libdwarf directory only has an archive, not a shared-library. But sometimes one wants a shared library. In that case one can set ld's -rpath on the gcc command line like this: LDFLAGS="-Wl,-rpath=/some/path/libdir" so the shared library can be found at run time automatically. The same problem may arise with libelf, and the same approach will solve the problem. David Anderson. davea42 at earthlink dot net. dwarf-20120410/dwarfdump/uri.c0000640000175000017500000002433411741100175014725 0ustar daveadavea/* Copyright 2011 David Anderson. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan */ /* The address of the Free Software Foundation is Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. SGI has moved from the Crittenden Lane address. */ #include "globals.h" #include "esb.h" #include "uri.h" #include #include /* dwarfdump_ctype table. See uritablebuild.c */ static char dwarfdump_ctype_table[256] = { 0, /* NUL 0x00 */ 0, /* control 0x01 */ 0, /* control 0x02 */ 0, /* control 0x03 */ 0, /* control 0x04 */ 0, /* control 0x05 */ 0, /* control 0x06 */ 0, /* control 0x07 */ 0, /* control 0x08 */ 0, /* whitespace 0x09 */ 0, /* whitespace 0x0a */ 0, /* whitespace 0x0b */ 0, /* whitespace 0x0c */ 0, /* whitespace 0x0d */ 0, /* control 0x0e */ 0, /* control 0x0f */ 0, /* control 0x10 */ 0, /* control 0x11 */ 0, /* control 0x12 */ 0, /* control 0x13 */ 0, /* control 0x14 */ 0, /* control 0x15 */ 0, /* control 0x16 */ 0, /* control 0x17 */ 0, /* control 0x18 */ 0, /* control 0x19 */ 0, /* control 0x1a */ 0, /* control 0x1b */ 0, /* control 0x1c */ 0, /* control 0x1d */ 0, /* control 0x1e */ 0, /* control 0x1f */ 1, /* ' ' 0x20 */ 1, /* '!' 0x21 */ 0, /* '"' 0x22 */ 1, /* '#' 0x23 */ 1, /* '$' 0x24 */ 0, /* '%' 0x25 */ 1, /* '&' 0x26 */ 0, /* ''' 0x27 */ 1, /* '(' 0x28 */ 1, /* ')' 0x29 */ 1, /* '*' 0x2a */ 1, /* '+' 0x2b */ 1, /* ',' 0x2c */ 1, /* '-' 0x2d */ 1, /* '.' 0x2e */ 1, /* '/' 0x2f */ 1, /* '0' 0x30 */ 1, /* '1' 0x31 */ 1, /* '2' 0x32 */ 1, /* '3' 0x33 */ 1, /* '4' 0x34 */ 1, /* '5' 0x35 */ 1, /* '6' 0x36 */ 1, /* '7' 0x37 */ 1, /* '8' 0x38 */ 1, /* '9' 0x39 */ 1, /* ':' 0x3a */ 0, /* ';' 0x3b */ 1, /* '<' 0x3c */ 1, /* '=' 0x3d */ 1, /* '>' 0x3e */ 1, /* '?' 0x3f */ 1, /* '@' 0x40 */ 1, /* 'A' 0x41 */ 1, /* 'B' 0x42 */ 1, /* 'C' 0x43 */ 1, /* 'D' 0x44 */ 1, /* 'E' 0x45 */ 1, /* 'F' 0x46 */ 1, /* 'G' 0x47 */ 1, /* 'H' 0x48 */ 1, /* 'I' 0x49 */ 1, /* 'J' 0x4a */ 1, /* 'K' 0x4b */ 1, /* 'L' 0x4c */ 1, /* 'M' 0x4d */ 1, /* 'N' 0x4e */ 1, /* 'O' 0x4f */ 1, /* 'P' 0x50 */ 1, /* 'Q' 0x51 */ 1, /* 'R' 0x52 */ 1, /* 'S' 0x53 */ 1, /* 'T' 0x54 */ 1, /* 'U' 0x55 */ 1, /* 'V' 0x56 */ 1, /* 'W' 0x57 */ 1, /* 'X' 0x58 */ 1, /* 'Y' 0x59 */ 1, /* 'Z' 0x5a */ 1, /* '[' 0x5b */ 1, /* '\' 0x5c */ 1, /* ']' 0x5d */ 1, /* '^' 0x5e */ 1, /* '_' 0x5f */ 0, /* '`' 0x60 */ 1, /* 'a' 0x61 */ 1, /* 'b' 0x62 */ 1, /* 'c' 0x63 */ 1, /* 'd' 0x64 */ 1, /* 'e' 0x65 */ 1, /* 'f' 0x66 */ 1, /* 'g' 0x67 */ 1, /* 'h' 0x68 */ 1, /* 'i' 0x69 */ 1, /* 'j' 0x6a */ 1, /* 'k' 0x6b */ 1, /* 'l' 0x6c */ 1, /* 'm' 0x6d */ 1, /* 'n' 0x6e */ 1, /* 'o' 0x6f */ 1, /* 'p' 0x70 */ 1, /* 'q' 0x71 */ 1, /* 'r' 0x72 */ 1, /* 's' 0x73 */ 1, /* 't' 0x74 */ 1, /* 'u' 0x75 */ 1, /* 'v' 0x76 */ 1, /* 'w' 0x77 */ 1, /* 'x' 0x78 */ 1, /* 'y' 0x79 */ 1, /* 'z' 0x7a */ 1, /* '{' 0x7b */ 1, /* '|' 0x7c */ 1, /* '}' 0x7d */ 1, /* '~' 0x7e */ 0, /* DEL 0x7f */ 1, /* 0x80 */ 1, /* 0x81 */ 1, /* 0x82 */ 1, /* 0x83 */ 1, /* 0x84 */ 1, /* 0x85 */ 1, /* 0x86 */ 1, /* 0x87 */ 1, /* 0x88 */ 1, /* 0x89 */ 1, /* 0x8a */ 1, /* 0x8b */ 1, /* 0x8c */ 1, /* 0x8d */ 1, /* 0x8e */ 1, /* 0x8f */ 1, /* 0x90 */ 1, /* 0x91 */ 1, /* 0x92 */ 1, /* 0x93 */ 1, /* 0x94 */ 1, /* 0x95 */ 1, /* 0x96 */ 1, /* 0x97 */ 1, /* 0x98 */ 1, /* 0x99 */ 1, /* 0x9a */ 1, /* 0x9b */ 1, /* 0x9c */ 1, /* 0x9d */ 1, /* 0x9e */ 1, /* 0x9f */ 0, /* other: 0xa0 */ 1, /* 0xa1 */ 1, /* 0xa2 */ 1, /* 0xa3 */ 1, /* 0xa4 */ 1, /* 0xa5 */ 1, /* 0xa6 */ 1, /* 0xa7 */ 1, /* 0xa8 */ 1, /* 0xa9 */ 1, /* 0xaa */ 1, /* 0xab */ 1, /* 0xac */ 1, /* 0xad */ 1, /* 0xae */ 1, /* 0xaf */ 1, /* 0xb0 */ 1, /* 0xb1 */ 1, /* 0xb2 */ 1, /* 0xb3 */ 1, /* 0xb4 */ 1, /* 0xb5 */ 1, /* 0xb6 */ 1, /* 0xb7 */ 1, /* 0xb8 */ 1, /* 0xb9 */ 1, /* 0xba */ 1, /* 0xbb */ 1, /* 0xbc */ 1, /* 0xbd */ 1, /* 0xbe */ 1, /* 0xbf */ 1, /* 0xc0 */ 1, /* 0xc1 */ 1, /* 0xc2 */ 1, /* 0xc3 */ 1, /* 0xc4 */ 1, /* 0xc5 */ 1, /* 0xc6 */ 1, /* 0xc7 */ 1, /* 0xc8 */ 1, /* 0xc9 */ 1, /* 0xca */ 1, /* 0xcb */ 1, /* 0xcc */ 1, /* 0xcd */ 1, /* 0xce */ 1, /* 0xcf */ 1, /* 0xd0 */ 1, /* 0xd1 */ 1, /* 0xd2 */ 1, /* 0xd3 */ 1, /* 0xd4 */ 1, /* 0xd5 */ 1, /* 0xd6 */ 1, /* 0xd7 */ 1, /* 0xd8 */ 1, /* 0xd9 */ 1, /* 0xda */ 1, /* 0xdb */ 1, /* 0xdc */ 1, /* 0xdd */ 1, /* 0xde */ 1, /* 0xdf */ 1, /* 0xe0 */ 1, /* 0xe1 */ 1, /* 0xe2 */ 1, /* 0xe3 */ 1, /* 0xe4 */ 1, /* 0xe5 */ 1, /* 0xe6 */ 1, /* 0xe7 */ 1, /* 0xe8 */ 1, /* 0xe9 */ 1, /* 0xea */ 1, /* 0xeb */ 1, /* 0xec */ 1, /* 0xed */ 1, /* 0xee */ 1, /* 0xef */ 1, /* 0xf0 */ 1, /* 0xf1 */ 1, /* 0xf2 */ 1, /* 0xf3 */ 1, /* 0xf4 */ 1, /* 0xf5 */ 1, /* 0xf6 */ 1, /* 0xf7 */ 1, /* 0xf8 */ 1, /* 0xf9 */ 1, /* 0xfa */ 1, /* 0xfb */ 1, /* 0xfc */ 1, /* 0xfd */ 1, /* 0xfe */ 0, /* other: 0xff */ }; static char * xchar(int c, char *buf, int size) { snprintf(buf, size,"%%%02x",c); return buf; } /* Translate dangerous and some other characters to safe %xx form. */ void translate_to_uri(const char * filename, struct esb_s *out) { char buf[8]; const char *cp = 0; for(cp = filename ; *cp; ++cp) { char v[2]; int c = 0xff & (unsigned char)*cp; if(dwarfdump_ctype_table[c]) { v[0] = c; v[1] = 0; esb_append(out,v); } else { char *b = xchar(c,buf,sizeof(buf)); esb_append(out,b); } } } /* This is not very efficient, but it is seldom called. */ static char hexdig(char c) { char ochar = 0; if(c >= 0 && c <= '9') { ochar = (c - '0'); return ochar; } if(c >= 'a' && c <= 'f') { ochar = (c - 'a')+10; return ochar; } if(c >= 'A' && c <= 'F') { ochar = (c - 'A')+10; return ochar; } // We have an input botch here. fprintf(stderr,"Translating from uri: " "A supposed hexadecimal input character is " "not 0-9 or a-f or A-F, it is (shown as hex here): %x\n",c); return ochar; } static char tohex(char c1, char c2) { char out = (hexdig(c1) << 4) | hexdig(c2); return out; } static int hexpairtochar(const char *cp, char*myochar) { char ochar = 0; int olen = 0; char c = cp[0]; if(c) { char c2 = cp[1]; if(c2) { ochar = tohex(c,c2); olen = 2; } else { fprintf(stderr,"Translating from uri: " "A supposed hexadecimal input character pair " "runs off the end of the input after 1 hex digit.\n"); /* botched input. */ ochar = c; olen = 1; } } else { /* botched input. */ fprintf(stderr,"Translating from uri: " "A supposed hexadecimal input character pair " "runs off the end of the input.\n"); ochar = '%'; olen = 0; } *myochar = ochar; return olen; } void translate_from_uri(const char * input, struct esb_s* out) { const char *cp = input; char tempstr[2]; for(; *cp; ++cp) { char c = *cp; if(c == '%') { int increment = 0; char c2 = cp[1]; // hexpairtochar deals with c2 being NUL. if ( c2 == '%') { tempstr[0] = c; tempstr[1] = 0; esb_append(out,tempstr); ++cp; continue; } increment = hexpairtochar(cp+1,&c); tempstr[0] = c; tempstr[1] = 0; esb_append(out,tempstr); cp +=increment; continue; } tempstr[0] = c; tempstr[1] = 0; esb_append(out,tempstr); } } #ifdef TEST unsigned errcnt = 0; static void mytestfrom(const char * in,const char *expected,int testnum) { struct esb_s out; esb_constructor(&out); translate_from_uri(in, &out); if(strcmp(expected, esb_get_string(&out))) { printf(" Fail test %d expected \"%s\" got \"%s\"\n", testnum,expected,esb_get_string(&out)); ++errcnt; } esb_destructor(&out); } static void mytest(char *in,char *expected,int testnum) { struct esb_s out; esb_constructor(&out); translate_to_uri(in, &out); if(strcmp(expected, esb_get_string(&out))) { printf(" Fail test %d expected %s got %s\n",testnum,expected,esb_get_string(&out)); ++errcnt; } esb_destructor(&out); } int main() { /* We no longer translate space to %20, that turns out not to help all that much. */ mytest("aaa","aaa",1); mytest(" bc"," bc",2); mytest(";bc","%3bbc",3); mytest(" bc\n"," bc%0a",4); mytest(";bc\n","%3bbc%0a",5); mytest(" bc\r"," bc%0d",6); mytest(";bc\r","%3bbc%0d",7); mytest(" \x01"," %01",8); mytest(";\x01","%3b%01",9); mytestfrom("abc","abc",10); mytestfrom("a%20bc","a bc",11); mytestfrom("a%%20bc","a%20bc",12); mytestfrom("a%%%20bc","a% bc",13); mytestfrom("a%%%%20bc","a%%20bc",14); mytestfrom("a%20","a ",15); /* The following is mistaken input. */ mytestfrom("a%2","a2",16); mytestfrom("a%","a%",17); mytest("%bc","%25bc",18); if(errcnt) { printf("uri errcount ",errcnt); } return errcnt? 1:0; } #endif dwarf-20120410/dwarfdump/makename.h0000640000175000017500000000350011741100175015701 0ustar daveadavea#ifndef names_h #define names_h /* Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright 2011 David Anderson. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan */ /* makename.h $Revision: 1.3 $ $Date: 2004/10/28 22:26:58 $ This is for putting strings into stable storage. Effectively an strdup() wrapper. Rarely called. It leaks memory, (the memory is never freed) but that seems unimportant since use of this is very rare. */ char * makename(const char *); /* Makes a copy of the string in a malloc area. Can never return 0. */ #endif dwarf-20120410/dwarfdump/print_weaknames.c0000640000175000017500000000704611741100175017316 0ustar daveadavea/* Copyright (C) 2000-2006 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright 2007-2010 Sun Microsystems, Inc. All rights reserved. Portions Copyright 2009-2011 SN Systems Ltd. All rights reserved. Portions Copyright 2008-2011 David Anderson. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/print_sections.c,v 1.69 2006/04/17 00:09:56 davea Exp $ */ /* The address of the Free Software Foundation is Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. SGI has moved from the Crittenden Lane address. */ #include "globals.h" #include "naming.h" #include "dwconf.h" #include "esb.h" #include "print_sections.h" /* Get all the data in .debug_weaknames */ extern void print_weaknames(Dwarf_Debug dbg) { Dwarf_Weak *weaknamebuf = NULL; Dwarf_Signed count = 0; Dwarf_Signed i = 0; Dwarf_Off die_off = 0; Dwarf_Off cu_off = 0; char *name = NULL; int wkres = 0; current_section_id = DEBUG_WEAKNAMES; if (!do_print_dwarf) { return; } printf("\n.debug_weaknames\n"); wkres = dwarf_get_weaks(dbg, &weaknamebuf, &count, &err); if (wkres == DW_DLV_ERROR) { print_error(dbg, "dwarf_get_weaks", wkres, err); } else if (wkres == DW_DLV_NO_ENTRY) { /* no weaknames */ } else { Dwarf_Unsigned maxoff = get_info_max_offset(dbg); for (i = 0; i < count; i++) { int tnres = 0; int cures3 = 0; Dwarf_Unsigned global_cu_off = 0; tnres = dwarf_weak_name_offsets(weaknamebuf[i], &name, &die_off, &cu_off, &err); deal_with_name_offset_err(dbg, "dwarf_weak_name_offsets", name, die_off, tnres, err); cures3 = dwarf_weak_cu_offset(weaknamebuf[i], &global_cu_off, &err); if (cures3 != DW_DLV_OK) { print_error(dbg, "dwarf_weakname_cu_offset", cures3, err); } print_pubname_style_entry(dbg, "weakname", name, die_off, cu_off, global_cu_off, maxoff); /* print associated die too? */ } dwarf_weaks_dealloc(dbg, weaknamebuf, count); } } /* print_weaknames() */ dwarf-20120410/dwarfdump/tag_attr.c0000640000175000017500000002072611741100175015734 0ustar daveadavea/* Copyright (C) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright (C) 2009-2010 SN Systems Ltd. All Rights Reserved. Portions Copyright (C) 2009-2011 David Anderson. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/tag_attr.c,v 1.8 2005/12/01 17:34:59 davea Exp $ */ #include #include #include /* For exit() declaration etc. */ #include /* For errno declaration. */ #include /* For getopt. */ #include "globals.h" #include "libdwarf.h" #include "common.h" #include "tag_common.h" boolean ellipsis = FALSE; /* So we can use dwarf_names.c */ /* Expected input format 0xffffffff value of a tag value of a standard attribute that follows that tag ... 0xffffffff value of a tag value of a standard attribute that follows that tag ... 0xffffffff ... No blank lines or commentary allowed, no symbols, just numbers. */ unsigned int tag_attr_combination_table[ATTR_TABLE_ROW_MAXIMUM][ATTR_TABLE_COLUMN_MAXIMUM]; static const char *usage[] = { "Usage: tag_attr_build ", " -i input-table-path", " -o output-table-path", " -s (Generate standard attribute table)", " -e (Generate extended attribute table (common extensions))", "" }; char *program_name = 0; char *input_name = 0; char *output_name = 0; int standard_flag = FALSE; int extended_flag = FALSE; /* process arguments */ void process_args(int argc, char *argv[]) { int c = 0; boolean usage_error = FALSE; program_name = argv[0]; while ((c = getopt(argc, argv, "i:o:se")) != EOF) { switch (c) { case 'i': input_name = optarg; break; case 'o': output_name = optarg; break; case 'e': extended_flag = TRUE; break; case 's': standard_flag = TRUE; break; default: usage_error = TRUE; break; } } if (usage_error || 1 == optind || optind != argc) { print_usage_message(argv[0],usage); exit(FAILED); } } int main(int argc, char **argv) { int i = 0; unsigned int num = 0; int input_eof = 0; int table_rows = 0; int table_columns = 0; int current_row = 0; FILE * fileInp = 0; FILE * fileOut = 0; print_version_details(argv[0],FALSE); process_args(argc,argv); print_args(argc,argv); if (!input_name ) { fprintf(stderr,"Input name required, not supplied.\n"); print_usage_message(argv[0],usage); exit(FAILED); } fileInp = fopen(input_name,"r"); if (!fileInp) { fprintf(stderr,"Invalid input filename, could not open '%s'\n", input_name); print_usage_message(argv[0],usage); exit(FAILED); } if (!output_name ) { fprintf(stderr,"Output name required, not supplied.\n"); print_usage_message(argv[0],usage); exit(FAILED); } fileOut = fopen(output_name,"w"); if (!fileOut) { fprintf(stderr,"Invalid output filename, could not open: '%s'\n", output_name); print_usage_message(argv[0],usage); exit(FAILED); } if ((standard_flag && extended_flag) || (!standard_flag && !extended_flag)) { fprintf(stderr,"Invalid table type\n"); fprintf(stderr,"Choose -e or -s .\n"); print_usage_message(argv[0],usage); exit(FAILED); } if(standard_flag) { table_rows = STD_ATTR_TABLE_ROWS; table_columns = STD_ATTR_TABLE_COLUMNS; } else { table_rows = EXT_ATTR_TABLE_ROWS; table_columns = EXT_ATTR_TABLE_COLS; } input_eof = read_value(&num,fileInp); /* 0xffffffff */ if (IS_EOF == input_eof) { bad_line_input("Empty input file"); } if (num != MAGIC_TOKEN_VALUE) { bad_line_input("Expected 0xffffffff"); } while (!feof(stdin)) { unsigned int tag; int curcol = 0; input_eof = read_value(&tag,fileInp); if (IS_EOF == input_eof) { /* Reached normal eof */ break; } if(standard_flag) { if (tag >= table_rows ) { bad_line_input("tag value exceeds standard table size"); } } else { if(current_row >= table_rows) { bad_line_input("too many extended table rows."); } tag_attr_combination_table[current_row][0] = tag; } input_eof = read_value(&num,fileInp); if (IS_EOF == input_eof) { bad_line_input("Not terminated correctly.."); } curcol = 1; while (num != MAGIC_TOKEN_VALUE) { if(standard_flag) { unsigned idx = num / BITS_PER_WORD; unsigned bit = num % BITS_PER_WORD; if (idx >= table_columns) { bad_line_input ("too many attributes: table incomplete."); } tag_attr_combination_table[tag][idx] |= (1 << bit); } else { if (curcol >= table_columns) { bad_line_input("too many attributes: table incomplete."); } tag_attr_combination_table[current_row][curcol] = num; curcol++; } input_eof = read_value(&num,fileInp); if (IS_EOF == input_eof) { bad_line_input("Not terminated correctly."); } } ++current_row; } fprintf(fileOut,"/* Generated code, do not edit. */\n"); fprintf(fileOut,"/* Generated on %s %s */\n",__DATE__,__TIME__); fprintf(fileOut,"\n/* BEGIN FILE */\n\n"); if (standard_flag) { fprintf(fileOut,"#define ATTR_TREE_ROW_COUNT %d\n\n",table_rows); fprintf(fileOut,"#define ATTR_TREE_COLUMN_COUNT %d\n\n",table_columns); fprintf(fileOut, "static unsigned int tag_attr_combination_table" "[ATTR_TREE_ROW_COUNT][ATTR_TREE_COLUMN_COUNT] = {\n"); } else { fprintf(fileOut,"/* Common extensions */\n"); fprintf(fileOut,"#define ATTR_TREE_EXT_ROW_COUNT %d\n\n",table_rows); fprintf(fileOut,"#define ATTR_TREE_EXT_COLUMN_COUNT %d\n\n", table_columns); fprintf(fileOut, "static unsigned int tag_attr_combination_ext_table" "[ATTR_TREE_EXT_ROW_COUNT][ATTR_TREE_EXT_COLUMN_COUNT] = {\n"); } for (i = 0; i < table_rows; i++) { int j = 0; const char *name = 0; if(standard_flag) { dwarf_get_TAG_name(i,&name); fprintf(fileOut,"/* %d %-37s*/\n",i,name); } else { int k = tag_attr_combination_table[i][0]; dwarf_get_TAG_name(k,&name); fprintf(fileOut,"/* %u %-37s*/\n",k,name); } fprintf(fileOut," { "); for(j = 0; j < table_columns; ++j ) { fprintf(fileOut,"0x%08x,",tag_attr_combination_table[i][j]); } fprintf(fileOut,"},\n"); } fprintf(fileOut,"};\n"); fprintf(fileOut,"\n/* END FILE */\n"); fclose(fileInp); fclose(fileOut); return (0); } /* A fake so we can use dwarf_names.c */ void print_error (Dwarf_Debug dbg, string msg,int res, Dwarf_Error err) { } dwarf-20120410/dwarfdump/ChangeLog0000640000175000017500000000015111741100175015523 0ustar daveadavea2012-04-10 DavidAnderson * dwarfdump.c, common.c: Updated version string. dwarf-20120410/dwarfdump/ChangeLog20070000640000175000017500000001323111741100175016037 0ustar daveadavea2007-12-09 DavidAnderson * print_sections.c print_frames.c: Forgot to commit yesterday. yesterday's commit includes renaming _dwarf_fde_section_offset _dwarf_cie_section_offset, _dwarf_print_lines, _dwarf_ld_sort_lines to dwarf_* form while retaining support for the now obsolete _dwarf_* form. 2007-12-08 DavidAnderson * config.h.in, configure.in: Latest linux libelf.h requires _GNU_SOURCE to get off64_t defined so dwarfdump compiles. Only define _GNU_SOURCE if libelf.h defines off64_t. Regenerated configure. * config.guess, config.sub: Updated to 2.61 * acconfig.h: Deleted, removing autoconf complaint. 2007-10-15 DavidAnderson * print_die.c (clean_up_die_esb): New function cleans up malloc space. * print_reloc.c (clean_up_syms_malloc_data): New function cleans up malloc space. * dwarfdump.c (main): Call new cleanup functions at end. * globals.h: Declare new cleanup functions. 2007-09-04 DavidAnderson * print_die.c (print_attribute): For DWARF4: DW_AT_high_pc: add qualifier to value when the value is an offset from DW_AT_low_pc (thus not itself a address). Update the address of the FSF. * print_frames.h DWARFDUMPCOPYRIGHT print_sections.c print_reloc.c dwarfdump.c tag_tree.c tag_attr.c esb.c esb.h makename.c acconfig.h dwconf.c makename.h dwconf.h globals.h print_frames.c: Update the address of the FSF. 2007-07-03 DavidAnderson * print_sections.c (dump_block): Removed superfluous return byte from printed characters. Removed unused variables. * print_die.c: A little refactoring for clarity. * globals.h: dwarfdump_print_one_locdesc() is now a global-to-dwarfdump function. * print_frames.c: Now (with -v) prints dwarf expression bytes in frame expressions readably. 2007-07-02 DavidAnderson * dwarfdump.c: Add new -R option for 'generic' register sets. * dwarfdump.1: document -R, add new -x documentation. * dwconf.c: Set up -R configuration. Slight revision of register printing code. * dwconf.h: Interface to register name printing simplified. * print_frames.c: Use the simpler register name interface. * dwarfdump.conf: Add new 'generic' abi for up to 1000 registers. 2007-07-01 DavidAnderson * print_frames.c: For DW_CFA_def_cfa_sf & DW_CFA_def_cfa_offset_sf print a computed data alignment factor. 2007-06-29 DavidAnderson * dwarfdump.1: Corrected spelling error. 2007-05-25 DavidAnderson * dwconf.h dwconf.c: Changed field name to cf_named_regs_table_size as old name was less than clear. * dwarfdump.c: Call frame table setup with cf_table_entry_count not cf_named_regs_table_size. The newly renamed field makes it clearer the call was wrong. 2007-05-04 DavidAnderson * print_die.c: printing of global offset of DIEs with -G is now more in the style of previous output. 2007-04-18 Chris Quenelle * Makefile.in: - use $(srcdir) for files in source directory - support running rules in parallel by - use different tmp file names in different rules. - use more accurate target for dwarf_names.{c,h} * dwarf_names.awk: Enhance script to be able to generate either #define-style headers or enum-style headers * dwarfdump.c: dump most everything by default if no arguments are given to dwarfdump. This seems to be a more useful default than showing nothing at all. Also add a -G option to show the (G)lobal section offset for each die within an a.out. If you think you're seeing data corruption inside a .debug_info section, this is a useful option to have. * print_die.c: Support compressed integer blocks. This is an array (DW_FORM_block) of LEB numbers used as part of a Sun extension, DW_AT_SUN_func_offsets. Also add support for a new dwarf enum DW_ATCF_xxxx. This is used in DW_AT_SUN_cf_kind. Also, fix DW_AT_upper_bound so it can be a constant or a location list. DW_AT_count and DW_AT_data_member_location should also be fixed eventually. * print_sections.c: Changes to support zero-padding in the middle of section data. Change offset labels to be a little more clear. Not sure about the get_str failure. * tag_tree.list: DW_TAG_compile_unit can contain a DW_TAG_namespace 2007-04-10 David Anderson * print_reloc.c dwarfdump.c print_frames.c: Unified copyright to the SGI form. No copyright change. 2007-04-06 David Anderson * print_die.c (print_die_and_children): Increase static depth of die stack. Notice if it overflows and print error. 2007-02-23 David Anderson * print_reloc.c: 2 lines added (long) cast in printf and made %3ld instead of %3d to fix compiler warning. * print_frames.c: newline was missing from the output. Thanks to Chris Quenelle for noticing. 2007-02-20 David Anderson * print_frame.c (print_frame_inst_bytes): Fixed an off by one error (several places) when printing dwarf expressions and added commentary about it. Thanks to Julian Seward for pointing out it was off by one. * dwarfdump.c (print_error): added fflush of stdout, stderr where we are going to exit right away anyway. dwarf-20120410/dwarfdump/ChangeLog20060000640000175000017500000003350111741100175016040 0ustar daveadavea2006-12-24 David Anderson * DWARFDUMPCOPYRIGHT: Added GPL copyright text with explanation of the intended content. * COPYING: added text explaining confusion of GPL vs LGPL. Thanks to Chris Quenelle for pointing out the disconnect between DWARFDUMPCOPYRIGHT and the source files in dwarfdump. 2006-12-21 David Anderson * tag_tree.list: add tags to make allowed list more complete. Omission noticed by Marcel Mettes. 2006-06-14 David Anderson * print_frames.c: Clean up printing of augmentation data by eliminating dangling 0x (for eh_frame). 2006-04-28 David Anderson * dwarfdump.conf: Now has x86_64 register names. x86_64 with help from Tom Hughes (verified from independent sources). Added m68k register names and refined x86 list by looking at various information-sources. 2006-04-18 David Anderson * *.c: Ran indent so all now follow a standard look. * dwconf.c: Added fclose(conf_stream). 2006-04-18 David Anderson * dwarfdump.c: Forgot to call key new functions for handling variable-size frame data and different frame rule initialization value. * dwconf.c: Add a default print for CFA in case of an omission in dwarfdump.conf. * dwarfdump.conf: Move setup and rename the ABIs slightly. 2006-04-17 David Anderson * dwarfdump.conf: Correct typos. Remove some register names. * dwarfdump.c: Fix compiler warnings, fix -x option usage message. * dwconf.h: Fix compiler warnings by changing types. * dwconf.c: Change error checking so we check all errors, do not stop at first error. Ran indent. Added code to check for extra junk after operand(s). * print_frames.c: Fix compiler warnings. * Makefile.in: get used in install rule and creating places to search for dwarfdump.conf 2006-04-16 David Anderson * dwarfdump.conf: New dwarfdump configuration file. Makes using frame information easy to read and correct for any ABI/ISA without rebuilding dwarfdump. * Makefile.in: Added new files dwconf.h dwconf.c * dwconf.h dwconf.c: New files implement reading dwarfdump.conf and help print_frames.c print frame information correctly for ABIs specified at runtime. * dwarfdump.1: document -x commands. * globals.h: Minor changes to support dwarfdump.conf * print_frames.c: Major changes to support a run-time description of the frames info and dwarfdump.conf. * print_frames.h: Changes to support a run-time description of the frames info and dwarfdump.conf. * print_sections.c: Minor tweaks to support a run-time description of the frames info and dwarfdump.conf. 2006-03-31 David Anderson * Makefile.in globals.h print_sections.c: Refer to new print_frames.h print_frames.c. * print_frames.h print_frames.c: Extract cie, fde printing to separate file, separating loop logic from the printing of an entry from the loop. 2006-03-31 David Anderson * dwarfdump.c global.h print_sections.c: Preparing for dwarf3 frame interface. * print_die.c: Corrects handling of DW_AT_encoding (etc) value. 2006-03-29 David Anderson * print_sections.c: define DWARFDUMP_TURN_OFF_MIPS_REG_NAMES at compile time to turn off the MIPS register names printing. Instead (aside from cfa) use a name like r4 (where the DWARF register number follows the letter 'r'). Indent. Initialize some local variables at declarations. 2006-03-13 David Anderson * print_sections.c: Now gets gnu eh_augmentation data by calling dwarf_get_cie_augmentation_data() or dwarf_get_fde_augmentation_data() and prints it (use -v to see cie data). Now prints DWARF3 frame information. 2006-03-08 David Anderson * print_sections.c: Add 'break;' at line 710. Thanks to Richard Stuckey for noticing. 2005-12-01 David Anderson * dwarf_names.awk: use snprintf instead of sprintf for safety. 2005-12-01 David Anderson * Makefile.in: Build attr/tag trees with individual commands to catch build errors. * tag_attr.c,tag_tree.c: Verify that tables fit in the generated C code and check for format errors in the *.list files. * tag_attr.list, tag_tree.list: Added some valid entries. * globals.h: add DWARF_ERROR3 macro for better diagnostics. * print_die.c: Show both sides of questionable tag relation in CHECK -k diagnostic output. 2005-11-25 David Anderson * print_die.c: DW_AT_stride_size changed to DW_AT_bit_stride, added DW_AT_byte_stride. * tag_attr.c,tag_tree.c: fixed array size now a #define for readability. * tag_attr.list: Added DWARF3 attributes, also new TAGs. * tag_tree.list: Added DWARF3 TAGs. 2005-11-08 David Anderson * makename.c: remove non-standard malloc.h include, stdlib.h suffices and is already included. 2005-10-24 David Anderson * tag_attr.c tag_tree.c: added DWARF3 TAGs to string array. 2005-08-01 David Anderson * Makefile.in: Add esb.o and test rule (test code for esb.c). * dwarfdump.c: Remove old static buffer initialization. * print_die.c: Use esb now, avoid crash due to long loclist overrunning static buffer. Uses snprintf now, not sprintf. snprintf is for safety. * esb.h esb.c: Adding extensible string buffer (esb) code. * testesb.c: Test code for esb.c. * print_reloc.c: size field is now Elf64_Xword for Elf64 as Elf64_Word is only 32 bits. 2005-07-15 David Anderson * dwarfdump.c: Add print of .debug_pubtypes, remove erroneous dealloc after dwarf_formstring() call. * globals.h: Add declarations for .debug_pubtypes print. Add declaration for full dealloc. * print_die.c: Remove erroneous dealloc after dwarf_formstring() call. * print_exception_tables.c: Call dwarf_fde_cie_list_dealloc() for complete dealloc. * print_sections.c: Remove incorrect dealloc() call. Add calls to new dealloc routines. Add support of .debug_pubtypes print. 2005-07-14 David Anderson * print_sections.c (print_line_numbers_this_cu): Use new dwarf_srclines_dealloc() for deallocation after dwarf_srclines() called. 2005-04-13 David Anderson * print_sections.c: Factors out common print code into a new routine. Avoid indexing past end of register names array. Adds checks and prints so that certain errors in pubnames-like sections are printed usefully (and dwarfdump then stops if libdwarf gave an error). 2005-03-21 David Anderson * dwarfdump.c: Add -F flag to request .eh_frame section print. Changed -f flag meaning to print .debug_frame only. -a flag no longer prints .debug_frame by default. * print_sections.c: avoid printing an eh_frame we don't understand. Add new information per CU when printing line info: specifically the line section offset. * globals.h: Added arguments to print_frames() for -F flag. 2005-03-18 David Anderson * print_sections.c: Correct macro section printing. 2004-10-28 David Anderson * DWARFDUMPCOPYRIGHT config.h defs.h dwarfdump.c globals.h makename.c makename.h print_die.c print_exception_tables.c print_reloc.c print_sections.c tag_attr.c tag_attr.list tag_tree.c tag_tree.list: Copyright update, SGI corporate address change. 2004-10-26 David Anderson * acconfig.h: removed. Was old style autoconf usage. * configure.in: Updated AC_DEFINE usage, adding args 2 & 3. * config.guess: Updated. timestamp='2004-06-11'. * config.sub: Updated. timestamp='2004-03-12'. * configure config.h.in: regenerated with autoconf 2.58. 2004-05-14 David Anderson * print_die.c (print_die_and_children): Change to iteration on siblings (still recursing on children). 2004-03-30 David Anderson * dwarfdump.c (main): getopt() string should contain k:g not kg: Thanks to Peter Seiderer for pointing this out. 2003-12-31 David Anderson * README: Added configure example. * Makefile.in: Removed bogus LIBS line, updated copyright date. * acconfig.h: Added LGPL copyright to match libdwarf Silly, but it matches libdwarf version boilerplate. * config.guess config.sub: new versions from automake-1.6. * config.h.in configure: Regenerated. 2003-10-06 David Anderson * dwarfdump.c print_sections.c: applied indent(1). * print_die.c: applied indent and added ; after invocations of macros PUSH_DIE_STACK POP_DIE_STACK SPACE as these were confusing indent a bit. The indent control file .indent.pro contained: -bad -bap -nbbo -br -ce -brs -l72 -lc72 -hnl -nprs -fca -i4 -lp -psl -npcs 2003-10-02 David Anderson * dwarfdump.c: Add -g to indicate use of older location entry code in libdwarf. So dwarf_loclist and dwarf_loclist_n are testable. * globals.h: Added use_old_dwarf_loclist flag so one can choose the old dwarf_loclist() interface. For testing. * print_die.c: Rearranged to avoid code duplication. Now supports .debug_loc fully. * print_sections.c: Prints .debug_loc now. 2003-09-29 David Anderson * print_die.c: with -v, print 'loclist' start and end addr and also a hint that DW_FORM_indirect is used. No change for normal output (for now). 2003-05-19 David Anderson * dwarfdump.c call dwarf_srcfiles() to get file names per cu and pass down to die print routines. Removed incorrect tests for when to print ".debug_info", leaving simpler test. * print_die.c globals.h: print file name (from line info) with DW_AT_decl_file, adding data from dwarf_srcfiles to argument list of a few routines to make that possible. * print_sections.c: moved "line number info" string print so it prints for -v as well as normal line ouput. 2002-10-23 Amaury Le Leyzour amaury@sgi.com * print_sections.c (print_weaknames): Changed DW_DLA_TYPENAME to DW_DLA_WEAK at dwarf_dealloc(). 2002-10-22 Tom Hughes * print_sections.c: macro printing now supported. * dwarfdump.c: removed erroneous dwarf_dealloc() of string returned by dwarf_errmsg(). 2002-11-22 David Anderson * dwarf_names.awk at_list.awk: Allow an name to have two spellings so the historical name preserved yet the dwarf3 version is supported. First name seen is used/reported by dwarfdump. * dwarf.h: DW_TAG_template_type_param(eter) DW_TAG_template_value_param(eter) DW_AT_namelist_itm(s) are the ones with alternate spellings now. Added Universal Parallel C TAGs/Attributes in user namespace. * tag_attr.c tag_attr.list tag_tree.c tag_tree.list: Use the DW_TAG_template_* dwarf3 spellings. 2002-05-08 David Anderson * tag_attr.list dwarf.h: DW_AT_namelist_items is wrong, changed to DW_AT_namelist_item 2002-04-29 Stephen Clarke * dwarfdump.c (main): #ifdef for __CYGWIN__ on open(). 2001-06-14 David Anderson * print_sections.c: Calling the new libdwarf function dwarf_get_arange_cu_header_offset() so we can print the cu header offset for aranges. 2000-07-14 Fred Fish * configure.in (LOCATION_OF_LIBELFHEADER): Fix typo for configure variable to be tested and enclose libelf/libelf.h in <>. * configure: Regenerated. 2000-07-10 Fred Fish * Makefile.in (install): Install dwarfdump.1 from $(srcdir). 2000 June 12 davea@sgi.com print_sections.c the DW_CFA_offset_extended print did not multiply by data-alignment factor in the -v -v detailed output. And the offsets used %2d when the values were unsigned int, so now %2u. And not all cfa prints of values had necessarily a type to match %llu or %lld where required. Depended on the size of Dwarf_Signed and Dwarf_Unsigned. So now explicitly use cast to the right type to match the % format. 2000 April 13 davea@sgi.com print_sections.c - 1.56 - A single byte of zero is a perfectly legitmate null abbreviation entry (in .debug_abbrev) now we print those directly and avoid a warning from dwarfdump print_die.c - 1.42 - Explain what combo checker is doing and make it more maintainable (and fix bug which would not be hit, but was real enough (in combo checker), using too large a number as highest tag number). tag_tree.list - 1.2 - Add valid parent/child relationships so checker does not report valid entries as bogus. 2000 Feb 24 Jason Merrill noticed that gcc did not like gcc -E foo.list, so incorporated his fix so now the Makefile.in makes a link and does gcc -E _tmp.c 2000 Jan 26 elena.demikhovsky@intel.com noticed that 3 statements in print_sections.c got warnings from the compiler she was using. Simple casts (provided by her) fixed these. 1999 July 21 davea@sgi.com print_sections changed to allow printing of dwarf-ish egcs c++ .eh_frame data 1999 June 14 Fred Fish fnf@ninemoons.com contributed autoconf'ing of the libdwarf and dwarfdump source. 1999 June 10 ChangeLog started. davea@sgi.com David Anderson dwarf-20120410/dwarfdump/configure.in0000640000175000017500000000653511741100175016276 0ustar daveadaveadnl Process this file with autoconf to produce a configure script. AC_INIT(dwarfdump.c) AC_CONFIG_HEADER(config.h) AC_PROG_CC AC_GCC_TRADITIONAL AC_PROG_INSTALL AC_CHECK_TOOL(RANLIB, ranlib, :) AC_CHECK_TOOL(AR, ar) dnl AC_ARFLAGS AC_CHECK_HEADERS(elf.h getopt.h libelf.h libelf/libelf.h sgidefs.h sys/types.h) AC_CHECK_LIB(elf,elf64_getehdr, AC_DEFINE(HAVE_ELF64_GETEHDR,1, [Define to 1 if the elf64_getehdr function is in libelf.a.])) dnl Find out where the elf header is. if test "$ac_cv_header_elf_h" = yes; then AC_DEFINE(LOCATION_OF_LIBELFHEADER,[], [Define to header that first defines elf]) elif test "$ac_cv_header_libelf_h" = yes; then AC_DEFINE(LOCATION_OF_LIBELFHEADER, [], [Define to header that first defines elf.]) elif test "$ac_cv_header_libelf_libelf_h" = yes; then AC_DEFINE(LOCATION_OF_LIBELFHEADER,[], [Define to header that first defines elf.]) fi AC_TRY_COMPILE([#include "stdafx.h"],[ int p; p = 27;] , AC_DEFINE(HAVE_STDAFX_H,1, [Define 1 if we have the Windows specific header stdafx.h])) AC_TRY_COMPILE([#include LOCATION_OF_LIBELFHEADER], Elf64_Rel *p; int i; i = p->r_info; ,AC_DEFINE(HAVE_ELF64_R_INFO,1, [Define to 1 if the Elf64_Rel structure has r_info field.])) AC_TRY_COMPILE([], __uint32_t p; p = 3; ,AC_DEFINE(HAVE___UINT32_T, 1,[See if __uint32_t is predefined in the compiler. ])) AC_TRY_COMPILE([], __uint64_t p; p = 3; ,AC_DEFINE(HAVE___UINT64_T, 1,[See if __uint64_t is predefined in the compiler. ])) AC_TRY_COMPILE([#include ],[ __uint32_t p; p = 3]; , AC_DEFINE(HAVE___UINT32_T_IN_SYS_TYPES_H,1, [Define 1 if sys/types.h defines __uint32_t.])) AC_TRY_COMPILE([#include #include ],[ int i; regex_t r; int cflags = REG_EXTENDED; const char *s = "abc"; i = regcomp(&r,s,cflags); regfree(&r); ]; , AC_DEFINE(HAVE_REGEX,1, [Define 1 if regex seems to be defined])) AC_TRY_LINK([#include #include /* On Ubuntu 10.x, tsearch is in package libc6-dev. */ /* The tdestroy function is GNU, not POSIX. */ #define __USE_GNU 1 #include struct my_tentry { long mt_key; char * mt_name; }; struct my_tentry * make_my_tentry(long k,char *name) { return 0; } void mt_free_func(void *mt_data) { return; } int mt_compare_func(const void *l, const void *r) { return 0; }],[ long i = 1; void *tree1 = 0; char *dbuf = 0; struct my_tentry *mt = 0; struct my_tentry *retval = 0; mt = make_my_tentry(i,dbuf); retval = tsearch(mt,&tree1, mt_compare_func ); tdestroy(tree1,mt_free_func); exit(0); ];, AC_DEFINE(HAVE_TSEARCH,1, [Define 1 if the tsearch functions seem to be defined])) AC_ARG_ENABLE(nonstandardprintf,AC_HELP_STRING([--enable-nonstandardprintf], [Use a special printf format for 64bit (default is NO)]), [ AC_DEFINE([HAVE_NONSTANDARD_PRINTF_64_FORMAT],[1], [Define 1 if need nonstandard printf format for 64bit] )], []) AC_TRY_COMPILE([ #include ],[ int p; p = 0; ] , AC_DEFINE(HAVE_RAW_LIBELF_OK,1, [Define 1 if plain libelf builds.])) AC_TRY_COMPILE([ #define _GNU_SOURCE #include ],[ off64_t p; p = 0;] , AC_DEFINE(HAVE_LIBELF_OFF64_OK,1, [Define 1 if off64 is defined via libelf with GNU_SOURCE.])) AC_OUTPUT(Makefile) dwarf-20120410/dwarfdump/CODINGSTYLE0000640000175000017500000000300711741100175015463 0ustar daveadaveaThis document is a brief description of the main coding style conventions in dwarfdump. Many of them will be obvious from the code, but over time some accidental diffences crept in. Code should be indented in multiples of 4 spaces, and tabs should not be used to indent the source code. Use the dicheck program to check indenting. The struct naming convention is 'struct my_struct_s' for the struct defined here (meaning the name should end with _s). It is better to not do struct typedefs of local structs. Coders should type 'struct mystruct_s'. Readability is much more important than brevity. Any data or function not referenced outside the defining source file should be declared 'static'. Any duplicated code is a candidate for refactoring into a subprogram. Function names should be all lower case with underbars with the goal that statements and comments 'read well'. Variables should be lower-case with underbars for readability. It's ok for a small loop with counters to use single letter names like i or k or m. Structure members should have a struct-specific 2-character prefix to the name (followed by an underbar). That makes it much easier to grep for uses of members. Try to keep lines under 80 characters in length. Ensure every if() has {} to enclose the actions. Use libdwarf.h types for all the data objects you define, though sometimes an 'unsigned' or 'int' or 'size_t' is ok in restricted circumstances. Dwarf_Unsigned and Dwarf_Signed are the preferred integer types for general use. ------------ dwarf-20120410/dwarfdump/common.h0000640000175000017500000000312711741100175015420 0ustar daveadavea/* Copyright (C) 2009-2010 SN Systems. All Rights Reserved. Portions Copyright (C) 2009-2010 David Anderson. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan */ #ifndef COMMON_INCLUDED_H #define COMMON_INCLUDED_H void print_args(int argc, char *argv[]); void print_version_details(const char *name, int alwaysprint); void print_usage_message(const char *program_name, const char **text); #endif /* COMMON_INCLUDED_H */ dwarf-20120410/dwarfdump/uritablebuild.c0000640000175000017500000001026611741100175016754 0ustar daveadavea/* Copyright 2011 David Anderson. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan */ /* The address of the Free Software Foundation is Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. SGI has moved from the Crittenden Lane address. */ #include #include /* Generates a table which identifies a few dangerous characters. Ones one does not want to appear in output. It's a bit arbitrary in that we allow lots of shell-interpreted characters through, and most characters generally. But not control characters or single or double quotes. The quotes would be particularly problematic for post-processing dwarfdump output sensibly. */ static void print_entry(int c) { char v[2]; v[0] = c; v[1] = 0; if(c == 0) { printf("0, /* NUL 0x%02x */\n",c); return; } if(isalnum(c) || c == ' ' ) { /* We let the space character print as space since lots of files are named that way in Mac and Windows. */ printf("1, /* \'%s\' 0x%02x */\n",v,c); return; } if(c == 0x21 || c == 0x23 || c == 0x26) { /* We let the space character print as space since lots of files are named that way in Mac and Windows. */ printf("1, /* \'%s\' 0x%02x */\n",v,c); return; } if(isspace(c) ) { /* Other white space translated. */ printf("0, /* whitespace 0x%02x */\n",c); return; } if(c == 0x7f) { printf("0, /* DEL 0x%02x */\n",c); return; } if(c >= 0x01 && c <= 0x20 ) { /* ASCII control characters. */ printf("0, /* control 0x%02x */\n",c); return; } if(c == '\'' || c == '\"' || c == '%' || c == ';' ) { printf("0, /* \'%s\' 0x%02x */\n",v,c); return; } if(c >= 0x3a && c <= 0x40 ) { /* ASCII */ printf("1, /* \'%s\' 0x%02x */\n",v,c); return; } if(c == 0xa0 || c == 0xff ) { printf("0, /* other: 0x%02x */\n",c); return; } if(c >= 0x27 && c <= 0x2f ) { /* ASCII */ printf("1, /* \'%s\' 0x%02x */\n",v,c); return; } if(c >= 0x5b && c <= 0x5f ) { /* ASCII */ printf("1, /* \'%s\' 0x%02x */\n",v,c); return; } if(c >= 0x60 && c <= 0x60 ) { /* ASCII */ printf("0, /* \'%s\' 0x%02x */\n",v,c); return; } if(c >= 0x7b && c <= 0x7e ) { /* ASCII */ printf("1, /* \'%s\' 0x%02x */\n",v,c); return; } if (c < 0x7f) { /* ASCII */ printf("1, /* \'%s\' 0x%02x */\n",v,c); return; } /* We are allowing other iso 8859 characters through unchanged. */ printf("1, /* 0x%02x */\n",c); } int main() { int i = 0; printf("/* dwarfdump_ctype table */\n"); printf("char dwarfdump_ctype_table[256] = { \n"); for ( i = 0 ; i <= 255; ++i) { print_entry(i); } printf("};\n"); } dwarf-20120410/dwarfdump/config.h.in0000640000175000017500000000530311741100175016000 0ustar daveadavea/* config.h.in. Generated from configure.in by autoheader. */ /* Define to 1 if the elf64_getehdr function is in libelf.a. */ #undef HAVE_ELF64_GETEHDR /* Define to 1 if the Elf64_Rel structure has r_info field. */ #undef HAVE_ELF64_R_INFO /* Define to 1 if you have the header file. */ #undef HAVE_ELF_H /* Define to 1 if you have the header file. */ #undef HAVE_GETOPT_H /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_LIBELF_H /* Define to 1 if you have the header file. */ #undef HAVE_LIBELF_LIBELF_H /* Define 1 if off64 is defined via libelf with GNU_SOURCE. */ #undef HAVE_LIBELF_OFF64_OK /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define 1 if need nonstandard printf format for 64bit */ #undef HAVE_NONSTANDARD_PRINTF_64_FORMAT /* Define 1 if plain libelf builds. */ #undef HAVE_RAW_LIBELF_OK /* Define 1 if regex seems to be defined */ #undef HAVE_REGEX /* Define to 1 if you have the header file. */ #undef HAVE_SGIDEFS_H /* Define 1 if we have the Windows specific header stdafx.h */ #undef HAVE_STDAFX_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define 1 if the tsearch functions seem to be defined */ #undef HAVE_TSEARCH /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* See if __uint32_t is predefined in the compiler. */ #undef HAVE___UINT32_T /* Define 1 if sys/types.h defines __uint32_t. */ #undef HAVE___UINT32_T_IN_SYS_TYPES_H /* See if __uint64_t is predefined in the compiler. */ #undef HAVE___UINT64_T /* Define to header that first defines elf. */ #undef LOCATION_OF_LIBELFHEADER /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS dwarf-20120410/dwarfdump/addrmap.c0000640000175000017500000000757611741100175015547 0ustar daveadavea/* Copyright 2010-2011 David Anderson. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. */ /* If memory full we do not exit, we just keep going as if all were well. */ #include "globals.h" #include #include "addrmap.h" #ifndef HAVE_TSEARCH struct Addr_Map_Entry * addr_map_insert( Dwarf_Unsigned addr, char *name,void **tree1) { return 0; } struct Addr_Map_Entry * addr_map_find(Dwarf_Unsigned addr,void **tree1) { return 0; } void addr_map_destroy(void *map) { return;} #else /* HAVE_TSEARCH */ #define __USE_GNU 1 #include char firststringcontent[100]; char *firststring = 0; struct Addr_Map_Entry *firstaddr = 0; static struct Addr_Map_Entry * addr_map_create_entry(Dwarf_Unsigned k,char *name) { struct Addr_Map_Entry *mp = (struct Addr_Map_Entry *)malloc(sizeof(struct Addr_Map_Entry)); if(!mp) { return 0; } mp->mp_key = k; if(name) { mp->mp_name = strdup(name); } else { mp->mp_name = 0; } return mp; } static void addr_map_free_func(void *mx) { struct Addr_Map_Entry *m = mx; if(!m) { return; } free(m->mp_name); m->mp_name = 0; free(m); return; } static void DUMPFIRST(int line) { if(!firststring) { return; } } static int addr_map_compare_func(const void *l, const void *r) { const struct Addr_Map_Entry *ml = l; const struct Addr_Map_Entry *mr = r; if(ml->mp_key < mr->mp_key) { return -1; } if(ml->mp_key > mr->mp_key) { return 1; } return 0; } struct Addr_Map_Entry * addr_map_insert( Dwarf_Unsigned addr,char *name,void **tree1) { void *retval = 0; struct Addr_Map_Entry *re = 0; struct Addr_Map_Entry *e; e = addr_map_create_entry(addr,name); DUMPFIRST(__LINE__); /* tsearch records e's contents unless e is already present . We must not free it till destroy time if it got added to tree1. */ retval = tsearch(e,tree1, addr_map_compare_func); if(retval) { re = *(struct Addr_Map_Entry **)retval; if ( re != e) { /* We returned an existing record, e not needed. */ addr_map_free_func(e); } else { /* Record e got added to tree1, do not free record e. */ } } return re; } struct Addr_Map_Entry * addr_map_find(Dwarf_Unsigned addr,void **tree1) { void *retval = 0; struct Addr_Map_Entry *re = 0; struct Addr_Map_Entry *e = 0; e = addr_map_create_entry(addr,NULL); DUMPFIRST(__LINE__); retval = tfind(e,tree1, addr_map_compare_func); if(retval) { re = *(struct Addr_Map_Entry **)retval; } /* The one we created here must be deleted, it is dead. We look at the returned one instead. */ addr_map_free_func(e); return re; } void addr_map_destroy(void *map) { /* tdestroy is not part of Posix, it is a GNU libc function. */ tdestroy(map,addr_map_free_func); } #endif /* HAVE_TSEARCH */ dwarf-20120410/dwarfdump/addrmap.h0000640000175000017500000000245211741100175015540 0ustar daveadavea/* Copyright 2010 David Anderson. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. */ struct Addr_Map_Entry { Dwarf_Unsigned mp_key; char * mp_name; }; struct Addr_Map_Entry * addr_map_insert(Dwarf_Unsigned addr, char *name, void **map); struct Addr_Map_Entry * addr_map_find(Dwarf_Unsigned addr, void **map); void addr_map_destroy(void *map); dwarf-20120410/dwarfdump/print_static_vars.c0000640000175000017500000000703711741100175017665 0ustar daveadavea/* Copyright (C) 2000-2006 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright 2007-2010 Sun Microsystems, Inc. All rights reserved. Portions Copyright 2009-2010 SN Systems Ltd. All rights reserved. Portions Copyright 2008-2011 David Anderson. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/print_sections.c,v 1.69 2006/04/17 00:09:56 davea Exp $ */ /* The address of the Free Software Foundation is Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. SGI has moved from the Crittenden Lane address. */ #include "globals.h" #include "naming.h" #include "dwconf.h" #include "esb.h" #include "print_sections.h" #include "print_frames.h" /* Get all the data in .debug_static_vars */ extern void print_static_vars(Dwarf_Debug dbg) { Dwarf_Var *varbuf = NULL; Dwarf_Signed count = 0; Dwarf_Signed i = 0; Dwarf_Off die_off = 0; Dwarf_Off cu_off = 0; char *name = 0; int gvres = 0; current_section_id = DEBUG_STATIC_VARS; if (!do_print_dwarf) { return; } printf("\n.debug_static_vars\n"); gvres = dwarf_get_vars(dbg, &varbuf, &count, &err); if (gvres == DW_DLV_ERROR) { print_error(dbg, "dwarf_get_vars", gvres, err); } else if (gvres == DW_DLV_NO_ENTRY) { /* no static vars */ } else { Dwarf_Unsigned maxoff = get_info_max_offset(dbg); for (i = 0; i < count; i++) { int vnres = 0; int cures3 = 0; Dwarf_Off global_cu_off = 0; vnres = dwarf_var_name_offsets(varbuf[i], &name, &die_off, &cu_off, &err); deal_with_name_offset_err(dbg, "dwarf_var_name_offsets", name, die_off, vnres, err); cures3 = dwarf_var_cu_offset(varbuf[i], &global_cu_off, &err); if (cures3 != DW_DLV_OK) { print_error(dbg, "dwarf_global_cu_offset", cures3, err); } print_pubname_style_entry(dbg, "static-var", name, die_off, cu_off, global_cu_off, maxoff); /* print associated die too? */ } dwarf_vars_dealloc(dbg, varbuf, count); } } /* print_static_vars */ dwarf-20120410/dwarfdump/testesb.c0000640000175000017500000000327211741100175015575 0ustar daveadavea/* testesb.c test code for esb.h esb.c Not part of a compiled dwarfdump. */ #include #include typedef char *string; #include "esb.h" void check(string msg, struct esb_s *data, string v) { string b = esb_get_string(data); size_t l = 0; size_t alloc = 0; if (strcmp(b, v)) { fprintf(stderr, "ERROR: %s content error %s != %s\n", msg, b, v); } l = esb_string_len(data); if (l != strlen(v)) { fprintf(stderr, "ERROR: %s length error %lu != %lu\n", msg, (unsigned long) l, (unsigned long) strlen(v)); } alloc = esb_get_allocated_size(data); if (l > alloc) { fprintf(stderr, "ERROR: %s allocation error %lu > %lu\n", msg, (unsigned long) l, (unsigned long) alloc); } return; } int main(void) { struct esb_s data; esb_alloc_size(2); /* small to get all code paths tested. */ esb_constructor(&data); esb_append(&data, "a"); esb_appendn(&data, "bc", 1); esb_append(&data, "d"); esb_append(&data, "e"); check("test 1", &data, "abde"); esb_destructor(&data); esb_constructor(&data); esb_append(&data, "abcdefghij" "0123456789"); check("test 2", &data, "abcdefghij" "0123456789"); esb_destructor(&data); esb_constructor(&data); esb_append(&data, "abcdefghij" "0123456789"); esb_append(&data, "abcdefghij" "0123456789"); esb_append(&data, "abcdefghij" "0123456789"); esb_append(&data, "abcdefghij" "0123456789"); check("test 3", &data, "abcdefghij" "0123456789" "abcdefghij" "0123456789" "abcdefghij" "0123456789" "abcdefghij" "0123456789"); return 0; } dwarf-20120410/dwarfdump/tag_common.c0000640000175000017500000000761511741100175016254 0ustar daveadavea/* Copyright (C) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright (C) 2009-2010 SN Systems Ltd. All Rights Reserved. Portions Copyright (C) 2009-2011 David Anderson. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/tag_common.c,v 1.8 2008/01/23 09:47:59 davea Exp $ */ #include #include #include /* For exit() declaration etc. */ #include /* For errno declaration. */ #include /* For isspace() declaration */ #include "globals.h" #include "naming.h" #include "tag_common.h" static int linecount = 0; static char line_in[MAX_LINE_SIZE]; void bad_line_input(char *msg) { fprintf(stderr, "tag_(tree,attr) table build failed %s, line %d: \"%s\" \n", msg, linecount, line_in); exit(FAILED); } void trim_newline(char *line, int max) { char *end = line + max - 1; for (; *line && (line < end); ++line) { if (*line == '\n') { /* Found newline, drop it */ *line = 0; return; } } return; } /* Detect empty lines (and other lines we do not want to read) */ boolean is_skippable_line(char *pLine) { boolean empty = TRUE; if(pLine[0] == '#') { /* Preprocessor lines are of no interest. */ return TRUE; } for (; *pLine && empty; ++pLine) { empty = isspace(*pLine); } return empty; } /* Reads a value from the text table. Exits with non-zero status if the table is erroneous in some way. */ int read_value(unsigned int *outval, FILE*file) { char *res = 0; unsigned long lval; char *strout = 0; boolean bBlankLine = TRUE; ++linecount; *outval = 0; while (bBlankLine) { res = fgets(line_in, sizeof(line_in), file); if (res == 0) { if (ferror(file)) { fprintf(stderr, "tag_attr: Error reading table, %d lines read\n", linecount); exit(FAILED); } if (feof(file)) { return IS_EOF; } /* Impossible */ fprintf(stderr, "tag_attr: Impossible error reading table, " "%d lines read\n", linecount); exit(FAILED); } bBlankLine = is_skippable_line(line_in); } trim_newline(line_in, sizeof(line_in)); errno = 0; lval = strtoul(line_in, &strout, 0); if (strout == line_in) { bad_line_input("bad number input!"); } if (errno != 0) { int myerr = errno; fprintf(stderr, "tag_attr errno %d\n", myerr); bad_line_input("invalid number on line"); } *outval = (int) lval; return NOT_EOF; } dwarf-20120410/dwarfdump/COPYING0000640000175000017500000000175411741100175015016 0ustar daveadavea David Anderson: December 2006 The code in the dwarfdump directory is (if you look in each file) covered by the GPL (not the LGPL). The DWARFDUMPCOPYRIGHT file, though, said (before December 24, 2006) the copyright is LGPL. There is no doubt in my (David Anderson) mind that the intent was always that dwarfdump be GPL and the copyright markings in each file are correct. There are three files marked with the LGPL: tag_tree.list tag_attr.list acconfig.h. These markings are left as is and these are are therefore LGPL files. The DWARFDUMPCOPYRIGHT file now (Dec 24 2006) has both copyrights and an explanation of where each applies. ------------------------------------------- The text present for years, thru Dec 23, 2006: The files: dwarfdump.c and all the .h and .c files in this implementation of dwarfdump are copyrighted according to the file DWARFDUMPCOPYRIGHT. $Source: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/COPYING,v $ $Revision: 1.1 $ $Date: 2001/01/16 17:47:55 $ dwarf-20120410/dwarfdump/print_macros.c0000640000175000017500000001463111741100175016625 0ustar daveadavea/* Copyright (C) 2000-2006 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright 2007-2010 Sun Microsystems, Inc. All rights reserved. Portions Copyright 2009-2011 SN Systems Ltd. All rights reserved. Portions Copyright 2008-2011 David Anderson. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/print_sections.c,v 1.69 2006/04/17 00:09:56 davea Exp $ */ /* The address of the Free Software Foundation is Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. SGI has moved from the Crittenden Lane address. */ #include "globals.h" #include "naming.h" #include "dwconf.h" #include "esb.h" #include "print_sections.h" #include "print_frames.h" struct macro_counts_s { long mc_start_file; long mc_end_file; long mc_define; long mc_undef; long mc_extension; long mc_code_zero; long mc_unknown; }; static void print_one_macro_entry_detail(long i, char *type, struct Dwarf_Macro_Details_s *mdp) { /* "DW_MACINFO_*: section-offset file-index [line] string\n" */ if (mdp->dmd_macro) { printf("%3ld %s: %6" DW_PR_DUu " %2" DW_PR_DSd " [%4" DW_PR_DSd "] \"%s\" \n", i, type, (Dwarf_Unsigned)mdp->dmd_offset, mdp->dmd_fileindex, mdp->dmd_lineno, mdp->dmd_macro); } else { printf("%3ld %s: %6" DW_PR_DUu " %2" DW_PR_DSd " [%4" DW_PR_DSd "] 0\n", i, type, (Dwarf_Unsigned)mdp->dmd_offset, mdp->dmd_fileindex, mdp->dmd_lineno); } } static void print_one_macro_entry(long i, struct Dwarf_Macro_Details_s *mdp, struct macro_counts_s *counts) { switch (mdp->dmd_type) { case 0: counts->mc_code_zero++; print_one_macro_entry_detail(i, "DW_MACINFO_type-code-0", mdp); break; case DW_MACINFO_start_file: counts->mc_start_file++; print_one_macro_entry_detail(i, "DW_MACINFO_start_file", mdp); break; case DW_MACINFO_end_file: counts->mc_end_file++; print_one_macro_entry_detail(i, "DW_MACINFO_end_file ", mdp); break; case DW_MACINFO_vendor_ext: counts->mc_extension++; print_one_macro_entry_detail(i, "DW_MACINFO_vendor_ext", mdp); break; case DW_MACINFO_define: counts->mc_define++; print_one_macro_entry_detail(i, "DW_MACINFO_define ", mdp); break; case DW_MACINFO_undef: counts->mc_undef++; print_one_macro_entry_detail(i, "DW_MACINFO_undef ", mdp); break; default: { char create_type[50]; /* More than large enough. */ counts->mc_unknown++; snprintf(create_type, sizeof(create_type), "DW_MACINFO_0x%x", mdp->dmd_type); print_one_macro_entry_detail(i, create_type, mdp); } break; } } /* print data in .debug_macinfo */ /* FIXME: should print name of file whose index is in macro data here -- somewhere. */ /*ARGSUSED*/ extern void print_macinfo(Dwarf_Debug dbg) { Dwarf_Off offset = 0; Dwarf_Unsigned max = 0; Dwarf_Signed count = 0; long group = 0; Dwarf_Macro_Details *maclist = NULL; int lres = 0; current_section_id = DEBUG_MACINFO; if (!do_print_dwarf) { return; } printf("\n.debug_macinfo\n"); while ((lres = dwarf_get_macro_details(dbg, offset, max, &count, &maclist, &err)) == DW_DLV_OK) { long i = 0; struct macro_counts_s counts; memset(&counts, 0, sizeof(counts)); printf("\n"); printf("compilation-unit .debug_macinfo # %ld\n", group); printf ("num name section-offset file-index [line] \"string\"\n"); for (i = 0; i < count; i++) { struct Dwarf_Macro_Details_s *mdp = &maclist[i]; print_one_macro_entry(i, mdp, &counts); } if (counts.mc_start_file == 0) { printf ("DW_MACINFO file count of zero is invalid DWARF2/3\n"); } if (counts.mc_start_file != counts.mc_end_file) { printf("Counts of DW_MACINFO file (%ld) end_file (%ld) " "do not match!.\n", counts.mc_start_file, counts.mc_end_file); } if (counts.mc_code_zero < 1) { printf("Count of zeros in macro group should be non-zero " "(1 preferred), count is %ld\n", counts.mc_code_zero); } printf("Macro counts: start file %ld, " "end file %ld, " "define %ld, " "undef %ld, " "ext %ld, " "code-zero %ld, " "unknown %ld\n", counts.mc_start_file, counts.mc_end_file, counts.mc_define, counts.mc_undef, counts.mc_extension, counts.mc_code_zero, counts.mc_unknown); /* int type= maclist[count - 1].dmd_type; */ /* ASSERT: type is zero */ offset = maclist[count - 1].dmd_offset + 1; dwarf_dealloc(dbg, maclist, DW_DLA_STRING); ++group; } if (lres == DW_DLV_ERROR) { print_error(dbg, "dwarf_get_macro_details", lres, err); } } dwarf-20120410/dwarfdump/dwconf.c0000640000175000017500000012141111741100175015400 0ustar daveadavea/* Copyright (C) 2006 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright 2011 David Anderson. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/dwconf.c,v 1.4 2006/04/18 18:05:57 davea Exp $ */ /* Windows specific */ #ifdef HAVE_STDAFX_H #include "stdafx.h" #endif /* HAVE_STDAFX_H */ #include "globals.h" #include "dwarf.h" #include "libdwarf.h" #include #include "dwconf.h" #include "makename.h" extern int verbose; /* The nesting level is arbitrary, 2 should suffice. But at least this prevents an infinite loop. */ #define MAX_NEST_LEVEL 3 struct token_s { unsigned tk_len; char *tk_data; }; enum linetype_e { LT_ERROR, LT_COMMENT, LT_BLANK, LT_BEGINABI, LT_REG, LT_FRAME_INTERFACE, LT_CFA_REG, LT_INITIAL_REG_VALUE, LT_SAME_VAL_REG, LT_UNDEFINED_VAL_REG, LT_REG_TABLE_SIZE, LT_ADDRESS_SIZE, LT_INCLUDEABI, LT_ENDABI }; struct comtable_s { enum linetype_e type; char *name; size_t namelen; }; static int errcount = 0; /* Count errors found in this scan of the configuration file. */ static char name_begin_abi[] = "beginabi:"; static char name_reg[] = "reg:"; static char name_frame_interface[] = "frame_interface:"; static char name_cfa_reg[] = "cfa_reg:"; static char name_initial_reg_value[] = "initial_reg_value:"; static char name_same_val_reg[] = "same_val_reg:"; static char name_undefined_val_reg[] = "undefined_val_reg:"; static char name_reg_table_size[] = "reg_table_size:"; static char name_address_size[] = "address_size:"; static char name_includeabi[] = "includeabi:"; static char name_endabi[] = "endabi:"; static struct comtable_s comtable[] = { {LT_BEGINABI, name_begin_abi}, {LT_REG, name_reg}, {LT_FRAME_INTERFACE, name_frame_interface}, {LT_CFA_REG, name_cfa_reg}, {LT_INITIAL_REG_VALUE, name_initial_reg_value}, {LT_SAME_VAL_REG, name_same_val_reg}, {LT_UNDEFINED_VAL_REG, name_undefined_val_reg}, {LT_REG_TABLE_SIZE, name_reg_table_size}, {LT_ADDRESS_SIZE, name_address_size}, {LT_INCLUDEABI, name_includeabi}, {LT_ENDABI, name_endabi}, }; struct conf_internal_s { unsigned long beginabi_lineno; unsigned long frame_interface_lineno; unsigned long initial_reg_value_lineno; unsigned long reg_table_size_lineno; unsigned long address_size_lineno; unsigned long same_val_reg_lineno; unsigned long undefined_val_reg_lineno; unsigned long cfa_reg_lineno; unsigned long regcount; struct dwconf_s * conf_out; const char * conf_name_used; char ** conf_defaults; }; static void init_conf_internal(struct conf_internal_s *s, struct dwconf_s * conf_out) { s->beginabi_lineno = 0; s->frame_interface_lineno = 0; s->initial_reg_value_lineno = 0; s->reg_table_size_lineno = 0; s->address_size_lineno = 0; s->same_val_reg_lineno = 0; s->undefined_val_reg_lineno = 0; s->cfa_reg_lineno = 0; s->cfa_reg_lineno = 0; s->conf_name_used = 0; s->conf_defaults = 0; s->regcount = 0; s->conf_out = conf_out; } static int size_of_comtable = sizeof(comtable) / sizeof(comtable[0]); static FILE *find_a_file(const char *named_file, char **defaults, const char** name_used); static int find_abi_start(FILE * stream, const char *abi_name, long *offset, unsigned long *lineno_out); static int parse_abi(FILE * stream, const char *fname, const char *abiname, struct conf_internal_s *out, unsigned long lineno, unsigned nest_level); static char *get_token(char *cp, struct token_s *outtok); /* This finds a dwarfdump.conf file and then parses it. It updates conf_out as appropriate. This finds the first file (looking in a set of places) with that name. It then looks for the right ABI entry. If the first file it finds does not have that ABI entry it gives up. It would also be reasonable to search every 'dwarfdump.conf' it finds for the abi. But we stop at the first dwarfdump.conf we find. This is the internal call to get the conf data to implement a crude 'includeabi' feature. Returns 0 if no errors found, else returns > 0. */ static int find_conf_file_and_read_config_inner(const char *named_file, const char *named_abi, struct conf_internal_s *conf_internal, unsigned nest_level) { FILE *conf_stream = 0; const char *name_used = 0; long offset = 0; int res = FALSE; unsigned long lineno = 0; errcount = 0; conf_stream = find_a_file(named_file, conf_internal->conf_defaults, &name_used); if (!conf_stream) { ++errcount; printf("dwarfdump found no file %s!\n", named_file ? named_file : "readable for configuration. " "(add options -v -v to see what file names tried)\n"); return errcount; } if (verbose > 1) { printf("dwarfdump using configuration file %s\n", name_used); } conf_internal->conf_name_used = name_used; res = find_abi_start(conf_stream, named_abi, &offset, &lineno); if (errcount > 0) { ++errcount; printf("dwarfdump found no ABI %s in file %s.\n", named_abi, name_used); return errcount; } res = fseek(conf_stream, offset, SEEK_SET); if (res != 0) { ++errcount; printf("dwarfdump seek to %ld offset in %s failed!\n", offset, name_used); return errcount; } parse_abi(conf_stream, name_used, named_abi, conf_internal, lineno, nest_level); fclose(conf_stream); return errcount; } /* This is the external-facing call to get the conf data. */ int find_conf_file_and_read_config(const char *named_file, const char *named_abi, char **defaults, struct dwconf_s *conf_out) { int res = 0; struct conf_internal_s conf_internal; init_conf_file_data(conf_out); init_conf_internal(&conf_internal,conf_out); conf_internal.conf_defaults = defaults; res = find_conf_file_and_read_config_inner(named_file, named_abi, &conf_internal,0); return res; } /* Given path strings, attempt to make a canonical file name: that is, avoid superfluous '/' so that no '//' (or worse) is created in the output. The path components are to be separated so at least one '/' is to appear between the two 'input strings' when creating the output. */ static char * canonical_append(char *target, unsigned int target_size, const char *first_string, const char *second_string) { size_t firstlen = strlen(first_string); /* +1 +1: Leave room for added "/" and final NUL, though that is overkill, as we drop a NUL byte too. */ if ((firstlen + strlen(second_string) + 1 + 1) >= target_size) { /* Not enough space. */ return NULL; } for (; *second_string == '/'; ++second_string) { } for (; firstlen > 0 && first_string[firstlen - 1] == '/'; --firstlen) { } target[0] = 0; if (firstlen > 0) { strncpy(target, first_string, firstlen); target[firstlen + 1] = 0; } target[firstlen] = '/'; firstlen++; target[firstlen] = 0; strcat(target, second_string); return target; } #ifdef BUILD_FOR_TEST #define CANBUF 25 struct canap_s { char *res_exp; char *first; char *second; } canap[] = { { "ab/c", "ab", "c"}, { "ab/c", "ab/", "c"}, { "ab/c", "ab", "/c"}, { "ab/c", "ab////", "/////c"}, { "ab/", "ab", ""}, { "ab/", "ab////", ""}, { "ab/", "ab////", ""}, { "/a", "", "a"}, { 0, "/abcdefgbijkl", "pqrstuvwxyzabcd"}, { 0, 0, 0} }; static void test_canonical_append(void) { /* Make buf big, this is test code, so be safe. */ char lbuf[1000]; unsigned i; unsigned failcount = 0; printf("Entry test_canonical_append\n"); for (i = 0;; ++i) { char *res = 0; if (canap[i].first == 0 && canap[i].second == 0) break; res = canonical_append(lbuf, CANBUF, canap[i].first, canap[i].second); if (res == 0) { if (canap[i].res_exp == 0) { /* GOOD */ printf("PASS %u\n", i); } else { ++failcount; printf("FAIL: entry %u wrong, expected %s, got NULL\n", i, canap[i].res_exp); } } else { if (canap[i].res_exp == 0) { ++failcount; printf("FAIL: entry %u wrong, got %s expected NULL\n", i, res); } else { if (strcmp(res, canap[i].res_exp) == 0) { printf("PASS %u\n", i); /* GOOD */ } else { ++failcount; printf("FAIL: entry %u wrong, expected %s got %s\n", i, canap[i].res_exp, res); } } } } printf("FAIL count %u\n", failcount); } #endif /* BUILD_FOR_TEST */ /* Try to find a file as named and open for read. We treat each name as a full name, we are not combining separate name and path components. This is an arbitrary choice... The defaults are listed in dwarfdump.c in the array config_file_defaults[]. */ static FILE * find_a_file(const char *named_file, char **defaults, const char ** name_used) { FILE *fin = 0; const char *lname = named_file; const char *type = "rw"; int i = 0; #ifdef BUILD_FOR_TEST test_canonical_append(); #endif /* BUILD_FOR_TEST */ if (lname) { /* Name given, just assume it is fully correct, try no other. */ if (verbose > 1) { printf("dwarfdump looking for configuration as %s\n", lname); } fin = fopen(lname, type); if (fin) { *name_used = lname; return fin; } return 0; } /* No name given, find a default, if we can. */ for (i = 0; defaults[i]; ++i) { lname = defaults[i]; #ifdef WIN32 /* Open the configuration file, located in the directory where the tool is loaded from */ { static char szPath[MAX_PATH]; if (GetModuleFileName(NULL,szPath,MAX_PATH)) { char *pDir = strrchr(szPath,'/'); if (!pDir) { pDir = strrchr(szPath,'\\'); if (!pDir) { /* No file was found */ return 0; } } /* Add the configuration name to the pathname */ ++pDir; strcpy(pDir,"dwarfdump.conf"); lname = szPath; } } #else /* non-Win */ if (strncmp(lname, "HOME/", 5) == 0) { /* arbitrary size */ char buf[2000]; char *homedir = getenv("HOME"); if (homedir) { char *cp = canonical_append(buf, sizeof(buf), homedir, lname + 5); if (!cp) { /* OOps, ignore this one. */ continue; } lname = makename(buf); } } #endif /* WIN32 */ if (verbose > 1) { printf("dwarfdump looking for configuration as %s\n", lname); } fin = fopen(lname, type); if (fin) { *name_used = lname; return fin; } } return 0; } /* Start at a token begin, see how long it is, return length. */ unsigned find_token_len(char *cp) { unsigned len = 0; for (; *cp; ++cp) { if (isspace(*cp)) { return len; } if (*cp == '#') { return len; /* begins comment */ } ++len; } return len; } /* Skip past all whitespace: the only code that even knows what whitespace is. */ static char * skipwhite(char *cp) { for (; *cp; ++cp) { if (!isspace(*cp)) { return cp; } } return cp; } /* Return TRUE if ok. FALSE if find more tokens. Emit error message if error. */ static int ensure_has_no_more_tokens(char *cp, const char *fname, unsigned long lineno) { struct token_s tok; cp = get_token(cp, &tok); if (tok.tk_len > 0) { printf("dwarfdump.conf error: " "extra characters after command operands, found " "\"%s\" in %s line %lu\n", tok.tk_data, fname, lineno); ++errcount; return FALSE; } return TRUE; } /* There may be many beginabi: lines in a dwarfdump.conf file, find the one we want and return its file offset. */ static int find_abi_start(FILE * stream, const char *abi_name, long *offset, unsigned long *lineno_out) { char buf[100]; unsigned long lineno = 0; for (; !feof(stream);) { struct token_s tok; char *line = 0; long loffset = ftell(stream); line = fgets(buf, sizeof(buf), stream); ++lineno; if (!line) { ++errcount; return FALSE; } line = get_token(buf, &tok); if (strcmp(tok.tk_data, name_begin_abi) != 0) { continue; } get_token(line, &tok); if (strcmp(tok.tk_data, abi_name) != 0) { continue; } *offset = loffset; *lineno_out = lineno; return TRUE; } ++errcount; return FALSE; } static char *tempstr = 0; static unsigned tempstr_len = 0; /* Use a global buffer (tempstr) to turn a non-delimited input char array into a NUL-terminated C string (with the help of makename() to get a permanent address for the result ing string). */ static char * build_string(unsigned tlen, char *cp) { if (tlen >= tempstr_len) { free(tempstr); tempstr = malloc(tlen + 100); } strncpy(tempstr, cp, tlen); tempstr[tlen] = 0; return makename(tempstr); } /* The tokenizer for our simple parser. */ static char * get_token(char *cp, struct token_s *outtok) { char *lcp = skipwhite(cp); unsigned tlen = find_token_len(lcp); outtok->tk_len = tlen; if (tlen > 0) { outtok->tk_data = build_string(tlen, lcp); } else { outtok->tk_data = ""; } return lcp + tlen; } /* We can't get all the field set up statically very easily, so we get the command string length set here. */ static void finish_comtable_setup(void) { unsigned i; for (i = 0; i < size_of_comtable; ++i) { comtable[i].namelen = strlen(comtable[i].name); } } /* Given a line of the table, determine if it is a command or not, and if a command, which one is it. Return LT_ERROR if it's not recognized. */ static enum linetype_e which_command(char *cp, struct comtable_s **tableentry) { int i; struct token_s tok; if (*cp == '#') return LT_COMMENT; if (!*cp) return LT_BLANK; get_token(cp, &tok); for (i = 0; i < size_of_comtable; ++i) { if (tok.tk_len == comtable[i].namelen && strcmp(comtable[i].name, tok.tk_data) == 0) { *tableentry = &comtable[i]; return comtable[i].type; } } return LT_ERROR; } /* We are promised it's an abiname: command find the name on the line. */ static int parsebeginabi(char *cp, const char *fname, const char *abiname, unsigned long lineno, struct comtable_s *comtab) { size_t clen = comtab->namelen; size_t abinamelen = strlen(abiname); struct token_s tok; cp = cp + clen + 1; cp = skipwhite(cp); get_token(cp, &tok); if (tok.tk_len != abinamelen || strncmp(cp, abiname, abinamelen) != 0) { printf("dwarfdump internal error: " "mismatch %s with %s %s line %lu\n", cp, tok.tk_data, fname, lineno); ++errcount; return FALSE; } ensure_has_no_more_tokens(cp + tok.tk_len, fname, lineno); return TRUE; } /* This expands register names as required, but does not ensure no names duplicated. */ #define CONF_TABLE_OVERSIZE 100 static void add_to_reg_table(struct dwconf_s *conf, char *rname, unsigned long rval, const char *fname, unsigned long lineno) { if (conf->cf_regs_malloced == 0) { conf->cf_regs = 0; conf->cf_named_regs_table_size = 0; } if (rval >= conf->cf_named_regs_table_size) { char **newregs = 0; unsigned long newtablen = rval + CONF_TABLE_OVERSIZE; unsigned long newtabsize = newtablen * sizeof(char *); unsigned long oldtabsize = conf->cf_named_regs_table_size * sizeof(char *); newregs = realloc(conf->cf_regs, newtabsize); if (!newregs) { printf("dwarfdump: unable to malloc table %lu bytes. " " %s line %lu\n", newtabsize, fname, lineno); exit(1); } /* Zero out the new entries. */ memset((char *) newregs + (oldtabsize), 0, (newtabsize - oldtabsize)); conf->cf_named_regs_table_size = (unsigned long) newtablen; conf->cf_regs = newregs; conf->cf_regs_malloced = 1; } conf->cf_regs[rval] = rname; return; } /* Our input is supposed to be a number. Determine the value (and return it) or generate an error message. */ static int make_a_number(char *cmd, const char *filename, unsigned long lineno, struct token_s *tok, unsigned long *val_out) { char *endnum = 0; unsigned long val = 0; val = strtoul(tok->tk_data, &endnum, 0); if (val == 0 && endnum == (tok->tk_data)) { printf("dwarfdump.conf error: " "%s missing register number (\"%s\" not valid) %s line %lu\n", cmd, tok->tk_data, filename, lineno); ++errcount; return FALSE; } if (endnum != (tok->tk_data + tok->tk_len)) { printf("dwarfdump.conf error: " "%s Missing register number (\"%s\" not valid) %s line %lu\n", cmd, tok->tk_data, filename, lineno); ++errcount; return FALSE; } *val_out = val; return TRUE; } /* We are guaranteed it's a reg: command, so parse that command and record the interesting data. */ static int parsereg(char *cp, const char *fname, unsigned long lineno, struct conf_internal_s *conf, struct comtable_s *comtab) { size_t clen = comtab->namelen; struct token_s regnum; struct token_s tokreg; unsigned long val = 0; int ok = FALSE; int res = FALSE; cp = cp + clen + 1; cp = get_token(cp, &tokreg); cp = get_token(cp, ®num); if (tokreg.tk_len == 0) { printf("dwarfdump.conf error: " "reg: missing register name %s line %lu", fname, lineno); ++errcount; return FALSE; } if (regnum.tk_len == 0) { printf("dwarfdump.conf error: " "reg: missing register number %s line %lu", fname, lineno); ++errcount; return FALSE; } ok = make_a_number(comtab->name, fname, lineno, ®num, &val); if (!ok) { ++errcount; return FALSE; } add_to_reg_table(conf->conf_out, tokreg.tk_data, val, fname, lineno); res = ensure_has_no_more_tokens(cp, fname, lineno); return res; } /* We are guaranteed it's an frame_interface: command. Parse it and record the value data. */ static int parseframe_interface(char *cp, const char *fname, unsigned long lineno, struct conf_internal_s *conf, struct comtable_s *comtab) { size_t clen = comtab->namelen; struct token_s tok; unsigned long val = 0; int ok = FALSE; int res = FALSE; cp = cp + clen + 1; cp = get_token(cp, &tok); if (tok.tk_len == 0) { printf("dwarfdump.conf error: " "%s missing interface number %s line %lu", comtab->name, fname, lineno); ++errcount; return FALSE; } ok = make_a_number(comtab->name, fname, lineno, &tok, &val); if (!ok) { ++errcount; return FALSE; } if (val != 2 && val != 3) { printf("dwarfdump.conf error: " "%s only interface numbers 2 or 3 are allowed, " " not %lu. %s line %lu", comtab->name, val, fname, lineno); ++errcount; return FALSE; } conf->conf_out->cf_interface_number = (int) val; res = ensure_has_no_more_tokens(cp, fname, lineno); return res; } /* We are guaranteed it's a cfa_reg: command. Parse it and record the important data. */ static int parsecfa_reg(char *cp, const char *fname, unsigned long lineno, struct conf_internal_s *conf, struct comtable_s *comtab) { size_t clen = comtab->namelen; struct token_s tok; unsigned long val = 0; int ok = FALSE; int res = FALSE; cp = cp + clen + 1; cp = get_token(cp, &tok); if (tok.tk_len == 0) { printf("dwarfdump.conf error: " "%s missing cfa_reg number %s line %lu", comtab->name, fname, lineno); ++errcount; return FALSE; } ok = make_a_number(comtab->name, fname, lineno, &tok, &val); if (!ok) { ++errcount; return FALSE; } conf->conf_out->cf_cfa_reg = (int) val; res = ensure_has_no_more_tokens(cp, fname, lineno); return res; } /* We are guaranteed it's an initial_reg_value: command, parse it and put the reg value where it will be remembered. */ static int parseinitial_reg_value(char *cp, const char *fname, unsigned long lineno, struct conf_internal_s *conf, struct comtable_s *comtab) { size_t clen = comtab->namelen; struct token_s tok; unsigned long val = 0; int ok = FALSE; int res = FALSE; cp = cp + clen + 1; cp = get_token(cp, &tok); if (tok.tk_len == 0) { printf("dwarfdump.conf error: " "%s missing initial reg value %s line %lu", comtab->name, fname, lineno); ++errcount; return FALSE; } ok = make_a_number(comtab->name, fname, lineno, &tok, &val); if (!ok) { ++errcount; return FALSE; } conf->conf_out->cf_initial_rule_value = (int) val; res = ensure_has_no_more_tokens(cp, fname, lineno); return res; } static int parsesame_val_reg(char *cp, const char *fname, unsigned long lineno, struct conf_internal_s *conf, struct comtable_s *comtab) { size_t clen = comtab->namelen; struct token_s tok; unsigned long val = 0; int ok = FALSE; int res = FALSE; cp = cp + clen + 1; cp = get_token(cp, &tok); if (tok.tk_len == 0) { printf("dwarfdump.conf error: " "%s missing same_reg value %s line %lu", comtab->name, fname, lineno); ++errcount; return FALSE; } ok = make_a_number(comtab->name, fname, lineno, &tok, &val); if (!ok) { ++errcount; return FALSE; } conf->conf_out->cf_same_val = (int) val; res = ensure_has_no_more_tokens(cp, fname, lineno); return res; } static int parseundefined_val_reg(char *cp, const char *fname, unsigned long lineno, struct conf_internal_s *conf, struct comtable_s *comtab) { size_t clen = comtab->namelen; struct token_s tok; unsigned long val = 0; int ok = FALSE; int res = FALSE; cp = cp + clen + 1; cp = get_token(cp, &tok); if (tok.tk_len == 0) { printf("dwarfdump.conf error: " "%s missing undefined_reg value %s line %lu", comtab->name, fname, lineno); ++errcount; return FALSE; } ok = make_a_number(comtab->name, fname, lineno, &tok, &val); if (!ok) { ++errcount; return FALSE; } conf->conf_out->cf_undefined_val = (int) val; res = ensure_has_no_more_tokens(cp, fname, lineno); return res; } /* We are guaranteed it's a table size command, parse it and record the table size. */ static int parsereg_table_size(char *cp, const char *fname, unsigned long lineno, struct conf_internal_s *conf, struct comtable_s *comtab) { size_t clen = comtab->namelen; struct token_s tok; unsigned long val = 0; int ok = FALSE; int res = FALSE; cp = cp + clen + 1; cp = get_token(cp, &tok); if (tok.tk_len == 0) { printf("dwarfdump.conf error: " "%s missing reg table size value %s line %lu", comtab->name, fname, lineno); ++errcount; return FALSE; } ok = make_a_number(comtab->name, fname, lineno, &tok, &val); if (!ok) { ++errcount; return FALSE; } conf->conf_out->cf_table_entry_count = (unsigned long) val; res = ensure_has_no_more_tokens(cp, fname, lineno); return res; } /* We are guaranteed it's a table size command, parse it and record the table size. */ static int parseaddress_size(char *cp, const char *fname, unsigned long lineno, struct conf_internal_s *conf, struct comtable_s *comtab) { size_t clen = comtab->namelen; struct token_s tok; unsigned long val = 0; int ok = FALSE; int res = FALSE; cp = cp + clen + 1; cp = get_token(cp, &tok); if (tok.tk_len == 0) { printf("dwarfdump.conf error: " "%s missing address size value %s line %lu", comtab->name, fname, lineno); ++errcount; return FALSE; } ok = make_a_number(comtab->name, fname, lineno, &tok, &val); if (!ok) { ++errcount; return FALSE; } conf->conf_out->cf_address_size = (unsigned long) val; res = ensure_has_no_more_tokens(cp, fname, lineno); return res; } /* We are guaranteed it's an endabi: command, parse it and check we have the right abi. */ static int parseendabi(char *cp, const char *fname, const char *abiname, unsigned long lineno, struct comtable_s *comtab) { size_t clen = comtab->namelen; struct token_s tok; int res = 0; cp = cp + clen + 1; cp = get_token(cp, &tok); if (strcmp(abiname, tok.tk_data) != 0) { printf("%s error: " "mismatch abi name %s (here) vs. %s (beginabi:) %s line %lu\n", comtab->name, tok.tk_data, abiname, fname, lineno); ++errcount; return FALSE; } res = ensure_has_no_more_tokens(cp, fname, lineno); return res; } static int parseincludeabi(char *cp, const char *fname, unsigned long lineno, char **abiname_out, struct comtable_s *comtab) { size_t clen = comtab->namelen; struct token_s tok; char *name = 0; int res = FALSE; cp = cp + clen + 1; cp = get_token(cp, &tok); name = makename(tok.tk_data); *abiname_out = name; res = ensure_has_no_more_tokens(cp, fname, lineno); return res; } /* Return TRUE if we succeeded and filed in *out. Return FALSE if we failed (and fill in nothing). beginabi: reg: frame_interface: cfa_reg: initial_reg_value: reg_table_size: endabi: We are positioned at the start of a beginabi: line when called. */ static int parse_abi(FILE * stream, const char *fname, const char *abiname, struct conf_internal_s *conf_internal, unsigned long lineno, unsigned int nest_level) { struct dwconf_s *localconf = conf_internal->conf_out; char buf[1000]; int comtype = 0; static int first_time_done = 0; struct comtable_s *comtabp = 0; if( nest_level > MAX_NEST_LEVEL) { ++errcount; printf("dwarfdump.conf: includeabi nest too deep in %s at line %lu\n", fname, lineno); return FALSE; } if (first_time_done == 0) { finish_comtable_setup(); first_time_done = 1; } for (; !feof(stream);) { char *line = 0; /* long loffset = ftell(stream); */ line = fgets(buf, sizeof(buf), stream); if (!line) { ++errcount; printf ("dwarfdump: end of file or error before endabi: in %s, line %lu\n", fname, lineno); return FALSE; } ++lineno; line = skipwhite(line); comtype = which_command(line, &comtabp); switch (comtype) { case LT_ERROR: ++errcount; printf ("dwarfdump: Unknown text in %s is \"%s\" at line %lu\n", fname, line, lineno); break; case LT_COMMENT: break; case LT_BLANK: break; case LT_BEGINABI: if (conf_internal->beginabi_lineno > 0) { ++errcount; printf ("dwarfdump: Encountered beginabi: when not expected. " "%s line %lu previous beginabi line %lu\n", fname, lineno, conf_internal->beginabi_lineno); } conf_internal->beginabi_lineno = lineno; parsebeginabi(line, fname, abiname, lineno, comtabp); break; case LT_REG: parsereg(line, fname, lineno, conf_internal, comtabp); conf_internal->regcount++; break; case LT_FRAME_INTERFACE: if (conf_internal->frame_interface_lineno > 0) { ++errcount; printf ("dwarfdump: Encountered duplicate frame_interface: " "%s line %lu previous frame_interface: line %lu\n", fname, lineno, conf_internal->frame_interface_lineno); } conf_internal->frame_interface_lineno = lineno; parseframe_interface(line, fname, lineno, conf_internal, comtabp); break; case LT_CFA_REG: if (conf_internal->cfa_reg_lineno > 0) { printf("dwarfdump: Encountered duplicate cfa_reg: " "%s line %lu previous cfa_reg line %lu\n", fname, lineno, conf_internal->cfa_reg_lineno); ++errcount; } conf_internal->cfa_reg_lineno = lineno; parsecfa_reg(line, fname, lineno, conf_internal, comtabp); break; case LT_INITIAL_REG_VALUE: if (conf_internal->initial_reg_value_lineno > 0) { printf ("dwarfdump: Encountered duplicate initial_reg_value: " "%s line %lu previous initial_reg_value: line %lu\n", fname, lineno, conf_internal->initial_reg_value_lineno); ++errcount; } conf_internal->initial_reg_value_lineno = lineno; parseinitial_reg_value(line, fname, lineno, conf_internal, comtabp); break; case LT_SAME_VAL_REG: if (conf_internal->same_val_reg_lineno > 0) { ++errcount; printf ("dwarfdump: Encountered duplicate same_val_reg: " "%s line %lu previous initial_reg_value: line %lu\n", fname, lineno, conf_internal->initial_reg_value_lineno); } conf_internal->same_val_reg_lineno = lineno; parsesame_val_reg(line, fname, lineno, conf_internal, comtabp); break; case LT_UNDEFINED_VAL_REG: if (conf_internal->undefined_val_reg_lineno > 0) { ++errcount; printf ("dwarfdump: Encountered duplicate undefined_val_reg: " "%s line %lu previous initial_reg_value: line %lu\n", fname, lineno, conf_internal->initial_reg_value_lineno); } conf_internal->undefined_val_reg_lineno = lineno; parseundefined_val_reg(line, fname, lineno, conf_internal, comtabp); break; case LT_REG_TABLE_SIZE: if (conf_internal->reg_table_size_lineno > 0) { printf("dwarfdump: duplicate reg_table_size: " "%s line %lu previous reg_table_size: line %lu\n", fname, lineno, conf_internal->reg_table_size_lineno); ++errcount; } conf_internal->reg_table_size_lineno = lineno; parsereg_table_size(line, fname, lineno, conf_internal, comtabp); break; case LT_ENDABI: parseendabi(line, fname, abiname, lineno, comtabp); if (conf_internal->regcount > localconf->cf_table_entry_count) { printf("dwarfdump: more registers named than " " in %s ( %lu named vs %s %lu) %s line %lu\n", abiname, (unsigned long) conf_internal->regcount, name_reg_table_size, (unsigned long) localconf->cf_table_entry_count, fname, (unsigned long) lineno); ++errcount; } return TRUE; case LT_ADDRESS_SIZE: if (conf_internal->address_size_lineno > 0) { printf("dwarfdump: duplicate address_size: " "%s line %lu previous address_size: line %lu\n", fname, lineno, conf_internal->address_size_lineno); ++errcount; } conf_internal->address_size_lineno = lineno; parseaddress_size(line, fname, lineno, conf_internal, comtabp); break; case LT_INCLUDEABI: { char *abiname_inner = 0; unsigned long abilno = conf_internal->beginabi_lineno; int ires = 0; ires = parseincludeabi(line,fname,lineno, &abiname_inner,comtabp); if(ires == FALSE) { return FALSE; } /* For the nested abi read, the abi line number must be set as if not-yet-read, and then restored. */ conf_internal->beginabi_lineno = 0; find_conf_file_and_read_config_inner( conf_internal->conf_name_used, abiname_inner, conf_internal,nest_level+1); conf_internal->beginabi_lineno = abilno; } break; default: printf ("dwarfdump internal error, impossible line type %d %s %lu \n", (int) comtype, fname, lineno); exit(1); } } ++errcount; printf("End of file, no endabi: found. %s, line %lu\n", fname, lineno); return FALSE; } /* MIPS/IRIX frame register names. For alternate name sets, use dwarfdump.conf or revise dwarf.h and libdwarf.h and this table. */ static char *regnames[] = { "cfa", "r1/at", "r2/v0", "r3/v1", "r4/a0", "r5/a1", "r6/a2", "r7/a3", "r8/t0", "r9/t1", "r10/t2", "r11/t3", "r12/t4", "r13/t5", "r14/t6", "r15/t7", "r16/s0", "r17/s1", "r18/s2", "r19/s3", "r20/s4", "r21/s5", "r22/s6", "r23/s7", "r24/t8", "r25/t9", "r26/k0", "r27/k1", "r28/gp", "r29/sp", "r30/s8", "r31", "$f0", "$f1", "$f2", "$f3", "$f4", "$f5", "$f6", "$f7", "$f8", "$f9", "$f10", "$f11", "$f12", "$f13", "$f14", "$f15", "$f16", "$f17", "$f18", "$f19", "$f20", "$f21", "$f22", "$f23", "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", "$f31", "ra", "slk", }; /* Naming a few registers makes printing these just a little bit faster. */ static char *genericregnames[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20" }; /* This is a simple generic set of registers. The table entry count is pretty arbitrary. */ void init_conf_file_data(struct dwconf_s *config_file_data) { unsigned generic_table_count; config_file_data->cf_abi_name = ""; config_file_data->cf_config_file_path = ""; config_file_data->cf_interface_number = 3; config_file_data->cf_table_entry_count = 100; config_file_data->cf_initial_rule_value = DW_FRAME_UNDEFINED_VAL; config_file_data->cf_cfa_reg = DW_FRAME_CFA_COL3; config_file_data->cf_address_size = 0; config_file_data->cf_same_val = DW_FRAME_SAME_VAL; config_file_data->cf_undefined_val = DW_FRAME_UNDEFINED_VAL; config_file_data->cf_regs = genericregnames; generic_table_count = sizeof(genericregnames) / sizeof(genericregnames[0]); config_file_data->cf_named_regs_table_size = generic_table_count; config_file_data->cf_regs_malloced = 0; } /* These defaults match MIPS/IRIX ABI defaults, but this function is not actually used. For a 'generic' ABI, see -R or init_conf_file_data(). To really get the old MIPS, use '-x abi=mips'. For other ABIs, see -x abi= to configure dwarfdump (and libdwarf) frame data reporting at runtime. */ void init_mips_conf_file_data(struct dwconf_s *config_file_data) { unsigned long base_table_count = sizeof(regnames) / sizeof(regnames[0]); memset(config_file_data, 0, sizeof(*config_file_data)); /* Interface 2 is deprecated, but for testing purposes is acceptable. */ config_file_data->cf_interface_number = 2; config_file_data->cf_table_entry_count = DW_REG_TABLE_SIZE; config_file_data->cf_initial_rule_value = DW_FRAME_REG_INITIAL_VALUE; config_file_data->cf_cfa_reg = DW_FRAME_CFA_COL; config_file_data->cf_address_size = 0; config_file_data->cf_same_val = DW_FRAME_SAME_VAL; config_file_data->cf_undefined_val = DW_FRAME_UNDEFINED_VAL; config_file_data->cf_regs = regnames; config_file_data->cf_named_regs_table_size = base_table_count; config_file_data->cf_regs_malloced = 0; if (config_file_data->cf_table_entry_count != base_table_count) { printf("dwarfdump: improper base table initization, " "header files wrong: " "DW_REG_TABLE_SIZE %u != string table size %lu\n", (unsigned) DW_REG_TABLE_SIZE, (unsigned long) base_table_count); exit(1); } return; } /* A 'generic' ABI. For up to 1200 registers. Perhaps cf_initial_rule_value should be d UNDEFINED VALUE (1034) instead, but for the purposes of getting the dwarfdump output correct either will work. */ void init_generic_config_1200_regs(struct dwconf_s *config_file_data) { unsigned long generic_table_count = sizeof(genericregnames) / sizeof(genericregnames[0]); config_file_data->cf_interface_number = 3; config_file_data->cf_table_entry_count = 1200; /* There is no defined name for cf_initial_rule_value, cf_same_val, or cf_undefined_val in libdwarf.h, these must just be high enough to be higher than any real register number. DW_FRAME_CFA_COL3 must also be higher than any real register number. */ config_file_data->cf_initial_rule_value = 1235; /* SAME VALUE */ config_file_data->cf_cfa_reg = DW_FRAME_CFA_COL3; config_file_data->cf_address_size = 0; config_file_data->cf_same_val = 1235; config_file_data->cf_undefined_val = 1234; config_file_data->cf_regs = genericregnames; config_file_data->cf_named_regs_table_size = generic_table_count; config_file_data->cf_regs_malloced = 0; } /* Print the 'right' string for the register we are given. Deal sensibly with the special regs as well as numbers we know and those we have not been told about. */ void print_reg_from_config_data(Dwarf_Signed reg, struct dwconf_s *config_data) { char *name = 0; if (reg == config_data->cf_cfa_reg) { fputs("cfa",stdout); return; } if (reg == config_data->cf_undefined_val) { fputs("u",stdout); return; } if (reg == config_data->cf_same_val) { fputs("s",stdout); return; } if (config_data->cf_regs == 0 || reg < 0 || reg >= config_data->cf_named_regs_table_size) { printf("r%" DW_PR_DSd "", (Dwarf_Signed) reg); return; } name = config_data->cf_regs[reg]; if (!name) { /* Can happen, the reg names table can be sparse. */ printf("r%" DW_PR_DSd "", (Dwarf_Signed) reg); return; } fputs(name,stdout); return; } dwarf-20120410/dwarfdump/print_strings.c0000640000175000017500000000551711741100175017035 0ustar daveadavea/* Copyright (C) 2000-2006 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright 2007-2010 Sun Microsystems, Inc. All rights reserved. Portions Copyright 2009-2010 SN Systems Ltd. All rights reserved. Portions Copyright 2008-2011 David Anderson. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/print_sections.c,v 1.69 2006/04/17 00:09:56 davea Exp $ */ /* The address of the Free Software Foundation is Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. SGI has moved from the Crittenden Lane address. */ #include "globals.h" #include "naming.h" #include "dwconf.h" #include "esb.h" #include "print_sections.h" /* print data in .debug_string */ extern void print_strings(Dwarf_Debug dbg) { Dwarf_Signed length = 0; string name; Dwarf_Off offset = 0; int sres = 0; current_section_id = DEBUG_STR; printf("\n.debug_string\n"); while ((sres = dwarf_get_str(dbg, offset, &name, &length, &err)) == DW_DLV_OK) { if (display_offsets) { printf("name at offset 0x%" DW_PR_XZEROS DW_PR_DUx ", length %4" DW_PR_DSd " is '%s'\n", (Dwarf_Unsigned)offset, length, name); } else { printf("name: length %4" DW_PR_DSd " is '%s'\n", length, name); } offset += length + 1; } /* An inability to find the section is not necessarily a real error, so do not report error unless we've seen a real record. */ if(sres == DW_DLV_ERROR && offset != 0) { print_error(dbg, "dwarf_get_str failure", sres, err); } } dwarf-20120410/dwarfdump/tag_attr_ext.list0000640000175000017500000000531111741100175017336 0ustar daveadavea/* Copyright (C) 2000-2010 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright (C) 2008-2010 SN Systems Ltd. All Rights Reserved. Portions Copyright (C) 2009-2011 David Anderson. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2.1 of the GNU Lesser General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/tag_attr.list,v 1.7 2005/12/01 17:34:59 davea Exp $ */ #include /* list for semantic check of tag-attr relation. See tag_attr.list for details. */ /* Common DWARF extensions */ 0xffffffff DW_TAG_member DW_AT_GNU_guarded_by /* gcc.gnu.org/wiki/ThreadSafetyAnnotationsInDWARF */ DW_AT_GNU_pt_guarded_by /* gcc.gnu.org/wiki/ThreadSafetyAnnotationsInDWARF */ DW_AT_GNU_guarded /* gcc.gnu.org/wiki/ThreadSafetyAnnotationsInDWARF */ DW_AT_GNU_pt_guarded /* gcc.gnu.org/wiki/ThreadSafetyAnnotationsInDWARF */ 0xffffffff DW_TAG_array_type DW_AT_GNU_vector 0xffffffff DW_TAG_subprogram DW_AT_MIPS_linkage_name /* Used by GNU, SGI-IRIX, and others. */ DW_AT_MIPS_fde /* SGI-IRIX uses this */ DW_AT_GNU_locks_excluded /* gcc.gnu.org/wiki/ThreadSafetyAnnotationsInDWARF */ DW_AT_GNU_exclusive_locks_required DW_AT_GNU_shared_locks_required 0xffffffff DW_TAG_variable DW_AT_MIPS_linkage_name /* Used by GNU, SGI-IRIX, and others. */ DW_AT_GNU_guarded_by DW_AT_GNU_pt_guarded_by DW_AT_GNU_guarded DW_AT_GNU_pt_guarded 0xffffffff DW_TAG_GNU_template_template_parameter DW_AT_decl_column DW_AT_decl_file DW_AT_decl_line DW_AT_name DW_AT_GNU_template_name DW_AT_GNU_guarded_by /* GNU changed the name of 0x2108! */ 0xffffffff dwarf-20120410/dwarfdump/GPL.txt0000640000175000017500000004310311741100175015140 0ustar daveadavea GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. dwarf-20120410/dwarfdump/dwarfdump.c0000640000175000017500000023277411741100175016130 0ustar daveadavea/* Copyright (C) 2000,2002,2004,2005 Silicon Graphics, Inc. All Rights Reserved. Portions Copyright (C) 2007-2010 David Anderson. All Rights Reserved. Portions Copyright 2007-2010 Sun Microsystems, Inc. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/dwarfdump.c,v 1.48 2006/04/18 18:05:57 davea Exp $ */ /* The address of the Free Software Foundation is Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. SGI has moved from the Crittenden Lane address. */ #include "globals.h" /* for 'open' */ #include #include #include #include #include /* For getopt */ #include "makename.h" #include "dwconf.h" #include "common.h" #include "esb.h" /* For flexible string buffer. */ #ifdef WIN32 extern int elf_open(char *name,int mode); #endif #define DWARFDUMP_VERSION " Tue Apr 10 11:43:32 PDT 2012 " extern char *optarg; #define OKAY 0 #define BYTES_PER_INSTRUCTION 4 static const char* process_args(int argc, char *argv[]); char * program_name; static int check_error = 0; /* The type of Bucket. */ #define KIND_RANGES_INFO 1 #define KIND_SECTIONS_INFO 2 #define KIND_VISITED_INFO 3 /* pRangesInfo records the DW_AT_high_pc and DW_AT_low_pc and is used to check that line range info falls inside the known valid ranges. The data is per CU, and is reset per CU in tag_specific_checks_setup(). */ Bucket_Group *pRangesInfo = NULL; /* pLinkonceInfo records data about the link once sections. If a line range is not valid in the current CU it might be valid in a linkonce section, this data records the linkonce sections. So it is filled in when an object file is read and remains unchanged for an entire object file. */ Bucket_Group *pLinkonceInfo = NULL; /* pVisitedInfo records a recursive traversal of DIE attributes DW_AT_specification DW_AT_abstract_origin DW_AT_type that let DWARF refer (as in a general graph) to arbitrary other DIEs. These traversals use pVisitedInfo to detect any compiler errors that introduce circular references. Printing of the traversals is also done on request. Entries are added and deleted as they are visited in a depth-first traversal. */ Bucket_Group *pVisitedInfo = NULL; /* Options to enable debug tracing */ int nTrace[MAX_TRACE_LEVEL + 1]; /* Build section information */ void build_linkonce_info(Dwarf_Debug dbg); static const char * do_uri_translation(const char *s, const char *context); static void reset_overall_CU_error_data(); boolean info_flag = FALSE; boolean use_old_dwarf_loclist = FALSE; /* This so both dwarf_loclist() and dwarf_loclist_n() can be tested. Defaults to new dwarf_loclist_n() */ boolean line_flag = FALSE; static boolean abbrev_flag = FALSE; static boolean frame_flag = FALSE; /* .debug_frame section. */ static boolean eh_frame_flag = FALSE; /* GNU .eh_frame section. */ static boolean pubnames_flag = FALSE; static boolean macinfo_flag = FALSE; static boolean loc_flag = FALSE; static boolean aranges_flag = FALSE; /* .debug_aranges section. */ static boolean ranges_flag = FALSE; /* .debug_ranges section. */ static boolean string_flag = FALSE; static boolean reloc_flag = FALSE; static boolean static_func_flag = FALSE; static boolean static_var_flag = FALSE; static boolean type_flag = FALSE; static boolean weakname_flag = FALSE; static boolean header_flag = FALSE; /* Control printing of Elf header. */ boolean producer_children_flag = FALSE; /* List of CUs per compiler */ /* Bitmap for relocations. See globals.h for DW_SECTION_REL_DEBUG_RANGES etc.*/ static unsigned reloc_map = 0; /* Start verbose at zero. verbose can be incremented with -v but not decremented. */ int verbose = 0; boolean dense = FALSE; boolean ellipsis = FALSE; boolean show_global_offsets = FALSE; /* Show global and relative offsets */ boolean show_form_used = FALSE; boolean display_offsets = TRUE; /* Emit offsets */ boolean check_abbrev_code = FALSE; boolean check_pubname_attr = FALSE; boolean check_reloc_offset = FALSE; boolean check_attr_tag = FALSE; boolean check_tag_tree = FALSE; boolean check_type_offset = FALSE; boolean check_decl_file = FALSE; boolean check_lines = FALSE; boolean check_fdes = FALSE; boolean check_ranges = FALSE; boolean check_aranges = FALSE; boolean check_harmless = FALSE; boolean check_abbreviations = FALSE; boolean check_dwarf_constants = FALSE; boolean check_di_gaps = FALSE; boolean check_forward_decl = FALSE; boolean check_self_references = FALSE; boolean generic_1200_regs = FALSE; boolean suppress_check_extensions_tables = FALSE; /* suppress_nested_name_search is a band-aid. A workaround. A real fix for N**2 behavior is needed. */ boolean suppress_nested_name_search = FALSE; static boolean uri_options_translation = TRUE; static boolean do_print_uri_in_input = TRUE; /* break_after_n_units is mainly for testing. It enables easy limiting of output size/running time when one wants the output limited. For example, -H 2 limits the -i output to 2 compilation units and the -f or -F output to 2 FDEs and 2 CIEs. */ int break_after_n_units = INT_MAX; boolean check_names = FALSE; boolean check_verbose_mode = TRUE; /* During '-k' mode, display errors */ boolean check_frames = FALSE; boolean check_frames_extended = FALSE; /* Extensive frames check */ boolean check_locations = FALSE; /* Location list check */ static boolean check_all_compilers = TRUE; static boolean check_snc_compiler = FALSE; /* Check SNC compiler */ static boolean check_gcc_compiler = FALSE; static boolean print_summary_all = FALSE; #define COMPILER_TABLE_MAX 100 typedef struct anc { struct anc *next; char *item; } a_name_chain; /* Records information about compilers (producers) found in the debug information, including the check results for several categories (see -k option). */ typedef struct { const char *name; boolean verified; a_name_chain *cu_list; a_name_chain *cu_last; Dwarf_Check_Result results[LAST_CATEGORY]; } Compiler; /* Record compilers whose CU names have been seen. Full CU names recorded here, though only a portion of the name may have been checked to cause the compiler data to be entered here. The +1 guarantees we do not overstep the array. */ static Compiler compilers_detected[COMPILER_TABLE_MAX]; static int compilers_detected_count = 0; /* compilers_targeted is a list of indications of compilers on which we wish error checking (and the counts of checks made and errors found). We do substring comparisons, so the compilers_targeted name might be simply a compiler version number or a short substring of a CU producer name. The +1 guarantees we do not overstep the array. */ static Compiler compilers_targeted[COMPILER_TABLE_MAX]; static int compilers_targeted_count = 0; static int current_compiler = -1; static void reset_compiler_entry(Compiler *compiler); static void PRINT_CHECK_RESULT(char *str, Compiler *pCompiler, Dwarf_Check_Categories category); /* The check and print flags here make it easy to allow check-only or print-only. We no longer support check-and-print in a single run. */ boolean do_check_dwarf = FALSE; boolean do_print_dwarf = FALSE; boolean check_show_results = FALSE; /* Display checks results. */ boolean record_dwarf_error = FALSE; /* A test has failed, this is normally set FALSE shortly after being set TRUE, it is a short-range hint we should print something we might not otherwise print (under the circumstances). */ /* These names make diagnostic messages more complete, the fixed length is safe, though ultra long names will get truncated. */ char PU_name[COMPILE_UNIT_NAME_LEN]; char CU_name[COMPILE_UNIT_NAME_LEN]; char CU_producer[COMPILE_UNIT_NAME_LEN]; boolean seen_PU = FALSE; /* Detected a PU */ boolean seen_CU = FALSE; /* Detected a CU */ boolean need_CU_name = TRUE; /* Need CU name */ boolean need_CU_base_address = TRUE; /* Need CU Base address */ boolean need_CU_high_address = TRUE; /* Need CU High address */ boolean need_PU_valid_code = TRUE; /* Need PU valid code */ boolean seen_PU_base_address = FALSE; /* Detected a Base address for PU */ boolean seen_PU_high_address = FALSE; /* Detected a High address for PU */ Dwarf_Addr PU_base_address = 0; /* PU Base address */ Dwarf_Addr PU_high_address = 0; /* PU High address */ Dwarf_Off DIE_offset = 0; /* DIE offset in compile unit */ Dwarf_Off DIE_overall_offset = 0; /* DIE offset in .debug_info */ /* These globals enable better error reporting. */ Dwarf_Off DIE_CU_offset = 0; /* CU DIE offset in compile unit */ Dwarf_Off DIE_CU_overall_offset = 0; /* CU DIE offset in .debug_info */ int current_section_id = 0; /* Section being process */ Dwarf_Addr CU_base_address = 0; /* CU Base address */ Dwarf_Addr CU_high_address = 0; /* CU High address */ Dwarf_Addr elf_max_address = 0; /* Largest representable address offset */ Dwarf_Half elf_address_size = 0; /* Target pointer size */ /* Display parent/children when in wide format? */ boolean display_parent_tree = FALSE; boolean display_children_tree = FALSE; int stop_indent_level = 0; /* Print search results in wide format? */ boolean search_wide_format = FALSE; /* -S option: strings for 'any' and 'match' */ boolean search_is_on = FALSE; const char *search_any_text = 0; const char *search_match_text = 0; const char *search_regex_text = 0; #ifdef HAVE_REGEX /* -S option: the compiled_regex */ regex_t search_re; #endif /* These configure items are for the frame data. We're pretty flexible in the path to dwarfdump.conf . */ static const char *config_file_path = 0; static const char *config_file_abi = 0; static char *config_file_defaults[] = { "dwarfdump.conf", "./dwarfdump.conf", "HOME/.dwarfdump.conf", "HOME/dwarfdump.conf", #ifdef CONFPREFIX /* See Makefile.in "libdir" and CFLAGS */ /* We need 2 levels of macro to get the name turned into the string we want. */ #define STR2(s) # s #define STR(s) STR2(s) STR(CONFPREFIX) "/dwarfdump.conf", #else "/usr/lib/dwarfdump.conf", #endif 0 }; static struct dwconf_s config_file_data; char cu_name[BUFSIZ]; boolean cu_name_flag = FALSE; Dwarf_Unsigned cu_offset = 0; Dwarf_Error err; static void suppress_check_dwarf() { do_print_dwarf = TRUE; if(do_check_dwarf) { fprintf(stderr,"Warning: check flag turned off, " "checking and printing are separate.\n"); } do_check_dwarf = FALSE; } static void suppress_print_dwarf() { do_print_dwarf = FALSE; do_check_dwarf = TRUE; } static int process_one_file(Elf * elf, const char * file_name, int archive, struct dwconf_s *conf); static int open_a_file(const char * name) { /* Set to a file number that cannot be legal. */ int f = -1; #if defined(__CYGWIN__) || defined(WIN32) /* It is not possible to share file handles between applications or DLLs. Each application has its own file-handle table. For two applications to use the same file using a DLL, they must both open the file individually. Let the 'libelf' dll to open and close the file. */ /* For WIN32 open the file as binary */ f = elf_open(name, O_RDONLY | O_BINARY); #else f = open(name, O_RDONLY); #endif return f; } static void close_a_file(int f) { close(f); } /* Iterate through dwarf and print all info. */ int main(int argc, char *argv[]) { const char * file_name = 0; int f = 0; Elf_Cmd cmd = 0; Elf *arf = 0; Elf *elf = 0; int archive = 0; #ifdef WIN32 /* Windows specific. */ /* Redirect stderr to stdout. */ /* Tried to use SetStdHandle, but it does not work properly. */ //BOOL bbb = SetStdHandle(STD_ERROR_HANDLE,GetStdHandle(STD_OUTPUT_HANDLE)); //_iob[2]._file = _iob[1]._file; stderr->_file = stdout->_file; #endif /* WIN32 */ print_version_details(argv[0],FALSE); (void) elf_version(EV_NONE); if (elf_version(EV_CURRENT) == EV_NONE) { (void) fprintf(stderr, "dwarfdump: libelf.a out of date.\n"); exit(1); } file_name = process_args(argc, argv); /* Because LibDwarf now generates some new warnings, allow the user to hide them by using command line options */ { Dwarf_Cmdline_Options cmd; cmd.check_verbose_mode = check_verbose_mode; dwarf_record_cmdline_options(cmd); } print_args(argc,argv); f = open_a_file(file_name); if (f == -1) { fprintf(stderr, "%s ERROR: can't open %s\n", program_name, file_name); return (FAILED); } cmd = ELF_C_READ; arf = elf_begin(f, cmd, (Elf *) 0); if (elf_kind(arf) == ELF_K_AR) { archive = 1; } /* If we are checking .debug_line, .debug_ranges, .debug_aranges, or .debug_loc build the tables containing the pairs LowPC and HighPC. It is safer (and not expensive) to build all of these at once so mistakes in options do not lead to coredumps (like -ka -p did once). */ if (check_decl_file || check_ranges || check_locations || do_check_dwarf || check_self_references) { pRangesInfo = AllocateBucketGroup(KIND_RANGES_INFO); pLinkonceInfo = AllocateBucketGroup(KIND_SECTIONS_INFO); pVisitedInfo = AllocateBucketGroup(KIND_VISITED_INFO); } while ((elf = elf_begin(f, cmd, arf)) != 0) { Elf32_Ehdr *eh32; #ifdef HAVE_ELF64_GETEHDR Elf64_Ehdr *eh64; #endif /* HAVE_ELF64_GETEHDR */ eh32 = elf32_getehdr(elf); if (!eh32) { #ifdef HAVE_ELF64_GETEHDR /* not a 32-bit obj */ eh64 = elf64_getehdr(elf); if (!eh64) { /* not a 64-bit obj either! */ /* dwarfdump is almost-quiet when not an object */ fprintf(stderr, "Can't process %s: unknown format\n",file_name); check_error = 1; } else { process_one_file(elf, file_name, archive, &config_file_data); } #endif /* HAVE_ELF64_GETEHDR */ } else { process_one_file(elf, file_name, archive, &config_file_data); } cmd = elf_next(elf); elf_end(elf); } elf_end(arf); /* Trivial malloc space cleanup. */ clean_up_die_esb(); clean_up_syms_malloc_data(); if(pRangesInfo) { ReleaseBucketGroup(pRangesInfo); pRangesInfo = 0; } if(pLinkonceInfo) { ReleaseBucketGroup(pLinkonceInfo); pLinkonceInfo = 0; } if(pVisitedInfo) { ReleaseBucketGroup(pVisitedInfo); pVisitedInfo = 0; } #ifdef HAVE_REGEX if(search_regex_text) { regfree(&search_re); } #endif close_a_file(f); if (check_error) return FAILED; else return OKAY; } void print_any_harmless_errors(Dwarf_Debug dbg) { #define LOCAL_PTR_ARY_COUNT 50 /* We do not need to initialize the local array, libdwarf does it. */ const char *buf[LOCAL_PTR_ARY_COUNT]; unsigned totalcount = 0; unsigned i = 0; unsigned printcount = 0; int res = dwarf_get_harmless_error_list(dbg,LOCAL_PTR_ARY_COUNT,buf, &totalcount); if(res == DW_DLV_NO_ENTRY) { return; } if(totalcount > 0) { printf("\n*** HARMLESS ERROR COUNT: %u ***\n",totalcount); } for(i = 0 ; buf[i]; ++i) { ++printcount; DWARF_CHECK_COUNT(harmless_result,1); DWARF_CHECK_ERROR(harmless_result,buf[i]); } if(totalcount > printcount) { //harmless_result.checks += (totalcount - printcount); DWARF_CHECK_COUNT(harmless_result,(totalcount - printcount)); //harmless_result.errors += (totalcount - printcount); DWARF_ERROR_COUNT(harmless_result,(totalcount - printcount)); } } static void print_object_header(Elf *elf,Dwarf_Debug dbg) { #ifdef WIN32 /* Standard libelf has no function generating the names of the encodings, but this libelf apparently does. */ Elf_Ehdr_Literal eh_literals; Elf32_Ehdr *eh32; #ifdef HAVE_ELF64_GETEHDR Elf64_Ehdr *eh64; #endif /* HAVE_ELF64_GETEHDR */ eh32 = elf32_getehdr(elf); if (eh32) { /* Get literal strings for header fields */ elf32_gethdr_literals(eh32,&eh_literals); /* Print 32-bit obj header */ printf("\nObject Header:\ne_ident:\n"); printf(" File ID = %s\n",eh_literals.e_ident_file_id); printf(" File class = %02x (%s)\n", eh32->e_ident[EI_CLASS], eh_literals.e_ident_file_class); printf(" Data encoding = %02x (%s)\n", eh32->e_ident[EI_DATA], eh_literals.e_ident_data_encoding); printf(" File version = %02x (%s)\n", eh32->e_ident[EI_VERSION], eh_literals.e_ident_file_version); printf(" OS ABI = %02x (%s) (%s)\n", eh32->e_ident[EI_OSABI], eh_literals.e_ident_os_abi_s, eh_literals.e_ident_os_abi_l); //printf(" ABI version = %02x (%s)\n", // eh32->e_ident[EI_ABIVERSION], eh_literals.e_ident_abi_version); printf("e_type : 0x%x (%s)\n", eh32->e_type, eh_literals.e_type); printf("e_machine: 0x%x (%s) (%s)\n", eh32->e_machine, eh_literals.e_machine_s, eh_literals.e_machine_l); printf("e_version: 0x%x\n", eh32->e_version); //printf("e_entry = 0x%I64x\n", eh32->e_entry); printf("e_flags : 0x%x\n", eh32->e_flags); printf("e_phnum : 0x%x\n", eh32->e_phnum); printf("e_shnum : 0x%x\n", eh32->e_shnum); } else { #ifdef HAVE_ELF64_GETEHDR /* not a 32-bit obj */ eh64 = elf64_getehdr(elf); if (eh64) { /* Get literal strings for header fields */ elf64_gethdr_literals(eh64,&eh_literals); /* Print 64-bit obj header */ printf("\nObject Header:\ne_ident:\n"); printf(" File ID = %s\n",eh_literals.e_ident_file_id); printf(" File class = %02x (%s)\n", eh64->e_ident[EI_CLASS], eh_literals.e_ident_file_class); printf(" Data encoding = %02x (%s)\n", eh64->e_ident[EI_DATA], eh_literals.e_ident_data_encoding); printf(" File version = %02x (%s)\n", eh64->e_ident[EI_VERSION], eh_literals.e_ident_file_version); printf(" OS ABI = %02x (%s) (%s)\n", eh64->e_ident[EI_OSABI], eh_literals.e_ident_os_abi_s, eh_literals.e_ident_os_abi_l); //printf(" ABI version = %02x (%s)\n", // eh64->e_ident[EI_ABIVERSION], eh_literals.e_ident_abi_version); printf("e_type : 0x%x (%s)\n", eh64->e_type, eh_literals.e_type); printf("e_machine: 0x%x (%s) (%s)\n", eh64->e_machine, eh_literals.e_machine_s, eh_literals.e_machine_l); printf("e_version: 0x%x\n", eh64->e_version); //printf("e_entry = 0x%I64x\n", eh64->e_entry); printf("e_flags : 0x%x\n", eh64->e_flags); printf("e_phnum : 0x%x\n", eh64->e_phnum); printf("e_shnum : 0x%x\n", eh64->e_shnum); } #endif /* HAVE_ELF64_GETEHDR */ } #endif /* WIN32 */ } /* Print checks and errors for a specific compiler */ static void print_specific_checks_results(Compiler *pCompiler) { fprintf(stderr, "\nDWARF CHECK RESULT\n"); fprintf(stderr, " \n"); if (check_pubname_attr) { PRINT_CHECK_RESULT("pubname_attr", pCompiler, pubname_attr_result); } if (check_attr_tag) { PRINT_CHECK_RESULT("attr_tag", pCompiler, attr_tag_result); } if (check_tag_tree) { PRINT_CHECK_RESULT("tag_tree", pCompiler, tag_tree_result); } if (check_type_offset) { PRINT_CHECK_RESULT("type_offset", pCompiler, type_offset_result); } if (check_decl_file) { PRINT_CHECK_RESULT("decl_file", pCompiler, decl_file_result); } if (check_ranges) { PRINT_CHECK_RESULT("ranges", pCompiler, ranges_result); } if (check_lines) { PRINT_CHECK_RESULT("line_table", pCompiler, lines_result); } if (check_fdes) { PRINT_CHECK_RESULT("fde table", pCompiler, fde_duplication); } if (check_aranges) { PRINT_CHECK_RESULT("aranges", pCompiler, aranges_result); } if (check_names) { PRINT_CHECK_RESULT("names",pCompiler, names_result); } if (check_frames) { PRINT_CHECK_RESULT("frames",pCompiler, frames_result); } if (check_locations) { PRINT_CHECK_RESULT("locations",pCompiler, locations_result); } if(check_harmless) { PRINT_CHECK_RESULT("harmless_errors", pCompiler, harmless_result); } if (check_abbreviations) { PRINT_CHECK_RESULT("abbreviations", pCompiler, abbreviations_result); } if (check_dwarf_constants) { PRINT_CHECK_RESULT("dwarf_constants", pCompiler, dwarf_constants_result); } if (check_di_gaps) { PRINT_CHECK_RESULT("debug_info_gaps", pCompiler, di_gaps_result); } if (check_forward_decl) { PRINT_CHECK_RESULT("forward_declarations", pCompiler, forward_decl_result); } if (check_self_references) { PRINT_CHECK_RESULT("self_references", pCompiler, self_references_result); } PRINT_CHECK_RESULT("** Summarize **",pCompiler, total_check_result); } static int qsort_compare_compiler(const void *elem1,const void *elem2) { Compiler cmp1 = *(Compiler *)elem1; Compiler cmp2 = *(Compiler *)elem2; int cnt1 = cmp1.results[total_check_result].errors; int cnt2 = cmp2.results[total_check_result].errors; int sc = 0; if (cnt1 < cnt2) { return 1; } else if (cnt1 > cnt2) { return -1; } /* When error counts match, sort on name. */ sc = strcmp(cmp2.name,cmp1.name); return sc; } /* Print a summary of checks and errors */ static void print_checks_results() { int index = 0; Compiler *pCompilers; Compiler *pCompiler; fflush(stdout); /* Sort based on errors detected; the first entry is reserved */ pCompilers = &compilers_detected[1]; qsort((void *)pCompilers, compilers_detected_count, sizeof(Compiler),qsort_compare_compiler); /* Print list of CUs for each compiler detected */ if (producer_children_flag) { a_name_chain *nc = 0; a_name_chain *nc_next = 0; int count = 0; int total = 0; fprintf(stderr,"\n*** CU NAMES PER COMPILER ***\n"); for (index = 1; index <= compilers_detected_count; ++index) { pCompiler = &compilers_detected[index]; fprintf(stderr,"\n%02d: %s\n",index,pCompiler->name); count = 0; for (nc = pCompiler->cu_list; nc; nc = nc_next) { fprintf(stderr,"\n %02d: '%s'",++count,nc->item); nc_next = nc->next; free(nc); } total += count; fprintf(stderr,"\n"); } fprintf(stderr,"\nDetected %d CU names\n",total); } /* Print error report only if errors have been detected */ /* Print error report if the -kd option */ if ((do_check_dwarf && check_error) || check_show_results) { int count = 0; int compilers_not_detected = 0; int compilers_verified = 0; /* Find out how many compilers have been verified. */ for (index = 1; index <= compilers_detected_count; ++index) { if (compilers_detected[index].verified) { ++compilers_verified; } } /* Find out how many compilers have been not detected. */ for (index = 1; index <= compilers_targeted_count; ++index) { if (!compilers_targeted[index].verified) { ++compilers_not_detected; } } /* Print compilers detected list */ fprintf(stderr, "\n%d Compilers detected:\n",compilers_detected_count); for (index = 1; index <= compilers_detected_count; ++index) { pCompiler = &compilers_detected[index]; fprintf(stderr,"%02d: %s\n",index,pCompiler->name); } /* Print compiler list specified by the user with the '-c', that were not detected. */ if (compilers_not_detected) { count = 0; fprintf(stderr, "\n%d Compilers not detected:\n",compilers_not_detected); for (index = 1; index <= compilers_targeted_count; ++index) { if (!compilers_targeted[index].verified) { fprintf(stderr, "%02d: '%s'\n", ++count,compilers_targeted[index].name); } } } count = 0; fprintf(stderr,"\n%d Compilers verified:\n",compilers_verified); for (index = 1; index <= compilers_detected_count; ++index) { pCompiler = &compilers_detected[index]; if (pCompiler->verified) { fprintf(stderr,"%02d: errors = %5d, %s\n", ++count, pCompiler->results[total_check_result].errors, pCompiler->name); } } /* Print summary if we have verified compilers or if the -kd option used. */ if (compilers_verified || check_show_results) { /* Print compilers detected summary*/ if (print_summary_all) { count = 0; fprintf(stderr,"\n*** ERRORS PER COMPILER ***\n"); for (index = 1; index <= compilers_detected_count; ++index) { pCompiler = &compilers_detected[index]; if (pCompiler->verified) { fprintf(stderr,"%02d: %s\n", ++count,pCompiler->name); print_specific_checks_results(pCompiler); } } } /* Print general summary (all compilers checked) */ fprintf(stderr,"\n*** TOTAL ERRORS FOR ALL COMPILERS ***\n"); print_specific_checks_results(&compilers_detected[0]); } } } /* Given a file which we know is an elf file, process the dwarf data. */ static int process_one_file(Elf * elf, const char * file_name, int archive, struct dwconf_s *config_file_data) { Dwarf_Debug dbg; int dres; dres = dwarf_elf_init(elf, DW_DLC_READ, NULL, NULL, &dbg, &err); if (dres == DW_DLV_NO_ENTRY) { printf("No DWARF information present in %s\n", file_name); return 0; } if (dres != DW_DLV_OK) { print_error(dbg, "dwarf_elf_init", dres, err); } if (archive) { Elf_Arhdr *mem_header = elf_getarhdr(elf); printf("\narchive member \t%s\n", mem_header ? mem_header->ar_name : ""); } dwarf_set_frame_rule_initial_value(dbg, config_file_data->cf_initial_rule_value); dwarf_set_frame_rule_table_size(dbg, config_file_data->cf_table_entry_count); dwarf_set_frame_cfa_value(dbg, config_file_data->cf_cfa_reg); dwarf_set_frame_same_value(dbg, config_file_data->cf_same_val); dwarf_set_frame_undefined_value(dbg, config_file_data->cf_undefined_val); if(config_file_data->cf_address_size) { dwarf_set_default_address_size(dbg, config_file_data->cf_address_size); } dwarf_set_harmless_error_list_size(dbg,50); /* Get address size and largest representable address */ dres = dwarf_get_address_size(dbg,&elf_address_size,&err); if (dres != DW_DLV_OK) { print_error(dbg, "get_location_list", dres, err); } elf_max_address = (elf_address_size == 8 ) ? 0xffffffffffffffffULL : 0xffffffff; /* Get .text and .debug_ranges info if in check mode */ if (do_check_dwarf) { Dwarf_Addr lower = 0; Dwarf_Addr upper = 0; Dwarf_Unsigned size = 0; int res = 0; res = dwarf_get_section_info_by_name(dbg,".text",&lower,&size,&err); if (DW_DLV_OK == res) { upper = lower + size; } /* Set limits for Ranges Information */ if (pRangesInfo) { SetLimitsBucketGroup(pRangesInfo,lower,upper); } /* Build section information */ build_linkonce_info(dbg); } if (header_flag) { print_object_header(elf,dbg); } reset_overall_CU_error_data(); if (info_flag || line_flag || cu_name_flag || search_is_on || producer_children_flag) { print_infos(dbg,TRUE); reset_overall_CU_error_data(); print_infos(dbg,FALSE); } if (pubnames_flag) { reset_overall_CU_error_data(); print_pubnames(dbg); } if (macinfo_flag) { reset_overall_CU_error_data(); print_macinfo(dbg); } if (loc_flag) { reset_overall_CU_error_data(); print_locs(dbg); } if (abbrev_flag) { reset_overall_CU_error_data(); print_abbrevs(dbg); } if (string_flag) { reset_overall_CU_error_data(); print_strings(dbg); } if (aranges_flag) { reset_overall_CU_error_data(); print_aranges(dbg); } if (ranges_flag) { reset_overall_CU_error_data(); print_ranges(dbg); } if (frame_flag || eh_frame_flag) { reset_overall_CU_error_data(); current_cu_die_for_print_frames = 0; print_frames(dbg, frame_flag, eh_frame_flag, config_file_data); } if (static_func_flag) { reset_overall_CU_error_data(); print_static_funcs(dbg); } if (static_var_flag) { reset_overall_CU_error_data(); print_static_vars(dbg); } /* DWARF_PUBTYPES is the standard typenames dwarf section. SGI_TYPENAME is the same concept but is SGI specific ( it was defined 10 years before dwarf pubtypes). */ if (type_flag) { reset_overall_CU_error_data(); print_types(dbg, DWARF_PUBTYPES); reset_overall_CU_error_data(); print_types(dbg, SGI_TYPENAME); } if (weakname_flag) { reset_overall_CU_error_data(); print_weaknames(dbg); } if (reloc_flag) { reset_overall_CU_error_data(); print_relocinfo(dbg, reloc_map); } /* The right time to do this is unclear. But we need to do it. */ print_any_harmless_errors(dbg); /* Print error report only if errors have been detected */ /* Print error report if the -kd option */ print_checks_results(); dres = dwarf_finish(dbg, &err); if (dres != DW_DLV_OK) { print_error(dbg, "dwarf_finish", dres, err); } printf("\n"); fflush(stderr); return 0; } /* Do printing of most sections. Do not do detailed checking. */ static void do_all() { info_flag = line_flag = frame_flag = TRUE; pubnames_flag = macinfo_flag = TRUE; aranges_flag = TRUE; /* Do not do loc_flag = TRUE abbrev_flag = TRUE; ranges_flag = TRUE; because nothing in the DWARF spec guarantees the sections are free of random bytes in areas not referenced by .debug_info */ string_flag = TRUE; /* Do not do reloc_flag = TRUE; as print_relocs makes no sense for non-elf dwarfdump users. */ static_func_flag = static_var_flag = TRUE; type_flag = weakname_flag = TRUE; header_flag = TRUE; /* Dump header info */ } static const char *usage_text[] = { "options:\t-a\tprint all .debug_* sections", "\t\t-b\tprint abbrev section", "\t\t-c\tprint loc section", "\t\t-c\tcheck only specific compiler objects", "\t\t \t is described by 'DW_AT_producer'. Examples:", "\t\t \t -cg check only GCC compiler objects", "\t\t \t -cs check only SNC compiler objects", "\t\t \t -c'350.1' check only compiler objects with 350.1 in the CU name", "\t\t-C\tactivate printing (with -i) of warnings about", "\t\t\tcertain common extensions of DWARF.", "\t\t-d\tdense: one line per entry (info section only)", "\t\t-D\tdo not show offsets", /* Do not show any offsets */ "\t\t-e\tellipsis: short names for tags, attrs etc.", "\t\t-E\tprint object Header information", "\t\t-f\tprint dwarf frame section", "\t\t-F\tprint gnu .eh_frame section", "\t\t-g\t(use incomplete loclist support)", "\t\t-G\tshow global die offsets", "\t\t-h\tprint IRIX exception tables (unsupported)", "\t\t-H \tlimit output to the first major units", "\t\t\t example: to stop after compilation units", "\t\t-i\tprint info section", "\t\t-k[abcdeEfFgilmMnrRsStx[e]y] check dwarf information", "\t\t a\tdo all checks", "\t\t b\tcheck abbreviations", /* Check abbreviations */ "\t\t c\texamine DWARF constants", /* Check for valid DWARF constants */ "\t\t d\tshow check results", /* Show check results */ "\t\t e\texamine attributes of pubnames", "\t\t E\tignore DWARF extensions", /* Ignore DWARF extensions */ "\t\t f\texamine frame information (use with -f or -F)", "\t\t F\texamine integrity of files-lines attributes", /* Files-Lines integrity */ "\t\t g\tcheck debug info gaps", /* Check for debug info gaps */ "\t\t i\tdisplay summary for all compilers", /* Summary all compilers */ "\t\t l\tcheck location list (.debug_loc)", /* Location list integrity */ "\t\t m\tcheck ranges list (.debug_ranges)", /* Ranges list integrity */ "\t\t M\tcheck ranges list (.debug_aranges)",/* Aranges list integrity */ "\t\t n\texamine names in attributes", /* Check for valid names */ "\t\t r\texamine tag-attr relation", "\t\t R\tcheck forward references to DIEs (declarations)", /* Check DW_AT_specification references */ "\t\t s\tperform checks in silent mode", "\t\t S\tcheck self references to DIEs", "\t\t t\texamine tag-tag relations", "\t\t x\tbasic frames check (.eh_frame, .debug_frame)", "\t\t xe\textensive frames check (.eh_frame, .debug_frame)", "\t\t y\texamine type info", "\t\t\tUnless -C option given certain common tag-attr and tag-tag", "\t\t\textensions are assumed to be ok (not reported).", "\t\t-l\tprint line section", "\t\t-m\tprint macinfo section", "\t\t-M\tprint the form name for each attribute", "\t\t-n\tsuppress frame information function name lookup", "\t\t \t(when printing frame information from multi-gigabyte", "\t\t \tobject files this option may save significant time).", "\t\t-N\tprint ranges section", "\t\t-o[liaprfoR]\tprint relocation info", "\t\t \tl=line,i=info,a=abbrev,p=pubnames,r=aranges,f=frames,o=loc,R=Ranges", "\t\t-p\tprint pubnames section", "\t\t-P\tprint list of compile units per producer", /* List of CUs per compiler */ "\t\t-Q\tsuppress printing section data", "\t\t-r\tprint aranges section", "\t\t-R\tPrint frame register names as r33 etc", "\t\t \t and allow up to 1200 registers.", "\t\t \t Print using a 'generic' register set.", "\t\t-s\tprint string section", "\t\t-S