From patchwork Thu Apr 10 12:40:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Agovic, Sanimir" X-Patchwork-Id: 485 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx23.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 3153136005B for ; Thu, 10 Apr 2014 05:51:18 -0700 (PDT) Received: by homiemail-mx23.g.dreamhost.com (Postfix, from userid 14314964) id E62AA627EFE37; Thu, 10 Apr 2014 05:51:17 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx23.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx23.g.dreamhost.com (Postfix) with ESMTPS id CBB0D627EFE34 for ; Thu, 10 Apr 2014 05:51:17 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=OFuwLe0IcrltNgJDDvkC3yfO94v73sV OqRCQvAt592aw2f2Sr0kOeluj9SUDqTKeP0W3XJdex/DVu48Cx5SQa6zL6H5Z5Ea qy5yrELORzmfU9yvqFYaPtq5WnmWaL3VeVktqD2qUWggaeRXnaRLrn8WzSQIX8Ou h8ptOtjqlIZA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=iqft1K0NJD5qjMvie8UUC2Yjzg4=; b=PaUrz 9/825ipycpdMYlIcX2cFFBvYj0BA7NMGSXaYrsK98TlDr1SL2bHxx0TEb1YOr36h zG/VId14R0fnYJXDHb+EaACU8Zgdf/k/FoDRFh6XxVCKafhhVUhNJhQhpurOioAP kMaPtXvijACDJE1fJsF8jmzs/kbgCQXcd6ibLY= Received: (qmail 4005 invoked by alias); 10 Apr 2014 12:51:16 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 3993 invoked by uid 89); 10 Apr 2014 12:51:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mga02.intel.com Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 Apr 2014 12:51:14 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 10 Apr 2014 05:51:13 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 10 Apr 2014 05:51:11 -0700 Received: from ulliclel004.iul.intel.com (ulliclel004.iul.intel.com [172.28.50.125]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s3ACoj9p011661; Thu, 10 Apr 2014 13:50:50 +0100 Received: from ulliclel004.iul.intel.com (ulliclel004.iul.intel.com [127.0.0.1]) by ulliclel004.iul.intel.com (8.13.8/8.12.8/MailSET/client) with ESMTP id s3ACnsaY026793; Thu, 10 Apr 2014 14:50:14 +0200 Received: (from sagovic@localhost) by ulliclel004.iul.intel.com (8.13.8/8.13.1/Submit) id s3ACnm4n026792; Thu, 10 Apr 2014 14:49:48 +0200 From: Sanimir Agovic To: brobecker@adacore.com Cc: gdb-patches@sourceware.org, tromey@redhat.com Subject: [PATCH v6 13/15] test: evaluate pointers to C99 vla correctly. Date: Thu, 10 Apr 2014 14:40:15 +0200 Message-Id: <1397133617-26681-14-git-send-email-sanimir.agovic@intel.com> In-Reply-To: <1397133617-26681-1-git-send-email-sanimir.agovic@intel.com> References: <1397133617-26681-1-git-send-email-sanimir.agovic@intel.com> X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in 2013-10-18 Keven Boell Sanimir Agovic gdb/testsuite: * gdb.base/vla-ptr.c: New file. * gdb.base/vla-ptr.exp: New file. Signed-off-by: Sanimir Agovic --- gdb/testsuite/gdb.base/vla-ptr.c | 58 ++++++++++++++++++++++++++++++++++++++ gdb/testsuite/gdb.base/vla-ptr.exp | 41 +++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 gdb/testsuite/gdb.base/vla-ptr.c create mode 100644 gdb/testsuite/gdb.base/vla-ptr.exp diff --git a/gdb/testsuite/gdb.base/vla-ptr.c b/gdb/testsuite/gdb.base/vla-ptr.c new file mode 100644 index 0000000..54d04a6 --- /dev/null +++ b/gdb/testsuite/gdb.base/vla-ptr.c @@ -0,0 +1,58 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2014 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 . */ + +#define SIZE 5 + +void +foo (int n, int vla_ptr[n]) +{ + return; /* foo_bp */ +} + +void +bar (int *vla_ptr) +{ + return; /* bar_bp */ +} + +void +vla_func (int n) +{ + int vla[n]; + typedef int typedef_vla[n]; + typedef_vla td_vla; + int i; + + for (i = 0; i < n; i++) + { + vla[i] = 2+i; + td_vla[i] = 4+i; + } + + foo(n, vla); + bar(vla); + + return; /* vla_func_bp */ +} + +int +main (void) +{ + vla_func(SIZE); + + return 0; +} diff --git a/gdb/testsuite/gdb.base/vla-ptr.exp b/gdb/testsuite/gdb.base/vla-ptr.exp new file mode 100644 index 0000000..56c9d5b --- /dev/null +++ b/gdb/testsuite/gdb.base/vla-ptr.exp @@ -0,0 +1,41 @@ +# Copyright 2014 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 . + +standard_testfile + +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } { + return -1 +} + +if ![runto_main] { + return -1 +} + +set sizeof_int [get_sizeof "int" 4] + +# Check that VLA passed to function (pointer) points to the first element. +gdb_breakpoint [gdb_get_line_number "foo_bp"] +gdb_continue_to_breakpoint "foo_bp" +gdb_test "print vla_ptr" "\\\(int \\\*\\\) $hex" "print vla_ptr (foo)" +gdb_test "print *vla_ptr" " = 2" "print *vla_ptr (foo)" + +gdb_breakpoint [gdb_get_line_number "bar_bp"] +gdb_continue_to_breakpoint "bar_bp" +gdb_test "print vla_ptr" "\\\(int \\\*\\\) $hex" "print vla_ptr (bar)" +gdb_test "print *vla_ptr" " = 2" "print *vla_ptr (bar)" + +gdb_breakpoint [gdb_get_line_number "vla_func_bp"] +gdb_continue_to_breakpoint "vla_func_bp" +gdb_test "print td_vla" " = \\\{4, 5, 6, 7, 8\\\}" "print td_vla"