From patchwork Mon Apr 14 17:13:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 547 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 11A33360075 for ; Mon, 14 Apr 2014 10:14:50 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14314964) id B509F4145331F; Mon, 14 Apr 2014 10:14:49 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx20.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-mx20.g.dreamhost.com (Postfix) with ESMTPS id 8A9DE41608D96 for ; Mon, 14 Apr 2014 10:14:49 -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=LFaCZazFHMRhMf+MD6AiOqdeXTlwhWd MnbjPiUE/q4fq3gA4mUZYcv2yi4ANpfO/RNpXYe4Gy9M9w1tCV0uO7QhqxL6Td+v 4oTk06OK0ve1pHGD79jImmRGJavakpVZJCRABTx7oGXM+zb2e7WVBm1LOvVVmaLc spFMaKokXzyQ= 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=iQZ7RYJUMNr7hjenU9M5g/Iixx8=; b=YD8Pf N3WiHF/jHJzkfKodMCm4JDcv40VbH6MInxRCyAVC4HWQuKQczH9+wEvFc6CnGGXb PeSCtDJNiDxyYrKqZ7+8MIrsCqGW2R4P7rsy4TdICYiU3hidrFithVRum38NEw0E VKs7EpJz2ftNWynzJoTfkyjxv1wSDD7E/xFdF4= Received: (qmail 10545 invoked by alias); 14 Apr 2014 17:14:08 -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 10479 invoked by uid 89); 14 Apr 2014 17:14:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 14 Apr 2014 17:14:06 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 837051160DD; Mon, 14 Apr 2014 13:14:04 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id WP0ITGtTdmMo; Mon, 14 Apr 2014 13:14:04 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 4F2431160DB; Mon, 14 Apr 2014 13:14:04 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id E6E6AE02C0; Mon, 14 Apr 2014 10:14:09 -0700 (PDT) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Sanimir Agovic Subject: [PATCH 10/12] test: evaluate pointers to C99 vla correctly. Date: Mon, 14 Apr 2014 10:13:14 -0700 Message-Id: <1397495596-25364-11-git-send-email-brobecker@adacore.com> In-Reply-To: <1397495596-25364-1-git-send-email-brobecker@adacore.com> References: <0377C58828D86C4588AEEC42FC3B85A71D8507B7@IRSMSX105.ger.corp.intel.com> <1397495596-25364-1-git-send-email-brobecker@adacore.com> X-DH-Original-To: gdb@patchwork.siddhesh.in From: Sanimir Agovic gdb/testsuite/ChangeLog: * gdb.base/vla-ptr.c: New file. * gdb.base/vla-ptr.exp: New file. --- gdb/testsuite/ChangeLog | 5 ++++ gdb/testsuite/gdb.base/vla-ptr.c | 58 ++++++++++++++++++++++++++++++++++++++ gdb/testsuite/gdb.base/vla-ptr.exp | 41 +++++++++++++++++++++++++++ 3 files changed, 104 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/ChangeLog b/gdb/testsuite/ChangeLog index 2882a74..83071a2 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2014-04-14 Sanimir Agovic + * gdb.base/vla-ptr.c: New file. + * gdb.base/vla-ptr.exp: New file. + +2014-04-14 Sanimir Agovic + * gdb.dwarf2/count.exp: New file. 2014-04-14 Sanimir Agovic 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"