From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9541 invoked by alias); 23 Aug 2013 20:37:03 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 9481 invoked by uid 89); 23 Aug 2013 20:37:03 -0000 X-Spam-SWARE-Status: No, score=-7.7 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 23 Aug 2013 20:37:02 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r7NKb09Y006767 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 23 Aug 2013 16:37:01 -0400 Received: from barimba.redhat.com (ovpn-113-142.phx2.redhat.com [10.3.113.142]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r7NKarxY017513; Fri, 23 Aug 2013 16:37:00 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 11/13] introduce relative_filename and use it Date: Fri, 23 Aug 2013 20:37:00 -0000 Message-Id: <1377290210-483-12-git-send-email-tromey@redhat.com> In-Reply-To: <1377290210-483-1-git-send-email-tromey@redhat.com> References: <1377290210-483-1-git-send-email-tromey@redhat.com> X-SW-Source: 2013-08/txt/msg00707.txt.bz2 This introduces a new relative_filename proc to gdb.exp and changes some tests to use it. This helps make these tests parallel-safe. * gdb.base/fullname.exp: Use standard_output_file, relative_filename. * gdb.base/hashline1.exp: Use standard_testfile, standard_output_file, relative_filename, clean_restart. * gdb.base/hashline2.exp: Use standard_testfile, standard_output_file, relative_filename. * gdb.base/hashline3.exp: Use standard_testfile, standard_output_file, relative_filename. * lib/gdb.exp (relative_filename): New proc. --- gdb/testsuite/gdb.base/fullname.exp | 5 +++-- gdb/testsuite/gdb.base/hashline1.exp | 21 +++++++++------------ gdb/testsuite/gdb.base/hashline2.exp | 13 ++++++------- gdb/testsuite/gdb.base/hashline3.exp | 14 +++++++------- gdb/testsuite/lib/gdb.exp | 10 ++++++++++ 5 files changed, 35 insertions(+), 28 deletions(-) diff --git a/gdb/testsuite/gdb.base/fullname.exp b/gdb/testsuite/gdb.base/fullname.exp index 32f6ea4..2754f59 100644 --- a/gdb/testsuite/gdb.base/fullname.exp +++ b/gdb/testsuite/gdb.base/fullname.exp @@ -70,7 +70,8 @@ if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] } # Build the test executable using a relative path. -if { [gdb_compile "${subdir}/tmp-${srcfile}" "${binfile}" executable {debug}] != "" } { +if { [gdb_compile [relative_filename [pwd] [standard_output_file tmp-${srcfile}]] \ + "${binfile}" executable {debug}] != "" } { return -1 } @@ -99,7 +100,7 @@ if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] # we'll run GDB from. set save_pwd [pwd] -cd ${subdir} +cd [standard_output_file {}] if { [gdb_compile [standard_output_file tmp-${srcfile}] "${testfile}" \ executable {debug}] != "" } { cd $save_pwd diff --git a/gdb/testsuite/gdb.base/hashline1.exp b/gdb/testsuite/gdb.base/hashline1.exp index 950d67e..2330daf 100644 --- a/gdb/testsuite/gdb.base/hashline1.exp +++ b/gdb/testsuite/gdb.base/hashline1.exp @@ -21,28 +21,25 @@ # srcfile is in objdir because we need to machine generate it in order # to get the correct path in the #line directive. -set testfile "hashline1" -set srcfile "${testfile}.c" -set binfile "${objdir}/${subdir}/${testfile}" +standard_testfile .c -set fd [open ${objdir}/${subdir}/${srcfile} w] -puts $fd "#line 2 \"[pwd]/${subdir}/${srcfile}\"" +set new_srcfile [standard_output_file $srcfile] +set fd [open $new_srcfile w] +puts $fd "#line 2 \"$new_srcfile\"" puts $fd "int main () { return 0; } /* set breakpoint here */" close $fd # The choice of path name for the source file is important in order to trigger -# the bug. Using ${objdir}/${subdir}/${srcfile} here won't trigger the bug. -if { [gdb_compile "./${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { +# the bug. Using $new_srcfile here won't trigger the bug. +set compile_name [relative_filename $objdir $new_srcfile] +if { [gdb_compile $compile_name "${binfile}" executable {debug}] != "" } { untested hashline1.exp return -1 } -gdb_exit -gdb_start -gdb_reinitialize_dir $srcdir/$subdir -gdb_load ${binfile} +clean_restart ${binfile} -set bp_location [gdb_get_line_number "set breakpoint here" ${objdir}/${subdir}/${srcfile}] +set bp_location [gdb_get_line_number "set breakpoint here" $new_srcfile] # Try to set a breakpoint on the specified file location. diff --git a/gdb/testsuite/gdb.base/hashline2.exp b/gdb/testsuite/gdb.base/hashline2.exp index d7ee4a7..cd748ca 100644 --- a/gdb/testsuite/gdb.base/hashline2.exp +++ b/gdb/testsuite/gdb.base/hashline2.exp @@ -21,16 +21,15 @@ # srcfile is in objdir because we need to machine generate it in order # to get the correct path in the #line directive. -set testfile "hashline2" -set srcfile "${testfile}.c" -set binfile "${objdir}/${subdir}/${testfile}" +standard_testfile .c -set fd [open ${objdir}/${subdir}/${srcfile} w] -puts $fd "#line 2 \"///[pwd]/${subdir}/${srcfile}\"" +set new_srcfile [standard_output_file $srcfile] +set fd [open $new_srcfile w] +puts $fd "#line 2 \"///${new_srcfile}\"" puts $fd "int main () { return 0; } /* set breakpoint here */" close $fd -if { [gdb_compile "${objdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { +if { [gdb_compile $new_srcfile "${binfile}" executable {debug}] != "" } { untested hashline2.exp return -1 } @@ -40,7 +39,7 @@ gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} -set bp_location [gdb_get_line_number "set breakpoint here" ${objdir}/${subdir}/${srcfile}] +set bp_location [gdb_get_line_number "set breakpoint here" ${new_srcfile}] # Try to set a breakpoint on the specified file location. diff --git a/gdb/testsuite/gdb.base/hashline3.exp b/gdb/testsuite/gdb.base/hashline3.exp index 2496b3c..eba5f77 100644 --- a/gdb/testsuite/gdb.base/hashline3.exp +++ b/gdb/testsuite/gdb.base/hashline3.exp @@ -21,16 +21,16 @@ # srcfile is in objdir because we need to machine generate it in order # to get the correct path in the #line directive. -set testfile "hashline3" -set srcfile "${testfile}.c" -set binfile "${objdir}/${subdir}/${testfile}" +standard_testfile -set fd [open ${objdir}/${subdir}/${srcfile} w] -puts $fd "#line 2 \"./${subdir}/${srcfile}\"" +set new_srcfile [standard_output_file $srcfile] +set fd [open $new_srcfile w] +set relative [relative_filename $objdir $new_srcfile] +puts $fd "#line 2 \"./$relative\"" puts $fd "int main () { return 0; } /* set breakpoint here */" close $fd -if { [gdb_compile "${objdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { +if { [gdb_compile $new_srcfile "${binfile}" executable {debug}] != "" } { untested hashline3.exp return -1 } @@ -40,7 +40,7 @@ gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} -set bp_location [gdb_get_line_number "set breakpoint here" ${objdir}/${subdir}/${srcfile}] +set bp_location [gdb_get_line_number "set breakpoint here" $new_srcfile] # Try to set a breakpoint on the specified file location. diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 25a91dd..8e83d8e 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4306,6 +4306,16 @@ proc set_remotetimeout { timeout } { } } +# ROOT and FULL are file names. Returns the relative path from ROOT +# to FULL. Note that FULL must be in a subdirectory of ROOT. +# For example, given ROOT = /usr/bin and FULL = /usr/bin/ls, this +# will return "ls". + +proc relative_filename {root full} { + set len [llength [file split $root]] + return [eval file join [lrange [file split $full] $len end]] +} + # Log gdb command line and script if requested. if {[info exists TRANSCRIPT]} { rename send_gdb real_send_gdb -- 1.8.1.4