From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29443 invoked by alias); 4 May 2011 16:47:59 -0000 Received: (qmail 29413 invoked by uid 22791); 4 May 2011 16:47:57 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 04 May 2011 16:47:36 +0000 Received: (qmail 3037 invoked from network); 4 May 2011 16:47:30 -0000 Received: from unknown (HELO ?192.168.1.4?) (janisjo@127.0.0.2) by mail.codesourcery.com with ESMTPA; 4 May 2011 16:47:30 -0000 Message-ID: <4DC18331.1020505@codesourcery.com> Date: Wed, 04 May 2011 16:47:00 -0000 From: Janis Johnson User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [patch] let gdb.base/reread.exp handle multiple binary files Content-Type: multipart/mixed; boundary="------------080101000908050604080105" 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: 2011-05/txt/msg00098.txt.bz2 This is a multi-part message in MIME format. --------------080101000908050604080105 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 530 Test gdb.base/reread.exp fails and reports ERROR for uClinux because it renames binary files directly using "shell mv", and this doesn't take into account the pair of binaries that are used for the bFLT format. This patch moves the file commands into new procedures in lib/gdb.exp that are used as defaults if the local environment doesn't override them. Tested on arm-none-linux-gnueabi as a platform that does not need overrides. OK? I have an FSF copyright assignment for gdb. Janis Johnson CodeSourcery / Mentor Graphics --------------080101000908050604080105 Content-Type: text/plain; name="gdb-20110504-1" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gdb-20110504-1" Content-length: 4418 20110-5-04 Janis Johnson * lib/gdb.exp (exec_target_file, exec_symbol_file, gdb_rename_execfile, gdb_touch_execfile): New. * gdb.base/reread.exp: Use new procs to handle multiple exec files. Index: gdb/testsuite/lib/gdb.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v retrieving revision 1.172 diff -u -p -r1.172 gdb.exp --- gdb/testsuite/lib/gdb.exp 27 Apr 2011 19:44:42 -0000 1.172 +++ gdb/testsuite/lib/gdb.exp 4 May 2011 16:07:25 -0000 @@ -2653,6 +2653,54 @@ proc shlib_symbol_file { libname } { return $libname } +# Return the filename to download to the target and load for this +# executable. Normally just BINFILE unless it is renamed to something +# else for this target. + +proc exec_target_file { binfile } { + return $binfile +} + +# Return the filename GDB will load symbols from when debugging this +# executable. Normally just BINFILE unless executables for this target +# have separate files for symbols. + +proc exec_symbol_file { binfile } { + return $binfile +} + +# Rename the executable file. Normally this is just BINFILE1 being renamed +# to BINFILE2, but some targets require multiple binary files. +proc gdb_rename_execfile { binfile1 binfile2 } { + catch { file rename -force \ + [exec_target_file ${binfile1}] \ + [exec_target_file ${binfile2}] } + if { [exec_target_file ${binfile1}] != [exec_symbol_file ${binfile1}] } { + catch { file rename -force \ + [exec_symbol_file ${binfile1}] \ + [exec_symbol_file ${binfile2}] } + } +} + +# "Touch" the executable file to update the date. Normally this is just +# BINFILE, but some targets require multiple files. +proc gdb_touch_execfile { binfile } { + catch { file copy -force \ + [exec_target_file ${binfile}] \ + [exec_target_file ${binfile}.tmp] } + catch { file rename -force \ + [exec_target_file ${binfile}.tmp] \ + [exec_target_file ${binfile}] } + if { [exec_target_file ${binfile}] != [exec_symbol_file ${binfile}] } { + catch { file copy -force \ + [exec_symbol_file ${binfile}] \ + [exec_symbol_file ${binfile}.tmp] } + catch { file rename -force \ + [exec_symbol_file ${binfile}.tmp] \ + [exec_symbol_file ${binfile}] } + } +} + # gdb_download # # Copy a file to the remote target and return its target filename. Index: gdb/testsuite/gdb.base/reread.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/reread.exp,v retrieving revision 1.18 diff -u -p -r1.18 reread.exp --- gdb/testsuite/gdb.base/reread.exp 7 Mar 2011 16:03:02 -0000 1.18 +++ gdb/testsuite/gdb.base/reread.exp 4 May 2011 16:07:25 -0000 @@ -53,7 +53,7 @@ gdb_reinitialize_dir $srcdir/$subdir # Load the first executable. -gdb_test "shell mv ${binfile1} ${binfile}" ".*" "" +gdb_rename_execfile ${binfile1} ${binfile} gdb_load ${binfile} # Set a breakpoint at foo @@ -82,10 +82,10 @@ gdb_expect { # second executable into its place. Ensure that the new # executable is at least a second newer than the old. -gdb_test "shell mv ${binfile} ${binfile1}" ".*" "" -gdb_test "shell mv ${binfile2} ${binfile}" ".*" "" +gdb_rename_execfile ${binfile} ${binfile1} +gdb_rename_execfile ${binfile2} ${binfile} gdb_test "shell sleep 1" ".*" "" -gdb_test "shell touch ${binfile}" ".*" "" +gdb_touch_execfile ${binfile} # Run a second time; GDB should detect that the executable has changed # and reset the breakpoints correctly. @@ -120,8 +120,8 @@ if [is_remote target] { } else { # Put the older executable back in place. - gdb_test "shell mv ${binfile} ${binfile2}" ".*" "" - gdb_test "shell mv ${binfile1} ${binfile}" ".*" "" + gdb_rename_execfile ${binfile} ${binfile2} + gdb_rename_execfile ${binfile1} ${binfile} # Restart GDB entirely. gdb_start @@ -154,8 +154,8 @@ if [is_remote target] { # Now move the newer executable into place, and re-run. GDB # should still notice that the executable file has changed, # and still re-set the breakpoint appropriately. - gdb_test "shell mv ${binfile} ${binfile1}" ".*" "" - gdb_test "shell mv ${binfile2} ${binfile}" ".*" "" + gdb_rename_execfile ${binfile} ${binfile1} + gdb_rename_execfile ${binfile2} ${binfile} gdb_run_cmd gdb_expect { -re ".*Breakpoint.* foo .* at .*:9.*$gdb_prompt $" { --------------080101000908050604080105--