From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9149 invoked by alias); 3 Mar 2004 04:21:07 -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 8979 invoked from network); 3 Mar 2004 04:21:05 -0000 Received: from unknown (HELO takamaka.act-europe.fr) (142.179.108.108) by sources.redhat.com with SMTP; 3 Mar 2004 04:21:05 -0000 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id BB0E747D62; Tue, 2 Mar 2004 20:21:07 -0800 (PST) Date: Fri, 19 Mar 2004 00:09:00 -0000 From: Joel Brobecker To: gdb-patches@sources.redhat.com Subject: Re: [RFC/RFA] (testsuite/Ada) Add gdb_compile_ada Message-ID: <20040303042107.GB1146@gnat.com> References: <20040224195615.GC542@gnat.com> <20040224230812.GE542@gnat.com> <20040225183211.GH1105@gnat.com> <20040225201749.GA21911@nevyn.them.org> <20040226223742.GH1154@gnat.com> <20040226230239.GA8487@nevyn.them.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040226230239.GA8487@nevyn.them.org> User-Agent: Mutt/1.4i X-SW-Source: 2004-03/txt/msg00038.txt.bz2 Hello Daniel, I think I am starting to slooooowly understand how this is all supposed to work. Would you mind reviewing what I have done so far, though, to see if I am heading in the right direction. I modified some files in dejagnu (used the CVS version from src), modified gdb.exp in gdb/.../lib, and added some others. First, some answers to your previous questions: > > 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. > > Well, I'm not so sure that qualifies as useful for the testsuite, but > if they go into gdb.ada I don't care :) Great :) > > proc gdb_begin {args expected_output} { > > gdb_test "begin $args" "$expected_output" "begin command" > > } > > What's begin do again in your sources? Also, I'm not sure about the > need for an ada.exp; what else do you expet to go here? "begin" is the Ada equivalent of the "break main; run" sequence in C. Basically, the main function in Ada is not necessarily called main. In fact, it is almost always never called main. The "begin" command digs into an Ada executable, finds the function name of the main routine, puts a temporary breakpoint inside it, and then "run". proc "gdb_begin" is designed to be the equivalent of "runto_main" for C and C++. So far, I don't anticipate anything else in ada.exp, but my little finger tells me that we will likely need something else one day which will fit perfectly into that file. Perhaps even our new gdb_compile_ada procedure should be placed into this file? I am perfectly happy to put this proc in gdb.exp, however, and drop the idea of a new ada.exp file. > Aye. You can put find_gnatmake in gdb.exp for now and submit it to > dejagnu later. > > The basic goals of the function are: > - Find an in-tree gnatmake and pass it appropriate options to run > from in-tree, for testing a combined tree. > - Use [transform], which will supply the appropriate cross prefixes. OK, here is how I understand thigs should be implemented to add support for Ada. - In libgloss.exp, I need to add a new function "find_gnatmake" << +proc find_gnatmake {} { + global tool_root_dir + + set root "$tool_root_dir/gcc" + set GM "" + + if ![is_remote host] { + set file [lookfor_file $root gnatmake] + if { $file != "" } { + set GM "$file -I$root/ada/rts --GCC=$root/xgcc --GNATBIND=$root/gnatbind --GNATLINK=$root/gnatlink -cargs -B$root -largs --GCC=$root/xgcc -margs"; + } + } + + if {$GM == ""} { + set GM [transform gnatmake] + } + + return $GM +} + >> - In target.exp (default_target_compile): I need to add handling of Ada sources via the "ada" option keyword: << @@ -333,6 +333,19 @@ proc default_target_compile {source dest } foreach i $options { + if { $i == "ada" } { + set compiler_type "ada" + if [board_info $dest exists gnatmakeflags] { + append add_flags " [target_info gnatmakeflags]" + } + # append add_flags " [gnatmake_include_flags]"; + if [board_info $dest exists gnatmakecompiler] { + set compiler [target_info gnatmakecompiler]; + } else { + set compiler [find_gnatmake]; + } + } + if { $i == "c++" } { set compiler_type "c++" if [board_info $dest exists cxxflags] { @@ -412,6 +425,7 @@ proc default_target_compile {source dest global CC_FOR_TARGET global CXX_FOR_TARGET global F77_FOR_TARGET + global GNATMAKE_FOR_TARGET if [info exists CC_FOR_TARGET] { if { $compiler == "" } { @@ -428,6 +442,12 @@ proc default_target_compile {source dest if [info exists F77_FOR_TARGET] { if { $compiler_type == "f77" } { set compiler $F77_FOR_TARGET + } + } + + if [info exists GNATMAKE_FOR_TARGET] { + if { $compiler_type == "ada" } { + set compiler $GNATMAKE_FOR_TARGET } } >> Then my new gdb_compile_ada function in gdb.exp simply becomes: << proc gdb_compile_ada {source dest objdir type options} { append options " ada" 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." } } >> And a simple testcase checking the null record problem is gone: << 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}" "${objdir}/${subdir}" 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" >> What do you think? Thanks a lot for you help, Daniel, -- Joel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9149 invoked by alias); 3 Mar 2004 04:21:07 -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 8979 invoked from network); 3 Mar 2004 04:21:05 -0000 Received: from unknown (HELO takamaka.act-europe.fr) (142.179.108.108) by sources.redhat.com with SMTP; 3 Mar 2004 04:21:05 -0000 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id BB0E747D62; Tue, 2 Mar 2004 20:21:07 -0800 (PST) Date: Wed, 03 Mar 2004 04:21:00 -0000 From: Joel Brobecker To: gdb-patches@sources.redhat.com Subject: Re: [RFC/RFA] (testsuite/Ada) Add gdb_compile_ada Message-ID: <20040303042107.GB1146@gnat.com> References: <20040224195615.GC542@gnat.com> <20040224230812.GE542@gnat.com> <20040225183211.GH1105@gnat.com> <20040225201749.GA21911@nevyn.them.org> <20040226223742.GH1154@gnat.com> <20040226230239.GA8487@nevyn.them.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040226230239.GA8487@nevyn.them.org> User-Agent: Mutt/1.4i X-SW-Source: 2004-03.o/txt/msg00038.txt Message-ID: <20040303042100.8jx62GD0Wz9e6WGw3BPL3wwxKUl7x5Zj2BoftFddqSU@z> Hello Daniel, I think I am starting to slooooowly understand how this is all supposed to work. Would you mind reviewing what I have done so far, though, to see if I am heading in the right direction. I modified some files in dejagnu (used the CVS version from src), modified gdb.exp in gdb/.../lib, and added some others. First, some answers to your previous questions: > > 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. > > Well, I'm not so sure that qualifies as useful for the testsuite, but > if they go into gdb.ada I don't care :) Great :) > > proc gdb_begin {args expected_output} { > > gdb_test "begin $args" "$expected_output" "begin command" > > } > > What's begin do again in your sources? Also, I'm not sure about the > need for an ada.exp; what else do you expet to go here? "begin" is the Ada equivalent of the "break main; run" sequence in C. Basically, the main function in Ada is not necessarily called main. In fact, it is almost always never called main. The "begin" command digs into an Ada executable, finds the function name of the main routine, puts a temporary breakpoint inside it, and then "run". proc "gdb_begin" is designed to be the equivalent of "runto_main" for C and C++. So far, I don't anticipate anything else in ada.exp, but my little finger tells me that we will likely need something else one day which will fit perfectly into that file. Perhaps even our new gdb_compile_ada procedure should be placed into this file? I am perfectly happy to put this proc in gdb.exp, however, and drop the idea of a new ada.exp file. > Aye. You can put find_gnatmake in gdb.exp for now and submit it to > dejagnu later. > > The basic goals of the function are: > - Find an in-tree gnatmake and pass it appropriate options to run > from in-tree, for testing a combined tree. > - Use [transform], which will supply the appropriate cross prefixes. OK, here is how I understand thigs should be implemented to add support for Ada. - In libgloss.exp, I need to add a new function "find_gnatmake" << +proc find_gnatmake {} { + global tool_root_dir + + set root "$tool_root_dir/gcc" + set GM "" + + if ![is_remote host] { + set file [lookfor_file $root gnatmake] + if { $file != "" } { + set GM "$file -I$root/ada/rts --GCC=$root/xgcc --GNATBIND=$root/gnatbind --GNATLINK=$root/gnatlink -cargs -B$root -largs --GCC=$root/xgcc -margs"; + } + } + + if {$GM == ""} { + set GM [transform gnatmake] + } + + return $GM +} + >> - In target.exp (default_target_compile): I need to add handling of Ada sources via the "ada" option keyword: << @@ -333,6 +333,19 @@ proc default_target_compile {source dest } foreach i $options { + if { $i == "ada" } { + set compiler_type "ada" + if [board_info $dest exists gnatmakeflags] { + append add_flags " [target_info gnatmakeflags]" + } + # append add_flags " [gnatmake_include_flags]"; + if [board_info $dest exists gnatmakecompiler] { + set compiler [target_info gnatmakecompiler]; + } else { + set compiler [find_gnatmake]; + } + } + if { $i == "c++" } { set compiler_type "c++" if [board_info $dest exists cxxflags] { @@ -412,6 +425,7 @@ proc default_target_compile {source dest global CC_FOR_TARGET global CXX_FOR_TARGET global F77_FOR_TARGET + global GNATMAKE_FOR_TARGET if [info exists CC_FOR_TARGET] { if { $compiler == "" } { @@ -428,6 +442,12 @@ proc default_target_compile {source dest if [info exists F77_FOR_TARGET] { if { $compiler_type == "f77" } { set compiler $F77_FOR_TARGET + } + } + + if [info exists GNATMAKE_FOR_TARGET] { + if { $compiler_type == "ada" } { + set compiler $GNATMAKE_FOR_TARGET } } >> Then my new gdb_compile_ada function in gdb.exp simply becomes: << proc gdb_compile_ada {source dest objdir type options} { append options " ada" 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." } } >> And a simple testcase checking the null record problem is gone: << 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}" "${objdir}/${subdir}" 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" >> What do you think? Thanks a lot for you help, Daniel, -- Joel