From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28475 invoked by alias); 19 Apr 2010 12:28:18 -0000 Received: (qmail 28198 invoked by uid 22791); 19 Apr 2010 12:28:15 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_BJ,TW_JC,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 19 Apr 2010 12:28:07 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o3JCS59I025583 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 19 Apr 2010 08:28:05 -0400 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o3JCS2np026574 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 19 Apr 2010 08:28:04 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id o3JCS2Ej015508 for ; Mon, 19 Apr 2010 14:28:02 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id o3JCS2a8015497 for gdb-patches@sourceware.org; Mon, 19 Apr 2010 14:28:02 +0200 Date: Mon, 19 Apr 2010 12:28:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] testsuite: Simplify + make more safe sepdebug Message-ID: <20100419122801.GA14177@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-08-17) X-IsSubscribed: yes 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 X-SW-Source: 2010-04/txt/msg00553.txt.bz2 Hi, function find_separate_debug_file_by_debuglink searches separate debug info files in this order: (1st) /* First try in the same directory as the original file. */ = dir/file.debug (2nd) #define DEBUG_SUBDIRECTORY ".debug" /* Then try in the subdirectory named DEBUG_SUBDIRECTORY. */ = dir/.debug/file.debug (3rd) /* Then try in the global debugfile directories. = /usr/lib/debug/dir/file.debug But the testsuite uses only the 2nd kind. That means if there exists some stale file of the 1st kind it may confuse the testsuite; try yourself: gcc -g -lm -o gdb.base/sepdebug2 ./gdb.base/sepdebug2.c; strip --only-keep-debug gdb.base/sepdebug2 -o gdb.base/sepdebug2.debug; runtest gdb.base/sepdebug.exp FAIL: gdb.base/sepdebug.exp: CRC mismatch is reported Testcase expects non-matching gdb.base/.debug/sepdebug2.debug but GDB surprisingly finds first matching gdb.base/sepdebug2.debug . Moreover dealing with the .debug subdirectory both complicates the testsuite and from my own experience one can more easily miss the .debug hidden subdirectory instead of clear dir/file.debug file of the 1st kind. I already tried to protect against the 1st kind in gdb.base/break-interp.exp but sure this problem is find_separate_debug_file_by_debuglink-bound and it has no place in any specific testcase. Submitting this change as I wanted to add the same protection into another specific testcase. While some systems do not use the ".debug" extension in their .gnu_debuglink section it does not apply for this code as find_separate_debug_file_by_debuglink creates its own separate debug info file explicitly using the ".debug" extension. Moreover the test # now move the .debug file to a different location so that we can test # the "set debug-file-directory" command. test_different_dir debuglink "${objdir}/${subdir}" 0 with results PASS: gdb.base/sepdebug.exp: debuglink: set separate debug location PASS: gdb.base/sepdebug.exp: debuglink: breakpoint function, optimized file PASS: gdb.base/sepdebug.exp: debuglink: breakpoint small function, optimized file PASS: gdb.base/sepdebug.exp: debuglink: run until function breakpoint, optimized file PASS: gdb.base/sepdebug.exp: debuglink: run until breakpoint set at small function, optimized file did not test the "set debug-file-directory" command at all as this command needs the full subdirectory tree. Try to remove the "set debug-file-directory" command there if anything changes (for the "debuglink" case). Fixed it to test the "set debug-file-directory" command. No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu. Thanks, Jan gdb/testsuite/ 2010-04-19 Jan Kratochvil * gdb.base/break-interp.exp: Remove $exec.debug safety removal. * gdb.base/sepdebug.exp: Remove .debug subdirectory handling. New variable different_dir. Move debugfile into a full directory pathname under DIFFERENT_DIR. * lib/gdb.exp (separate_debug_filename): Remove. (gdb_gnu_strip_debug): No longer call separate_debug_filename. Remove variable debug_dir and mkdir of it. Update function comments. --- a/gdb/testsuite/gdb.base/break-interp.exp +++ b/gdb/testsuite/gdb.base/break-interp.exp @@ -636,10 +636,6 @@ foreach ldprelink {NO YES} { } if {$binsepdebug == "SEP"} { gdb_gnu_strip_debug $exec - # Just a sanity check. As gdb_gnu_strip_debug uses the - # "[file dirname $exec]/.debug/[file tail $exec].debug" - # variant delete the higher-priority exec.debug file. - file delete "$exec.debug" } # Supply a self-sufficent directory $dir with the required --- a/gdb/testsuite/gdb.base/sepdebug.exp +++ b/gdb/testsuite/gdb.base/sepdebug.exp @@ -50,7 +50,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb # ${binfile}, which is just like the executable ($binfile) but without # the debuginfo. Instead $binfile has a .gnudebuglink section which contains # the name of a debuginfo only file. This file will be stored in the -# gdb.base/.debug subdirectory. +# gdb.base/ subdirectory. if [gdb_gnu_strip_debug $binfile] { # check that you have a recent version of strip and objcopy installed @@ -946,11 +946,14 @@ proc test_different_dir {type test_different_dir xfail} { # now move the .debug file to a different location so that we can test # the "set debug-file-directory" command. - -remote_exec build "mv ${objdir}/${subdir}/.debug/${testfile}.debug ${objdir}/${subdir}" -set debugfile "${objdir}/${subdir}/${testfile}.debug" -test_different_dir debuglink "${objdir}/${subdir}" 0 +set different_dir "${objdir}/${subdir}/${testfile}.dir" +set debugfile "${different_dir}/${objdir}/${subdir}/${testfile}.debug" +remote_exec build "rm -rf $different_dir" +remote_exec build "mkdir -p [file dirname $debugfile]" +remote_exec build "mv -f ${objdir}/${subdir}/${testfile}.debug $debugfile" + +test_different_dir debuglink $different_dir 0 # Test CRC mismatch is reported. @@ -958,7 +961,7 @@ test_different_dir debuglink "${objdir}/${subdir}" 0 if {[build_executable sepdebug.exp sepdebug2 sepdebug2.c debug] != -1 && ![gdb_gnu_strip_debug ${objdir}/${subdir}/sepdebug2]} { - remote_exec build "cp ${debugfile} ${objdir}/${subdir}/.debug/sepdebug2.debug" + remote_exec build "cp ${debugfile} ${objdir}/${subdir}/sepdebug2.debug" gdb_exit gdb_start @@ -966,7 +969,7 @@ if {[build_executable sepdebug.exp sepdebug2 sepdebug2.c debug] != -1 set escapedobjdirsubdir [string_to_regexp ${objdir}/${subdir}] - gdb_test "file ${objdir}/${subdir}/sepdebug2" "warning: the debug information found in \"${escapedobjdirsubdir}/\\.debug/sepdebug2\\.debug\" does not match \"${escapedobjdirsubdir}/sepdebug2\" \\(CRC mismatch\\)\\..*\\(no debugging symbols found\\).*" "CRC mismatch is reported" + gdb_test "file ${objdir}/${subdir}/sepdebug2" "warning: the debug information found in \"${escapedobjdirsubdir}/sepdebug2\\.debug\" does not match \"${escapedobjdirsubdir}/sepdebug2\" \\(CRC mismatch\\)\\..*\\(no debugging symbols found\\).*" "CRC mismatch is reported" } --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -2833,8 +2833,8 @@ proc gdb_skip_xml_test { } { # Note: the procedure gdb_gnu_strip_debug will produce an executable called # ${binfile}.dbglnk, which is just like the executable ($binfile) but without # the debuginfo. Instead $binfile has a .gnu_debuglink section which contains -# the name of a debuginfo only file. This file will be stored in the -# gdb.base/.debug subdirectory. +# the name of a debuginfo only file. This file will be stored in the same +# subdirectory. # Functions for separate debug info testing @@ -2843,27 +2843,9 @@ proc gdb_skip_xml_test { } { # at the end of the process we have: # foo.stripped --> foo w/o debug info -# .debug/foo.debug --> foo's debug info +# foo.debug --> foo's debug info # foo --> like foo, but with a new .gnu_debuglink section pointing to foo.debug. -# Return the name of the file in which we should stor EXEC's separated -# debug info. EXEC contains the full path. -proc separate_debug_filename { exec } { - - # In a .debug subdirectory off the same directory where the testcase - # executable is going to be. Something like: - # /gdb/testsuite/gdb.base/.debug/blah.debug. - # This is the default location where gdb expects to findi - # the debug info file. - - set exec_dir [file dirname $exec] - set exec_file [file tail $exec] - set debug_dir [file join $exec_dir ".debug"] - set debug_file [file join $debug_dir "${exec_file}.debug"] - - return $debug_file -} - # Return the build-id hex string (usually 160 bits as 40 hex characters) # converted to the form: .build-id/ab/cdef1234...89.debug # Return "" if no build-id found. @@ -2899,17 +2881,13 @@ proc build_id_debug_filename_get { exec } { proc gdb_gnu_strip_debug { dest args } { - set debug_file [separate_debug_filename $dest] + # Use the first separate debug info file location searched by GDB so the + # run cannot be breaken by some stale file searched with higher precedence. + set debug_file "${dest}.debug" + set strip_to_file_program [transform strip] set objcopy_program [transform objcopy] - # Make sure the directory that will hold the separated debug - # info actually exists. - set debug_dir [file dirname $debug_file] - if {! [file isdirectory $debug_dir]} { - file mkdir $debug_dir - } - set debug_link [file tail $debug_file] set stripped_file "${dest}.stripped"