From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 512 invoked by alias); 11 Jan 2012 10:59:36 -0000 Received: (qmail 422 invoked by uid 22791); 11 Jan 2012 10:59:33 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from syracuse.mckusick.com (HELO syracuse.mckusick.com) (70.36.157.236) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 11 Jan 2012 10:59:18 +0000 Received: from syracuse.mckusick.com (localhost [127.0.0.1]) by syracuse.mckusick.com (8.14.3/8.14.3/Debian-9.1ubuntu1) with ESMTP id q0BAwsMo018040; Wed, 11 Jan 2012 02:58:54 -0800 Received: (from hilfingr@localhost) by syracuse.mckusick.com (8.14.3/8.14.3/Submit) id q0BAwspJ018039; Wed, 11 Jan 2012 02:58:54 -0800 From: Hilfinger@adacore.com To: gdb-patches@sourceware.org Cc: Paul Hilfinger Subject: [PATCH 2/3] Add testcase for locals identified with FUNCTION::VAR syntax. Date: Wed, 11 Jan 2012 15:54:00 -0000 Message-Id: <1326279522-18004-2-git-send-email-Hilfinger@adacore.com> In-Reply-To: <1326279522-18004-1-git-send-email-Hilfinger@adacore.com> References: <20120110102729.GA5070@adacore.com> <1326279522-18004-1-git-send-email-Hilfinger@adacore.com> Reply-To: Hilfinger@adacore.com MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------3141592718281828" Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-01/txt/msg00352.txt.bz2 From: Paul Hilfinger This is a multi-part message in MIME format. --------------3141592718281828 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit Content-length: 802 I have committed this patch. This test stops inside a recursive function after a few levels of recursion, goes up some frames, and then accesses a local variable with 'print foo::val' rather than the usual 'print val' to see if the former pays attention to the selected frame. 2012-01-11 Paul Hilfinger Joel Brobecker * gdb.base/recpar.c, gdb.base/recpar.exp: New files. --- gdb/testsuite/ChangeLog | 5 ++++ gdb/testsuite/gdb.base/recpar.c | 42 +++++++++++++++++++++++++++++++++++++ gdb/testsuite/gdb.base/recpar.exp | 42 +++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 0 deletions(-) create mode 100644 gdb/testsuite/gdb.base/recpar.c create mode 100644 gdb/testsuite/gdb.base/recpar.exp --------------3141592718281828 Content-Type: text/x-patch; name="0002-Add-testcase-for-locals-identified-with-FUNCTION-VAR.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0002-Add-testcase-for-locals-identified-with-FUNCTION-VAR.patch" Content-length: 3388 diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index c79071c..8c811c9 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-01-11 Paul Hilfinger + Joel Brobecker + + * gdb.base/recpar.c, gdb.base/recpar.exp: New files. + 2012-01-05 Pedro Alves * gdb.mi/mi-stepn.c, gdb.mi/mi-stepn.exp: New files. diff --git a/gdb/testsuite/gdb.base/recpar.c b/gdb/testsuite/gdb.base/recpar.c new file mode 100644 index 0000000..e6c3e23 --- /dev/null +++ b/gdb/testsuite/gdb.base/recpar.c @@ -0,0 +1,42 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2012 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 . */ + +int +foo (int n) +{ + int val = n; + + { + char val = n ? 'y' : 'n'; /* Hides upper-level `val'. */ + + if (val == 'y') /* BREAK */ + return n + foo (n - 1); + } + + return 0; +} + +int +main (void) +{ + int res = foo (5); + + if (res != 15) /* Dummy use of variable res. */ + return 1; + + return 0; +} diff --git a/gdb/testsuite/gdb.base/recpar.exp b/gdb/testsuite/gdb.base/recpar.exp new file mode 100644 index 0000000..6dd466b --- /dev/null +++ b/gdb/testsuite/gdb.base/recpar.exp @@ -0,0 +1,42 @@ +# Copyright (C) 2012 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 . + +set testfile recpar +set srcfile ${testfile}.c +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } { + return -1 +} + +if ![runto_main] { + untested ${testfile}.exp + return -1 +} + +gdb_test "break $srcfile:[gdb_get_line_number BREAK $srcfile] if n == 3" \ + "Breakpoint $decimal at $hex: file .*recpar\\.c, line $decimal\\." + +gdb_test "continue" \ + "Breakpoint .* foo \\(n=3\\) at .*$srcfile:$decimal.*" + +gdb_test "backtrace" \ + "#0 +foo \\(n=3\\).*\r\n#1.* foo \\(n=4\\).*\r\n#2.* foo \\(n=5\\).*#3.* main \\(\\).*" + +gdb_test "frame 2" \ + "#2 .* foo \\(n=5\\) .*" + +# In the currently selected frame, n=5, and thus foo::val should be 5 +# as well. +gdb_test "print foo::val" \ + " = 5" --------------3141592718281828--