From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id fKwXHgmlsWBGagAAWB0awg (envelope-from ) for ; Fri, 28 May 2021 22:20:57 -0400 Received: by simark.ca (Postfix, from userid 112) id 6C2CB1F11C; Fri, 28 May 2021 22:20:57 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id E9BE51E813 for ; Fri, 28 May 2021 22:20:55 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9AB583857C74; Sat, 29 May 2021 02:20:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9AB583857C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1622254855; bh=Wr79cotRQMX2gqDvj74yrdhb0ZptVokLCDYxLVityKs=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=WAFPlZbJ1pTV8btVIJ5r5bshyS+r3QmUTKhjQ4yztEz9LaSyi59E8OQDZAw2K+Bt/ ovVAMn4FlYbxnrgNt1mMh93DbsXQE/TuyX7OSrjvsJpXYqIlWT8XnvrzwCaJMSYAP8 MBaVYv+5A95GLW1WvEa1+8ExbaZ2KfennspZ7ynY= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 63B313857C74 for ; Sat, 29 May 2021 02:20:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 63B313857C74 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 14T2KiBa027233 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 May 2021 22:20:48 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 14T2KiBa027233 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id DE6D81E813; Fri, 28 May 2021 22:20:43 -0400 (EDT) Subject: Re: [PATCH] [gdb.base] Add additional next commands for clang-12 and above in foll-exec.exp To: "Kumar N, Bhuvanendra" , "gdb-patches@sourceware.org" References: Message-ID: <50265efc-2fa2-8bb4-7285-60fa32b8ead2@polymtl.ca> Date: Fri, 28 May 2021 22:20:43 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Sat, 29 May 2021 02:20:44 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Cc: "George, Jini Susan" , "Achra, Nitika" , "Sharma, Alok Kumar" , "Tomar, Sourabh Singh" , "E, Nagajyothi" Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 2021-04-15 3:37 p.m., Kumar N, Bhuvanendra via Gdb-patches wrote: > [AMD Official Use Only - Internal Distribution Only] > > Hello All, > > I request all of you to please review this patch. Below are the details. > > Problem Description: > Following 8 test points started to fail after the clang patch(https://reviews.llvm.org/D91734). > > FAIL: gdb.base/foll-exec.exp: step through execlp call > FAIL: gdb.base/foll-exec.exp: step after execlp call > FAIL: gdb.base/foll-exec.exp: print execd-program/global_i (after execlp) > FAIL: gdb.base/foll-exec.exp: print execd-program/local_j (after execlp) > FAIL: gdb.base/foll-exec.exp: print follow-exec/local_k (after execlp) > FAIL: gdb.base/foll-exec.exp: step through execl call > FAIL: gdb.base/foll-exec.exp: step after execl call > FAIL: gdb.base/foll-exec.exp: print execd-program/local_j (after execl) > > Resolution: > > > These comments in the clang patch(https://reviews.llvm.org/D91734) explain/address the issue : > > ". . .the test is trying to "next" over a function call; gcc attributes all parameter evaluation to the function name, while clang will attribute each parameter to its own location. And when the parameters span multiple source lines, the is_stmt heuristic kicks in, so we stop on each line with actual parameters. > > This is not ideal IMO; I'd rather be more principled about (a) stop at every parameter, or (b) stop at no parameters. But without reworking how we do is_stmt, I think fiddling the test to do enough single-steps to actually get past the function call is okay." > > After this clang patch, we can see additional .debug_line entries created while handling the function call and parameter evaluation as mentioned in the commit message. Hence to suit the new clang behavior, its suggested to modify the test case for clang-12 and above. > > Thanks and Regards, > Bhuvan > > Patch content inlined: > > From b6c3646cdd40fae679131107a0b2be4ff5b9eae5 Mon Sep 17 00:00:00 2001 > From: =?UTF-8?q?=E2=80=9Cbhkumarn=E2=80=9D?= Bhuvanendra.KumarN@amd.com > Date: Fri, 16 Apr 2021 00:18:07 +0530 > Subject: [PATCH] [gdb.base] Additional next commands added for > clang-12 and above. > > After this clang patch(https://reviews.llvm.org/D91734), 8 test points > started to FAIL in this test case. As mentioned in this PR, > "...this test is trying to "next" over a function call; gcc attributes > all parameter evaluation to the function name, while clang will attribute > each parameter to its own location. And when the parameters span across > multiple source lines, the is_stmt heuristic kicks in, so we stop on each > line with actual parameters...". > We can see additional .debug_line entries getting created after this clang > patch, hence the test case is modified accordingly to suit the new clang > behavior. This test case modification is required for clang-12 and above. > > Line table: (before clang patch for the below code snippet) : > 0x000000b0: 84 address += 8, line += 2 > 0x000000000020196a 42 3 1 0 0 > 0x000000b1: 08 DW_LNS_const_add_pc (0x0000000000000011) > 0x000000b2: 41 address += 3, line += 5 > 0x000000000020197e 47 3 1 0 0 > > Line table: (after clang patch for the below code snippet) : > 0x000000b5: 84 address += 8, line += 2 > 0x0000000000201958 42 11 1 0 0 > 0x000000b6: 05 DW_LNS_set_column (4) > 0x000000b8: 75 address += 7, line += 1 > 0x000000000020195f 43 4 1 0 0 > 0x000000b9: 05 DW_LNS_set_column (3) > 0x000000bb: 73 address += 7, line += -1 > 0x0000000000201966 42 3 1 0 0 > 0x000000bc: 08 DW_LNS_const_add_pc (0x0000000000000011) > 0x000000bd: 4f address += 4, line += 5 > 0x000000000020197b 47 3 1 0 0 > > gdb.base/foll-exec.c test file snippet : > . . . > 42 execlp (prog, /* tbreak-execlp */ > 43 prog, > 44 "execlp arg1 from foll-exec", > 45 (char *) 0); > 46 > 47 printf ("foll-exec is about to execl(execd-prog)...\n"); > > Following 8 test points started to fail after the above clang patch. > > FAIL: gdb.base/foll-exec.exp: step through execlp call > FAIL: gdb.base/foll-exec.exp: step after execlp call > FAIL: gdb.base/foll-exec.exp: print execd-program/global_i (after execlp) > FAIL: gdb.base/foll-exec.exp: print execd-program/local_j (after execlp) > FAIL: gdb.base/foll-exec.exp: print follow-exec/local_k (after execlp) > FAIL: gdb.base/foll-exec.exp: step through execl call > FAIL: gdb.base/foll-exec.exp: step after execl call > FAIL: gdb.base/foll-exec.exp: print execd-program/local_j (after execl) > > gdb/testsuite/ChangeLog: > * gdb.base/foll-exec.exp: Additional next commands added for > clang-12 and above. > --- > gdb/testsuite/ChangeLog | 5 +++++ > gdb/testsuite/gdb.base/foll-exec.exp | 15 +++++++++++++-- > 2 files changed, 18 insertions(+), 2 deletions(-) For some reason I can't apply your patch, git tells me it's corrupt. Did you use git-send-email to send it? > diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog > index 52b0752276..ad289c135d 100644 > --- a/gdb/testsuite/ChangeLog > +++ b/gdb/testsuite/ChangeLog > @@ -1,3 +1,8 @@ > +2021-04-16 Bhuvanendra Kumar Bhuvanendra.KumarN@amd.com > + > + * gdb.base/foll-exec.exp: Additional next commands added for > + clang-12 and above. > + > 2021-02-12 Andrew Burgess andrew.burgess@embecosm.com > * gdb.fortran/allocated.exp: New file. > diff --git a/gdb/testsuite/gdb.base/foll-exec.exp b/gdb/testsuite/gdb.base/foll-exec.exp > index 6d5e21f54d..8b1fa42db9 100644 > --- a/gdb/testsuite/gdb.base/foll-exec.exp > +++ b/gdb/testsuite/gdb.base/foll-exec.exp > @@ -118,7 +118,14 @@ proc do_exec_tests {} { > # We should stop in execd-program, at its first statement. > # > set execd_line [gdb_get_line_number "after-exec" $srcfile2] > - send_gdb "next\n" > + # Clang-12 and above will emit extra .debug_line entries when > + # parameters span across multiple source lines, hence additional > + # next commands were added. > + if {[test_compiler_info {clang-1[2-9]-*}]} { > + send_gdb "next 3\n" > + } else { > + send_gdb "next\n" > + } > gdb_expect { > -re ".*xecuting new program: .*${testfile2}.*${srcfile2}:${execd_line}.*int local_j = argc;.*$gdb_prompt $"\ > {pass "step through execlp call"} > @@ -269,7 +276,11 @@ proc do_exec_tests {} { > # the newly-exec'd program, not after the remaining step-count > # reaches zero. > # > - send_gdb "next 2\n" > + if {[test_compiler_info {clang-1[2-9]-*}]} { > + send_gdb "next 3\n" > + } else { > + send_gdb "next 2\n" > + } > gdb_expect { > -re ".*xecuting new program: .*${testfile2}.*${srcfile2}:${execd_line}.*int local_j = argc;.*$gdb_prompt $"\ > {pass "step through execl call"} > -- > 2.17.1 Does it work if we just put the whole execlp call on a single line instead? Simon