From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 2DOsFUMdhl+BFAAAWB0awg (envelope-from ) for ; Tue, 13 Oct 2020 17:33:55 -0400 Received: by simark.ca (Postfix, from userid 112) id 56BC01EF6F; Tue, 13 Oct 2020 17:33:55 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.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 A720E1E58D for ; Tue, 13 Oct 2020 17:33:54 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 37FF7385042A; Tue, 13 Oct 2020 21:33:54 +0000 (GMT) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by sourceware.org (Postfix) with ESMTPS id 83117386101B for ; Tue, 13 Oct 2020 21:33:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 83117386101B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=alves.ped@gmail.com Received: by mail-wr1-f65.google.com with SMTP id n15so1171754wrq.2 for ; Tue, 13 Oct 2020 14:33:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=kxPsUQNj3dLCU46rQjBO9ZraZ4m02b3pR+Zk0rwmrps=; b=gLMCZpznI/ox/QCPMB2GkmxMdpZKXLacXLYrpsI71m3Sa/CUIRMp7cDgn8k7i70cqK 5NbD59Qms8TB4mlmlokh6x7FzrxqOLyAmHxJ8AKe5ldqPp5R1unegp+I/dY9w+FYz5f2 jGmsSX4YdIj8XsLH55xkh8G+2FtjVWkGTfzSX/HT5Q5hCPg037025ijpySX9Y1gIqfR2 YeQ+yGXwOxTKqQykCwGccM2+D3hJwWmoBl8VhbYAeEffcEhdxSx4VSXl/GDsxvALvVUU CVjgvlMPDtPTMxOtFQhMGIpCKeYQgBPLkf8ngB2EpPkpbRfqed5VncPhbEg5S/tzK+mb oNug== X-Gm-Message-State: AOAM530xbGYquLiyHfpNlJjoTAjRoSUGaCsjaaBSuDzlbMyMJfLxJXl2 C/beZyRHESlpbg+YUC1bie3MIUviu5khbg== X-Google-Smtp-Source: ABdhPJybpsGCj7MPeB2GeYHYIRhs55OGWFRSpP1gs7zqGTbtqX4ysHPPRNcg3Gt1n7NZ5vkMaTu3AQ== X-Received: by 2002:a05:6000:104c:: with SMTP id c12mr1664922wrx.133.1602624829417; Tue, 13 Oct 2020 14:33:49 -0700 (PDT) Received: from ?IPv6:2001:8a0:f91e:6d00:c80a:ea25:47ef:5f73? ([2001:8a0:f91e:6d00:c80a:ea25:47ef:5f73]) by smtp.gmail.com with ESMTPSA id z191sm348826wme.30.2020.10.13.14.33.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Oct 2020 14:33:48 -0700 (PDT) Subject: Re: [PATCH 3/5] gdb/testsuite/: Use -qualified in runto_main / mi_runto_main To: Simon Marchi , gdb-patches@sourceware.org References: <20201012004732.22999-1-pedro@palves.net> <20201012004732.22999-4-pedro@palves.net> From: Pedro Alves Message-ID: Date: Tue, 13 Oct 2020 22:33:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 10/13/20 7:06 PM, Simon Marchi wrote: > On 2020-10-11 8:47 p.m., Pedro Alves wrote: >> diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp >> index 732aed27b27..693c7d2c467 100644 >> --- a/gdb/testsuite/lib/mi-support.exp >> +++ b/gdb/testsuite/lib/mi-support.exp >> @@ -1056,7 +1056,7 @@ proc mi_run_to_main { } { >> # -1 if test suppressed, failed, timedout >> # 0 if test passed >> >> -proc mi_runto_helper {func run_or_continue} { >> +proc mi_runto_helper {func run_or_continue {qualified 0}} { > > For new options, I'd suggest using the parse_args procedure, instead of > using arguments with default values. That makes it nicer when a > procedure has multiple optional arguments and want to specifiy just one > (that isn't the first one). I agree that using parse_args is nice. I've used it recently in the MI --qualified patch, and also in a local patch I have that adds options to Dwarf::assemble. Here this is an internal routine, just a helper, not meant to be used as "public" api, so I didn't bother. But it's not really much trouble. I've done that change. > > So a call to mi_runto_helper would look like: > > mi_runto_helper main run -qualified Below's what I merged. Yay, we now have: "qualified" in gdb_breakpoint/runto, "-qualified" in mi_runto_helper, and "--qualified" in the actual MI command... :-) >From 8abd8ee8c878f52469896c716732a974e6abeebe Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Wed, 2 Sep 2020 23:20:45 +0100 Subject: [PATCH] gdb/testsuite/: Use -qualified in runto_main / mi_runto_main In some runtimes, there may be a "main" function in some class or namespace. The breakpoint created by runto_main may therefore have unexpected locations on some other functions than the actual main. These breakpoint locations can unexpectedly get hit during tests and lead to failures. I saw this while playing with AMD's ROCm toolchain -- I wrote a board file to run the testsuite against device kernels. There, the runtime calls a "main" function before the device kernel code is reached: Thread 4 "bit_extract" hit Breakpoint 1, 0x00007ffeea140960 in lld::elf::LinkerDriver::main(llvm::ArrayRef) () from /opt/rocm/lib/libamd_comgr.so.1 (gdb) bt #0 0x00007ffeea140960 in lld::elf::LinkerDriver::main(llvm::ArrayRef) () from /opt/rocm/lib/libamd_comgr.so.1 #1 0x00007ffeea2257a5 in lld::elf::link(llvm::ArrayRef, bool, llvm::raw_ostream&, llvm::raw_ostream&) () from /opt/rocm/lib/libamd_comgr.so.1 #2 0x00007ffeea1bc374 in COMGR::linkWithLLD(llvm::ArrayRef, llvm::raw_ostream&, llvm::raw_ostream&) () from /opt/rocm/lib/libamd_comgr.so.1 #3 0x00007ffeea1bfb09 in COMGR::InProcessDriver::execute(llvm::ArrayRef) () from /opt/rocm/lib/libamd_comgr.so.1 #4 0x00007ffeea1c4da9 in COMGR::AMDGPUCompiler::linkToExecutable() () from /opt/rocm/lib/libamd_comgr.so.1 #5 0x00007ffeea1fde20 in dispatchCompilerAction(amd_comgr_action_kind_s, COMGR::DataAction*, COMGR::DataSet*, COMGR::DataSet*, llvm::raw_ostream&) () from /opt/rocm/lib/libamd_comgr.so.1 #6 0x00007ffeea203a87 in amd_comgr_do_action () from /opt/rocm/lib/libamd_comgr.so.1 ... To avoid that, pass "qualified" to runto, in runto_main, so that gdb_breakpoint ends up creating a breakpoint with -qualified. This avoids creating breakpoints locations for other unrelated "main" functions. Note: I first tried making runto itself use "-qualified", but that caused regressions in the gdb.ada/ tests, which use runto without specifying the whole fully-qualified function name (i.e., without the package). So I end up restricting the -qualified to runto_main/mi_runto_main. The gdb.base/ui-redirect.exp change is necessary because that testcase is looking at what "save breakpoint" generates. gdb/testsuite/ChangeLog: * gdb.base/ui-redirect.exp: Expect "break -qualified main" in saved breakpoints file. * gdb.guile/scm-breakpoint.exp: Expect "-qualified main" when inspecting breakpoint list. * lib/gdb.exp (runto_main): Add "qualified" to options. * lib/mi-support.exp (mi_runto_helper): Add 'qualified' parameter, and handle it. (mi_runto_main): Pass 1 as qualified argument. Change-Id: I51468359ab0a518f05f7c0394c97f7e33b45fe69 --- gdb/testsuite/ChangeLog | 11 +++++++++++ gdb/testsuite/gdb.base/ui-redirect.exp | 2 +- gdb/testsuite/gdb.guile/scm-breakpoint.exp | 2 +- gdb/testsuite/lib/gdb.exp | 2 +- gdb/testsuite/lib/mi-support.exp | 16 +++++++++++++--- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 19b4e2b138c..ea6241b77c8 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2020-10-13 Pedro Alves + + * gdb.base/ui-redirect.exp: Expect "break -qualified main" in + saved breakpoints file. + * gdb.guile/scm-breakpoint.exp: Expect "-qualified main" when + inspecting breakpoint list. + * lib/gdb.exp (runto_main): Add "qualified" to options. + * lib/mi-support.exp (mi_runto_helper): Add 'qualified' parameter, + and handle it. + (mi_runto_main): Pass 1 as qualified argument. + 2020-10-13 Pedro Alves * lib/mi-support.exp (mi_runto_main): New proc. diff --git a/gdb/testsuite/gdb.base/ui-redirect.exp b/gdb/testsuite/gdb.base/ui-redirect.exp index ef0a79178c7..9e0a694c798 100644 --- a/gdb/testsuite/gdb.base/ui-redirect.exp +++ b/gdb/testsuite/gdb.base/ui-redirect.exp @@ -47,7 +47,7 @@ gdb_breakpoint "foo" gdb_breakpoint "bar" set cmds [multi_line_input \ - "break main" \ + "break -qualified main" \ " commands" \ " print 1" \ " end" \ diff --git a/gdb/testsuite/gdb.guile/scm-breakpoint.exp b/gdb/testsuite/gdb.guile/scm-breakpoint.exp index 7545392452e..3bcd5c81546 100644 --- a/gdb/testsuite/gdb.guile/scm-breakpoint.exp +++ b/gdb/testsuite/gdb.guile/scm-breakpoint.exp @@ -43,7 +43,7 @@ proc test_bkpt_basic { } { gdb_scm_test_silent_cmd "guile (define blist (breakpoints))" \ "get breakpoint list 1" gdb_test "guile (print (car blist))" \ - "" \ + "" \ "check main breakpoint" gdb_test "guile (print (breakpoint-location (car blist)))" \ "main" "check main breakpoint location" diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 608469953bf..4c9675f255f 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -689,7 +689,7 @@ proc runto { function args } { # If you don't want that, use gdb_start_cmd. proc runto_main { } { - return [runto main no-message] + return [runto main no-message qualified] } ### Continue, and expect to hit a breakpoint. diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index 732aed27b27..ea59288443e 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -1055,8 +1055,12 @@ proc mi_run_to_main { } { # It returns: # -1 if test suppressed, failed, timedout # 0 if test passed +# +# Supported options: +# +# -qualified -- pass --qualified to -break-insert -proc mi_runto_helper {func run_or_continue} { +proc mi_runto_helper {func run_or_continue args} { global suppress_flag if { $suppress_flag } { return -1 @@ -1065,10 +1069,16 @@ proc mi_runto_helper {func run_or_continue} { global mi_gdb_prompt expect_out global hex decimal fullname_syntax + parse_args {{qualified}} + set test "mi runto $func" set bp [mi_make_breakpoint -type breakpoint -disp del \ -func $func\(\\\(.*\\\)\)?] - mi_gdb_test "200-break-insert -t $func" "200\\^done,$bp" \ + set extra_opts "" + if {$qualified} { + append extra_opts "--qualified" + } + mi_gdb_test "200-break-insert $extra_opts -t $func" "200\\^done,$bp" \ "breakpoint at $func" if {$run_or_continue == "run"} { @@ -1089,7 +1099,7 @@ proc mi_runto {func} { # Just like runto_main but works with the MI interface. proc mi_runto_main {} { - return [mi_runto_helper "main" "run"] + return [mi_runto_helper "main" "run" -qualified] } # Next to the next statement base-commit: d3a071228e8f7cf9da017f2d0d6c28468a652795 -- 2.14.5