From patchwork Tue Dec 22 15:33:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 10104 Received: (qmail 107267 invoked by alias); 22 Dec 2015 15:33:58 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 107253 invoked by uid 89); 22 Dec 2015 15:33:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.3 required=5.0 tests=AWL, BAYES_50, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=UD:gdb.ada, gdb.ada, gdbada, UD:ada X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 22 Dec 2015 15:33:55 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 03C6911674D for ; Tue, 22 Dec 2015 10:33:54 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id IEJw4OeCm4F3 for ; Tue, 22 Dec 2015 10:33:46 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 8F8B0116745 for ; Tue, 22 Dec 2015 10:33:45 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 7866646BAD; Tue, 22 Dec 2015 19:33:41 +0400 (RET) From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [RFC/commmit] [testsuite/Ada] stop using project files when building test programs Date: Tue, 22 Dec 2015 19:33:31 +0400 Message-Id: <1450798411-26617-1-git-send-email-brobecker@adacore.com> Hello, Below is a fairly straightforward change, except maybe for the use of try / finally, which requires TCL version 8.6, released Dec 2012. I think it's a reasonable requirement; any objection? Thanks! ------------------------------------------------------------- The current approach when building Ada programs for testing is based on the use of a project file (testsuite/gdb.ada/gnat_ada.gpr). To do that, we pass a number of additional arguments to target_compile, one of them being the project file (via "-P/path/to/gnat_ada.gpr"). This used to work well-enough, but AdaCore is currently working towards removing project-file support from gnatmake (the prefered tool for using project files is gprbuild). So, we need to either switch the compilation to gprbuild, or stop using project files. First, using gprbuild is not always what users will be using to build their applications. So having the option of using gnatmake provides more flexibility towards exactly reproducing past bugs. If we ever need a testcase that requires the use of gprbuild, then I believe support for a new target needs to be added to dejagnu's target_compile. Also, the only real reason behind using a project file in the first place is that we wanted to make it easy to specify the directory where all compilation artifacts get stored. This is a consequence of the organization choice we made for gdb.ada to keep each testcase well organized. It is very easy to achieve that goal without using project files. This is therefore what this patch does: It change gdb_compile_ada to build any program using gnatmake without using a project file (by temporarily changing the current working directory). There is a small (beneficial) side-effect; in the situation where GDB is built in-tree, gnatmake is called as... % gnatmake [...] unit.adb ... which means that the debugging info in unit.o will say contain a filename whose name is 'unit.adb', rather than '/path/to/unit.adb'. This also better matches what users might typically do. But the side- effect is that the unit name in the GDB output is not always a full path. This patch tweaks a couple of testcases to make the path part optional. Note that this patch requires TCL version 8.6, which was released Dec 2012. gdb/testsuite: * lib/ada.exp (gdb_compile_ada): Reimplement avoiding the use of project files. * gdb.ada/gnat_ada.gpr: Delete. * gdb.ada/cond_lang.exp: Adjust test to make path before filename optional. * gdb.ada/small_reg_param.exp: Likewise. Tested on x86_64-linux, with both in-tree and out-of-tree builds. --- gdb/testsuite/gdb.ada/cond_lang.exp | 2 +- gdb/testsuite/gdb.ada/gnat_ada.gpr | 25 ------------------------- gdb/testsuite/gdb.ada/small_reg_param.exp | 2 +- gdb/testsuite/lib/ada.exp | 20 ++++++++++++++++---- 4 files changed, 18 insertions(+), 31 deletions(-) delete mode 100644 gdb/testsuite/gdb.ada/gnat_ada.gpr diff --git a/gdb/testsuite/gdb.ada/cond_lang.exp b/gdb/testsuite/gdb.ada/cond_lang.exp index 0dfb9e3..7c3ad6e 100644 --- a/gdb/testsuite/gdb.ada/cond_lang.exp +++ b/gdb/testsuite/gdb.ada/cond_lang.exp @@ -39,7 +39,7 @@ gdb_test "show lang" \ # current language mode is auto, and the breakpoint is inside Ada code. set bp_location [gdb_get_line_number "STOP" ${testdir}/mixed.adb] gdb_test "break mixed.adb:${bp_location} if light = green" \ - "Breakpoint \[0-9\]* at .*: file .*/mixed.adb, line \[0-9\]*\\." + "Breakpoint \[0-9\]* at .*: file (.*/)?mixed.adb, line \[0-9\]*\\." # Now, continue until we hit the breakpoint. If the condition is # evaluated correctly, the first hit will be ignored, and the debugger diff --git a/gdb/testsuite/gdb.ada/gnat_ada.gpr b/gdb/testsuite/gdb.ada/gnat_ada.gpr deleted file mode 100644 index 2736206..0000000 --- a/gdb/testsuite/gdb.ada/gnat_ada.gpr +++ /dev/null @@ -1,25 +0,0 @@ --- Copyright 2004-2015 Free Software Foundation, Inc. --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see . - --- This project file allows us to control the location where the --- compilation artifacts produced when building the Ada examples --- are stored. - -project Gnat_Ada is - - for Source_Dirs use (external ("SRC")); - for Object_Dir use external ("OBJ"); - -end Gnat_Ada; diff --git a/gdb/testsuite/gdb.ada/small_reg_param.exp b/gdb/testsuite/gdb.ada/small_reg_param.exp index bd5cfd6..0a3b972 100644 --- a/gdb/testsuite/gdb.ada/small_reg_param.exp +++ b/gdb/testsuite/gdb.ada/small_reg_param.exp @@ -33,7 +33,7 @@ gdb_breakpoint "call_me" # Continue until we hit the breakpoint inside `Call_Me'. We verify # that the parameter value is correct. gdb_test "continue" \ - "Breakpoint .*, pck\\.call_me \\(w=(w@entry=)?50\\) at .*/pck.adb:.*" \ + "Breakpoint .*, pck\\.call_me \\(w=(w@entry=)?50\\) at (.*)?/pck.adb:.*" \ "continue to call_me" # And just to make sure, we also verify that the parameter value diff --git a/gdb/testsuite/lib/ada.exp b/gdb/testsuite/lib/ada.exp index 6a1e192..b8a1724 100644 --- a/gdb/testsuite/lib/ada.exp +++ b/gdb/testsuite/lib/ada.exp @@ -21,12 +21,24 @@ proc gdb_compile_ada {source dest type options} { set gprdir [file dirname $srcdir] set objdir [file dirname $dest] + # Although strictly not necessary, we force the recompilation + # of all units (additional_flags=-f). This is what is done + # when using GCC to build programs in the other languages, + # and it avoids using a stray objfile file from a long-past + # run, for instance. append options " ada" - append options " additional_flags=-P$gprdir/gnat_ada" - append options " additional_flags=-XSRC=[file tail $srcdir]" - append options " additional_flags=-XOBJ=$objdir" + append options " additional_flags=-f" + append options " additional_flags=-I$srcdir" - set result [target_compile [file tail $source] $dest $type $options] + # Run target_compile from the directory where we want the object + # files and the executable to be written. + set saved_cwd [pwd] + try { + cd $objdir + set result [target_compile [file tail $source] $dest $type $options] + } finally { + cd $saved_cwd + } # The Ada build always produces some output, even when the build # succeeds. Thus, we can not use the output the same way we do in