static const char * ellipname(int res, int val_in, const char *v,const char *ty,int printonerr) { #ifndef TRIVIAL_NAMING if (glflags.gf_check_dwarf_constants && checking_this_compiler()) { DWARF_CHECK_COUNT(dwarf_constants_result,1); } #endif if (res != DW_DLV_OK) { char buf[100]; char *n; #ifdef ORIGINAL_SPRINTF snprintf(buf,sizeof(buf),"<Unknown %s value 0x%x>",ty,val_in); #else struct esb_s eb; esb_constructor_fixed(&eb,buf,sizeof(buf)); esb_append_printf_s(&eb, "<Unknown %s",ty); esb_append_printf_u(&eb, " value 0x%x>",val_in); #endif /* Capture any name error in DWARF constants */ #ifndef TRIVIAL_NAMING if (printonerr && glflags.gf_check_dwarf_constants && checking_this_compiler()) { if (glflags.gf_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 #ifdef ORIGINAL_SPRINTF n = makename(buf); #else n = makename(esb_get_string(&eb)); esb_destructor(&eb); #endif return n; } #ifndef TRIVIAL_NAMING if (glflags.ellipsis) { return skipunder(v); } #endif return v; }
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),"<Unknown %s value 0x%x>",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; }
extern void print_line_numbers_this_cu(Dwarf_Debug dbg, Dwarf_Die cu_die) { Dwarf_Unsigned lineversion = 0; Dwarf_Signed linecount = 0; Dwarf_Line *linebuf = NULL; Dwarf_Signed linecount_actuals = 0; Dwarf_Line *linebuf_actuals = NULL; Dwarf_Small table_count = 0; int lres = 0; int line_errs = 0; Dwarf_Line_Context line_context = 0; const char *sec_name = 0; current_section_id = DEBUG_LINE; /* line_flag is TRUE */ lres = dwarf_get_line_section_name_from_die(cu_die, &sec_name,&err); if (lres != DW_DLV_OK || !sec_name || !strlen(sec_name)) { sec_name = ".debug_line"; } if (do_print_dwarf) { printf("\n%s: line number info for a single cu\n", sec_name); } else { /* We are checking, not printing. */ Dwarf_Half tag = 0; int tres = dwarf_tag(cu_die, &tag, &err); if (tres != DW_DLV_OK) { /* Something broken here. */ print_error(dbg,"Unable to see CU DIE tag " "though we could see it earlier. Something broken.", tres,err); return; } else if (tag == DW_TAG_type_unit) { /* Not checking since type units missing address or range in CU header. */ return; } } if (verbose > 1) { int errcount = 0; print_source_intro(cu_die); print_one_die(dbg, cu_die, /* print_information= */ 1, /* indent level */0, /* srcfiles= */ 0, /* cnt= */ 0, /* ignore_die_stack= */TRUE); DWARF_CHECK_COUNT(lines_result,1); lres = dwarf_print_lines(cu_die, &err,&errcount); if (errcount > 0) { DWARF_ERROR_COUNT(lines_result,errcount); DWARF_CHECK_COUNT(lines_result,(errcount-1)); } if (lres == DW_DLV_ERROR) { print_error(dbg, "dwarf_srclines details", lres, err); } return; } if (check_lines && checking_this_compiler()) { DWARF_CHECK_COUNT(lines_result,1); dwarf_check_lineheader(cu_die,&line_errs); if (line_errs > 0) { DWARF_CHECK_ERROR_PRINT_CU(); DWARF_ERROR_COUNT(lines_result,line_errs); DWARF_CHECK_COUNT(lines_result,(line_errs-1)); } } /* The following is complicated by a desire to test various line table interface functions. Hence we test line_flag_selection. Normal code should pick an interface (for most the best choice is what we here call line_flag_selection == std) and use just that interface set. Sorry about the length of the code that results from having so many interfaces. */ if (line_flag_selection == std) { lres = dwarf_srclines_b(cu_die,&lineversion, &table_count,&line_context, &err); if(lres == DW_DLV_OK) { lres = dwarf_srclines_from_linecontext(line_context, &linebuf, &linecount,&err); } } else if (line_flag_selection == orig) { /* DWARF2,3,4, ok for 5. */ /* Useless for experimental line tables */ lres = dwarf_srclines(cu_die, &linebuf, &linecount, &err); if(lres == DW_DLV_OK && linecount ){ table_count++; } } else if (line_flag_selection == orig2l) { lres = dwarf_srclines_two_level(cu_die, &lineversion, &linebuf, &linecount, &linebuf_actuals, &linecount_actuals, &err); if(lres == DW_DLV_OK && linecount){ table_count++; } if(lres == DW_DLV_OK && linecount_actuals){ table_count++; } } else if (line_flag_selection == s2l) { lres = dwarf_srclines_b(cu_die,&lineversion, &table_count,&line_context, &err); if(lres == DW_DLV_OK) { lres = dwarf_srclines_two_level_from_linecontext(line_context, &linebuf, &linecount, &linebuf_actuals, &linecount_actuals, &err); } } if (lres == DW_DLV_ERROR) { /* Do not terminate processing */ if (check_decl_file) { DWARF_CHECK_COUNT(decl_file_result,1); DWARF_CHECK_ERROR2(decl_file_result,"dwarf_srclines", dwarf_errmsg(err)); record_dwarf_error = FALSE; /* Clear error condition */ } else { print_error(dbg, "dwarf_srclines", lres, err); } } else if (lres == DW_DLV_NO_ENTRY) { /* no line information is included */ } else if (table_count > 0) { /* DW_DLV_OK */ if(line_context && verbose) { print_line_context_record(dbg,line_context); } if (do_print_dwarf) { print_source_intro(cu_die); if (verbose) { print_one_die(dbg, cu_die, /* print_information= */ TRUE, /* indent_level= */ 0, /* srcfiles= */ 0, /* cnt= */ 0, /* ignore_die_stack= */TRUE); } } if(line_flag_selection == std || line_flag_selection == s2l) { if (table_count == 0 || table_count == 1) { /* ASSERT: is_single_table == true */ Dwarf_Bool is_logicals = FALSE; Dwarf_Bool is_actuals = FALSE; process_line_table(dbg,sec_name, linebuf, linecount, is_logicals,is_actuals); } else { Dwarf_Bool is_logicals = TRUE; Dwarf_Bool is_actuals = FALSE; process_line_table(dbg,sec_name, linebuf, linecount, is_logicals, is_actuals); process_line_table(dbg,sec_name, linebuf_actuals, linecount_actuals, !is_logicals, !is_actuals); } dwarf_srclines_dealloc_b(line_context); } else if (line_flag_selection == orig) { Dwarf_Bool is_logicals = FALSE; Dwarf_Bool is_actuals = FALSE; process_line_table(dbg,sec_name, linebuf, linecount, is_logicals, is_actuals); dwarf_srclines_dealloc(dbg,linebuf,linecount); } else if (line_flag_selection == orig2l) { if (table_count == 1 || table_count == 0) { Dwarf_Bool is_logicals = FALSE; Dwarf_Bool is_actuals = FALSE; process_line_table(dbg,sec_name, linebuf, linecount, is_logicals, is_actuals); } else { Dwarf_Bool is_logicals = TRUE; Dwarf_Bool is_actuals = FALSE; process_line_table(dbg,sec_name, linebuf, linecount, is_logicals, is_actuals); process_line_table(dbg,sec_name, linebuf_actuals, linecount_actuals, !is_logicals, !is_actuals); } dwarf_srclines_dealloc(dbg,linebuf,linecount); } /* end, table_count > 0 */ } else { /* DW_DLV_OK */ /* table_count == 0. no lines in table. Just a line table header. */ if (do_print_dwarf) { int ores = 0; Dwarf_Unsigned off = 0; print_source_intro(cu_die); if (verbose) { print_one_die(dbg, cu_die, /* print_information= */ TRUE, /* indent_level= */ 0, /* srcfiles= */ 0, /* cnt= */ 0, /* ignore_die_stack= */TRUE); } if(line_context) { if (verbose > 2) { print_line_context_record(dbg,line_context); } ores = dwarf_srclines_table_offset(line_context, &off,&err); if (ores != DW_DLV_OK) { print_error(dbg,"dwarf_srclines_table_offset fail",ores,err); } else { printf(" Line table is present (offset 0x%" DW_PR_XZEROS DW_PR_DUx ") but no lines present\n", off); } } else { printf(" Line table is present but no lines present\n"); } } if(line_flag_selection == std || line_flag_selection == s2l) { dwarf_srclines_dealloc_b(line_context); } else { /* Original allocation. */ dwarf_srclines_dealloc(dbg,linebuf,linecount); } /* end, linecounttotal == 0 */ } }