From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by sourceware.org (Postfix) with ESMTPS id CCB12385DC02 for ; Fri, 3 Apr 2020 22:21:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CCB12385DC02 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrew.burgess@embecosm.com Received: by mail-wm1-x344.google.com with SMTP id t203so203794wmt.2 for ; Fri, 03 Apr 2020 15:21:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=pksq3nQ38Yc1/a2QrguWyeejQsFDAXz8LCeTgdjBzic=; b=Py9BcjE7ihJXxLiJKT52V41I8UwqjwEjHTOiqlI8SwCkyyT7IcYelyeNZxecxLwJyz i5LcUnL0uK3ZTf2gT2V12gtkl6zXna2tPKJYNiH97PsVRkmwo7nK7UxekPKF85G5nH08 B7ERWGHFGn10/E7Flm9J6bFN3B3Lw5oo/Ewk683YTfI1HOdqs5+aGOR00m+0Nef775dB BHVfni4QExpFSkOVAzjlVigzUFLFzP09O08ntIUo76t664amKuOfwueLsfNU8GZO9UwE bt10C+jjnjLdobumG0Puof4NSlb8maJEFOeq4juEDf8hVQMGXnHkuXGSrkk2tf9qoHH5 s1LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=pksq3nQ38Yc1/a2QrguWyeejQsFDAXz8LCeTgdjBzic=; b=rnQNFMYUoeFyeELatfferIQyVb24YAA/jm7bh8YXyfjhjLWQ/s0ov+W6VEwqDvo9gY n0KRS+8VxM5oH79pnzQJarh3ErKH17DSrdDi1X2QXmetzV5UFiv39b/4GDYnO3lTgTff /76gVq8t0cxBdJo2dS1rFYe3dltkN2FFaQ/ekBwfiQMl8HAX0WzqDZnOpcKDFwaKedSK 1EVWVs1u9d8NxaK9Q4cM/KV3Xm0i8ov0O6MAm41IQTFrqlCL+AOSoaKrNsD2yBWTbck9 ivFSVU4/AfNHO6c/83gHt1r4R5oN5P3NtoFBTBzVMd4340gBG6JdUwzZj8VjOZOfeoGa FU6w== X-Gm-Message-State: AGi0PuZB7EZ+xkReXoD/nVmL7nO8W43DT4rWy4tpxqftmeGiWb0dP9RG s6wDk12DhcKuwPCWTWl8uvI0sfcPJJo= X-Google-Smtp-Source: APiQypISuNZ6BxlB4VGSnNcDqkfxPnZI59qc8lV8I3opD+Wj21Z3NYNCWAwbcoK7P9oKwwGf6HL74w== X-Received: by 2002:a7b:c7cb:: with SMTP id z11mr10644803wmk.15.1585952470546; Fri, 03 Apr 2020 15:21:10 -0700 (PDT) Received: from localhost (host86-186-80-207.range86-186.btcentralplus.com. [86.186.80.207]) by smtp.gmail.com with ESMTPSA id e5sm14064034wru.92.2020.04.03.15.21.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Apr 2020 15:21:10 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Bernd Edlinger , Tom Tromey , Andrew Burgess Subject: [PATCH 1/2] gdb/testsuite: Move helper function into lib/dwarf.exp Date: Fri, 3 Apr 2020 23:21:03 +0100 Message-Id: X-Mailer: git-send-email 2.14.5 In-Reply-To: References: In-Reply-To: References: X-Spam-Status: No, score=-25.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Fri, 03 Apr 2020 22:21:13 -0000 Every time I write a test making use of the DWARF assembler I end up copying in the function get_func_info. Duplicating code is bad, so lets put this function into lib/dwarf.exp and remove all of the duplicates. There should be no changes in the testsuite behaviour after this commit. gdb/testsuite/ChangeLog: * gdb.dwarf2/dw2-inline-many-frames.exp (get_func_info): Delete. * gdb.dwarf2/dw2-inline-small-func.exp: Pass options to get_func_info. (get_func_info): Delete. * gdb.dwarf2/dw2-is-stmt-2.exp (get_func_info): Delete. * gdb.dwarf2/dw2-is-stmt.exp (get_func_info): Delete. * lib/dwarf.exp (get_func_info): New function. --- gdb/testsuite/ChangeLog | 10 ++++++++++ gdb/testsuite/gdb.dwarf2/dw2-inline-many-frames.exp | 14 -------------- gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp | 16 +--------------- gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp | 14 -------------- gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp | 14 -------------- gdb/testsuite/lib/dwarf.exp | 16 ++++++++++++++++ 6 files changed, 27 insertions(+), 57 deletions(-) diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-many-frames.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-many-frames.exp index 146af8c6ef7..0c2c6612265 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-inline-many-frames.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-many-frames.exp @@ -40,20 +40,6 @@ if !$gcc_compiled { standard_testfile dw2-inline-many-frames.c dw2-inline-many-frames.S -# Extract the start, length, and end for function called NAME and -# create suitable variables in the callers scope. -proc get_func_info { name } { - global srcdir subdir srcfile - - upvar 1 "${name}_start" func_start - upvar 1 "${name}_len" func_len - upvar 1 "${name}_end" func_end - - lassign [function_range ${name} [list ${srcdir}/${subdir}/$srcfile]] \ - func_start func_len - set func_end "$func_start + $func_len" -} - set asm_file [standard_output_file $srcfile2] Dwarf::assemble $asm_file { global srcdir subdir srcfile srcfile2 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp index 777db062b37..4fcc3cfeac9 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp @@ -42,26 +42,12 @@ if !$gcc_compiled { standard_testfile dw2-inline-small-func-lbls.c dw2-inline-small-func.S \ dw2-inline-small-func.c dw2-inline-small-func.h -# Extract the start, length, and end for function called NAME and -# create suitable variables in the callers scope. -proc get_func_info { name } { - global srcdir subdir srcfile - - upvar 1 "${name}_start" func_start - upvar 1 "${name}_len" func_len - upvar 1 "${name}_end" func_end - - lassign [function_range ${name} [list ${srcdir}/${subdir}/$srcfile] {debug optimize=-O1}] \ - func_start func_len - set func_end "$func_start + $func_len" -} - set asm_file [standard_output_file $srcfile2] Dwarf::assemble $asm_file { global srcdir subdir srcfile srcfile3 srcfile4 declare_labels lines_label callee_subprog_label - get_func_info main + get_func_info main {debug optimize=-O1} cu {} { # It is important that the producer here be 'clang' as, at the diff --git a/gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp b/gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp index 436c4d01024..2fcad93e957 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp @@ -40,20 +40,6 @@ if !$gcc_compiled { standard_testfile dw2-is-stmt-2.c dw2-is-stmt-2.S -# Extract the start, length, and end for function called NAME and -# create suitable variables in the callers scope. -proc get_func_info { name } { - global srcdir subdir srcfile - - upvar 1 "${name}_start" func_start - upvar 1 "${name}_len" func_len - upvar 1 "${name}_end" func_end - - lassign [function_range ${name} [list ${srcdir}/${subdir}/$srcfile]] \ - func_start func_len - set func_end "$func_start + $func_len" -} - set asm_file [standard_output_file $srcfile2] Dwarf::assemble $asm_file { global srcdir subdir srcfile diff --git a/gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp b/gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp index 1bcf5b0c698..e200e91fd77 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp @@ -40,20 +40,6 @@ if !$gcc_compiled { standard_testfile dw2-is-stmt.c dw2-is-stmt.S -# Extract the start, length, and end for function called NAME and -# create suitable variables in the callers scope. -proc get_func_info { name } { - global srcdir subdir srcfile - - upvar 1 "${name}_start" func_start - upvar 1 "${name}_len" func_len - upvar 1 "${name}_end" func_end - - lassign [function_range ${name} [list ${srcdir}/${subdir}/$srcfile]] \ - func_start func_len - set func_end "$func_start + $func_len" -} - set asm_file [standard_output_file $srcfile2] Dwarf::assemble $asm_file { global srcdir subdir srcfile diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp index 93bde76de35..a7dbe25fd45 100644 --- a/gdb/testsuite/lib/dwarf.exp +++ b/gdb/testsuite/lib/dwarf.exp @@ -164,6 +164,22 @@ proc function_range { func src {options {debug}} } { return [list "${func}_label - $func_label_offset" $func_length] } +# Extract the start, length, and end for function called NAME and +# create suitable variables in the callers scope. +proc get_func_info { name {options {debug}} } { + global srcdir subdir srcfile + + upvar 1 "${name}_start" func_start + upvar 1 "${name}_len" func_len + upvar 1 "${name}_end" func_end + + lassign [function_range ${name} \ + [list ${srcdir}/${subdir}/$srcfile] \ + ${options}] \ + func_start func_len + set func_end "$func_start + $func_len" +} + # A DWARF assembler. # # All the variables in this namespace are private to the -- 2.14.5