From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12098 invoked by alias); 19 Jul 2007 15:31:00 -0000 Received: (qmail 12088 invoked by uid 22791); 19 Jul 2007 15:31:00 -0000 X-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,DK_POLICY_SIGNSOME,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 19 Jul 2007 15:30:57 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.1/8.13.1) with ESMTP id l6JFUo8f011662 for ; Thu, 19 Jul 2007 11:30:50 -0400 Received: from pobox.toronto.redhat.com (pobox.toronto.redhat.com [172.16.14.4]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id l6JFUk4l010341; Thu, 19 Jul 2007 11:30:46 -0400 Received: from [172.16.14.55] (toner.toronto.redhat.com [172.16.14.55]) by pobox.toronto.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id l6JFUjgJ023091; Thu, 19 Jul 2007 11:30:46 -0400 Message-ID: <469F83A5.8090803@redhat.com> Date: Thu, 19 Jul 2007 15:31:00 -0000 From: Sami Wagiaalla User-Agent: Thunderbird 1.5.0.12 (X11/20070530) MIME-Version: 1.0 To: Roland McGrath CC: frysk Subject: Re: Dwarf expertise needed References: <20070718224349.165984D05CF@magilla.localdomain> In-Reply-To: <20070718224349.165984D05CF@magilla.localdomain> Content-Type: multipart/mixed; boundary="------------070708090400010203010306" X-Virus-Checked: Checked by ClamAV on sourceware.org X-IsSubscribed: yes Mailing-List: contact frysk-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-owner@sourceware.org X-SW-Source: 2007-q3/txt/msg00159.txt.bz2 This is a multi-part message in MIME format. --------------070708090400010203010306 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 2034 >> That will do, although I think there might be a bug there :(. Let me >> double check. >> > > There is certainly a bug hit by Stan's test case, since it gets an error. > So yes there is a bug, I have not checked to see if it is Stan's bug, but here it goes: This is the test case that I am using: inline void second(){ int* a = 0; a[0] = 0; <-------- pc } void first(){ second(); } int main(){ first(); return 0; } So if I try to dwarf_getscopes at pc i get 0 scopes returned. The problem is in the pc_record function from dwarf_getscopes.c: > /* Now we are in a scope that contains the concrete inlined instance. > Search it for the inline function's abstract definition. > If we don't find it, return to search the containing scope. > If we do find it, the nonzero return value will bail us out > of the postorder traversal. */ > return __libdw_visit_scopes (depth, die, &origin_match, NULL, &a); > } The problem is that if the die passed to __libdw_visit_scopes has no children, __libdw_visit_scopes returns -1 which means that pc_record returns -1 and the search aborts, and no scopes are returned. The particular childless die in this case happens to be the one corresponding to main. I can fudge it by adding some variables to main and get the following scopes: scopes[0] DW_TAG_lexical_block name: scopes[1] DW_TAG_inlined_subroutine name: second scopes[2] DW_TAG_compile_unit name: /to/scratch/swagiaal/frysks/frysk/frysk-core/frysk/pkglibdir/funit-scopes.c I have attached two of possible patches: patch1 just check for children before the call, patch2 takes the responsibility away from pc_record and relies on the later call to pc_origin in dwarf_getscopes: [...] int result = __libdw_visit_scopes (0, &cu, &pc_match, &pc_record, &a); if (result == 0 && a.scopes != NULL) result = __libdw_visit_scopes (0, &cu, &origin_match, NULL, &a); [...] I personally like patch2 better. This way you only do two searches. Thoughts ? Thanks, Sami Wagiaalla --------------070708090400010203010306 Content-Type: text/plain; name="patch1" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch1" Content-length: 713 Index: libdw/dwarf_getscopes.c =================================================================== RCS file: /cvs/frysk/frysk-imports/elfutils/libdw/dwarf_getscopes.c,v retrieving revision 1.3 diff -u -r1.3 dwarf_getscopes.c --- libdw/dwarf_getscopes.c 26 Apr 2007 15:18:42 -0000 1.3 +++ libdw/dwarf_getscopes.c 19 Jul 2007 15:22:53 -0000 @@ -170,6 +170,10 @@ /* Not there yet. */ return 0; + struct Dwarf_Die_Chain child; + if (INTUSE(dwarf_child) (&die->die, &child.die) != 0) + return 0; + /* Now we are in a scope that contains the concrete inlined instance. Search it for the inline function's abstract definition. If we don't find it, return to search the containing scope. --------------070708090400010203010306 Content-Type: text/plain; name="patch2" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch2" Content-length: 1073 Index: libdw/dwarf_getscopes.c =================================================================== RCS file: /cvs/frysk/frysk-imports/elfutils/libdw/dwarf_getscopes.c,v retrieving revision 1.3 diff -u -r1.3 dwarf_getscopes.c --- libdw/dwarf_getscopes.c 26 Apr 2007 15:18:42 -0000 1.3 +++ libdw/dwarf_getscopes.c 19 Jul 2007 15:24:47 -0000 @@ -159,23 +159,8 @@ return -1; return 0; } - - - /* We've recorded the scopes back to one that is a concrete inlined - instance. Now return out of the traversal back to the scope - containing that instance. */ - - assert (a->inlined); - if (depth >= a->inlined) - /* Not there yet. */ - return 0; - - /* Now we are in a scope that contains the concrete inlined instance. - Search it for the inline function's abstract definition. - If we don't find it, return to search the containing scope. - If we do find it, the nonzero return value will bail us out - of the postorder traversal. */ - return __libdw_visit_scopes (depth, die, &origin_match, NULL, &a); + + return 0; } --------------070708090400010203010306--