From patchwork Tue Jul 21 04:02:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 7770 Received: (qmail 42886 invoked by alias); 21 Jul 2015 04:02:10 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 42874 invoked by uid 89); 21 Jul 2015 04:02:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_20, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f73.google.com Received: from mail-pa0-f73.google.com (HELO mail-pa0-f73.google.com) (209.85.220.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 21 Jul 2015 04:02:07 +0000 Received: by pacom8 with SMTP id om8so3503945pac.0 for ; Mon, 20 Jul 2015 21:02:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:message-id:date:subject:from:to :content-type; bh=MplMdc06F1knfJlqU7TB/oyxU03vgjKZWFVouGqedEA=; b=GePkoSXkX4F040twdZPzrFnfjIyM2vz2yNJAJIfo2mF3CJ3BwHk/xmVT73m8+Yk455 sKpRSzsShz+vwlmuR5MMcsd3U7Gojy/4715FTqR3VREYo+D8gjnYTd+UD8poXKSa8RNV bQd71GxXGfd9oHyn57KzTA1NMBNQSCCkNx0l5sdH8F8uuDpaEP2pTzwVLtndIR+uVmIo pFHMlfsdVYEhlrVF0jK/2NSQS5wemfQGjJ9kZjRHRlkMSbsAbpltIQPLrNyfQdmHQ45F OEyiRQ642JCuw0cyhOXbqYhLEyzbO+gnJHmfQ9LaRYjT+egv8ii2GOFO7QTjFCT8uhZh Omtw== X-Gm-Message-State: ALoCoQmlx36x3Dy/oHDt4O8U54k/LeChGJjXbRAMVED3UG1F1NEwKPNaqaxrXxp+AvKLq3owSqrn5zoU1UsoqE9KRM9omW+hkQZUV5KbTZldPxpHvYvhBYLSRTh1XuOvA8eoKfzpmYy7mITsx4sGnzcozmYqZ9UM9Z4gxz1SFipOV+Us7EfiaP4= MIME-Version: 1.0 X-Received: by 10.70.49.77 with SMTP id s13mr16414486pdn.14.1437451325667; Mon, 20 Jul 2015 21:02:05 -0700 (PDT) Message-ID: <047d7bfe971ea61c69051b5ab775@google.com> Date: Tue, 21 Jul 2015 04:02:05 +0000 Subject: [PATCH 2/8] gen-pert-test: compiler-info From: Doug Evans To: gdb-patches@sourceware.org X-IsSubscribed: yes Hi. This patch cleans up compiler-info handling. 2015-07-20 Doug Evans * gdb.base/watchpoint.exp (test_complex_watchpoint): Remove compiler_info references. * gdb.cp/temargs.exp: Ditto. * lib/gdb.exp: Unset compiler_info instead of setting to "unknown". (get_compiler_info): Early exit if already computed. Set compiler_info to "unknown" if there was a problem. (test_compiler_info): Add function comment. Call get_compiler_info. diff --git a/gdb/testsuite/gdb.base/watchpoint.exp b/gdb/testsuite/gdb.base/watchpoint.exp index b2924d7..fcc9a8d 100644 --- a/gdb/testsuite/gdb.base/watchpoint.exp +++ b/gdb/testsuite/gdb.base/watchpoint.exp @@ -464,12 +464,11 @@ proc test_complex_watchpoint {} { pass $test } -re "can't compute CFA for this frame.*\r\n$gdb_prompt $" { - global compiler_info no_hw + global no_hw # GCC < 4.5.0 does not get LOCATIONS_VALID set by dwarf2read.c. # Therefore epilogue unwinder gets applied which is # incompatible with dwarf2_frame_cfa. - verbose -log "compiler_info: $compiler_info" if {$no_hw && ([test_compiler_info {gcc-[0-3]-*}] || [test_compiler_info {gcc-4-[0-4]-*}])} { xfail "$test (old GCC has broken watchpoints in epilogues)" diff --git a/gdb/testsuite/gdb.cp/temargs.exp b/gdb/testsuite/gdb.cp/temargs.exp index e5aff51..f086a63 100644 --- a/gdb/testsuite/gdb.cp/temargs.exp +++ b/gdb/testsuite/gdb.cp/temargs.exp @@ -34,7 +34,6 @@ if {![runto_main]} { # NOTE: prepare_for_testing calls get_compiler_info, which we need # for the test_compiler_info calls. # gcc 4.4 and earlier don't emit enough info for some of our template tests. -verbose -log "compiler_info: $compiler_info" set have_older_template_gcc 0 set have_pr_41736_fixed 1 set have_pr_45024_fixed 1 diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 0805de9..4edc95f 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -2788,12 +2788,20 @@ gdb_caching_proc target_is_gdbserver { return $is_gdbserver } -set compiler_info "unknown" +# N.B. compiler_info is intended to be local to this file. +# Call test_compiler_info with no arguments to fetch its value. +# Yes, this is counterintuitive when there's get_compiler_info, +# but that's the current API. +if [info exists compiler_info] { + unset compiler_info +} + set gcc_compiled 0 set hp_cc_compiler 0 set hp_aCC_compiler 0 # Figure out what compiler I am using. +# The result is cached so only the first invocation runs the compiler. # # ARG can be empty or "C++". If empty, "C" is assumed. # @@ -2860,6 +2868,11 @@ proc get_compiler_info {{arg ""}} { global hp_cc_compiler global hp_aCC_compiler + if [info exists compiler_info] { + # Already computed. + return 0 + } + # Choose which file to preprocess. set ifile "${srcdir}/lib/compiler.c" if { $arg == "c++" } { @@ -2901,8 +2914,14 @@ proc get_compiler_info {{arg ""}} { } } - # Reset to unknown compiler if any diagnostics happened. + # Set to unknown if for some reason compiler_info didn't get defined. + if ![info exists compiler_info] { + verbose -log "get_compiler_info: compiler_info not provided" + set compiler_info "unknown" + } + # Also set to unknown compiler if any diagnostics happened. if { $unknown } { + verbose -log "get_compiler_info: got unexpected diagnostics" set compiler_info "unknown" } @@ -2936,18 +2955,18 @@ proc get_compiler_info {{arg ""}} { return 0 } +# Return the compiler_info string if no arg is provided. +# Otherwise the argument is a glob-style expression to match against +# compiler_info. + proc test_compiler_info { {compiler ""} } { global compiler_info + get_compiler_info - # if no arg, return the compiler_info string - - if [string match "" $compiler] { - if [info exists compiler_info] { - return $compiler_info - } else { - perror "No compiler info found." - } - } + # If no arg, return the compiler_info string. + if [string match "" $compiler] { + return $compiler_info + } return [string match $compiler $compiler_info] }