[PATCH] Detect frame size overflow (2)

Eric Botcazou ebotcazou@adacore.com
Sat Mar 11 14:47:00 GMT 2006


> This is OK for mainline.

Thanks for the quick review.

> I was wondering whether it would be possible to add a new gnat.dg/
> subdirectory to the current dejagnu testing infrastructure?  I notice
> that you even provide a nice Ada testcase with your posting, but
> because GCC's Ada testing currently just tracks the "official" ACATS
> testsuite, its difficult to add new tests not covered by ACATS
> functionality.

Absolutely. Long overdue. Laziness. Thanks for the sting. :-)

> Over the years hundreds of Ada test cases have been posted to gcc-patches,
> only to be lost to the mailing list archives.

"Hundreds" is a bit of an overstatement, "dozens" is more realistic I'd think.
I'll make a pass over the archives and try to rescue as many of them as I can.


I've attached the skeleton of the harness for gnat.dg.  Very limited for the 
time being, as it only supports dg-compile (and dg-assemble).  Tested on 
x86/Linux and x86-64/Linux.


2006-03-11  Eric Botcazou  <ebotcazou@adacore.com>

ada/
	* Make-lang.in: Add check-gnat to lang_checks.
	Rename existing check-gnat into check-acats.

testsuite/

	* lib/gnat.exp: New driver.
	* lib/gnat-dg.exp: Likewise.
	* gnat.dg: New directory.
	* gnat.dg/dg.exp: New driver.
	* gnat.dg/frame_overflow.adb: New test.


-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: check-gnat.diff
Type: text/x-diff
Size: 774 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060311/84f68cf2/attachment.bin>
-------------- next part --------------
# Copyright (C) 2006 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 2 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, write to the Free Software
# Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

load_lib libgloss.exp
load_lib prune.exp
load_lib gcc-defs.exp

#
# GNAT_UNDER_TEST is the compiler under test.
#

#
# default_gnat_version -- extract and print the version number of the compiler
#

proc default_gnat_version { } {
    global GNAT_UNDER_TEST

    gnat_init

    # ignore any arguments after the command
    set compiler [lindex $GNAT_UNDER_TEST 0]

    if ![is_remote host] {
	set compiler_name [which $compiler]
    } else {
	set compiler_name $compiler
    }

    # verify that the compiler exists
    if { $compiler_name != 0 } then {
	set tmp [remote_exec host "$compiler -v"]
	set status [lindex $tmp 0]
	set output [lindex $tmp 1]
	regexp " version \[^\n\r\]*" $output version
	if { $status == 0 && [info exists version] } then {
	    clone_output "$compiler_name $version\n"
	} else {
	    clone_output "Couldn't determine version of $compiler_name: $output\n"
	}
    } else {
	# compiler does not exist (this should have already been detected)
	warning "$compiler does not exist"
    }
}

#
# gnat_version -- Call default_gnat_version, so we can override it if needed.
#

proc gnat_version { } {
    default_gnat_version
}

#
# gnat_init -- called at the start of each .exp script.
#
# There currently isn't much to do, but always using it allows us to
# make some enhancements without having to go back and rewrite the scripts.
#

proc gnat_init { args } {
    global tmpdir
    global base_dir
    global GNAT_UNDER_TEST
    global TOOL_EXECUTABLE
    global TESTING_IN_BUILD_TREE

    if ![info exists GNAT_UNDER_TEST] then {
	if [info exists TOOL_EXECUTABLE] {
	    set GNAT_UNDER_TEST $TOOL_EXECUTABLE;
	} else {
	    if { [is_remote host] || ! [info exists TESTING_IN_BUILD_TREE] } {
		set GNAT_UNDER_TEST "[find_gcc]"
	    } else {
		set GNAT_UNDER_TEST "[find_gcc] -I$base_dir/../../ada/rts"
	    }
	}
    }

    if ![info exists tmpdir] then {
	set tmpdir /tmp
    }
}

#
# gnat_target_compile -- compile a source file
#

proc gnat_target_compile { source dest type options } {
    global tmpdir
    global GNAT_UNDER_TEST
    global TOOL_OPTIONS

    # TOOL_OPTIONS must come first, so that it doesn't override testcase
    # specific options.
    if [info exists TOOL_OPTIONS] {
	set options [concat "{additional_flags=$TOOL_OPTIONS}" $options]
    }
    lappend options "compiler=$GNAT_UNDER_TEST"
    set options [dg-additional-files-options $options $source]
    return [target_compile $source $dest $type $options]
}
-------------- next part --------------
# Copyright (C) 2006 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 2 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, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  

# Define gnat callbacks for dg.exp.

load_lib gcc-dg.exp

proc gnat-dg-test { prog do_what extra_tool_flags } {
    return [gcc-dg-test-1 gnat_target_compile $prog $do_what $extra_tool_flags]
}


proc gnat-dg-prune { system text } {
    return [gcc-dg-prune $system $text]
}
-------------- next part --------------
# GCC Ada testsuite that uses the `dg.exp' driver.
# Copyright (C) 2006 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 2 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, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  

# Load support procs.
load_lib gnat-dg.exp

# If a testcase doesn't have special options, use these.
#  -gnatwZ: turn off size/align warnings for unchecked conversion
global DEFAULT_ADAFLAGS
if ![info exists DEFAULT_ADAFLAGS] then {
    set DEFAULT_ADAFLAGS " -gnatwZ"
}

# Initialize `dg'.
dg-init

# Gather a list of all tests.
set tests [lsort [find $srcdir/$subdir *.adb]]

# Main loop.
dg-runtest $tests "" $DEFAULT_ADAFLAGS

# All done.
dg-finish
-------------- next part --------------
A non-text attachment was scrubbed...
Name: frame_overflow.adb
Type: text/x-adasrc
Size: 784 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060311/84f68cf2/attachment-0001.bin>


More information about the Gcc-patches mailing list