From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3069 invoked by alias); 26 Feb 2004 22:37:42 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 3062 invoked from network); 26 Feb 2004 22:37:41 -0000 Received: from unknown (HELO takamaka.act-europe.fr) (209.53.16.160) by sources.redhat.com with SMTP; 26 Feb 2004 22:37:41 -0000 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id 22B4247D62; Thu, 26 Feb 2004 14:37:42 -0800 (PST) Date: Thu, 26 Feb 2004 22:37:00 -0000 From: Joel Brobecker To: gdb-patches@sources.redhat.com Subject: Re: [RFC/RFA] (testsuite/Ada) Add gdb_compile_ada Message-ID: <20040226223742.GH1154@gnat.com> References: <20040224195615.GC542@gnat.com> <20040224230812.GE542@gnat.com> <20040225183211.GH1105@gnat.com> <20040225201749.GA21911@nevyn.them.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="R+My9LyyhiUvIEro" Content-Disposition: inline In-Reply-To: <20040225201749.GA21911@nevyn.them.org> User-Agent: Mutt/1.4i X-SW-Source: 2004-02/txt/msg00783.txt.bz2 --R+My9LyyhiUvIEro Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 4507 On Wed, Feb 25, 2004 at 03:17:49PM -0500, Daniel Jacobowitz wrote: > On Wed, Feb 25, 2004 at 10:32:11AM -0800, Joel Brobecker wrote: > > Continuing my fascinating monologous with myself :) > > > > > - Object files are placed in the testsuite directory. I'd rather > > > see them being placed in gdb.ada. > > > > > > I managed to do this, but I a not completely sure that it's such > > > a good idea after all. See patch below. On the one hand, the object > > > files et al are placed in gdb.ada rather than gdb/testsuite, but > > > on the other hand this has a slight impact in the debug info generated > > > by the compiler, since the source file name is no longer absolute. > > > So this change is not completely transparent for the debugger... > > > What do you think? > > > > Actually, I just noticed that the few tests that do generate object > > files and other compilation artifacts actually leave them in the > > testsuite directory, not inside the gdb.* directories. > > > > So I would be tempted to discard the idea above of making sure that > > all these artifacts be placed in the gdb.ada directory for all Ada > > testcases. Hence the attached patch. One note, however: contrary to > > C where temporary .o files are automatically deleted, gnatmake leaves > > behind. This is to allow incremental builds, similar what make does. > > This will cause a much higher number of object files to be created > > in the testsuite directory. I hope this is fine? Otherwise, we'll > > can use the previous approach, but I believe it should be done > > consistently across all languages. > > I would prefer to have them placed in the subdirectory. Can't you > specify an output directory for gnatmake? It seems like a terrible > limitation. Normally, gnatmake is just a tool like make which job is to call the compiler with the appropriate switches. It actually does a "little more" since is also evaluates the dependencies and determines which files need to be recompiled, but the general idea is that gnatmake = make for GNAT. That being said, it just occured to me that there is a very simple way to control the location of the files generated by gnatmake: the GNAT project files. I created a new file gnat_ada.gpr.in in gdb.ada which contains the following: << -- This project files allows us to control the loation where the -- compilation artifacts produced when building the Ada examples -- are stored. project Gnat_Ada is for Source_Dirs use ("@srcdir@"); -- No need to set the Object_Dir, it is set to "." by default. end Gnat_Ada; >> And then building a typical Ada program will be done using the following command: % gnatmake -P$objdir/gdb.ada/gnat_ada -g -o where is the name of the Ada file (*basename* only) and is the name of the executable (can be basename or fullname, it doesn't matter) > Also, gdb_compile_ada may want to remove the incremental files in this > case, since the testsuite will not use them. gnatmake will. For instance gnatmake won't recompile the test programs on subsequent runs, unless the sources have changes. Or if we have two test programs depending on the same unit, this unit will only be compiled once. I think we should keep them, they are useful. > > + lappend options "compiler=gnatmake" > > See find_gcc in dejagnu's libgloss.exp. Could you explain a bit more what you mean (sorry, dejagnu is still new to me, and I have allergic reactions to tcl and expect :-/)? Do you means that I should create a new find_gnatmake function and then do lappend options "compiler=[find_gnatmake]" instead? I think this is the last sticky point to look at before being able to properly submit these changes for inclusion. Here is a small preview of where I current am, adding our first ada testcase to our dejagnu testsuite. This is with our debugger based on 6.0, but should be fairly close to apply to head as well. * lib/gdb.exp (gdb_compile_ada): New function. * lib/ada.exp: New file. * gdb.ada/Makefile.in: New file. * gdb.ada/gnat_ada.gpr.in: New file. * Makefile.in (ALL_SUBDIRS): Add gdb.ada. * configure.in: Generate gdb.ada/Makefile and gdb.ada/gnat_ada.gpr. And the new testcase: * gdb.ada/bar.ads: New file. * gdb.ada/bar.adb: New file. * gdb.ada/null_record.adb: New file. * gdb.ada/null_record.exp: New file. Am I on the right track? Thanks, -- Joel --R+My9LyyhiUvIEro Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="lib-gdb.exp.diff" Content-length: 940 Index: lib/gdb.exp =================================================================== RCS file: /nile.c/cvs/Dev/gdb/gdb-6.0/gdb/testsuite/lib/gdb.exp,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 gdb.exp --- lib/gdb.exp 5 Oct 2003 10:40:20 -0000 1.1.1.1 +++ lib/gdb.exp 26 Feb 2004 22:31:36 -0000 @@ -1323,6 +1323,26 @@ } } +# +# Compile some Ada code. +# +proc gdb_compile_ada {source dest type options} { + + set objdir [file dirname $dest] + + lappend options "compiler=gnatmake" + append options " additional_flags=-P$objdir/gnat_ada" + + set result [target_compile $source $dest $type $options] + + # Make sure that the dest file has been created. Otherwise, + # the build has failed. + if ![file exists $dest] { + verbose "Ada compilation failed: $result" + return "Ada compilation failed." + } +} + proc send_gdb { string } { global suppress_flag; if { $suppress_flag } { --R+My9LyyhiUvIEro Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ada.exp" Content-length: 126 load_lib libgloss.exp proc gdb_begin {args expected_output} { gdb_test "begin $args" "$expected_output" "begin command" } --R+My9LyyhiUvIEro Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="Makefile.in" Content-length: 580 VPATH = @srcdir@ srcdir = @srcdir@ EXECUTABLES = null_record MISCELLANEOUS = all info install-info dvi install uninstall installcheck check: @echo "Nothing to be done for $@..." clean mostlyclean: -gnatclean -Pgnat_ada -q $(EXECUTABLES) -rm -f *~ *.o a.out xgdb *.x *.ci *.tmp -rm -f core core.coremaker coremaker.core corefile $(EXECUTABLES) -rm -f $(MISCELLANEOUS) twice-tmp.c distclean maintainer-clean realclean: clean -rm -f *~ core -rm -f Makefile config.status config.log gnat_ada.gpr -rm -f *-init.exp -rm -fr *.log summary detail *.plog *.sum *.psum site.* --R+My9LyyhiUvIEro Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="gnat_ada.gpr.in" Content-length: 289 -- This project files allows us to control the loation where the -- compilation artifacts produced when building the Ada examples -- are stored. project Gnat_Ada is for Source_Dirs use ("@srcdir@"); -- No need to set the Object_Dir, it is set to "." by default. end Gnat_Ada; --R+My9LyyhiUvIEro Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="dejagnu.ada.diff" Content-length: 1464 Index: Makefile.in =================================================================== RCS file: /nile.c/cvs/Dev/gdb/gdb-6.0/gdb/testsuite/Makefile.in,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 Makefile.in --- Makefile.in 5 Oct 2003 10:40:09 -0000 1.1.1.1 +++ Makefile.in 26 Feb 2004 22:29:22 -0000 @@ -35,8 +35,8 @@ EXEEXT = @EXEEXT@ SUBDIRS = @subdirs@ RPATH_ENVVAR = @RPATH_ENVVAR@ -ALL_SUBDIRS = gdb.arch gdb.asm gdb.base gdb.cp gdb.disasm gdb.java gdb.mi \ - gdb.objc gdb.threads gdb.trace $(SUBDIRS) +ALL_SUBDIRS = gdb.ada gdb.arch gdb.asm gdb.base gdb.cp gdb.disasm \ + gdb.java gdb.mi gdb.objc gdb.threads gdb.trace $(SUBDIRS) EXPECT = `if [ -f $${rootme}/../../expect/expect ] ; then \ echo $${rootme}/../../expect/expect ; \ Index: configure.in =================================================================== RCS file: /nile.c/cvs/Dev/gdb/gdb-6.0/gdb/testsuite/configure.in,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 configure.in --- configure.in 5 Oct 2003 10:40:09 -0000 1.1.1.1 +++ configure.in 26 Feb 2004 22:29:22 -0000 @@ -112,6 +112,7 @@ AC_EXEEXT AC_CONFIG_SUBDIRS($configdirs) -AC_OUTPUT([Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile \ +AC_OUTPUT([Makefile gdb.ada/Makefile gdb.ada/gnat_ada.gpr \ + gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile \ gdb.cp/Makefile gdb.disasm/Makefile gdb.java/Makefile gdb.mi/Makefile \ gdb.objc/Makefile gdb.threads/Makefile gdb.trace/Makefile]) --R+My9LyyhiUvIEro Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="bar.ads" Content-length: 83 package Bar is type Empty is null record; procedure Do_Nothing; end Bar; --R+My9LyyhiUvIEro Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="bar.adb" Content-length: 98 package body Bar is procedure Do_Nothing is begin null; end Do_Nothing; end Bar; --R+My9LyyhiUvIEro Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="null_record.adb" Content-length: 84 with Bar; use Bar; procedure Null_Record is begin Do_Nothing; end Null_Record; --R+My9LyyhiUvIEro Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="null_record.exp" Content-length: 503 if $tracelevel then { strace $tracelevel } load_lib "ada.exp" set testfile "null_record" set srcfile ${testfile}.adb set binfile ${objdir}/${subdir}/${testfile} if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } { return -1 } gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} gdb_begin "" "Breakpoint \[0-9\]+ at .*null_record.adb.*" gdb_test "ptype empty" \ "type = record null; end record" \ "ptype on null record" --R+My9LyyhiUvIEro--