[RFA,2/3,V3] Add "class" option for pascal compiler

Message ID 002901d036a1$5c2e30f0$148a92d0$@muller@ics-cnrs.unistra.fr
State New, archived
Headers

Commit Message

Pierre Muller Jan. 23, 2015, 12:13 a.m. UTC
  > -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Pedro Alves
> Envoyé : jeudi 22 janvier 2015 13:50
> À : Pierre Muller; 'Doug Evans'
> Cc : 'gdb-patches'
> Objet : Re: [RFA PATCH 2/3 V2] Add "class" option for pascal compiler
> 
> On 01/14/2015 03:04 PM, Pierre Muller wrote:
> 
> >      set result [remote_exec host $gpc_compiler "-o $dest --automake
> $add_flags $source"]
> > @@ -120,6 +127,13 @@ proc fpc_compile {source dest type options} {
> >  		append add_flags " -g"
> >  	    }
> >  	}
> > +	if { $i == "class" } {
> > +	    if [board_info $dest exists pascal_class_flags] {
> > +		append add_flags " [board_info $dest pscal_class_flags]"
> 
> It'd be good to try setting this in a board file to make sure it
> works.  I've spotted a typo here (same in the gpc branch):
> "pscal_class_flags".

  I corrected the error below,
but I never worked with boardinfo files,
so I am not really sure how this works.
 
> Thanks,
> Pedro Alves

  Corrected patch below,

Pierre

gdb/ChangeLog entry:

2015-01-23  Pierre Muller  <muller@sourceware.org>

	* lib/pascal.exp (gpc_compile): Add new option "class".
	(fpc_compile): Likewise.
---
 gdb/testsuite/lib/pascal.exp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
  

Comments

Pedro Alves Jan. 23, 2015, 10:45 a.m. UTC | #1
On 01/23/2015 12:13 AM, Pierre Muller wrote:
>> Pedro Alves wrote:
>>> +	if { $i == "class" } {
>>> +	    if [board_info $dest exists pascal_class_flags] {
>>> +		append add_flags " [board_info $dest pscal_class_flags]"
>>
>> It'd be good to try setting this in a board file to make sure it
>> works.  I've spotted a typo here (same in the gpc branch):
>> "pscal_class_flags".
> 
>   I corrected the error below,
> but I never worked with boardinfo files,
> so I am not really sure how this works.

Should be something around this:

Create an empty ~/etc/site.exp file.  Point the
DEJAGNU environment variable to it, like:

  export DEJAGNU=/home/pedro/etc/site.exp

Create a ~/etc/boards/ directory, and create
a ~/etc/boards/fpc.exp file with this:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
unset_board_info isremote
set_board_info isremote 0
load_generic_config "unix"

set_board_info compiler "[find_gcc]"

set_board_info pascal_class_flags "-Mobjfpc"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Run the pascal tests with

make check RUNTESTFLAGS="--target_board=fpc --directory=gdb.pascal"

Play with $pascal_class_flags, and make sure it does have the
effect intended.

The patch looks good to me.

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/testsuite/lib/pascal.exp b/gdb/testsuite/lib/pascal.exp
index 994e3da..0a2aa75 100644
--- a/gdb/testsuite/lib/pascal.exp
+++ b/gdb/testsuite/lib/pascal.exp
@@ -91,6 +91,13 @@  proc gpc_compile {source dest type options} {
 		append add_flags " -g"
 	    }
 	}
+	if { $i == "class" } {
+	    if [board_info $dest exists pascal_class_flags] {
+		append add_flags " [board_info $dest pascal_class_flags]"
+	    } else {
+		append add_flags " --extended-syntax"
+	    }
+	}
     }
 
     set result [remote_exec host $gpc_compiler "-o $dest --automake $add_flags $source"]
@@ -120,6 +127,13 @@  proc fpc_compile {source dest type options} {
 		append add_flags " -g"
 	    }
 	}
+	if { $i == "class" } {
+	    if [board_info $dest exists pascal_class_flags] {
+		append add_flags " [board_info $dest pascal_class_flags]"
+	    } else {
+		append add_flags " -Mobjfpc"
+	    }
+	}
     }