From 6b989c1e4f8f818a59caf69426843a4b3d1144f0 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 5 Jun 2011 07:32:06 -0700 Subject: [PATCH] Altered indents to multiples of 4 spaces, no tabs, in the dwarfexample directory. --- dwarfexample/ChangeLog | 3 ++ dwarfexample/frame1.c | 82 ++++++++++++++++++------------------- dwarfexample/simplereader.c | 70 ++++++++++++++++--------------- 3 files changed, 80 insertions(+), 75 deletions(-) diff --git a/dwarfexample/ChangeLog b/dwarfexample/ChangeLog index 97f8952..e635b2f 100644 --- a/dwarfexample/ChangeLog +++ b/dwarfexample/ChangeLog @@ -1,2 +1,5 @@ +2011-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. diff --git a/dwarfexample/frame1.c b/dwarfexample/frame1.c index d89544f..80d3430 100644 --- a/dwarfexample/frame1.c +++ b/dwarfexample/frame1.c @@ -25,17 +25,17 @@ 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. +/* 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! + It specifically calls dwarf_expand_frame_instructions() + to verify that works without crashing! - To use, try - make - ./frame1 frame1 + To use, try + make + ./frame1 frame1 */ #include /* For open() */ #include /* For open() */ @@ -90,16 +90,16 @@ main(int argc, char **argv) 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. */ + /* 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); @@ -131,8 +131,8 @@ read_frame_data(Dwarf_Debug dbg) 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); + printf("No frame data present "); + exit(0); } if( res == DW_DLV_ERROR) { printf("Error reading frame data "); @@ -237,13 +237,13 @@ print_fde_instrs(Dwarf_Debug dbg, 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); + " 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. */ + /* 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); @@ -271,8 +271,8 @@ print_fde_instrs(Dwarf_Debug dbg, } res = dwarf_get_cie_of_fde(fde,&cie,error); if(res != DW_DLV_OK) { - printf("Error getting cie from fde\n"); - exit(1); + printf("Error getting cie from fde\n"); + exit(1); } res = dwarf_expand_frame_instructions(cie, @@ -321,8 +321,8 @@ print_one_regentry(const char *prefix,Dwarf_Fde fde,Dwarf_Debug dbg, (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"); + "DW_EXPR_VAL_EXPRESSION": + "Unknown"); switch(entry->dw_value_type) { case DW_EXPR_OFFSET: print_reg(entry->dw_regnum); @@ -336,7 +336,7 @@ print_one_regentry(const char *prefix,Dwarf_Fde fde,Dwarf_Debug dbg, printf("address of value is CFA plus signed offset"); } if(!is_cfa && entry->dw_regnum != CFA_VAL) { - printf(" compiler botch, regnum != CFA_VAL"); + printf(" compiler botch, regnum != CFA_VAL"); } } else { printf("value in register"); @@ -345,14 +345,14 @@ print_one_regentry(const char *prefix,Dwarf_Fde fde,Dwarf_Debug dbg, case DW_EXPR_VAL_OFFSET: print_reg(entry->dw_regnum); printf(" offset %" DW_PR_DSd " " , - entry->dw_offset_or_block_len); + 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"); + printf(" compiler botch, regnum != CFA_VAL"); } break; case DW_EXPR_EXPRESSION: @@ -391,14 +391,14 @@ print_regtable(Dwarf_Fde fde,Dwarf_Regtable3 *tab3,int oldrulecount, max = tab3->rt3_reg_table_size; } print_one_regentry("cfa",fde,dbg,oldrulecount,&tab3->rt3_cfa_rule, - error); + 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); - } + 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); + } } diff --git a/dwarfexample/simplereader.c b/dwarfexample/simplereader.c index bc02c5c..da21b65 100644 --- a/dwarfexample/simplereader.c +++ b/dwarfexample/simplereader.c @@ -24,17 +24,17 @@ 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. +/* 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. + The --names + option adds some extra printing. - To use, try - make - ./simplereader simplereader + To use, try + make + ./simplereader simplereader */ #include /* For open() */ #include /* For open() */ @@ -80,9 +80,9 @@ main(int argc, char **argv) int i = 0; for(i = 1; i < (argc-1) ; ++i) { if(strcmp(argv[i],"--names") == 0) { - namesoptionon=1; + namesoptionon=1; } else { - printf("Unknown argument \"%s\" ignored\n",argv[i]); + printf("Unknown argument \"%s\" ignored\n",argv[i]); } } filepath = argv[i]; @@ -250,26 +250,26 @@ print_subprog(Dwarf_Debug dbg,Dwarf_Die die, int level, 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]; - } + 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); + get_number(attrbuf[i],&linenum); } if(aform == DW_AT_low_pc) { - get_addr(attrbuf[i],&lowpc); + get_addr(attrbuf[i],&lowpc); } if(aform == DW_AT_high_pc) { - get_addr(attrbuf[i],&highpc); + 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); + DW_PR_DUu "\n",level,filenum,filename?filename:"",linenum); } if(lowpc) { printf("<%3d> low_pc : 0x%" DW_PR_DUx "\n", @@ -301,11 +301,12 @@ print_comp_dir(Dwarf_Debug dbg,Dwarf_Die die,int level, struct srcfilesdata *sf) 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); - } + 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 */ @@ -319,14 +320,14 @@ print_comp_dir(Dwarf_Debug dbg,Dwarf_Die die,int level, struct srcfilesdata *sf) 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; + 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 @@ -364,8 +365,9 @@ print_die_data(Dwarf_Debug dbg, Dwarf_Die print_me,int level, 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) { + 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);