2007-10-08 Luis Machado * gdb.opt/clobbered-registers-O2.c: New testcase source file. * gdb.opt/clobbered-registers-O2.exp: New testcase expect file. Index: gdb/testsuite/gdb.opt/clobbered-registers-O2.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ gdb/testsuite/gdb.opt/clobbered-registers-O2.c 2007-10-08 09:36:28.000000000 -0700 @@ -0,0 +1,44 @@ +/* This file is part of GDB, the GNU debugger. + + Copyright 2007 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 . + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@prep.ai.mit.edu */ + +#ifndef __GNUC__ +#define __attribute__(x) +#endif + +unsigned * __attribute__((noinline)) +start_sequence (unsigned * x, unsigned * y) +{ + return (unsigned *)0xdeadbeef; +}; + +unsigned __attribute__((noinline)) +gen_movsd (unsigned * operand0, unsigned * operand1) +{ + return *start_sequence(operand0, operand1); +} + +int main(void) +{ + unsigned x, y; + + x = 13; + y = 14; + return (int)gen_movsd (&x, &y); +} Index: gdb/testsuite/gdb.opt/clobbered-registers-O2.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ gdb/testsuite/gdb.opt/clobbered-registers-O2.exp 2007-10-08 11:20:17.000000000 -0700 @@ -0,0 +1,56 @@ +# Copyright 2007 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# This file is part of the gdb testsuite. + +if $tracelevel { + strace $tracelevel +} + +# Test displaying call clobbered registers in optimized binaries for ppc. +# GDB should not show incorrect values. + +set prms_id 0 +set bug_id 0 + +set testfile "clobbered-registers-O2" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +set compile_flags "debug optimize=-O2" + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ${compile_flags}] != "" } { + untested clobbered-registers-O2.exp + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "Couldn't run to breakpoint" + continue +} + +gdb_test "b start_sequence" ".*Breakpoint 2 at.*line 29.*" \ + "Insert breakpoint at problematic function" + +gdb_test continue ".*Breakpoint 2.*in start_sequence.*" \ + "Run until problematic function" + +gdb_test backtrace ".*operand0=.*operand1=.*" \ + "Check value of call clobbered registers"