From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11036 invoked by alias); 29 Aug 2008 09:14:55 -0000 Received: (qmail 11020 invoked by uid 22791); 29 Aug 2008 09:14:53 -0000 X-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_73 X-Spam-Check-By: sourceware.org Received: from e28smtp02.in.ibm.com (HELO e28esmtp02.in.ibm.com) (59.145.155.2) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 29 Aug 2008 09:13:58 +0000 Received: from d28relay04.in.ibm.com (d28relay04.in.ibm.com [9.184.220.61]) by e28esmtp02.in.ibm.com (8.13.1/8.13.1) with ESMTP id m7T9Dh9R007755 for ; Fri, 29 Aug 2008 14:43:43 +0530 Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v9.0) with ESMTP id m7T9DfjJ1212632 for ; Fri, 29 Aug 2008 14:43:41 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.13.1/8.13.3) with ESMTP id m7T9DfiP006502 for ; Fri, 29 Aug 2008 14:43:41 +0530 Received: from [9.124.35.32] ([9.124.35.32]) by d28av04.in.ibm.com (8.13.1/8.12.11) with ESMTP id m7T9Df8C005903 for ; Fri, 29 Aug 2008 14:43:41 +0530 Message-ID: <48B7BE86.9070905@linux.vnet.ibm.com> Date: Fri, 29 Aug 2008 09:14:00 -0000 From: Prerna Saxena User-Agent: Thunderbird 2.0.0.14 (X11/20080501) MIME-Version: 1.0 To: systemtap@sourceware.org Subject: [RFC PATCH 1/2] Bug Translator 3016 : Error accessing members of anonymous structs / unions Content-Type: multipart/mixed; boundary="------------020205010404010805040703" X-Virus-Checked: Checked by ClamAV on sourceware.org X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2008-q3/txt/msg00525.txt.bz2 This is a multi-part message in MIME format. --------------020205010404010805040703 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 190 Hi all, This patch modifies tapsets.cxx to enable members of anonymous structs/ unions to be recognised by the systemtap translator. Pls let me know your comments.. Regards, Prerna Saxena --------------020205010404010805040703 Content-Type: text/plain; name="anon-union-1.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="anon-union-1.patch" Content-length: 3040 Signed-off-by: Prerna Saxena Index: systemtap/tapsets.cxx =================================================================== --- systemtap.orig/tapsets.cxx +++ systemtap/tapsets.cxx @@ -1866,6 +1866,8 @@ struct dwflpp { Dwarf_Die *die = vardie; Dwarf_Die struct_die; + Dwarf_Attribute temp_attr; + unsigned i = 0; while (i < components.size()) { @@ -1924,9 +1926,9 @@ struct dwflpp switch (dwarf_child (die, die_mem)) { case 1: /* No children. */ - throw semantic_error ("empty struct " - + string (dwarf_diename_integrate (die) ?: "")); - break; + clog<<"\n Empty Struct " + <<(dwarf_diename_integrate(die)?:""); + return NULL; case -1: /* Error. */ default: /* Shouldn't happen */ throw semantic_error (string (typetag == DW_TAG_union_type ? "union" : "struct") @@ -1941,14 +1943,36 @@ struct dwflpp while (dwarf_tag (die) != DW_TAG_member || ({ const char *member = dwarf_diename_integrate (die); member == NULL || string(member) != components[i].second; })) + { + if ( dwarf_diename (die) == NULL ) // handling Anonymous structs/unions + { + Dwarf_Die temp_die = *die; + + if (!dwarf_attr_integrate (&temp_die, DW_AT_type, &temp_attr)) + { + clog<<"\n Error in obtaining type attribute for " + <<(dwarf_diename(&temp_die)?:""); + return NULL; + } + + if ( !dwarf_formref_die (&temp_attr,&temp_die) ) + { + clog<<"\n Error in decoding type attribute for " + <<(dwarf_diename(&temp_die)?:""); + return NULL; + } + + Dwarf_Die *result_die = translate_components(pool, tail, pc, components, &temp_die, &temp_die, &temp_attr ); + + if (result_die != NULL) + { + *attr_mem = temp_attr; + return result_die; + } + } if (dwarf_siblingof (die, die_mem) != 0) - { - stringstream alternatives; - print_members (&struct_die, alternatives); - throw semantic_error ("field '" + components[i].second - + "' not found (alternatives:" - + alternatives.str () + ")"); - } + return NULL; + } if (dwarf_attr_integrate (die, DW_AT_data_member_location, attr_mem) == NULL) @@ -2230,6 +2254,8 @@ struct dwflpp Dwarf_Die die_mem, *die = NULL; die = translate_components (&pool, &tail, pc, components, &vardie, &die_mem, &attr_mem); + if(!die) + throw semantic_error("Translation failure"); /* Translate the assignment part, either x = $foo->bar->baz[NN] @@ -2297,6 +2323,8 @@ struct dwflpp Dwarf_Die die_mem, *die = NULL; die = translate_components (&pool, &tail, pc, components, vardie, &die_mem, &attr_mem); + if(!die) + throw semantic_error("Translation Failure"); /* Translate the assignment part, either x = $return->bar->baz[NN] --------------020205010404010805040703--