Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/2] Add support procs (to lib/gdb.exp) for OpenMP
Date: Wed, 27 Sep 2017 15:31:00 -0000	[thread overview]
Message-ID: <20170927083114.1117b724@pinnacle.lan> (raw)
In-Reply-To: <20170927082748.5b379d06@pinnacle.lan>

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 } {


  reply	other threads:[~2017-09-27 15:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-27 15:27 [PATCH 0/2] OpenMP parallel region scope tests Kevin Buettner
2017-09-27 15:31 ` Kevin Buettner [this message]
2017-09-27 15:33 ` [PATCH 2/2] " Kevin Buettner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170927083114.1117b724@pinnacle.lan \
    --to=kevinb@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox