From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by sourceware.org (Postfix) with ESMTPS id 424EE3850873 for ; Wed, 8 Jun 2022 15:37:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 424EE3850873 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f48.google.com with SMTP id o8so1035185wro.3 for ; Wed, 08 Jun 2022 08:37:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=2GvV+MVepnUuUxYjVjE4zqww5835rgAHZ4xZ2wv1xYY=; b=dtQzXsYjAgKfrOx1vuqxVqQmY/v6wsy8+A5Xs8VFFBjFpRHghK6xg/5uzDQ6o3T4Ke Nk0MUsWXy3Mezkr30DjRDMr2viCgXdOg846iUObodQ7uoA9upTZVCCgUwVaOfpCtSRge ahUe3V3ayXInP7SD0X+E6UbWAOwAQYIGJKZtvVGWeSww15U8w502Kdl7esySqT9rcEOa 8k/awzfk5pJsZK4jOojXzYvI1gK2GFJaCUi4tyVMktk/Tu3a3pFSAZK3aXM+R4jZq72D znrwguNAF0wjTeWlF3aPaSQ+wG6OuBFVl72qcnpmIFdq7zt3God5sq7jr1PZE715b21q egkw== X-Gm-Message-State: AOAM531xmyHMpdd9UruHyY6/ZM3zaZJvmHiWbtVidKXYH5WydiwoUQbl Cj+L4LzDJJRajIGOvauAOwBFQHQMaXM= X-Google-Smtp-Source: ABdhPJx9e2TRvkzq9GJbpSwJIOOZ/vtZDcmpjRVS6GdrzuEBrjytycsybLx2BeprKgKZBGrzgF1qQA== X-Received: by 2002:a5d:43ce:0:b0:214:fdd9:1189 with SMTP id v14-20020a5d43ce000000b00214fdd91189mr27125225wrr.449.1654702624025; Wed, 08 Jun 2022 08:37:04 -0700 (PDT) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id bp11-20020a5d5a8b000000b0020c5253d926sm7989078wrb.114.2022.06.08.08.37.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Jun 2022 08:37:03 -0700 (PDT) Message-ID: Date: Wed, 8 Jun 2022 16:37:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v3 02/14] Change gdb.base/skip-solib.exp deal with lack of epilogue information Content-Language: en-US To: Bruno Larsen , gdb-patches@sourceware.org References: <20220526151041.23223-1-blarsen@redhat.com> <20220526151041.23223-3-blarsen@redhat.com> From: Pedro Alves In-Reply-To: <20220526151041.23223-3-blarsen@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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: , X-List-Received-Date: Wed, 08 Jun 2022 15:37:07 -0000 On 2022-05-26 16:10, Bruno Larsen via Gdb-patches wrote: > When running gdb.base/skip-solib.exp, the backtrace tests could fail if > the compiler did not emit epilogue information for trivial epilogues, I found "emit epilogue information" very confusing FWIW. When I read that the first time, I thought this was talking about unwind info for the prologue after the stack is destroyed, and I wondered why not fix clang instead. I think the following would be more accurate: "fail with compilers that associate prologue insns with the function's last statement line instead of the function's closing brace". > despite the feature being fully functional. As an example, when testing > skipping the function square, the testsuite would show > > --- > gdb/testsuite/gdb.base/skip-inline.exp | 18 +++++++++++------- > gdb/testsuite/gdb.base/skip-solib-lib.c | 3 ++- > gdb/testsuite/gdb.base/skip-solib-main.c | 3 ++- > gdb/testsuite/gdb.base/skip-solib.exp | 12 ++++++++++-- > 4 files changed, 25 insertions(+), 11 deletions(-) > > diff --git a/gdb/testsuite/gdb.base/skip-inline.exp b/gdb/testsuite/gdb.base/skip-inline.exp > index f6e9926b66c..327ea676140 100644 > --- a/gdb/testsuite/gdb.base/skip-inline.exp > +++ b/gdb/testsuite/gdb.base/skip-inline.exp > @@ -35,16 +35,20 @@ gdb_test "skip function foo" "Function foo will be skipped when stepping\." > gdb_test "bt" "\\s*\\#0\\s+main.*" "in the main" > gdb_test "step" ".*" "step into baz, since foo will be skipped" > gdb_test "bt" "\\s*\\#0\\s+baz.*" "in the baz, since foo was skipped" > -gdb_test "step" ".*" "step in the baz" > -gdb_test "bt" "\\s*\\#0\\s+baz.*" "still in the baz" > -gdb_test "step" ".*" "step back to main" > +gdb_step_until_regexp ".*x = 0; x = baz \\(foo \\(\\)\\).*" FWIW, I'd remove the "regexp" from the function's name, just call it gdb_step_until. > gdb_test "bt" "\\s*\\#0\\s+main.*" "again in the main" > gdb_test "step" ".*" "step again into baz, since foo will be skipped" > gdb_test "bt" "\\s*\\#0\\s+baz.*" "again in the baz" > -gdb_test "step" ".*" "step in the baz, again" > -gdb_test "bt" "\\s*\\#0\\s+baz.*" "still in the baz, again" > -gdb_test "step" ".*" "step back to main, again" > -gdb_test "bt" "\\s*\\#0\\s+main.*" "again back to main" > +gdb_step_until_regexp "main \\(\\) at .*" "step back to main, again" > +gdb_test "bt" "\\s*\\#0.*main.*" "again back to main" > + > +# because clang doesn't add epilogue information, having a set number of "add epilogue information" here falls in the "very confusing" camp for me. > +# steps puts clang more and more out of sync with gcc. It is unlikely that > +# the effort of keeping both outputs will be useful. > +if {[test_compiler_info "clang-*"]} { > + untested "Multiple steps are not supported with clang" > + return > +} That begs the question -- what if clang changes in the future? Nobody will remember to update this. I think it would be better to add a procedure to lib/gdb.exp that detects this automatically, if possible. I.e., with the gdb.base/skip.exp program, note: (gdb) list foo 36 return 0; 37 } 38 39 int 40 foo () 41 { 42 return 0; 43 } 44 45 static void (gdb) 46 test_skip (void) 47 { 48 } 49 50 static void 51 end_test_skip_file_and_function (void) 52 { 53 abort (); 54 } 55 (gdb) when the program is compiled with clang, we get this: (gdb) info line 42 Line 42 of "../../../src/gdb/testsuite/gdb.base/skip.c" starts at address 0x201804 and ends at 0x201810 . (gdb) info line 43 Line 43 of "../../../src/gdb/testsuite/gdb.base/skip.c" is at address 0x201830 but contains no code. while if the program is compiled with gcc, we get this: (gdb) info line 42 Line 42 of "/home/pedro/rocm/gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/skip.c" starts at address 0x117d and ends at 0x1182 . (gdb) info line 43 Line 43 of "/home/pedro/rocm/gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/skip.c" starts at address 0x1182 and ends at 0x1184 . Or even with a simple "just main" program, like so: (gdb) list 1 int 2 main () 3 { 4 return 0; 5 } we get this with gcc: (gdb) info line 4 Line 4 of "main.c" starts at address 0x1131 and ends at 0x1136 . (gdb) info line 5 Line 5 of "main.c" starts at address 0x1136 and ends at 0x1138. (gdb) and this with clang: (gdb) info line 4 Line 4 of "main.c" starts at address 0x40111d and ends at 0x40111f. (gdb) info line 5 Line number 5 is out of range for "main.c". (gdb) I think that we can use that to write a caching proc like: # Return true if the compiler emits line information associating prologue insns with # the function's closing brace. Return false if not, meaning the prologue # associates prologue instructions with function's last line with a statement. gdb_caching_proc have_prologue_line_info { use gdb_simple_compile the simple main program from above use "info line 5", and return false if we get "out of range", otherwise return true. }