From: Doug Evans Date: Wed, 7 Aug 2013 23:51:45 +0000 (+0000) Subject: * gdb.python/py-value-cc.cc: Renamed from py-value.cc. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ac52f9a22a4c139774b105164911ad866aae1476;p=binutils-gdb.git * gdb.python/py-value-cc.cc: Renamed from py-value.cc. * gdb.python/py-value-cc.exp: Update. * gdb.python/py-value.exp: Use different names for .o files for C and C++. Only perform C++ tests if !skip_cplus_tests. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index fb21761fe7f..5f38aa00ef0 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2013-08-07 Doug Evans + + * gdb.python/py-value-cc.cc: Renamed from py-value.cc. + * gdb.python/py-value-cc.exp: Update. + * gdb.python/py-value.exp: Use different names for .o files for + C and C++. Only perform C++ tests if !skip_cplus_tests. + 2013-08-07 Tom Tromey * gdb.base/maint.exp: Allow zero symtabs to be expanded. diff --git a/gdb/testsuite/gdb.python/py-value-cc.cc b/gdb/testsuite/gdb.python/py-value-cc.cc new file mode 100644 index 00000000000..c010fc98d8b --- /dev/null +++ b/gdb/testsuite/gdb.python/py-value-cc.cc @@ -0,0 +1,39 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2012-2013 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 . */ + +class A { +}; + +typedef int *int_ptr; + +int +func (const A &a) +{ + int val = 10; + int &int_ref = val; + int_ptr ptr = &val; + int_ptr &int_ptr_ref = ptr; + + return 0; /* Break here. */ +} + +int +main () +{ + A obj; + return func (obj); +} diff --git a/gdb/testsuite/gdb.python/py-value-cc.exp b/gdb/testsuite/gdb.python/py-value-cc.exp index 914dbaa7b36..55c3b970cc4 100644 --- a/gdb/testsuite/gdb.python/py-value-cc.exp +++ b/gdb/testsuite/gdb.python/py-value-cc.exp @@ -18,7 +18,7 @@ if { [skip_cplus_tests] } { continue } -standard_testfile py-value.cc +standard_testfile .cc if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} { return -1 diff --git a/gdb/testsuite/gdb.python/py-value.cc b/gdb/testsuite/gdb.python/py-value.cc deleted file mode 100644 index c010fc98d8b..00000000000 --- a/gdb/testsuite/gdb.python/py-value.cc +++ /dev/null @@ -1,39 +0,0 @@ -/* This testcase is part of GDB, the GNU debugger. - - Copyright 2012-2013 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 . */ - -class A { -}; - -typedef int *int_ptr; - -int -func (const A &a) -{ - int val = 10; - int &int_ref = val; - int_ptr ptr = &val; - int_ptr &int_ptr_ref = ptr; - - return 0; /* Break here. */ -} - -int -main () -{ - A obj; - return func (obj); -} diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp index 9142c729927..4f863a6c91b 100644 --- a/gdb/testsuite/gdb.python/py-value.exp +++ b/gdb/testsuite/gdb.python/py-value.exp @@ -21,13 +21,26 @@ load_lib gdb-python.exp standard_testfile # Build inferior to language specification. +# LANG is one of "c" or "c++". proc build_inferior {exefile lang} { global srcdir subdir srcfile testfile hex - if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${exefile}" executable "debug $lang"] != "" } { + # Use different names for .o files based on the language. + # For Fission, the debug info goes in foo.dwo and we don't want, + # for example, a C++ compile to clobber the dwo of a C compile. + # ref: http://gcc.gnu.org/wiki/DebugFission + switch ${lang} { + "c" { set filename ${testfile}.o } + "c++" { set filename ${testfile}-cxx.o } + } + set objfile [standard_output_file $filename] + + if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object "debug $lang"] != "" + || [gdb_compile "${objfile}" "${exefile}" executable "debug $lang"] != "" } { untested "Couldn't compile ${srcfile} in $lang mode" return -1 } + return 0 } proc test_value_creation {} { @@ -463,9 +476,10 @@ proc test_value_hash {} { gdb_test "python print (one.__hash__() == hash(one))" "True" "Test inbuilt hash" } -# Build C and C++ versions of executable -build_inferior "${binfile}" "c" -build_inferior "${binfile}-cxx" "c++" +# Build C version of executable. C++ is built later. +if { [build_inferior "${binfile}" "c"] < 0 } { + return -1 +} # Start with a fresh gdb. clean_restart ${binfile} @@ -494,5 +508,12 @@ test_lazy_strings test_value_after_death # Test either C or C++ values. + test_subscript_regression "${binfile}" "c" -test_subscript_regression "${binfile}-cxx" "c++" + +if ![skip_cplus_tests] { + if { [build_inferior "${binfile}-cxx" "c++"] < 0 } { + return -1 + } + test_subscript_regression "${binfile}-cxx" "c++" +}