From patchwork Wed Sep 27 15:31:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Buettner X-Patchwork-Id: 23176 Received: (qmail 38028 invoked by alias); 27 Sep 2017 15:31:19 -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 37729 invoked by uid 89); 27 Sep 2017 15:31:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Sep 2017 15:31:16 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 57B1B3E2B7 for ; Wed, 27 Sep 2017 15:31:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 57B1B3E2B7 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kevinb@redhat.com Received: from pinnacle.lan (ovpn-117-96.phx2.redhat.com [10.3.117.96]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3A05F16900 for ; Wed, 27 Sep 2017 15:31:15 +0000 (UTC) Date: Wed, 27 Sep 2017 08:31:14 -0700 From: Kevin Buettner To: gdb-patches@sourceware.org Subject: [PATCH 1/2] Add support procs (to lib/gdb.exp) for OpenMP Message-ID: <20170927083114.1117b724@pinnacle.lan> In-Reply-To: <20170927082748.5b379d06@pinnacle.lan> References: <20170927082748.5b379d06@pinnacle.lan> MIME-Version: 1.0 X-IsSubscribed: yes gdb/testsuite/ChangeLog: * lib/gdb.exp (gdb_compile_openmp, openmp_setup): New procs. --- gdb/testsuite/lib/gdb.exp | 82 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 48fec2f..252a006 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -3847,6 +3847,88 @@ proc gdb_compile_objc {source dest type options} { } } +# Build an OpenMP program from SOURCE. See prefatory comment for +# gdb_compile, above, for discussion of the parameters to this proc. + +proc gdb_compile_openmp {source dest type options} { + switch -glob [test_compiler_info] { + "gcc-*" { + if { !([istarget "*-*-cygwin*"] + || [istarget "*-*-mingw*"] + || [istarget "*-*-pe*"]) } { + lappend options "additional_flags=-fopenmp" + } + } + default { + # Don't know what flags to pass for this compiler + } + } + + return [gdb_compile $source $dest $type $options] +} + +# Set auto-load safe-path and possibly sysroot for debugging an OpenMP +# program. This is needed because, at the moment, when the compiler +# is gcc, a python plugin associated with libgomp needs to be loaded +# for OpenMP debugging support. +# +# If auto-load safe-path is not set, GDB won't be able to autoload the +# requisite python script. This proc attempts to find the location +# of the plugin so that auto-load safe-path may be set to a +# that (restrictive) location. (Setting it to / would also work, but +# has the potential to load unwanted plugins.) +# +# For remote targets, GDB is not currently able to load a python +# script from the remote target and must instead rely on the host +# filesystem to find the script. If sysroot is either unset or set to +# "target:", set sysroot to / so that the python plugin can be found. + +proc openmp_setup {binfile} { + global gdb_prompt + + switch -glob [test_compiler_info] { + "gcc-*" { + set ldd [gdb_find_ldd] + set command "$ldd $binfile" + set result [catch "exec $command" output] + verbose -log "result of $command is $result" + verbose -log "output of $command is $output" + if {$result != 0 || $output == ""} { + untested "Failed to run ldd on OpenMP executable" + return -1 + } + + set foundgomp [regexp -line {=> (.+)/libgomp\.so} $output -> gomppath] + if {$foundgomp == 0 || $gomppath == ""} { + untested "libgomp not found in ldd output for OpenMP executable" + return -1 + } + verbose -log "libgomp path is $gomppath" + + gdb_test_no_output "set auto-load safe-path $gomppath" + + # Set sysroot for native-gdbserver testing + if [is_remote target] { + set sysroot "" + set test "show sysroot" + gdb_test_multiple $test $test { + -re "The current system root is \"(.*)\"\..*${gdb_prompt} $" { + set sysroot $expect_out(1,string) + } + } + if {$sysroot == "" || $sysroot == "target:"} { + gdb_test_no_output "set sysroot /" + } + } + } + default { + untested "Can't set up testing for OpenMP" + return -1 + } + } + return "" +} + proc send_gdb { string } { global suppress_flag if { $suppress_flag } {