
Hello community, here is the log from the commit of package dwarfextract checked in at Fri Nov 28 16:23:16 CET 2008. -------- --- dwarfextract/dwarfextract.changes 2008-10-31 14:58:41.000000000 +0100 +++ dwarfextract/dwarfextract.changes 2008-11-28 15:20:04.000000000 +0100 @@ -1,0 +2,5 @@ +Fri Nov 28 15:19:36 CET 2008 - dgollub@suse.de + +- implement handling of unnamed const_types (bnc#446032) + +------------------------------------------------------------------- calling whatdependson for head-i586 Old: ---- dwarfextract-20081031.tar.bz2 New: ---- dwarfextract-20081128.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ dwarfextract.spec ++++++ --- /var/tmp/diff_new_pack.bo8249/_old 2008-11-28 16:22:48.000000000 +0100 +++ /var/tmp/diff_new_pack.bo8249/_new 2008-11-28 16:22:48.000000000 +0100 @@ -1,5 +1,5 @@ # -# spec file for package dwarfextract (Version 20081031) +# spec file for package dwarfextract (Version 20081128) # # Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany. # @@ -21,7 +21,7 @@ Name: dwarfextract Url: http://lkcd.sourceforge.net Summary: Extract and reduce DWARF debugging information -Version: 20081031 +Version: 20081128 Release: 1 License: GPL v2 or later; LGPL v3 or later Group: Development/Tools/Other @@ -56,6 +56,8 @@ %{_bindir}/dwarfextract %changelog +* Fri Nov 28 2008 dgollub@suse.de +- implement handling of unnamed const_types (bnc#446032) * Fri Oct 31 2008 dgollub@suse.de - Updated to dwarfextract 20081030: * ignore stmt_list on purpose for conversion. ++++++ dwarfextract-20081031.tar.bz2 -> dwarfextract-20081128.tar.bz2 ++++++ diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/dwarfextract-20081031/CMakeLists.txt new/dwarfextract-20081128/CMakeLists.txt --- old/dwarfextract-20081031/CMakeLists.txt 2008-10-31 15:06:39.000000000 +0100 +++ new/dwarfextract-20081128/CMakeLists.txt 2008-11-28 14:33:48.000000000 +0100 @@ -68,3 +68,5 @@ SET( CPACK_SOURCE_PACKAGE_FILE_NAME "dwarfextract-${DWARFEXTRACT_VERSION}" ) INCLUDE( CPack ) +SET ( BUILD_NAME "foobar" CACHE STRING "Build" ) + diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/dwarfextract-20081031/CTestConfig.cmake new/dwarfextract-20081128/CTestConfig.cmake --- old/dwarfextract-20081031/CTestConfig.cmake 2008-10-31 15:06:39.000000000 +0100 +++ new/dwarfextract-20081128/CTestConfig.cmake 2008-11-28 14:33:48.000000000 +0100 @@ -7,3 +7,4 @@ set(CTEST_DROP_SITE "marvin.suse.de") set(CTEST_DROP_LOCATION "/~dgollub/cdash/submit.php?project=dwarfextract") set(CTEST_DROP_SITE_CDASH TRUE) + diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/dwarfextract-20081031/dwarfextract.c new/dwarfextract-20081128/dwarfextract.c --- old/dwarfextract-20081031/dwarfextract.c 2008-10-31 15:06:39.000000000 +0100 +++ new/dwarfextract-20081128/dwarfextract.c 2008-11-28 14:33:48.000000000 +0100 @@ -70,6 +70,7 @@ #include "dwarfextract_list.h" #include "dwarfextract_list_pointers.h" #include "dwarfextract_refs.h" +#include "dwarfextract_show.h" #include <stdio.h> #include <errno.h> @@ -114,6 +115,7 @@ DwarfExtract_List *proto_names = NULL; /* struct prototype offsets in new Producer Dbg */ DwarfExtract_List *pointers = NULL; +DwarfExtract_List *consttypes = NULL; struct avl_table *tree_base, *alias_tree; @@ -489,6 +491,7 @@ /* Pointers which need translation of reference */ pointers = dwarfextract_list_new(INITIAL_NEEDPOINTERS, sizeof(DwarfExtract_Pointers)); + consttypes = dwarfextract_list_new(INITIAL_NEEDPOINTERS, sizeof(DwarfExtract_Pointers)); init_misc_area(); init_pieces_area(); @@ -517,6 +520,7 @@ dwarfextract_list_free(proto_names); dwarfextract_list_free(pointers); + dwarfextract_list_free(consttypes); } elf_end(elf); diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/dwarfextract-20081031/dwarfextract_convert.c new/dwarfextract-20081128/dwarfextract_convert.c --- old/dwarfextract-20081031/dwarfextract_convert.c 2008-10-31 15:06:39.000000000 +0100 +++ new/dwarfextract-20081128/dwarfextract_convert.c 2008-11-28 14:33:48.000000000 +0100 @@ -285,7 +285,6 @@ /* String experiment */ case DW_AT_comp_dir: /* ignored on purpose! */ - case DW_AT_producer: /* ignored on purpose! */ /* TODO: Review */ case DW_AT_name: diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/dwarfextract-20081031/dwarfextract_die.c new/dwarfextract-20081128/dwarfextract_die.c --- old/dwarfextract-20081031/dwarfextract_die.c 2008-10-31 15:06:39.000000000 +0100 +++ new/dwarfextract-20081128/dwarfextract_die.c 2008-11-28 14:33:48.000000000 +0100 @@ -408,6 +408,38 @@ *isptr = ARRAYLINK; } } + if (type_tag == DW_TAG_const_type) { + /* this thing points to an unnamed const_type; return + the offset of the die the pointer points to */ + if (!get_attr(type_die, DW_AT_type, &attr)) { + /* having no type attribute is possible if + this is a void * */ + ptroffset = 0 ; + *isptr = CONSTTYPELINK; + } else { + get_refoffset(attr, &type_offset); + /* ptroffset will be passed to the caller */ + ptroffset = type_offset; + /* arrays of arrays will be + handled the same way as other + types; only the final array link to + the type will be returned in + *isptr as such */ + get_die(dbg, type_offset, &type_die); + get_tag(type_die, &type_tag); + /* do not return CONSTTYPELINK for const_type of + const_type or const_type of pointer */ + if (type_tag != DW_TAG_pointer_type && + type_tag != DW_TAG_const_type) { + /* setting this causes this const_type + to be handled specially by creating + the die at the end of the run */ + *isptr = CONSTTYPELINK; + } else { + } + } + } + } countchildren: @@ -734,6 +766,44 @@ } /* + * return 1 if this die is an unnamed const_type + * else return 0 + */ +int +is_unnamed_const_type(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Half tag, char *namep) +{ + Dwarf_Off type_offset; + Dwarf_Die type_die; + Dwarf_Attribute attr; + Dwarf_Half type_tag; + + /* assuming get_type_values() has created namep and assigned + MYNO_DIE_NAME to an unnamed die */ + if (tag == DW_TAG_const_type) { + if (!strcmp(namep, MYNO_DIE_NAME)) { + /* if this is const_type to a pointer or a const_type + to an array link do NOT consider it an unnamed + const_type */ + if (get_attr(die, DW_AT_type, &attr)) { + get_refoffset(attr, &type_offset); + get_die(dbg, type_offset, &type_die); + get_tag(type_die, &type_tag); + if (type_tag == DW_TAG_pointer_type || + type_tag == DW_TAG_const_type) { + /* this is const_type to pointer or + pointer to const_type */ + return 0; + } + } + + return 1; + } + } + return 0; +} + + +/* * return 1 if this die is an unnamed array link * else return 0 */ diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/dwarfextract-20081031/dwarfextract_die.h new/dwarfextract-20081128/dwarfextract_die.h --- old/dwarfextract-20081031/dwarfextract_die.h 2008-10-31 15:06:39.000000000 +0100 +++ new/dwarfextract-20081128/dwarfextract_die.h 2008-11-28 14:33:48.000000000 +0100 @@ -12,6 +12,7 @@ int child_count(Dwarf_Debug, Dwarf_Die); int is_unnamed_pointer(Dwarf_Debug, Dwarf_Die, Dwarf_Half, char *); int is_unnamed_array(Dwarf_Debug, Dwarf_Die, Dwarf_Half, char *); +int is_unnamed_const_type(Dwarf_Debug, Dwarf_Die, Dwarf_Half, char *); char *die_type (Dwarf_Die); diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/dwarfextract-20081031/dwarfextract.h new/dwarfextract-20081128/dwarfextract.h --- old/dwarfextract-20081031/dwarfextract.h 2008-10-31 15:06:39.000000000 +0100 +++ new/dwarfextract-20081128/dwarfextract.h 2008-11-28 14:33:48.000000000 +0100 @@ -12,8 +12,10 @@ #define LFOUND 1 #define LUNPTR 2 #define LUNARRAY 3 +#define LUNCONSTTYPE 4 #define PTRLINK 1 #define ARRAYLINK 2 +#define CONSTTYPELINK 3 diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/dwarfextract-20081031/dwarfextract_list.c new/dwarfextract-20081128/dwarfextract_list.c --- old/dwarfextract-20081031/dwarfextract_list.c 2008-10-31 15:06:39.000000000 +0100 +++ new/dwarfextract-20081128/dwarfextract_list.c 2008-11-28 14:33:48.000000000 +0100 @@ -30,6 +30,7 @@ extern DwarfExtract_List *proto_names; extern DwarfExtract_List *pointers; +extern DwarfExtract_List *consttypes; extern int startsec; extern int current_file_number; @@ -389,6 +390,7 @@ DwarfExtract_List *copy_ref_containing_type; DwarfExtract_List *copy_pointers; + DwarfExtract_List *copy_consttypes; if (Pflag) { gettimeofday(&tv, &tz); @@ -407,6 +409,11 @@ printf ("NOTE: increase INITIAL_NEEDPOINTERS above %d\n", pointers->used); } + if (consttypes->used > INITIAL_NEEDPOINTERS) { + printf ("NOTE: increase INITIAL_NEEDPOINTERS above %d\n", + consttypes->used); + } + if (num_needarrs > INITIAL_NEEDARRAYS) { printf ("NOTE: increase INITIAL_NEEDARRAYS above %d\n", num_needarrs); @@ -425,6 +432,10 @@ dwarfextract_list_sort(pointers, pointers_compare); copy_pointers = dwarfextract_list_copy(pointers); + dwarfextract_list_sort(consttypes, pointers_compare); + copy_consttypes = dwarfextract_list_copy(consttypes); + + sort_needarrs(); /* and make identical lists for the proto translations */ needarr_refp2 = alloc_offset_list(num_needarrs); @@ -484,6 +495,15 @@ ((DwarfExtract_Pointers *) copy_pointers->refs + j)->ref = rp2; } } + /* and if any unnamed constttypes pointed to it, + point them to the full type as well */ + if (dwarfextract_list_lookup(consttypes, rp1b, &j, &j2, pointers_get_offset)) { + /* modify the alternate list */ + for (; j<=j2; j++) { + ((DwarfExtract_Pointers *) copy_consttypes->refs + j)->ref = rp2; + } + } + /* and if any unnamed array links pointed to it, point them to the full type as well */ if (lookup_needarr_ref(rp1b, &j, &j2)) { @@ -512,6 +532,9 @@ dwarfextract_list_free(pointers); pointers = copy_pointers; + + dwarfextract_list_free(consttypes); + consttypes = copy_consttypes; /* no need to sort - walked sequentially from here on */ free (needarr_refp); @@ -530,6 +553,7 @@ a pointer created */ if (pflag) { printf ("resolving %d dies needing pointers\n", pointers->used); + printf ("resolving %d dies needing consttypess\n", consttypes->used); } for (i=0; i<pointers->used; i++) { fnd = 0; @@ -599,6 +623,77 @@ } } + /* CONSTTYPES */ + for (i=0; i<consttypes->used; i++) { + fnd = 0; + if (((DwarfExtract_Pointers *)consttypes->refs + i)->typep == 0) { + offset = ((DwarfExtract_Pointers *)consttypes->refs + i)->ref; + if (offset < FMAX) { + /* a void pointer has no type attribute, + so the offset is 0*FMAX + file number */ + /* leave ((DwarfExtract_Pointers *)consttypes->refs + i) NULL */ + } else { + if (lookup_type_ref(offset, &typep)) { + fnd = 1; + ((DwarfExtract_Pointers *)consttypes->refs + i)->typep = typep; + } else { + aliasp = lookup_alias_ref(offset); + if (aliasp){ + ((DwarfExtract_Pointers *)consttypes->refs + i)->typep = + aliasp->typep; + typep = aliasp->typep; + fnd = 1; + } else { + printf ( + "Pointers slot %d: offset %#llx <%lld> cannot be resolved; ABORT\n\n", + i, offset, offset); + exit(1); + } + } + /* propagate the found one to the rest of + the array */ + if (fnd) { + for (j=i+1; j<consttypes->used; j++) { + if (((DwarfExtract_Pointers *)consttypes->refs + j)->ref == + offset) { + ((DwarfExtract_Pointers *)consttypes->refs + j)->typep = + typep; + } + } + } + } + } + } + /* make the new dies for the unnamed consttypes and connect + the referencing dies to them */ + for (i=0; i<consttypes->used; i++) { + /* this is the type that this die needs a pointer to: */ + typep = ((DwarfExtract_Pointers *)consttypes->refs + i)->typep; + if (typep == NULL) { + /* a void *; the pointer we make will not + have a type attribute */ + /* make all the void *'s point to the same p_die */ + if (void_pointer_die == 0) { + dp2 = make_pointer_die(0); + void_pointer_die = dp2; + } + dp1 = ((DwarfExtract_Pointers *)consttypes->refs + i)->diep; + /* link this die to the void pointer die */ + link_to_pointer(dp1, void_pointer_die); + } else { + /* link this die to the single pointer to this type */ + if (typep->ptrto == NULL) { + dp2 = make_pointer_die(typep->pdie); + typep->ptrto = dp2; + } + dp1 = ((DwarfExtract_Pointers *)consttypes->refs + i)->diep; + /* link this die to the pointer die */ + link_to_pointer(dp1, typep->ptrto); + } + } + /* CONSTTYPES */ + + /* fill in the typenode pointer in the list of dies needing an array link created */ if (pflag) { diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/dwarfextract-20081031/dwarfextract_show.c new/dwarfextract-20081128/dwarfextract_show.c --- old/dwarfextract-20081031/dwarfextract_show.c 2008-10-31 15:06:39.000000000 +0100 +++ new/dwarfextract-20081128/dwarfextract_show.c 2008-11-28 14:33:48.000000000 +0100 @@ -400,11 +400,24 @@ avl_t_init(&my_trav, tree); node = (struct typenode *)avl_t_first(&my_trav, tree); + printf("members\thfnum\thdiesum\thnamele\thnmsum\tsize\ttag\toffset\t\tnamep\n"); while (node) { - printf ("%p: (%d)(%lld)(%d)(%lld)(%s)", - node,node->members,node->hash,node->size, - node->tag,node->namep); - printf ("ref:%lld\n", node->offset); + + unsigned int hashfilenum = ((node->hash >> 53) & 0x7ff); + unsigned int hashdiesum = ((node->hash >> 37) & 0xffff); + unsigned int hashnamelen = ((node->hash >> 22) & 0x7fff); + unsigned int hashnamesum = ((node->hash >> 0) & 0x3fffff); + + printf("%d\t", node->members); + printf("%d\t", hashfilenum); + printf("%d\t", hashdiesum); + printf("%d\t", hashnamelen); + printf("%d\t", hashnamesum); + printf("%d\t%#x\t%#-10x\t%s\n", node->size, + (int) node->tag, + node->offset, + node->namep); + node = (struct typenode *)avl_t_next(&my_trav); } return; diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/dwarfextract-20081031/dwarfextract_show.h new/dwarfextract-20081128/dwarfextract_show.h --- old/dwarfextract-20081031/dwarfextract_show.h 2008-10-31 15:06:39.000000000 +0100 +++ new/dwarfextract-20081128/dwarfextract_show.h 2008-11-28 14:33:48.000000000 +0100 @@ -18,4 +18,6 @@ void show_union(Dwarf_Debug, Dwarf_Die, char *, int, int); void show_array(Dwarf_Debug, Dwarf_Die, char *, int , int); +void printTree(struct avl_table *tree); + #endif /* _DWARFEXTRACT_SHOW_H_ */ diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/dwarfextract-20081031/dwarfextract_tree_types.c new/dwarfextract-20081128/dwarfextract_tree_types.c --- old/dwarfextract-20081031/dwarfextract_tree_types.c 2008-10-31 15:06:39.000000000 +0100 +++ new/dwarfextract-20081128/dwarfextract_tree_types.c 2008-11-28 14:33:48.000000000 +0100 @@ -165,6 +165,14 @@ retval = LUNARRAY; goto lookupexit; } + if (is_unnamed_const_type(dbg, die, tag, namep)) { + /* don't save un-named const_types'; we'll provide + them to the dies that need them during + do_reference_translations() */ + retval = LUNCONSTTYPE; + goto lookupexit; + } + worktype.hash = hash; worktype.members = members; diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/dwarfextract-20081031/dwarfextract_walk.c new/dwarfextract-20081128/dwarfextract_walk.c --- old/dwarfextract-20081031/dwarfextract_walk.c 2008-10-31 15:06:39.000000000 +0100 +++ new/dwarfextract-20081128/dwarfextract_walk.c 2008-11-28 14:33:48.000000000 +0100 @@ -47,6 +47,7 @@ extern DwarfExtract_List *proto_names; extern DwarfExtract_List *pointers; +extern DwarfExtract_List *consttypes; /* * process all DIE's in all compilation units @@ -284,7 +285,13 @@ will be added to those types that reference them (at the end of the program) */ do_this_one = 0; + } else if (fndtype == LUNCONSTTYPE) { + /* this is an unnamed const type that + will be added to those types that reference + them (at the end of the program) */ + do_this_one = 0; } + } if (debug) { printf ("%s: after lookups, do this one:%d\n", @@ -323,6 +330,17 @@ get_refoffset(attr, &array_offset); add_to_needs_arr_list(dbg, array_offset, typeoffset, new_p_die); + } else if (isptr == CONSTTYPELINK) { + /* this die links to a const_type; add it to the + list of dies for which a const_type needs to + be created at the end */ + /* the pointer dies themselves are not + created yet (see LUNCONSTTYPE) */ + DwarfExtract_Pointers *consttype_slot; + consttype_slot = (DwarfExtract_Pointers *) dwarfextract_list_add_empty_slot(consttypes); + consttype_slot->ref = typeoffset * FMAX + current_file_number; + consttype_slot->diep = new_p_die; + consttype_slot->typep = 0; } /* this is a child; link it to its parent */ diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/dwarfextract-20081031/tests/CMakeLists.txt new/dwarfextract-20081128/tests/CMakeLists.txt --- old/dwarfextract-20081031/tests/CMakeLists.txt 2008-10-31 15:06:39.000000000 +0100 +++ new/dwarfextract-20081128/tests/CMakeLists.txt 2008-11-28 14:33:48.000000000 +0100 @@ -16,6 +16,12 @@ TEST_COMPILE_C_NOTLINK( "REGRESSION_const_array" "const_array.c" ) TEST_COMPILE_C_NOTLINK( "REGRESSION_self_undeclared_struct_const_pointer" "self_undeclared_struct_const_pointer.c" ) +# Build Simple Struct dummy +ADD_CUSTOM_TARGET( test_simplestruct ALL gcc -g -O0 -c ${CMAKE_CURRENT_SOURCE_DIR}/simple_struct.c -o simple_struct.o ) + +# Call dwarfextract multiple times +ADD_TEST( test_multiplecalls ${CMAKE_CURRENT_SOURCE_DIR}/multi_dwarfextract_call.sh simple_struct.o ) + ADD_EXECUTABLE( perf_sort_by_offset perf_sort_by_offset.c ../dwarfextract_refs.c ../dwarfextract_list_new.c ) TARGET_LINK_LIBRARIES( perf_sort_by_offset -ldwarf -lelf ) ADD_TEST( perf_sort_by_offset perf_sort_by_offset -f ${CMAKE_CURRENT_SOURCE_DIR}/sample.offsets ) diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/dwarfextract-20081031/tests/multi_dwarfextract_call.sh new/dwarfextract-20081128/tests/multi_dwarfextract_call.sh --- old/dwarfextract-20081031/tests/multi_dwarfextract_call.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/dwarfextract-20081128/tests/multi_dwarfextract_call.sh 2008-11-28 14:33:48.000000000 +0100 @@ -0,0 +1,21 @@ +#!/bin/bash -x + +TMPDIR=`mktemp -d /tmp/testing-dwarfextract-XXXXXXXX` + +PREV_SIZE=0 + +../dwarfextract $1 $TMPDIR/kerntypes || exit 1 + +for n in `seq 1 10`; do + CUR_SIZE=`du $TMPDIR/kerntypes | awk '{ print $1 }'` + ../dwarfextract $TMPDIR/kerntypes -c $1 + + if ! [[ "$n" -eq "1" || "$CUR_SIZE" -eq "$PREV_SIZE" ]]; then + exit 1; + fi; + + PREV_SIZE=$CUR_SIZE; + +done; + +exit 0; diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/dwarfextract-20081031/tests/simple_struct.c new/dwarfextract-20081128/tests/simple_struct.c --- old/dwarfextract-20081031/tests/simple_struct.c 1970-01-01 01:00:00.000000000 +0100 +++ new/dwarfextract-20081128/tests/simple_struct.c 2008-11-28 14:33:48.000000000 +0100 @@ -0,0 +1,4 @@ +struct foobar { + unsigned int a; + int b; +}; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun... -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org
participants (1)
-
root@Hilbert.suse.de