From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 100514 invoked by alias); 29 May 2015 13:43:29 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 100503 invoked by uid 89); 29 May 2015 13:43:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f43.google.com Received: from mail-pa0-f43.google.com (HELO mail-pa0-f43.google.com) (209.85.220.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 29 May 2015 13:43:27 +0000 Received: by pacux9 with SMTP id ux9so18361155pac.3 for ; Fri, 29 May 2015 06:43:25 -0700 (PDT) X-Received: by 10.68.205.2 with SMTP id lc2mr15153488pbc.147.1432907005402; Fri, 29 May 2015 06:43:25 -0700 (PDT) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by mx.google.com with ESMTPSA id jd4sm5690055pbd.46.2015.05.29.06.43.22 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 29 May 2015 06:43:24 -0700 (PDT) From: Yao Qi To: Jan Kratochvil Cc: Yao Qi , Andreas Schwab , gdb-patches@sourceware.org Subject: Re: [PATCH] Fix wrong assertions References: <87vbg1eg08.fsf@igel.home> <20150513140106.GB3023@host1.jankratochvil.net> <86bnh3pw61.fsf@gmail.com> <20150529113101.GA15460@host1.jankratochvil.net> Date: Fri, 29 May 2015 13:43:00 -0000 In-Reply-To: <20150529113101.GA15460@host1.jankratochvil.net> (Jan Kratochvil's message of "Fri, 29 May 2015 13:31:01 +0200") Message-ID: <86382fpki0.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-05/txt/msg00716.txt.bz2 Jan Kratochvil writes: Hi, Jan, thanks for your explanations... they are very helpful. >> Further, what is "partially ambiguous result" in the comments below? > > The terminology seems bogus there. > > "partially ambiguous" was meant the chain: > main -> a -> -> d > An intersection of all possible chains. > Sounds like "partially ambiguous" is equivalent to "ambiguous". > >> /* Determined tail calls for constructing virtual tail call frames. */ >>=20 >> struct call_site_chain >> { >> /* Initially CALLERS =3D=3D CALLEES =3D=3D LENGTH. For partially am= biguous result >> CALLERS + CALLEES < LENGTH. */ >> int callers, callees, length; >>=20 >> /* Variably sized array with LENGTH elements. Later [0..CALLERS-1] = contain >> top (GDB "prev") sites and [LENGTH-CALLEES..LENGTH-1] contain bot= tom >> (GDB "next") sites. One is interested primarily in the PC field.= */ >> struct call_site *call_site[1]; >> }; >>=20 >> I am confused by the usage of the variable-sized array call_site, >> elements from 0 to CALLERS-1 are top sites, and elements from >> LENGTH-CALLEES to LENGTH-1 are bottom sites, so I conclude that >> CALLERS-1 < LENGTH-CALLEES, then CALLERS + CALLEES < LENGTH + 1, >> then CALLERS + CALLEES =3D< LENGTH. Is it right? > > Yes, that is right. Initially there is some chain (let's say the longest= one If that is right, the assert below is too strict, isn't? /* See call_site_find_chain_1 why there is no way to reach the bottom cal= lee PC again. In such case there must be two different code paths to reach it, therefore some of the former determined intermediate PCs must diff= er and the unambiguous chain gets shortened. */ gdb_assert (result->callers + result->callees < result->length); > but that doe snot matter). Consequently its elements from the middle are > being removed and there remains only some few unambiguous top and > bottom ones. If there is no call sites removed from the chain during the intersection, CALLERS + CALLEES =3D=3D LENGTH, right? in function chain_candidate, result->length is set by the length of a chain. If this chain is the shortest one, CALLERS + CALLEES =3D=3D LENGTH otherwise, CALLERS + CALLEES < LENGTH. Is it right? If so, we need to relax the condition in the assert and update the comments. > > The original idea why the comparison should be sharp ("<") was that if th= ere > are multiple chains like (0xaddr show jmp instruction address): > main(0x100) -> a(0x200) -> d(0x400) > main(0x100) -> a(0x200) -> c(0x300) -> d(0x400) > then - such situation cannot exist - if two jmp instructions in "a" have = the > same address they must also jump to the same address (*). > > (*) jump to a computed address would be never considered for the DWARF > tail-call records. > > So there could be: > main(0x100) -> a(0x200) -> d(0x400) > main(0x100) -> a(0x270) -> c(0x300) -> d(0x400) > But then "a" frame itself is ambiguous and it must not be displayed. > > I did not realize that there can be self-tail-call: > main(0x100) -> a(0x200) -> d(0x400) > main(0x100) -> a(0x280) -> a(0x200) -> d(0x400) > which intersects to: > main(0x100) -> ? -> a(0x200) -> d(0x400) > And so if the first chain was chosen the > main(0x100) -> a(0x200) -> d(0x400) > then the final intersection has callers+callees=3D=3Dlength. What are the definitions of CALLERS, CALLEES, top and bottom? given this ex= ample? --=20 Yao (=E9=BD=90=E5=B0=A7)