[PATCH 1/2] Add support procs (to lib/gdb.exp) for OpenMP
Kevin Buettner
kevinb@redhat.com
Wed Sep 27 15:31:00 GMT 2017
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 } {
More information about the Gdb-patches
mailing list