From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 37632 invoked by alias); 1 Aug 2018 02:56:56 -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 37614 invoked by uid 89); 1 Aug 2018 02:56:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,GIT_PATCH_1,KAM_SHORT,KAM_TK autolearn=ham version=3.3.2 spammy=UD:tk X-HELO: sessmg23.ericsson.net Received: from sessmg23.ericsson.net (HELO sessmg23.ericsson.net) (193.180.251.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 01 Aug 2018 02:56:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1533092211; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=SJJ85f/zG5ivZ+D77e1Y4vfyN03JnnmT4wk5nlBpcB8=; b=aDxg3lzqudc17yTW9PIDil4nof7oGo5VZOxekwvHAbk005NiktRZwxp+bVesFmG/ t6lHkMFq8HPyG0AJTk3Y2BBoswdNiKfPpLrcmjVO6/7NJjFLuqYQ2Pli3JPv2Sh/ US4cO28HwOYux8h3gn87+APyB6CkGTT2xwCYi2ESCDc=; Received: from ESESSMB503.ericsson.se (Unknown_Domain [153.88.183.121]) by sessmg23.ericsson.net (Symantec Mail Security) with SMTP id CE.85.22015.371216B5; Wed, 1 Aug 2018 04:56:51 +0200 (CEST) Received: from ESESBMB503.ericsson.se (153.88.183.170) by ESESSMB503.ericsson.se (153.88.183.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 1 Aug 2018 04:56:50 +0200 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (153.88.183.157) by ESESBMB503.ericsson.se (153.88.183.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Wed, 1 Aug 2018 04:56:50 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xxZhwmYhfWFN63uQhSwirLZVD38b+FOT3Z5Jzso3CDw=; b=jb5fRsb/LPYtFXBS7cg/c7lH9Z6l/C11bclqYc505ss8Eb/T1eIjSPbKktgRM1FJ/jFLiutR6n0QptWigelcspSfJYTsRJrVH+ayWlj/agMGvOasHBeMdalGOMSdfydp7mNKixjoL3eaj4DMOxmyw1hGGtzuyjVbMO2Q696XJb4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; Received: from [10.0.0.110] (192.222.164.54) by SN6PR15MB2397.namprd15.prod.outlook.com (2603:10b6:805:24::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.17; Wed, 1 Aug 2018 02:56:48 +0000 Subject: Re: [PATCH 8/8] Test case for functions with non-contiguous ranges To: Kevin Buettner , References: <20180625233239.49dc52ea@pinnacle.lan> <20180625235706.5efafbfd@pinnacle.lan> From: Simon Marchi Message-ID: <8e0d6c58-397e-9612-9183-6c0aa0781e23@ericsson.com> Date: Wed, 01 Aug 2018 02:56:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180625235706.5efafbfd@pinnacle.lan> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-Path: simon.marchi@ericsson.com Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-IsSubscribed: yes X-SW-Source: 2018-08/txt/msg00009.txt.bz2 On 2018-06-26 02:57 AM, Kevin Buettner wrote: > See comments in the new files for what this is about - I tried to > explain it all there. This test looks really nice and thorough. > +# This test can only be run on targets which support DWARF-2 and use gas. > +if {![dwarf2_support]} { > + verbose "Skipping DW_AT_ranges test." I think "unsupported" would be more appropriate. > + return 0 > +} > + > +# The .c files use __attribute__. This comment seems wrong/outdated. > +if [get_compiler_info] { > + return -1 > +} > +if !$gcc_compiled { > + verbose "Skipping DW_AT_ranges test." "unsupported" here too? > + return 0 > +} > > + > +standard_testfile dw2-ranges-func.c dw2-ranges-func-dw.S > + > +# We need to know the size of integer and address types in order to > +# write some of the debugging info we'd like to generate. > +# > +# For that, we ask GDB by debugging our test program. Any program > +# would do, but since we already have it specifically for this > +# testcase, might as well use that. > + > +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { > + return -1 > +} > + > +set asm_file [standard_output_file $srcfile2] > +Dwarf::assemble $asm_file { > + global srcdir subdir srcfile srcfile2 > + declare_labels integer_label volatile_label ranges_label ranges2_label L > + set int_size [get_sizeof "int" 4] > + > + # Find start address and length for our functions. > + set main_func \ > + [function_range main [list ${srcdir}/${subdir}/$srcfile]] > + set foo_func \ > + [function_range foo [list ${srcdir}/${subdir}/$srcfile]] > + set foo_low_func \ > + [function_range foo_low [list ${srcdir}/${subdir}/$srcfile]] > + set bar_func \ > + [function_range bar [list ${srcdir}/${subdir}/$srcfile]] > + set baz_func \ > + [function_range baz [list ${srcdir}/${subdir}/$srcfile]] > + > + set main_start [lindex $main_func 0] > + set main_len [lindex $main_func 1] > + set foo_start [lindex $foo_func 0] > + set foo_end {$foo_start + [lindex $foo_func 1]} > + set foo_low_start [lindex $foo_low_func 0] > + set foo_low_len [lindex $foo_low_func 1] > + set foo_low_end {$foo_low_start + $foo_low_len} > + set bar_start [lindex $bar_func 0] > + set bar_len [lindex $bar_func 1] > + set baz_start [lindex $baz_func 0] > + set baz_len [lindex $baz_func 1] If you want to make this shorter, you could use lassign: https://www.tcl.tk/man/tcl/TclCmd/lassign.htm Something like: lassign [function_range main [list ${srcdir}/${subdir}/$srcfile]] \ main_start main_len I see that you use expressions like " [lindex $main_func 0]" below, it would be clearer to always use the *_start or *_len variables. > + # Generate ranges data. > + ranges {is_64 [is_64_target]} { > + ranges_label: sequence { > + {range {$foo_start } $foo_end} > + {range {$foo_low_start} $foo_low_end} > + } > + ranges2_label: sequence { > + {range {$foo_start } $foo_end} > + {range {$foo_low_start} $foo_low_end} > + {range {$main_start} $main_start + $main_len} > + {range {$bar_start} $bar_start + $bar_len} > + {range {$baz_start} $baz_start + $baz_len} > + } ranges_label and ranges2_label could perhaps have more expressive names? > +set test "foo and foo_low are at different addresses" > +if {$foo_low_addr == $foo_addr} { > + fail $test > +} else { > + pass $test > +} This can be gdb_assert {$foo_low_addr != $foo_addr} "foo and foo_low are at different addresses" > + > +# This more permissive RE for "break foo" will allow a breakpoint on > +# multiple locations to PASS. */ > +gdb_test "break foo" \ > + "Breakpoint.*at.*" \ > + "break foo (2nd time)" We should avoid having trailing parenthesis in test messages: https://sourceware.org/gdb/wiki/GDBTestcaseCookbook#Do_not_use_.22tail_parentheses.22_on_test_messages In a test like yours, that is really multiple independent scenarios tested one after the other, I like to structure the test like this: proc_with_prefix test_something {} { ... } proc_with_prefix test_something_else {} { ... } test_something test_something_else Using proc_with_prefix automatically prefixes test names with the name of the proc (which is usually self-explanatory). This avoids have to manually differentiate test names such as in "break foo (2nd time)". I also like to do a clean_restart at the beginning of each test procedure, to reduce the chance of inter-dependency between each test procedure, though it's not strictly necessary. Simon